Closed Bug 327239 Opened 20 years ago Closed 20 years ago

label's accessors getValue() method should return explicit content too

Categories

(Core Graveyard :: XForms, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: surkov, Assigned: surkov)

References

Details

(Keywords: fixed1.8.0.8, fixed1.8.1.1)

Attachments

(1 file, 4 obsolete files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9a1) Gecko/20051212 Firefox/1.6a1 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9a1) Gecko/20051212 Firefox/1.6a1 It's needed a discussion. Reproducible: Always
Blocks: 323849
I imagine the fix after some discussion with Allan by the following way. nsIXFormsLabelElement interface should be removed and xbl binding control should do own implementation of getValue() method of nsIXFormsAccessors interface.
(In reply to comment #1) > I imagine the fix after some discussion with Allan by the following way. > nsIXFormsLabelElement interface should be removed and xbl binding control > should do own implementation of getValue() method of nsIXFormsAccessors > interface. > Though I can't see a way how it can be done. XBL binding should override the method getXFormsAccessors to replace nsIXFormsAccessors object (to override nsIXFormsAccessors::getValue() method). But if xbl binding will override getXFormsAccessors() method then it will not be able to call original getXFormsAccessors() method. It's a problem. If there isn't a solution for the situation then we can do it as I proposed in comment 2 of bug 323849.
I don't know exactly how you plan to use this, but I'm thinking why not override nsIXFormsUIWidget's stringValue() for label, then change label's XBL guts to use getValue() (or some other internal method) rather than stringValue?
(In reply to comment #3) > I don't know exactly how you plan to use this, but I'm thinking why not > override nsIXFormsUIWidget's stringValue() for label, then change label's XBL > guts to use getValue() (or some other internal method) rather than stringValue? > It should be used as from c++ (f.x. now it is used in itemset) as from js. The problem is there is not stringValue() in nsIXFormsUIWidget interface and threafore it can be used in c++.
Mozilla is crashed when I try to substitute accessors object: <constructor> var accessors = { __proto__: this.accessors, getValue: function() { return "hello"; } }; var delegate = { __proto__: this.delegate, getXFormsAccessors: function() { return accessors; } }; this.delegate = delegate; </constructor>
could you file a bug w/ a testcase (attach the xbl first, then change the xul to reference the attachment url and attach it) and a stack trace?
(In reply to comment #6) > could you file a bug w/ a testcase (attach the xbl first, then change the xul > to reference the attachment url and attach it) and a stack trace? > Unfortunately I cannot reproduce crash again. I guess I was in hurry to report about this. If I'll get it again then I'll say you for sure.
I try to replace getValue method of accessors. It works fine for js but doesn't work for c++ (http://lxr.mozilla.org/mozilla/source/extensions/xforms/nsXFormsItemElement.cpp#442 I just replaced a call of nsIXFormsLabelElement::textValue on call of nsIXFormsAccessors::getValue()). <constructor> var delegate = { getXFormsAccessors: function() { var accessors = this.__proto__.getXFormsAccessors(); return { getValue: function() { return "heddldllld"; }, __proto__: accessors }; }, __proto__: this.QueryInterface(Components.interfaces.nsIXFormsDelegate) }; this._delegate = delegate; this._accessors = this._delegate.getXFormsAccessors(); this._delegate.widgetAttached(); </constructor>
The next is not work in c++ too: this.QueryInterface(Components.interfaces.nsIXFormsDelegate); var getNativeAccessors = this.getXFormsAccessors; this.getXFormsAccessors = function() { var accessors = { getValue: function() { return "I love you"; }, __proto__: getNativeAccessors() }; return accessors; } this.widgetAttached();
I didn't imaging how I can substitute method defined in c++ by method in js. I don't know how it should work. I dunno behaviour what I get is right or not. We can define interface witch label binding will realize and override nsIXFormsAccessors::getValue() for label in c++. getValue() will call method of interface from label binding. Something like: interface nsIXFormsLabelUIElement { attribute readonly string nonBoundTextValue; // it's needed a better name :) } <binding id="xformswidget-label-base" extends=""> <implementation implements="nsIXFormsWidgetUI, nsIXFormsLabelUIElement"> <property name="nonBoundTextValue" onget="tralala"/> </implementation> </binding> nsXFormsLabelAccessors: public nsXFormsAccessors { GetValue(nsAutoString&) { here we check instance data value, value for @src, value of nonBoundTextValue } }; nsXFormsLabelElement::GetXFormsAccessors(nsIXFormsAccessors**) { return new nsXFormsLabelAccessors(); }
No longer blocks: 323849
Blocks: 337690
Probably it's not a bad way to add setAccessors() method to nsIXFormsDelegate? In that case xbl binding of xforms controls will replace accessors object by own one. How it looks?
Assignee: aaronr → surkov
Status: UNCONFIRMED → NEW
Ever confirmed: true
I guess that I still don't get this bug. Can you please give an example of where we need this? Why can't you just create an interface that the xbl side of label implements and have the xbl side of label call through XTF under the covers to the c++ to get the text content?
(In reply to comment #12) > I guess that I still don't get this bug. Can you please give an example of > where we need this? Now I can see two issues where it is needed. 1) now xf:label has 'textValue' property that is used by xf:select. I guess it's not good. 2) the bug 337690, accessible object should can get values of xf:label/xf:hint. > Why can't you just create an interface that the xbl side > of label implements and have the xbl side of label call through XTF under the > covers to the c++ to get the text content? Initially I wanted to choose that way. But after talk with Allan I've changed my mind. The nsIXFormsAccessors::GetValue() returns: 1) instance data if xf:label has bound 2) value of resource if xf:label has @src attribute I guess it will be resonable if the list will be extended by third item. 3) value of explicit content for other cases.
Status: NEW → ASSIGNED
Attached patch patch (obsolete) — — Splinter Review
Attachment #222821 - Flags: review?(aaronr)
Comment on attachment 222821 [details] [diff] [review] patch The patch modifys nsIXFormsAccessors::GetValue() method for xf:label only. I want to do nsIXFormsLabelElement interface removing and xf:select modifying in following up bug.
Blocks: 338776
Hmmm, it is really not how I see things. Too much complexity handled in XBL, and replacing accessors also sounds bad to me. But I cannot really remember the issues in this :(
Comment on attachment 222821 [details] [diff] [review] patch >Index: extensions/xforms/nsIXFormsDelegate.idl >=================================================================== >RCS file: /cvsroot/mozilla/extensions/xforms/nsIXFormsDelegate.idl,v >retrieving revision 1.3 >diff -u -p -U8 -r1.3 nsIXFormsDelegate.idl >--- extensions/xforms/nsIXFormsDelegate.idl 14 Nov 2005 08:42:36 -0000 1.3 >+++ extensions/xforms/nsIXFormsDelegate.idl 22 May 2006 03:45:56 -0000 >@@ -48,21 +48,28 @@ interface nsIXFormsAccessors; > * For more information on this interface please see > * http://developer.mozilla.org/en/docs/XForms:Custom_Controls > * > */ > [scriptable, uuid(902898eb-490e-4c36-a00b-9e74adcfbc43)] > interface nsIXFormsDelegate : nsISupports > { > /** >- * Get the IXFormsAccessors object for this control. >+ * Get the nsIXFormsAccessors object for this control. > */ > nsIXFormsAccessors getXFormsAccessors(); > > /** >+ * Set the nsIXFormsAccessors object for this control. The >+ * method should be called by XBL widget when it need to >+ * override default nsIXFormsAccessors object. >+ */ >+ void setXFormsAccessors(in nsIXFormsAccessors accessors); >+ >+ /** don't forget that you are changing the interface so you need to replace the uuid with a new one. >Index: extensions/xforms/nsXFormsDelegateStub.cpp >=================================================================== >RCS file: /cvsroot/mozilla/extensions/xforms/nsXFormsDelegateStub.cpp,v >retrieving revision 1.8 >diff -u -p -U8 -r1.8 nsXFormsDelegateStub.cpp >--- extensions/xforms/nsXFormsDelegateStub.cpp 19 Apr 2006 08:22:28 -0000 1.8 >+++ extensions/xforms/nsXFormsDelegateStub.cpp 22 May 2006 03:45:57 -0000 >@@ -266,8 +263,17 @@ nsXFormsDelegateStub::GetXFormsAccessors > mAccessor = new nsXFormsAccessors(this, mElement); > if (!mAccessor) { > return NS_ERROR_OUT_OF_MEMORY; > } > } > NS_ADDREF(*aAccessor = mAccessor); > return NS_OK; > } >+ >+NS_IMETHODIMP >+nsXFormsDelegateStub::SetXFormsAccessors(nsIXFormsAccessors *aAccessor) >+{ >+ NS_ENSURE_ARG_POINTER(aAccessor); >+ >+ mAccessor = aAccessor; >+ return NS_OK; >+} nit: mozilla usually uses NS_ENSURE_ARG for 'input' parameters and NS_ENSURE_ARG_POINTER for 'output' or 'return buffer' parameters. >Index: extensions/xforms/nsXFormsDelegateStub.h >=================================================================== >RCS file: /cvsroot/mozilla/extensions/xforms/nsXFormsDelegateStub.h,v >retrieving revision 1.4 >diff -u -p -U8 -r1.4 nsXFormsDelegateStub.h >--- extensions/xforms/nsXFormsDelegateStub.h 5 Nov 2005 16:11:42 -0000 1.4 >+++ extensions/xforms/nsXFormsDelegateStub.h 22 May 2006 03:45:57 -0000 >@@ -107,12 +107,12 @@ protected: > // Sets/removes the moz:type attribute. The attribute can be used to detect the > // type of the node, which is bound the the control. > void SetMozTypeAttribute(); > > nsString mControlType; > nsRepeatState mRepeatState; > > /** The accessors object for this delegate */ >- nsRefPtr<nsXFormsAccessors> mAccessor; >+ nsRefPtr<nsIXFormsAccessors> mAccessor; > }; > I think that you are supposed to use nsCOMPtr for things that descend from nsISupports. You might want to double check that, though. I'm no expert on the subject :=) > #endif >Index: extensions/xforms/nsXFormsRangeElement.cpp >=================================================================== >RCS file: /cvsroot/mozilla/extensions/xforms/nsXFormsRangeElement.cpp,v >retrieving revision 1.1 >diff -u -p -U8 -r1.1 nsXFormsRangeElement.cpp >--- extensions/xforms/nsXFormsRangeElement.cpp 14 Nov 2005 08:42:36 -0000 1.1 >+++ extensions/xforms/nsXFormsRangeElement.cpp 22 May 2006 03:45:57 -0000 >@@ -32,16 +32,17 @@ > * decision by deleting the provisions above and replace them with the notice > * and other provisions required by the GPL or the LGPL. If you do not delete > * the provisions above, a recipient may use your version of this file under > * the terms of any one of the MPL, the GPL or the LGPL. > * > * ***** END LICENSE BLOCK ***** */ > > #include "nsXFormsDelegateStub.h" >+#include "nsIXFormsAccessors.h" > #include "nsXFormsRangeAccessors.h" > > /** > * Implementation of the XForms \<range\> element > * @see http://www.w3.org/TR/xforms/slice8.html#ui-range > * > * @todo Check data binding restrictions (XXX) > */ >@@ -58,20 +59,27 @@ public: > }; > > // nsIXFormsDelegate > > NS_IMETHODIMP > nsXFormsRangeElement::GetXFormsAccessors(nsIXFormsAccessors **aAccessor) > { > if (!mAccessor) { >- mAccessor = new nsXFormsRangeAccessors(this, mElement); >- if (!mAccessor) { >+ nsXFormsRangeAccessors* rangeAccessor = >+ new nsXFormsRangeAccessors(this, mElement); >+ >+ if (!rangeAccessor) { > return NS_ERROR_OUT_OF_MEMORY; > } >+ >+ nsIXFormsAccessors *accessor; >+ rangeAccessor->QueryInterface(NS_GET_IID(nsIXFormsAccessors), (void**)&accessor); >+ mAccessor = accessor; >+ FYI, in bug 300248 I'm adding another accessor layer between nsXFormsRangeAccessor and nsXFormsAccessor. > } > NS_ADDREF(*aAccessor = mAccessor); > return NS_OK; > } > > > // Creator > >Index: extensions/xforms/resources/content/xforms.xml >=================================================================== >RCS file: /cvsroot/mozilla/extensions/xforms/resources/content/xforms.xml,v >retrieving revision 1.36 >diff -u -p -U8 -r1.36 xforms.xml >--- extensions/xforms/resources/content/xforms.xml 27 Apr 2006 09:04:59 -0000 1.36 >+++ extensions/xforms/resources/content/xforms.xml 22 May 2006 03:45:57 -0000 >@@ -174,16 +174,69 @@ > if (!this._delegate) { > this._delegate = > this.QueryInterface(Components.interfaces.nsIXFormsDelegate); > } > return this._delegate; > </getter> > </property> > >+ <method name="getAccessorsStub"> >+ <body> >+ if (!this.accessors) >+ return null; >+ >+ var nsISupports = Components.interfaces.nsISupports; >+ var nsIXFormsAccessors = Components.interfaces.nsIXFormsAccessors; >+ >+ var accessors = { >+ // nsISupports >+ QueryInterface: function(aIID) { >+ if (aIID.equals(nsISupports) || aIID.equals(nsIXFormsAccessors)) >+ return this; >+ throw Components.results.NS_ERROR_NO_INTERFACE; >+ }, >+ >+ // nsIXFormsAccessors >+ getValue: function() { >+ return this.accessors.getValue(); >+ }, >+ setValue: function(aValue) { >+ this.accessors = aValue; >+ }, shouldn't this be this.accessors.setValue(aValue)? none of these are all that major, but r-'ing as I'd like to see it again after the new patch is put together. Also, can you add a comment to the XBL label explaining why this is necessary? Why you couldn't just change nsXFormsLabelElement::GetValue to provide this functionality? That will be the first thing anyone who sees this will think. Thanks.
Attachment #222821 - Flags: review?(aaronr) → review-
Attached patch patch2 (obsolete) — — Splinter Review
The patch makes nsXFormsLabelElement::GetValue() to return inline value too.
Attachment #222821 - Attachment is obsolete: true
Attachment #223157 - Flags: review?(allan)
Comment on attachment 223157 [details] [diff] [review] patch2 Looks mighty good! It makes the inline label text work. But not the external ones on: http://beaufour.dk/xftst/Label/bindtest.xml.show Could we fix that, while we are at it?
Attachment #223157 - Flags: review?(allan) → review-
Attached patch patch3 (obsolete) — — Splinter Review
(In reply to comment #19) > (From update of attachment 223157 [details] [diff] [review] [edit]) > Looks mighty good! It makes the inline label text work. > > But not the external ones on: > http://beaufour.dk/xftst/Label/bindtest.xml.show > > Could we fix that, while we are at it? > If all controls should be ready when "xforms-ready" event is fired then we should fix it if not the we shouldn't. I'll add widgetAttached() method to descrease refresh() calls.
Attachment #223157 - Attachment is obsolete: true
Attachment #223902 - Flags: review?(allan)
(In reply to comment #20) > Created an attachment (id=223902) [edit] > patch3 > > (In reply to comment #19) > > (From update of attachment 223157 [details] [diff] [review] [edit] [edit]) > > Looks mighty good! It makes the inline label text work. > > > > But not the external ones on: > > http://beaufour.dk/xftst/Label/bindtest.xml.show > > > > Could we fix that, while we are at it? > > > > If all controls should be ready when "xforms-ready" event is fired then we > should fix it if not the we shouldn't. "After all form controls have been initialized, an xforms-ready event is dispatched to each model element." [http://www.w3.org/TR/2006/REC-xforms-20060314/slice4.html#evt-modelConstructDone]
Comment on attachment 223902 [details] [diff] [review] patch3 >+ PRBool mWidgetLoaded; Remember to initialize this. >- if (nsXFormsUtils::CheckConnectionAllowed(mElement, uri)) { >+ if (nsXFormsUtils::CheckSameOrigin(doc, uri)) { Huh? If I understand comment 20 correctly, then the problem with external labels is that we do not delay the xforms-ready signal on external labels. I guess we should delay it for all loading of external resources. Right now we do it for messages, but we should also do it for labels. A follow-up bug for that. r=me with the two above fixed.
Attachment #223902 - Flags: review?(allan) → review+
Attached patch patch4 (obsolete) — — Splinter Review
Attachment #223902 - Attachment is obsolete: true
Attachment #224088 - Flags: review?(Olli.Pettay)
Summary: Move 'textValue' of xforms:label from c++ to xbl. → label's accessors getValue() method should return explicit content too
Comment on attachment 224088 [details] [diff] [review] patch4 > >+ nsXFormsLabelElement(): mWidgetLoaded(PR_FALSE) {}; >+ Nit, space before ':' r=me
Attachment #224088 - Flags: review?(Olli.Pettay) → review+
Attached patch checkin patch — — Splinter Review
Attachment #224088 - Attachment is obsolete: true
checked into trunk for surkov
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Whiteboard: xf-to-branch
checked into 1.8.0 branch on 2006/09/21
Keywords: fixed1.8.0.8
checked into 1.8 branch on 2006/11/21
Keywords: fixed1.8.1.1
Whiteboard: xf-to-branch
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: