Closed
Bug 428509
Opened 17 years ago
Closed 17 years ago
Cannot attach JavaScript listeners to XForms events
Categories
(Core Graveyard :: XForms, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: jlc6, Assigned: msterlin)
Details
(Keywords: fixed1.8.1.17)
Attachments
(2 files, 3 obsolete files)
985 bytes,
application/xhtml+xml
|
Details | |
3.02 KB,
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.13) Gecko/20080325 Ubuntu/7.10 (gutsy) Firefox/2.0.0.13
Build Identifier: 0.8.5
JavaScript event listeners that listen for XForms events do not fire when those events are dispatched. This is a regression, as this functionality used to work in 0.8.4. My wild guess is that this is related to the context information work that went into the latest release. I will attach a test form shortly.
A workaround is to listen for the event using an XForms event listener, then to use `xf:dispatch` to dispatch a custom event, and finally to listen for that custom event with the desired JavaScript event listener.
Reproducible: Always
Reporter | ||
Comment 1•17 years ago
|
||
Assignee | ||
Comment 2•17 years ago
|
||
The problem appears to be the QI from nsIXFormsDOMEvent to nsIDOMEvent in nsEventListenerThisTranslator::TranslateThis.
nsCOMPtr<nsIDOMEvent> event(do_QueryInterface(aInitialThis));
NS_ENSURE_TRUE(event, NS_ERROR_UNEXPECTED);
nsXFormsDOMEvent wraps nsDOMEvent (named mInner) because we cannot inherit from nsDOMEvent. We probably need to override QueryInterface and return the ISupports* of mInner but that is easier said than done with the decl and impl macros in nsISupportsImpl.h.
Comment 3•17 years ago
|
||
One doesn't have to use those macros.
Assignee | ||
Comment 4•17 years ago
|
||
(In reply to comment #3)
> One doesn't have to use those macros.
True but the idl compiler will generate ns_decl_isupports at a minimum. I was using ns_impl_isupports3 for QI of nsIXFormsDOMEvent, nsIDOMNSEvent, and nsIPrivateDOMEvent but haven't yet figured out how to get nsIDOMEvent. The nsIXFormsDOMEvent interface inherits from nsIDOMEvent. Any ideas?
Assignee | ||
Comment 5•17 years ago
|
||
We have to get nsIDOMEvent added to the interface map so it can be QI'ed from nsIXFormsDOMEvent but also need to implement nsIClassInfo.
Attachment #316146 -
Flags: review?(Olli.Pettay)
Comment 6•17 years ago
|
||
Did you try using the nsIClassInfo implementation of nsDOMEvent?
So implementing QI something like:
NS_INTERFACE_MAP_BEGIN(nsXFormsDOMEvent)
NS_INTERFACE_MAP_ENTRY(nsIXFormsDOMEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSEvent)
NS_INTERFACE_MAP_ENTRY(nsIPrivateDOMEvent)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END_AGGREGATED(mInner)
Assignee | ||
Comment 7•17 years ago
|
||
That will work too if you add NS_INTERFACE_MAP_ENTRY(nsIClassInfo). Then you need to implement AddRef and Release using NS_IMPL_ADDREF(nsXFormsDOMEvent) and NS_IMPL_RELEASE(nsXFormsDOMEvent).
NS_IMPL_ISUPPORTS5 is all of that in one macro so I used it instead.
Comment 8•17 years ago
|
||
I meant that with NS_IMPL_ADDREF and NS_IMPL_RELEASE, but without NS_INTERFACE_MAP_ENTRY(nsIClassInfo) and without the actual classinfo implementation, since mInner can be QI'ed to classinfo.
Assignee | ||
Comment 9•17 years ago
|
||
I did it this way, which is very similar to what you suggest, but it did not work without adding nsIClassInfo because the javascript code throws an exception with a message like 'Permision denied to get property UnnamedClass.type'.
NS_INTERFACE_MAP_BEGIN(nsXFormsDOMEvent)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXFormsDOMEvent)
NS_INTERFACE_MAP_ENTRY(nsIXFormsDOMEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSEvent)
NS_INTERFACE_MAP_ENTRY(nsIPrivateDOMEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMEvent)
NS_INTERFACE_MAP_ENTRY(nsIClassInfo)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(nsXFormsDOMEvent)
NS_IMPL_RELEASE(nsXFormsDOMEvent)
I can try your way with only NS_INTERFACE_MAP_ENTRY(nsISupports).
Assignee | ||
Comment 10•17 years ago
|
||
Ah, just noticed the NS_INTERFACE_MAP_END_AGGREGATED(mInner).
Assignee | ||
Comment 11•17 years ago
|
||
It works if you use NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXFormsDOMEvent)
I'll make a new patch using that interface map and we can do away with the nsIClassInfo implementation.
Assignee | ||
Comment 12•17 years ago
|
||
Attachment #316146 -
Attachment is obsolete: true
Attachment #316284 -
Flags: review?(Olli.Pettay)
Attachment #316146 -
Flags: review?(Olli.Pettay)
Comment 13•17 years ago
|
||
Comment on attachment 316284 [details] [diff] [review]
patch2
>+#include "nsXFormsUtils.h"
>+#include "nsIProgrammingLanguage.h"
I guess these aren't needed.
> NS_METHOD
> nsXFormsDOMEvent::SetTrusted(PRBool aTrusted)
> {
> nsCOMPtr<nsIPrivateDOMEvent> privEvent = do_QueryInterface(mInner);
> return privEvent->SetTrusted(aTrusted);
> }
>+
Extra newline
>+#include "nsIClassInfo.h"
Is this needed?
Those addressed, r=me
Attachment #316284 -
Flags: review?(Olli.Pettay) → review+
Assignee | ||
Comment 14•17 years ago
|
||
Removing unnecessary includes and extra newlines.
Attachment #316284 -
Attachment is obsolete: true
Attachment #316294 -
Flags: review?(aaronr)
Assignee: nobody → msterlin
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee | ||
Updated•17 years ago
|
Status: NEW → ASSIGNED
Comment 15•17 years ago
|
||
Comment on attachment 316294 [details] [diff] [review]
patch3
>Index: nsXFormsDOMEvent.cpp
>===================================================================
>RCS file: /cvsroot/mozilla/extensions/xforms/nsXFormsDOMEvent.cpp,v
>retrieving revision 1.1
>diff -u -8 -p -r1.1 nsXFormsDOMEvent.cpp
>--- nsXFormsDOMEvent.cpp 10 Jan 2008 23:34:07 -0000 1.1
>+++ nsXFormsDOMEvent.cpp 17 Apr 2008 22:02:40 -0000
>@@ -38,17 +38,26 @@
>
> #include "nsXFormsDOMEvent.h"
>
> /**
> * Implementation for XForms events.
> *
> */
>
>-NS_IMPL_ISUPPORTS3(nsXFormsDOMEvent, nsIXFormsDOMEvent, nsIDOMNSEvent, nsIPrivateDOMEvent)
>+NS_INTERFACE_MAP_BEGIN(nsXFormsDOMEvent)
>+ NS_INTERFACE_MAP_ENTRY(nsIXFormsDOMEvent)
>+ NS_INTERFACE_MAP_ENTRY(nsIDOMEvent)
>+ NS_INTERFACE_MAP_ENTRY(nsIDOMNSEvent)
>+ NS_INTERFACE_MAP_ENTRY(nsIPrivateDOMEvent)
>+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXFormsDOMEvent)
>+NS_INTERFACE_MAP_END_AGGREGATED(mInner)
>+
nit: Please add comments here explaining why all of this is needed. Especially the ambiguous and aggregated parts since they aren't commonly found in our code. If someone decided that we didn't need these for some reason we wouldn't notice a problem until someone tried JS event handlers which isn't in our normal test bucket. But if we have comments here then it won't likely be touched unless there is a good reason.
Otherwise looks good to me. r+ with that change.
Attachment #316294 -
Flags: review?(aaronr) → review+
Assignee | ||
Comment 16•17 years ago
|
||
Adding comments to explain the interface map.
Attachment #316294 -
Attachment is obsolete: true
Comment 17•17 years ago
|
||
checked into trunk for msterlin
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Whiteboard: xf-to-branch
Comment 18•17 years ago
|
||
checked into 1.8 branch for msterlin
Keywords: fixed1.8.1.17
Whiteboard: xf-to-branch
Updated•9 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•