From 7a4b830d2c3396b34aa696b489d90d2ea9ecfdd0 Mon Sep 17 00:00:00 2001 From: "jst%netscape.com" Date: Fri, 7 Dec 2001 08:22:02 +0000 Subject: [PATCH] Fixing bug 110798. Freezing nsIDOMEvent and related interfaces. r=harishd@netscape.com, sr=jband@netscape.com git-svn-id: svn://10.0.0.236/branches/MOZILLA_0_9_4_BRANCH@109987 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/accessible/src/nsRootAccessible.cpp | 8 +- mozilla/content/base/src/nsDocument.cpp | 32 +++--- mozilla/content/base/src/nsDocument.h | 9 +- mozilla/content/base/src/nsGenericElement.cpp | 4 +- mozilla/content/events/src/nsDOMEvent.cpp | 1 + mozilla/content/events/src/nsDOMEvent.h | 36 +++---- .../events/src/nsEventListenerManager.cpp | 56 +++++----- .../events/src/nsEventListenerManager.h | 2 +- .../html/content/src/nsHTMLButtonElement.cpp | 18 +++- .../html/content/src/nsHTMLInputElement.cpp | 23 +++- .../content/xul/content/src/nsXULElement.cpp | 7 +- .../content/xul/content/src/nsXULElement.h | 6 +- .../xul/content/src/nsXULPopupListener.cpp | 15 ++- .../xul/document/src/nsXULDocument.cpp | 7 +- .../content/xul/document/src/nsXULDocument.h | 8 +- mozilla/dom/public/idl/events/MANIFEST_IDL | 3 +- mozilla/dom/public/idl/events/Makefile.in | 3 +- mozilla/dom/public/idl/events/makefile.win | 3 +- .../public/idl/events/nsIDOMDocumentEvent.idl | 57 +++++++--- mozilla/dom/public/idl/events/nsIDOMEvent.idl | 100 ++++++++---------- .../public/idl/events/nsIDOMEventListener.idl | 54 +++++++--- .../public/idl/events/nsIDOMEventTarget.idl | 57 +++++++--- mozilla/dom/src/base/nsDOMClassInfo.cpp | 10 ++ mozilla/dom/src/base/nsFocusController.cpp | 16 ++- mozilla/dom/src/base/nsGlobalWindow.cpp | 8 +- mozilla/dom/src/base/nsGlobalWindow.h | 2 +- mozilla/dom/src/base/nsWindowRoot.cpp | 5 +- .../editor/base/nsEditorEventListeners.cpp | 37 +++++-- mozilla/editor/base/nsHTMLDataTransfer.cpp | 18 +++- .../editor/base/nsPlaintextDataTransfer.cpp | 18 +++- .../libeditor/html/nsHTMLDataTransfer.cpp | 19 +++- .../libeditor/text/nsEditorEventListeners.cpp | 31 +++++- .../text/nsPlaintextDataTransfer.cpp | 19 +++- .../xmlextras/base/src/nsXMLHttpRequest.cpp | 2 +- .../layout/html/base/src/nsObjectFrame.cpp | 33 +++++- .../html/forms/src/nsListControlFrame.cpp | 39 +++++-- .../layout/xul/base/src/nsMenuBarListener.cpp | 26 +++-- .../layout/xul/base/src/nsMenuListener.cpp | 30 ++++-- 38 files changed, 558 insertions(+), 264 deletions(-) diff --git a/mozilla/accessible/src/nsRootAccessible.cpp b/mozilla/accessible/src/nsRootAccessible.cpp index a8549fa0daf..e70f10ac03d 100644 --- a/mozilla/accessible/src/nsRootAccessible.cpp +++ b/mozilla/accessible/src/nsRootAccessible.cpp @@ -30,6 +30,7 @@ #include "nsIFrame.h" #include "nsIDOMEventTarget.h" #include "nsIDOMElement.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMEventReceiver.h" #include "nsReadableUtils.h" #include "nsILink.h" @@ -293,7 +294,12 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent) NS_IMETHODIMP nsRootAccessible::GetTargetNode(nsIDOMEvent *aEvent, nsCOMPtr& aTargetNode) { nsCOMPtr domEventTarget; - aEvent->GetOriginalTarget(getter_AddRefs(domEventTarget)); + + nsCOMPtr nsevent(do_QueryInterface(aEvent)); + + if (nsevent) { + nsevent->GetOriginalTarget(getter_AddRefs(domEventTarget)); + } nsresult rv; aTargetNode = do_QueryInterface(domEventTarget, &rv); diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 087e03939ab..a2ea02a2370 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -1557,18 +1557,19 @@ nsDocument::EndLoad() i--; } } - - // Fire a DOM event notifying listeners that this document has been - // loaded (excluding images and other loads initiated by this - // document). - nsCOMPtr event; - CreateEvent(NS_LITERAL_STRING("Events"), - getter_AddRefs(event)); - if (event) { - event->InitEvent(NS_LITERAL_STRING("DOMContentLoaded"), PR_TRUE, PR_TRUE); - DispatchEvent(event); - } - + + // Fire a DOM event notifying listeners that this document has been + // loaded (excluding images and other loads initiated by this + // document). + nsCOMPtr event; + CreateEvent(NS_LITERAL_STRING("Events"), + getter_AddRefs(event)); + if (event) { + event->InitEvent(NS_LITERAL_STRING("DOMContentLoaded"), PR_TRUE, PR_TRUE); + PRBool noDefault; + DispatchEvent(event, &noDefault); + } + return NS_OK; } @@ -2917,7 +2918,8 @@ nsresult nsDocument::GetListenerManager(nsIEventListenerManager **aInstancePtrRe nsresult nsDocument::HandleEvent(nsIDOMEvent *aEvent) { - return DispatchEvent(aEvent); + PRBool noDefault; + return DispatchEvent(aEvent, &noDefault); } nsresult nsDocument::HandleDOMEvent(nsIPresContext* aPresContext, @@ -3040,8 +3042,10 @@ nsresult nsDocument::RemoveEventListener(const nsAReadableString& aType, nsIDOME } NS_IMETHODIMP -nsDocument::DispatchEvent(nsIDOMEvent* aEvent) +nsDocument::DispatchEvent(nsIDOMEvent* aEvent, PRBool *aRetVal) { + *aRetVal = PR_TRUE; + // Obtain a presentation context PRInt32 count = GetNumberOfShells(); if (count == 0) diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index 6a338a9dfce..51e3a128cb4 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -506,14 +506,7 @@ public: NS_DECL_NSIDISKDOCUMENT // nsIDOMEventTarget interface - NS_IMETHOD AddEventListener(const nsAReadableString& aType, - nsIDOMEventListener* aListener, - PRBool aUseCapture); - NS_IMETHOD RemoveEventListener(const nsAReadableString& aType, - nsIDOMEventListener* aListener, - PRBool aUseCapture); - NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent); - + NS_DECL_NSIDOMEVENTTARGET NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 76c978c509c..1054fcd08b1 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -599,13 +599,13 @@ nsDOMEventRTTearoff::RemoveEventListener(const nsAReadableString& type, } NS_IMETHODIMP -nsDOMEventRTTearoff::DispatchEvent(nsIDOMEvent *evt) +nsDOMEventRTTearoff::DispatchEvent(nsIDOMEvent *evt, PRBool *aRetVal) { nsCOMPtr event_receiver; nsresult rv = GetEventReceiver(getter_AddRefs(event_receiver)); NS_ENSURE_SUCCESS(rv, rv); - return event_receiver->DispatchEvent(evt); + return event_receiver->DispatchEvent(evt, aRetVal); } diff --git a/mozilla/content/events/src/nsDOMEvent.cpp b/mozilla/content/events/src/nsDOMEvent.cpp index 6b26480aedc..df9eb7e4868 100644 --- a/mozilla/content/events/src/nsDOMEvent.cpp +++ b/mozilla/content/events/src/nsDOMEvent.cpp @@ -256,6 +256,7 @@ NS_INTERFACE_MAP_BEGIN(nsDOMEvent) NS_INTERFACE_MAP_ENTRY(nsIDOMMouseEvent) NS_INTERFACE_MAP_ENTRY(nsIDOMKeyEvent) NS_INTERFACE_MAP_ENTRY(nsIDOMNSUIEvent) + NS_INTERFACE_MAP_ENTRY(nsIDOMNSEvent) NS_INTERFACE_MAP_ENTRY(nsIPrivateDOMEvent) NS_INTERFACE_MAP_ENTRY(nsIPrivateTextEvent) NS_INTERFACE_MAP_ENTRY(nsIPrivateCompositionEvent) diff --git a/mozilla/content/events/src/nsDOMEvent.h b/mozilla/content/events/src/nsDOMEvent.h index b8f7c77b781..6fc19739df8 100644 --- a/mozilla/content/events/src/nsDOMEvent.h +++ b/mozilla/content/events/src/nsDOMEvent.h @@ -26,6 +26,7 @@ #include "nsIDOMKeyEvent.h" #include "nsIDOMMouseEvent.h" #include "nsIDOMNSUIEvent.h" +#include "nsIDOMNSEvent.h" #include "nsISupports.h" #include "nsIPrivateDOMEvent.h" #include "nsIPrivateCompositionEvent.h" @@ -39,15 +40,16 @@ class nsIContent; class nsIScrollableView; -class nsDOMEvent : public nsIDOMKeyEvent, +class nsDOMEvent : public nsIDOMKeyEvent, + public nsIDOMNSEvent, public nsIDOMMouseEvent, - public nsIDOMNSUIEvent, - public nsIPrivateDOMEvent, - public nsIPrivateTextEvent, + public nsIDOMNSUIEvent, + public nsIPrivateDOMEvent, + public nsIPrivateTextEvent, public nsIPrivateCompositionEvent { - public: + // Note: this enum must be kept in sync with mEventNames in nsDOMEvent.cpp enum nsDOMEvents { eDOMEvents_mousedown=0, @@ -108,27 +110,13 @@ public: NS_DECL_ISUPPORTS // nsIDOMEvent Interface - NS_IMETHOD GetType(nsAWritableString& aType); - NS_IMETHOD GetTarget(nsIDOMEventTarget** aTarget); - NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget); - NS_IMETHOD GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget); - NS_IMETHOD GetEventPhase(PRUint16* aEventPhase); - NS_IMETHOD GetBubbles(PRBool* aBubbles); - NS_IMETHOD GetCancelable(PRBool* aCancelable); - NS_IMETHOD GetTimeStamp(PRUint64* aTimestamp); - NS_IMETHOD StopPropagation(); - NS_IMETHOD PreventBubble(); - NS_IMETHOD PreventCapture(); - NS_IMETHOD PreventDefault(); - NS_IMETHOD InitEvent(const nsAReadableString& aEventTypeArg, - PRBool aCanBubbleArg, PRBool aCancelableArg); + NS_DECL_NSIDOMEVENT + + // nsIDOMNSEvent Interface + NS_DECL_NSIDOMNSEVENT // nsIDOMUIEvent Interface - NS_IMETHOD GetView(nsIDOMAbstractView** aView); - NS_IMETHOD GetDetail(PRInt32* aDetail); - NS_IMETHOD InitUIEvent(const nsAReadableString& aTypeArg, - PRBool aCanBubbleArg, PRBool aCancelableArg, - nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg); + NS_DECL_NSIDOMUIEVENT // nsIDOMMouseEvent Interface and nsIDOMKeyEvent Interface NS_IMETHOD GetScreenX(PRInt32* aScreenX); diff --git a/mozilla/content/events/src/nsEventListenerManager.cpp b/mozilla/content/events/src/nsEventListenerManager.cpp index 71ef985d9cc..11673ba1331 100644 --- a/mozilla/content/events/src/nsEventListenerManager.cpp +++ b/mozilla/content/events/src/nsEventListenerManager.cpp @@ -24,6 +24,7 @@ #include "nsGUIEvent.h" #include "nsDOMEvent.h" #include "nsEventListenerManager.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMEventListener.h" #include "nsIDOMMouseListener.h" #include "nsIDOMMouseMotionListener.h" @@ -2360,7 +2361,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni EventArrayType arrayType; nsListenerStruct *ls; - if (aEventTypes & nsIDOMEvent::MOUSEDOWN) { + if (aEventTypes & nsIDOMNSEvent::MOUSEDOWN) { arrayType = eEventArrayType_Mouse; ls = FindJSEventListener(arrayType); if (ls) { @@ -2369,7 +2370,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::MOUSEUP) { + if (aEventTypes & nsIDOMNSEvent::MOUSEUP) { arrayType = eEventArrayType_Mouse; ls = FindJSEventListener(arrayType); if (ls) { @@ -2378,7 +2379,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::MOUSEOVER) { + if (aEventTypes & nsIDOMNSEvent::MOUSEOVER) { arrayType = eEventArrayType_Mouse; ls = FindJSEventListener(arrayType); if (ls) { @@ -2387,7 +2388,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::MOUSEOUT) { + if (aEventTypes & nsIDOMNSEvent::MOUSEOUT) { arrayType = eEventArrayType_Mouse; ls = FindJSEventListener(arrayType); if (ls) { @@ -2396,7 +2397,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::MOUSEMOVE) { + if (aEventTypes & nsIDOMNSEvent::MOUSEMOVE) { arrayType = eEventArrayType_MouseMotion; ls = FindJSEventListener(arrayType); if (ls) { @@ -2405,7 +2406,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::CLICK) { + if (aEventTypes & nsIDOMNSEvent::CLICK) { arrayType = eEventArrayType_Mouse; ls = FindJSEventListener(arrayType); if (ls) { @@ -2414,7 +2415,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::DBLCLICK) { + if (aEventTypes & nsIDOMNSEvent::DBLCLICK) { arrayType = eEventArrayType_Mouse; ls = FindJSEventListener(arrayType); if (ls) { @@ -2423,7 +2424,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::KEYDOWN) { + if (aEventTypes & nsIDOMNSEvent::KEYDOWN) { arrayType = eEventArrayType_Key; ls = FindJSEventListener(arrayType); if (ls) { @@ -2432,7 +2433,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::KEYUP) { + if (aEventTypes & nsIDOMNSEvent::KEYUP) { arrayType = eEventArrayType_Key; ls = FindJSEventListener(arrayType); if (ls) { @@ -2441,7 +2442,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::KEYPRESS) { + if (aEventTypes & nsIDOMNSEvent::KEYPRESS) { arrayType = eEventArrayType_Key; ls = FindJSEventListener(arrayType); if (ls) { @@ -2450,7 +2451,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::DRAGDROP) { + if (aEventTypes & nsIDOMNSEvent::DRAGDROP) { arrayType = eEventArrayType_Drag; ls = FindJSEventListener(arrayType); if (ls) { @@ -2459,7 +2460,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - /*if (aEventTypes & nsIDOMEvent::MOUSEDRAG) { + /*if (aEventTypes & nsIDOMNSEvent::MOUSEDRAG) { arrayType = kIDOMMouseListenerarrayType; ls = FindJSEventListener(arrayType); if (ls) { @@ -2468,7 +2469,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } }*/ - if (aEventTypes & nsIDOMEvent::FOCUS) { + if (aEventTypes & nsIDOMNSEvent::FOCUS) { arrayType = eEventArrayType_Focus; ls = FindJSEventListener(arrayType); if (ls) { @@ -2477,7 +2478,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::BLUR) { + if (aEventTypes & nsIDOMNSEvent::BLUR) { arrayType = eEventArrayType_Focus; ls = FindJSEventListener(arrayType); if (ls) { @@ -2486,7 +2487,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::SELECT) { + if (aEventTypes & nsIDOMNSEvent::SELECT) { arrayType = eEventArrayType_Form; ls = FindJSEventListener(arrayType); if (ls) { @@ -2495,7 +2496,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::CHANGE) { + if (aEventTypes & nsIDOMNSEvent::CHANGE) { arrayType = eEventArrayType_Form; ls = FindJSEventListener(arrayType); if (ls) { @@ -2504,7 +2505,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::RESET) { + if (aEventTypes & nsIDOMNSEvent::RESET) { arrayType = eEventArrayType_Form; ls = FindJSEventListener(arrayType); if (ls) { @@ -2513,7 +2514,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::SUBMIT) { + if (aEventTypes & nsIDOMNSEvent::SUBMIT) { arrayType = eEventArrayType_Form; ls = FindJSEventListener(arrayType); if (ls) { @@ -2522,7 +2523,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::LOAD) { + if (aEventTypes & nsIDOMNSEvent::LOAD) { arrayType = eEventArrayType_Load; ls = FindJSEventListener(arrayType); if (ls) { @@ -2531,7 +2532,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::UNLOAD) { + if (aEventTypes & nsIDOMNSEvent::UNLOAD) { arrayType = eEventArrayType_Load; ls = FindJSEventListener(arrayType); if (ls) { @@ -2540,7 +2541,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::ABORT) { + if (aEventTypes & nsIDOMNSEvent::ABORT) { arrayType = eEventArrayType_Load; ls = FindJSEventListener(arrayType); if (ls) { @@ -2549,7 +2550,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::ERROR) { + if (aEventTypes & nsIDOMNSEvent::ERROR) { arrayType = eEventArrayType_Load; ls = FindJSEventListener(arrayType); if (ls) { @@ -2558,7 +2559,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::RESIZE) { + if (aEventTypes & nsIDOMNSEvent::RESIZE) { arrayType = eEventArrayType_Paint; ls = FindJSEventListener(arrayType); if (ls) { @@ -2567,7 +2568,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni ls->mFlags |= NS_EVENT_FLAG_CAPTURE; } } - if (aEventTypes & nsIDOMEvent::SCROLL) { + if (aEventTypes & nsIDOMNSEvent::SCROLL) { arrayType = eEventArrayType_Scroll; ls = FindJSEventListener(arrayType); if (ls) { @@ -2609,8 +2610,10 @@ nsEventListenerManager::RemoveEventListener(const nsAReadableString& aType, } NS_IMETHODIMP -nsEventListenerManager::DispatchEvent(nsIDOMEvent* aEvent) +nsEventListenerManager::DispatchEvent(nsIDOMEvent* aEvent, PRBool *aRetVal) { + *aRetVal = PR_TRUE; + //If we don't have a target set this doesn't work. if (mTarget) { nsCOMPtr targetContent(do_QueryInterface(mTarget)); @@ -2667,7 +2670,8 @@ nsEventListenerManager::GetListenerManager(nsIEventListenerManager** aInstancePt NS_IMETHODIMP nsEventListenerManager::HandleEvent(nsIDOMEvent *aEvent) { - return DispatchEvent(aEvent); + PRBool noDefault; + return DispatchEvent(aEvent, &noDefault); } nsresult diff --git a/mozilla/content/events/src/nsEventListenerManager.h b/mozilla/content/events/src/nsEventListenerManager.h index 165a2f8a54e..019dc0b07ac 100644 --- a/mozilla/content/events/src/nsEventListenerManager.h +++ b/mozilla/content/events/src/nsEventListenerManager.h @@ -152,7 +152,7 @@ public: NS_IMETHOD RemoveEventListener(const nsAReadableString& aType, nsIDOMEventListener* aListener, PRBool aUseCapture); - NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent); + NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent, PRBool *aRetVal); // nsIDOMEventReceiver interface NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp index 1cff64952ed..8c05fb2a9ab 100644 --- a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp @@ -37,6 +37,7 @@ #include "nsIFormControlFrame.h" #include "nsIEventStateManager.h" #include "nsIDOMEvent.h" +#include "nsIDOMNSEvent.h" #include "nsISizeOfHandler.h" #include "nsIDocument.h" #include "nsGUIEvent.h" @@ -461,11 +462,20 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext, case NS_MOUSE_RIGHT_DOUBLECLICK: case NS_MOUSE_RIGHT_BUTTON_DOWN: case NS_MOUSE_RIGHT_BUTTON_UP: - if (aDOMEvent != nsnull && *aDOMEvent != nsnull) { - (*aDOMEvent)->PreventBubble(); - } else { - ret = NS_ERROR_FAILURE; + { + nsCOMPtr nsevent; + + if (aDOMEvent) { + nsevent = do_QueryInterface(*aDOMEvent); + } + + if (nsevent) { + nsevent->PreventBubble(); + } else { + ret = NS_ERROR_FAILURE; + } } + break; case NS_MOUSE_ENTER_SYNTH: diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index d64f4f2ea60..5a1c7e99f4c 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -58,6 +58,7 @@ #include "nsIPresState.h" #include "nsIDOMEvent.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMNodeList.h" #include "nsIDOMHTMLCollection.h" #include "nsICheckboxControlFrame.h" @@ -1019,7 +1020,13 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext, (*aDOMEvent)->GetTarget(getter_AddRefs(oldTarget)); nsCOMPtr originalTarget; - (*aDOMEvent)->GetOriginalTarget(getter_AddRefs(originalTarget)); + + nsCOMPtr nsevent(do_QueryInterface(*aDOMEvent)); + + if (nsevent) { + nsevent->GetOriginalTarget(getter_AddRefs(originalTarget)); + } + if (!originalTarget) { privateEvent->SetOriginalTarget(oldTarget); } @@ -1243,8 +1250,14 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext, if (type == NS_FORM_INPUT_BUTTON || type == NS_FORM_INPUT_RESET || type == NS_FORM_INPUT_SUBMIT ) { - if (aDOMEvent != nsnull && *aDOMEvent != nsnull) { - (*aDOMEvent)->PreventBubble(); + nsCOMPtr nsevent; + + if (aDOMEvent) { + nsevent = do_QueryInterface(*aDOMEvent); + } + + if (nsevent) { + nsevent->PreventBubble(); } else { rv = NS_ERROR_FAILURE; } @@ -1682,7 +1695,9 @@ nsHTMLInputElement::FireEventForAccessibility(nsIPresContext* aPresContext, nsCOMPtr eventReceiver(do_QueryInterface(listenerManager)); if ( ! eventReceiver ) return NS_ERROR_FAILURE; - eventReceiver->DispatchEvent(domEvent); + + PRBool noDefault; + eventReceiver->DispatchEvent(domEvent, &noDefault); return NS_OK; } diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 53f30443d66..ac2b92e3bef 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -2008,8 +2008,10 @@ nsXULElement::RemoveEventListener(const nsAReadableString& aType, } NS_IMETHODIMP -nsXULElement::DispatchEvent(nsIDOMEvent* aEvent) +nsXULElement::DispatchEvent(nsIDOMEvent* aEvent, PRBool *aRetVal) { + *aRetVal = PR_TRUE; + // Obtain a presentation context PRInt32 count = mDocument->GetNumberOfShells(); if (count == 0) @@ -2052,7 +2054,8 @@ nsXULElement::GetListenerManager(nsIEventListenerManager** aResult) NS_IMETHODIMP nsXULElement::HandleEvent(nsIDOMEvent *aEvent) { - return DispatchEvent(aEvent); + PRBool noDefault; + return DispatchEvent(aEvent, &noDefault); } diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index 79ed8d0a202..4e516883d0d 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -443,11 +443,7 @@ public: NS_DECL_NSIDOMXULELEMENT // nsIDOMEventTarget interface (from nsIDOMEventReceiver) - NS_IMETHOD AddEventListener(const nsAReadableString& aType, nsIDOMEventListener* aListener, - PRBool aUseCapture); - NS_IMETHOD RemoveEventListener(const nsAReadableString& aType, nsIDOMEventListener* aListener, - PRBool aUseCapture); - NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent); + NS_DECL_NSIDOMEVENTTARGET // nsIDOMEventReceiver NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID); diff --git a/mozilla/content/xul/content/src/nsXULPopupListener.cpp b/mozilla/content/xul/content/src/nsXULPopupListener.cpp index aa65719a037..3cdec63080e 100644 --- a/mozilla/content/xul/content/src/nsXULPopupListener.cpp +++ b/mozilla/content/xul/content/src/nsXULPopupListener.cpp @@ -54,6 +54,7 @@ #include "nsITimer.h" #include "nsIDOMNSUIEvent.h" #include "nsIDOMEventTarget.h" +#include "nsIDOMNSEvent.h" #include "nsIBoxObject.h" #include "nsIPopupBoxObject.h" @@ -357,6 +358,8 @@ XULPopupListenerImpl::PreLaunchPopup(nsIDOMEvent* aMouseEvent) // Store clicked-on node in xul document. xulDocument->SetPopupNode( targetNode ); + nsCOMPtr nsevent(do_QueryInterface(aMouseEvent)); + switch (popupType) { case eXULPopupType_popup: // Check for left mouse button down @@ -364,7 +367,11 @@ XULPopupListenerImpl::PreLaunchPopup(nsIDOMEvent* aMouseEvent) if (button == 0) { // Time to launch a popup menu. LaunchPopup(aMouseEvent); - aMouseEvent->PreventBubble(); + + if (nsevent) { + nsevent->PreventBubble(); + } + aMouseEvent->PreventDefault(); } break; @@ -377,7 +384,11 @@ XULPopupListenerImpl::PreLaunchPopup(nsIDOMEvent* aMouseEvent) FireFocusOnTargetContent(targetNode); #endif LaunchPopup(aMouseEvent); - aMouseEvent->PreventBubble(); + + if (nsevent) { + nsevent->PreventBubble(); + } + aMouseEvent->PreventDefault(); break; diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index c09aa2e63b4..d3c1fba2b92 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -4265,8 +4265,10 @@ nsXULDocument::RemoveEventListener(const nsAReadableString& aType, } NS_IMETHODIMP -nsXULDocument::DispatchEvent(nsIDOMEvent* aEvent) +nsXULDocument::DispatchEvent(nsIDOMEvent* aEvent, PRBool *aRetVal) { + *aRetVal = PR_TRUE; + // Obtain a presentation context PRInt32 count = GetNumberOfShells(); if (count == 0) @@ -4335,7 +4337,8 @@ nsXULDocument::GetListenerManager(nsIEventListenerManager** aResult) NS_IMETHODIMP nsXULDocument::HandleEvent(nsIDOMEvent *aEvent) { - return DispatchEvent(aEvent); + PRBool noDefault; + return DispatchEvent(aEvent, &noDefault); } nsresult diff --git a/mozilla/content/xul/document/src/nsXULDocument.h b/mozilla/content/xul/document/src/nsXULDocument.h index c42b6f2436f..c6a31d7321e 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.h +++ b/mozilla/content/xul/document/src/nsXULDocument.h @@ -355,13 +355,7 @@ public: NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent); // nsIDOMEventTarget interface - NS_IMETHOD AddEventListener(const nsAReadableString& aType, - nsIDOMEventListener* aListener, - PRBool aUseCapture); - NS_IMETHOD RemoveEventListener(const nsAReadableString& aType, - nsIDOMEventListener* aListener, - PRBool aUseCapture); - NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent); + NS_DECL_NSIDOMEVENTTARGET // nsIDOMDocument interface NS_DECL_NSIDOMDOCUMENT diff --git a/mozilla/dom/public/idl/events/MANIFEST_IDL b/mozilla/dom/public/idl/events/MANIFEST_IDL index 038d3168a3c..47733b3657a 100644 --- a/mozilla/dom/public/idl/events/MANIFEST_IDL +++ b/mozilla/dom/public/idl/events/MANIFEST_IDL @@ -1,9 +1,10 @@ nsIDOMDocumentEvent.idl nsIDOMEvent.idl +nsIDOMNSEvent.idl nsIDOMEventListener.idl nsIDOMEventTarget.idl nsIDOMKeyEvent.idl nsIDOMMouseEvent.idl nsIDOMMutationEvent.idl -nsIDOMNSUIEvent.idl nsIDOMUIEvent.idl +nsIDOMNSUIEvent.idl diff --git a/mozilla/dom/public/idl/events/Makefile.in b/mozilla/dom/public/idl/events/Makefile.in index eee70d29d4d..8dce27cf94d 100644 --- a/mozilla/dom/public/idl/events/Makefile.in +++ b/mozilla/dom/public/idl/events/Makefile.in @@ -32,12 +32,13 @@ XPIDL_MODULE = dom_events XPIDLSRCS = \ nsIDOMDocumentEvent.idl \ nsIDOMEvent.idl \ + nsIDOMNSEvent.idl \ nsIDOMEventTarget.idl \ nsIDOMKeyEvent.idl \ nsIDOMMouseEvent.idl \ nsIDOMMutationEvent.idl \ - nsIDOMNSUIEvent.idl \ nsIDOMUIEvent.idl \ + nsIDOMNSUIEvent.idl \ nsIDOMEventListener.idl \ $(NULL) diff --git a/mozilla/dom/public/idl/events/makefile.win b/mozilla/dom/public/idl/events/makefile.win index 25044354f9a..37dcd2162fe 100644 --- a/mozilla/dom/public/idl/events/makefile.win +++ b/mozilla/dom/public/idl/events/makefile.win @@ -27,12 +27,13 @@ XPIDL_MODULE=dom_events XPIDLSRCS = \ .\nsIDOMDocumentEvent.idl \ .\nsIDOMEvent.idl \ + .\nsIDOMNSEvent.idl \ .\nsIDOMEventTarget.idl \ .\nsIDOMKeyEvent.idl \ .\nsIDOMMouseEvent.idl \ .\nsIDOMMutationEvent.idl \ - .\nsIDOMNSUIEvent.idl \ .\nsIDOMUIEvent.idl \ + .\nsIDOMNSUIEvent.idl \ .\nsIDOMEventListener.idl \ $(NULL) diff --git a/mozilla/dom/public/idl/events/nsIDOMDocumentEvent.idl b/mozilla/dom/public/idl/events/nsIDOMDocumentEvent.idl index 667168b32da..c5004e9be58 100644 --- a/mozilla/dom/public/idl/events/nsIDOMDocumentEvent.idl +++ b/mozilla/dom/public/idl/events/nsIDOMDocumentEvent.idl @@ -1,31 +1,58 @@ /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. * * The Original Code is mozilla.org code. * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 2000 Netscape Communications Corporation. All - * Rights Reserved. + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2000 + * the Initial Developer. All Rights Reserved. * * Contributor(s): * Tom Pixley (original author) * Johnny Stenback - */ + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * 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 NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ #include "domstubs.idl" +/** + * The nsIDOMDocumentEvent interface is the interface to the event + * factory method on a DOM document object. + * + * For more information on this interface please see + * http://www.w3.org/TR/DOM-Level-2-Events/ + * + * @status FROZEN + */ + [scriptable, uuid(46b91d66-28e2-11d4-ab1e-0010830123b4)] interface nsIDOMDocumentEvent : nsISupports { - nsIDOMEvent createEvent(in DOMString eventType); + nsIDOMEvent createEvent(in DOMString eventType) + raises(DOMException); }; diff --git a/mozilla/dom/public/idl/events/nsIDOMEvent.idl b/mozilla/dom/public/idl/events/nsIDOMEvent.idl index 975445a729d..22e9607d350 100644 --- a/mozilla/dom/public/idl/events/nsIDOMEvent.idl +++ b/mozilla/dom/public/idl/events/nsIDOMEvent.idl @@ -1,88 +1,74 @@ /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. * * The Original Code is mozilla.org code. * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 2000 Netscape Communications Corporation. All - * Rights Reserved. + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2000 + * the Initial Developer. All Rights Reserved. * * Contributor(s): * Tom Pixley (original author) * Johnny Stenback - */ + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * 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 NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ #include "domstubs.idl" interface nsIDOMEventTarget; +/** + * The nsIDOMEvent interface is the primary datatype for all events in + * the Document Object Model. + * + * For more information on this interface please see + * http://www.w3.org/TR/DOM-Level-2-Events/ + * + * @status FROZEN + */ [scriptable, uuid(a66b7b80-ff46-bd97-0080-5f8ae38add32)] interface nsIDOMEvent : nsISupports { - const unsigned short CAPTURING_PHASE = 1; - const unsigned short AT_TARGET = 2; - const unsigned short BUBBLING_PHASE = 3; - - const long MOUSEDOWN = 0x00000001; - const long MOUSEUP = 0x00000002; - const long MOUSEOVER = 0x00000004; - const long MOUSEOUT = 0x00000008; - const long MOUSEMOVE = 0x00000010; - const long MOUSEDRAG = 0x00000020; - const long CLICK = 0x00000040; - const long DBLCLICK = 0x00000080; - const long KEYDOWN = 0x00000100; - const long KEYUP = 0x00000200; - const long KEYPRESS = 0x00000400; - const long DRAGDROP = 0x00000800; - const long FOCUS = 0x00001000; - const long BLUR = 0x00002000; - const long SELECT = 0x00004000; - const long CHANGE = 0x00008000; - const long RESET = 0x00010000; - const long SUBMIT = 0x00020000; - const long SCROLL = 0x00040000; - const long LOAD = 0x00080000; - const long UNLOAD = 0x00100000; - const long XFER_DONE = 0x00200000; - const long ABORT = 0x00400000; - const long ERROR = 0x00800000; - const long LOCATE = 0x01000000; - const long MOVE = 0x02000000; - const long RESIZE = 0x04000000; - const long FORWARD = 0x08000000; - const long HELP = 0x10000000; - const long BACK = 0x20000000; - const long TEXT = 0x40000000; - - const long ALT_MASK = 0x00000001; - const long CONTROL_MASK = 0x00000002; - const long SHIFT_MASK = 0x00000004; - const long META_MASK = 0x00000008; + // PhaseType + const unsigned short CAPTURING_PHASE = 1; + const unsigned short AT_TARGET = 2; + const unsigned short BUBBLING_PHASE = 3; readonly attribute DOMString type; readonly attribute nsIDOMEventTarget target; readonly attribute nsIDOMEventTarget currentTarget; - readonly attribute nsIDOMEventTarget originalTarget; readonly attribute unsigned short eventPhase; readonly attribute boolean bubbles; readonly attribute boolean cancelable; readonly attribute DOMTimeStamp timeStamp; void stopPropagation(); - void preventBubble(); - void preventCapture(); void preventDefault(); void initEvent(in DOMString eventTypeArg, in boolean canBubbleArg, diff --git a/mozilla/dom/public/idl/events/nsIDOMEventListener.idl b/mozilla/dom/public/idl/events/nsIDOMEventListener.idl index 93317d2e489..92fc8dca7f7 100644 --- a/mozilla/dom/public/idl/events/nsIDOMEventListener.idl +++ b/mozilla/dom/public/idl/events/nsIDOMEventListener.idl @@ -1,29 +1,55 @@ /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. * * The Original Code is mozilla.org code. * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 2000 Netscape Communications Corporation. All - * Rights Reserved. + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2000 + * the Initial Developer. All Rights Reserved. * * Contributor(s): * Tom Pixley (original author) * Johnny Stenback - */ + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * 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 NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ #include "domstubs.idl" +/** + * The nsIDOMEventListener interface is a callback interface for + * listening to events in the Document Object Model. + * + * For more information on this interface please see + * http://www.w3.org/TR/DOM-Level-2-Events/ + * + * @status FROZEN + */ + [scriptable, function, uuid(df31c120-ded6-11d1-bd85-00805f8ae3f4)] interface nsIDOMEventListener : nsISupports { diff --git a/mozilla/dom/public/idl/events/nsIDOMEventTarget.idl b/mozilla/dom/public/idl/events/nsIDOMEventTarget.idl index 98a81cfd175..6094a985f53 100644 --- a/mozilla/dom/public/idl/events/nsIDOMEventTarget.idl +++ b/mozilla/dom/public/idl/events/nsIDOMEventTarget.idl @@ -1,29 +1,55 @@ /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. * * The Original Code is mozilla.org code. * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 2000 Netscape Communications Corporation. All - * Rights Reserved. + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2000 + * the Initial Developer. All Rights Reserved. * * Contributor(s): * Tom Pixley (original author) * Johnny Stenback - */ + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * 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 NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ #include "domstubs.idl" +/** + * The nsIDOMEventTarget interface is the interface implemented by all + * event targets in the Document Object Model. + * + * For more information on this interface please see + * http://www.w3.org/TR/DOM-Level-2-Events/ + * + * @status FROZEN + */ + [scriptable, uuid(1c773b30-d1cf-11d2-bd95-00805f8ae3f4)] interface nsIDOMEventTarget : nsISupports { @@ -34,5 +60,6 @@ interface nsIDOMEventTarget : nsISupports void removeEventListener(in DOMString type, in nsIDOMEventListener listener, in boolean useCapture); - void dispatchEvent(in nsIDOMEvent evt); + boolean dispatchEvent(in nsIDOMEvent evt) + raises(DOMException); }; diff --git a/mozilla/dom/src/base/nsDOMClassInfo.cpp b/mozilla/dom/src/base/nsDOMClassInfo.cpp index db00e1f7b2e..8040137c7cd 100644 --- a/mozilla/dom/src/base/nsDOMClassInfo.cpp +++ b/mozilla/dom/src/base/nsDOMClassInfo.cpp @@ -43,6 +43,7 @@ #include "nsIDOMDocument.h" #include "nsIDOMNSDocument.h" #include "nsIDOMEvent.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMKeyEvent.h" #include "nsIDOMEventListener.h" @@ -1051,6 +1052,7 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_BEGIN(Event, nsIDOMEvent) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEvent) DOM_CLASSINFO_MAP_ENTRY(nsIDOMKeyEvent) DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent) DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSUIEvent) @@ -2619,6 +2621,14 @@ nsWindowSH::GlobalResolve(nsISupports *native, JSContext *cx, JSObject *obj, rv = DefineInterfaceConstants(cx, cfnc_obj, &primary_iid); NS_ENSURE_SUCCESS(rv, rv); + // Special case for |Event|, Event needs constants from NSEvent + // too for backwards compatibility. + if (primary_iid.Equals(NS_GET_IID(nsIDOMEvent))) { + rv = DefineInterfaceConstants(cx, cfnc_obj, + &NS_GET_IID(nsIDOMNSEvent)); + NS_ENSURE_SUCCESS(rv, rv); + } + nsCOMPtr iim = dont_AddRef(XPTI_GetInterfaceInfoManager()); NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE); diff --git a/mozilla/dom/src/base/nsFocusController.cpp b/mozilla/dom/src/base/nsFocusController.cpp index 86b9fc8b2ea..28eeeabf30e 100644 --- a/mozilla/dom/src/base/nsFocusController.cpp +++ b/mozilla/dom/src/base/nsFocusController.cpp @@ -29,6 +29,7 @@ #include "nsIDOMNSHTMLInputElement.h" #include "nsIDOMNSHTMLTextAreaElement.h" #include "nsIDOMUIEvent.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMWindowInternal.h" #include "nsIDocument.h" #include "nsIPresContext.h" @@ -245,8 +246,12 @@ nsFocusController::Focus(nsIDOMEvent* aEvent) return NS_OK; nsCOMPtr t; - aEvent->GetOriginalTarget(getter_AddRefs(t)); - + + nsCOMPtr nsevent(do_QueryInterface(aEvent)); + if (nsevent) { + nsevent->GetOriginalTarget(getter_AddRefs(t)); + } + nsCOMPtr domElement = do_QueryInterface(t); if (domElement && (domElement != mCurrentElement)) { SetFocusedElement(domElement); @@ -297,7 +302,12 @@ nsFocusController::Blur(nsIDOMEvent* aEvent) return NS_OK; nsCOMPtr t; - aEvent->GetOriginalTarget(getter_AddRefs(t)); + + nsCOMPtr nsevent(do_QueryInterface(aEvent)); + + if (nsevent) { + nsevent->GetOriginalTarget(getter_AddRefs(t)); + } nsCOMPtr domElement = do_QueryInterface(t); if (domElement) { diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index 344d74c3e6c..9588fafccbb 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -2690,8 +2690,11 @@ GlobalWindowImpl::RemoveEventListener(const nsAReadableString& aType, return NS_ERROR_FAILURE; } -NS_IMETHODIMP GlobalWindowImpl::DispatchEvent(nsIDOMEvent* aEvent) +NS_IMETHODIMP GlobalWindowImpl::DispatchEvent(nsIDOMEvent* aEvent, + PRBool *aRetVal) { + *aRetVal = PR_TRUE; + if (mDocument) { nsCOMPtr idoc(do_QueryInterface(mDocument)); if (idoc) { @@ -2770,7 +2773,8 @@ GlobalWindowImpl::GetNewListenerManager(nsIEventListenerManager **aResult) NS_IMETHODIMP GlobalWindowImpl::HandleEvent(nsIDOMEvent *aEvent) { - return DispatchEvent(aEvent); + PRBool noDefault; + return DispatchEvent(aEvent, &noDefault); } //***************************************************************************** diff --git a/mozilla/dom/src/base/nsGlobalWindow.h b/mozilla/dom/src/base/nsGlobalWindow.h index 2133cc02193..aaa21a5ad8d 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.h +++ b/mozilla/dom/src/base/nsGlobalWindow.h @@ -140,7 +140,7 @@ public: NS_IMETHOD RemoveEventListener(const nsAReadableString& aType, nsIDOMEventListener* aListener, PRBool aUseCapture); - NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent); + NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent, PRBool *aRetVal); // nsIDOMEventReceiver NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, diff --git a/mozilla/dom/src/base/nsWindowRoot.cpp b/mozilla/dom/src/base/nsWindowRoot.cpp index d27c61bcf3a..d7e3630c14f 100644 --- a/mozilla/dom/src/base/nsWindowRoot.cpp +++ b/mozilla/dom/src/base/nsWindowRoot.cpp @@ -84,7 +84,7 @@ nsWindowRoot::RemoveEventListener(const nsAReadableString& aType, nsIDOMEventLis } NS_IMETHODIMP -nsWindowRoot::DispatchEvent(nsIDOMEvent* aEvt) +nsWindowRoot::DispatchEvent(nsIDOMEvent* aEvt, PRBool *aRetVal) { // Obtain a presentation context nsCOMPtr domDoc; @@ -153,7 +153,8 @@ nsWindowRoot::GetListenerManager(nsIEventListenerManager** aResult) NS_IMETHODIMP nsWindowRoot::HandleEvent(nsIDOMEvent *aEvent) { - return DispatchEvent(aEvent); + PRBool noDefault; + return DispatchEvent(aEvent, &noDefault); } NS_IMETHODIMP nsWindowRoot::HandleChromeEvent(nsIPresContext* aPresContext, diff --git a/mozilla/editor/base/nsEditorEventListeners.cpp b/mozilla/editor/base/nsEditorEventListeners.cpp index 5c7c3af0b2e..d947f78fc19 100644 --- a/mozilla/editor/base/nsEditorEventListeners.cpp +++ b/mozilla/editor/base/nsEditorEventListeners.cpp @@ -26,6 +26,7 @@ #include "nsString.h" #include "nsIDOMEvent.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMDocument.h" #include "nsIDocument.h" #include "nsIPresShell.h" @@ -427,9 +428,14 @@ nsTextEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent) else editor->Paste(clipboard); - // Prevent the event from bubbling up to be possibly handled - // again by the containing window: - mouseEvent->PreventBubble(); + nsCOMPtr nsevent(do_QueryInterface(mouseEvent)); + + if (nsevent) { + // Prevent the event from bubbling up to be possibly handled + // again by the containing window: + nsevent->PreventBubble(); + } + mouseEvent->PreventDefault(); // We processed the event, whether drop/paste succeeded or not @@ -725,8 +731,13 @@ nsTextEditorDragListener::DragDrop(nsIDOMEvent* aMouseEvent) nsCOMPtr nsuiEvent (do_QueryInterface(aMouseEvent)); if (!nsuiEvent) return NS_OK; - //some day we want to use another way to stop this from bubbling. - aMouseEvent->PreventBubble(); + nsCOMPtr nsevent(do_QueryInterface(aMouseEvent)); + + if (nsevent) { + //some day we want to use another way to stop this from bubbling. + nsevent->PreventBubble(); + } + aMouseEvent->PreventDefault(); /* for bug 47399, when dropping a drag session, if you are over your original @@ -1061,7 +1072,13 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent) if (mEditor) { PRUint32 flags; - aEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } + mEditor->GetFlags(&flags); if (! (flags & nsIPlaintextEditor::eEditorDisabledMask)) { // only enable caret and selection if the editor is not disabled @@ -1122,7 +1139,13 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent) if (mEditor) { PRUint32 flags; - aEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } + mEditor->GetFlags(&flags); nsCOMPtreditor = do_QueryInterface(mEditor); if (editor) diff --git a/mozilla/editor/base/nsHTMLDataTransfer.cpp b/mozilla/editor/base/nsHTMLDataTransfer.cpp index 758c641d00b..f4a7dbaf609 100644 --- a/mozilla/editor/base/nsHTMLDataTransfer.cpp +++ b/mozilla/editor/base/nsHTMLDataTransfer.cpp @@ -34,6 +34,7 @@ #include "nsIDOMAttr.h" #include "nsIDocument.h" #include "nsIDOMEventReceiver.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMKeyEvent.h" #include "nsIDOMKeyListener.h" #include "nsIDOMMouseListener.h" @@ -923,8 +924,15 @@ NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag) return NS_OK; nsCOMPtr eventTarget; - res = aDragEvent->GetOriginalTarget(getter_AddRefs(eventTarget)); - if (NS_FAILED(res)) return res; + + nsCOMPtr nsevent(do_QueryInterface(aDragEvent)); + + if (nsevent) { + res = nsevent->GetOriginalTarget(getter_AddRefs(eventTarget)); + if (NS_FAILED(res)) + return res; + } + if ( eventTarget ) { nsCOMPtr eventTargetDomNode = do_QueryInterface(eventTarget); @@ -1056,7 +1064,11 @@ NS_IMETHODIMP nsHTMLEditor::DoDrag(nsIDOMEvent *aDragEvent) rv = dragService->InvokeDragSession( domnode, transferableArray, nsnull, flags); if (NS_FAILED(rv)) return rv; - aDragEvent->PreventBubble(); + nsCOMPtr nsevent(do_QueryInterface(aDragEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } } } diff --git a/mozilla/editor/base/nsPlaintextDataTransfer.cpp b/mozilla/editor/base/nsPlaintextDataTransfer.cpp index 8dcf08fa3a4..70be86a8262 100644 --- a/mozilla/editor/base/nsPlaintextDataTransfer.cpp +++ b/mozilla/editor/base/nsPlaintextDataTransfer.cpp @@ -30,6 +30,7 @@ #include "nsIDOMAttr.h" #include "nsIDocument.h" #include "nsIDOMEventReceiver.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMKeyEvent.h" #include "nsIDOMKeyListener.h" #include "nsIDOMMouseListener.h" @@ -387,8 +388,15 @@ NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDr return NS_OK; nsCOMPtr eventTarget; - res = aDragEvent->GetOriginalTarget(getter_AddRefs(eventTarget)); - if (NS_FAILED(res)) return res; + + nsCOMPtr nsevent(do_QueryInterface(aDragEvent)); + + if (nsevent) { + res = nsevent->GetOriginalTarget(getter_AddRefs(eventTarget)); + if (NS_FAILED(res)) + return res; + } + if ( eventTarget ) { nsCOMPtr eventTargetDomNode = do_QueryInterface(eventTarget); @@ -520,7 +528,11 @@ NS_IMETHODIMP nsPlaintextEditor::DoDrag(nsIDOMEvent *aDragEvent) rv = dragService->InvokeDragSession( domnode, transferableArray, nsnull, flags); if (NS_FAILED(rv)) return rv; - aDragEvent->PreventBubble(); + nsCOMPtr nsevent(do_QueryInterface(aDragEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } } } diff --git a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp index 758c641d00b..d024c03ab34 100644 --- a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -34,6 +34,7 @@ #include "nsIDOMAttr.h" #include "nsIDocument.h" #include "nsIDOMEventReceiver.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMKeyEvent.h" #include "nsIDOMKeyListener.h" #include "nsIDOMMouseListener.h" @@ -923,8 +924,16 @@ NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag) return NS_OK; nsCOMPtr eventTarget; - res = aDragEvent->GetOriginalTarget(getter_AddRefs(eventTarget)); - if (NS_FAILED(res)) return res; + + nsCOMPtr nsevent(do_QueryInterface(aDragEvent)); + + if (nsevent) { + res = nsevent->GetOriginalTarget(getter_AddRefs(eventTarget)); + if (NS_FAILED(res)) { + return res; + } + } + if ( eventTarget ) { nsCOMPtr eventTargetDomNode = do_QueryInterface(eventTarget); @@ -1056,7 +1065,11 @@ NS_IMETHODIMP nsHTMLEditor::DoDrag(nsIDOMEvent *aDragEvent) rv = dragService->InvokeDragSession( domnode, transferableArray, nsnull, flags); if (NS_FAILED(rv)) return rv; - aDragEvent->PreventBubble(); + nsCOMPtr nsevent(do_QueryInterface(aDragEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } } } diff --git a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp index 5c7c3af0b2e..44c24b47c3d 100644 --- a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp +++ b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp @@ -26,6 +26,7 @@ #include "nsString.h" #include "nsIDOMEvent.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMDocument.h" #include "nsIDocument.h" #include "nsIPresShell.h" @@ -429,7 +430,12 @@ nsTextEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent) // Prevent the event from bubbling up to be possibly handled // again by the containing window: - mouseEvent->PreventBubble(); + nsCOMPtr nsevent(do_QueryInterface(mouseEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } + mouseEvent->PreventDefault(); // We processed the event, whether drop/paste succeeded or not @@ -726,7 +732,12 @@ nsTextEditorDragListener::DragDrop(nsIDOMEvent* aMouseEvent) if (!nsuiEvent) return NS_OK; //some day we want to use another way to stop this from bubbling. - aMouseEvent->PreventBubble(); + nsCOMPtr nsevent(do_QueryInterface(aMouseEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } + aMouseEvent->PreventDefault(); /* for bug 47399, when dropping a drag session, if you are over your original @@ -1061,7 +1072,13 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent) if (mEditor) { PRUint32 flags; - aEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } + mEditor->GetFlags(&flags); if (! (flags & nsIPlaintextEditor::eEditorDisabledMask)) { // only enable caret and selection if the editor is not disabled @@ -1122,7 +1139,13 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent) if (mEditor) { PRUint32 flags; - aEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } + mEditor->GetFlags(&flags); nsCOMPtreditor = do_QueryInterface(mEditor); if (editor) diff --git a/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp b/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp index 8dcf08fa3a4..17a8cc05698 100644 --- a/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp +++ b/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp @@ -30,6 +30,7 @@ #include "nsIDOMAttr.h" #include "nsIDocument.h" #include "nsIDOMEventReceiver.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMKeyEvent.h" #include "nsIDOMKeyListener.h" #include "nsIDOMMouseListener.h" @@ -387,8 +388,16 @@ NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDr return NS_OK; nsCOMPtr eventTarget; - res = aDragEvent->GetOriginalTarget(getter_AddRefs(eventTarget)); - if (NS_FAILED(res)) return res; + + nsCOMPtr nsevent(do_QueryInterface(aDragEvent)); + + if (nsevent) { + res = nsevent->GetOriginalTarget(getter_AddRefs(eventTarget)); + if (NS_FAILED(res)) { + return res; + } + } + if ( eventTarget ) { nsCOMPtr eventTargetDomNode = do_QueryInterface(eventTarget); @@ -520,7 +529,11 @@ NS_IMETHODIMP nsPlaintextEditor::DoDrag(nsIDOMEvent *aDragEvent) rv = dragService->InvokeDragSession( domnode, transferableArray, nsnull, flags); if (NS_FAILED(rv)) return rv; - aDragEvent->PreventBubble(); + nsCOMPtr nsevent(do_QueryInterface(aDragEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } } } diff --git a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp index 7a63f23e827..bb9a2670c7a 100644 --- a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp @@ -211,7 +211,7 @@ nsXMLHttpRequest::RemoveEventListener(const nsAReadableString & type, /* void dispatchEvent (in nsIDOMEvent evt); */ NS_IMETHODIMP -nsXMLHttpRequest::DispatchEvent(nsIDOMEvent *evt) +nsXMLHttpRequest::DispatchEvent(nsIDOMEvent *evt, PRBool *aRetVal) { // Ignored diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 42aa5230639..14bc8eed092 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -64,6 +64,7 @@ #include "nsIDOMMouseMotionListener.h" #include "nsIDOMFocusListener.h" #include "nsIDOMEventReceiver.h" +#include "nsIDOMNSEvent.h" #include "nsIPrivateDOMEvent.h" #include "nsIDocumentEncoder.h" #include "nsXPIDLString.h" @@ -3007,7 +3008,13 @@ nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent) nsEventStatus rv = ProcessEvent(focusEvent); if (nsEventStatus_eConsumeNoDefault == rv) { aFocusEvent->PreventDefault(); - aFocusEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aFocusEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } + return NS_ERROR_FAILURE; // means consume event } } @@ -3037,7 +3044,13 @@ nsresult nsPluginInstanceOwner::KeyPress(nsIDOMEvent* aKeyEvent) // If this event is going to the plugin, we want to kill it. // Not actually sending keypress to the plugin, since we didn't before. aKeyEvent->PreventDefault(); - aKeyEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aKeyEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } + return NS_ERROR_FAILURE; // means consume event } return NS_OK; @@ -3055,7 +3068,13 @@ nsresult nsPluginInstanceOwner::DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent) nsEventStatus rv = ProcessEvent(*keyEvent); if (nsEventStatus_eConsumeNoDefault == rv) { aKeyEvent->PreventDefault(); - aKeyEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aKeyEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } + return NS_ERROR_FAILURE; // means consume event } } @@ -3171,7 +3190,13 @@ nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent) nsEventStatus rv = ProcessEvent(*mouseEvent); if (nsEventStatus_eConsumeNoDefault == rv) { aMouseEvent->PreventDefault(); - aMouseEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aMouseEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + } + return NS_ERROR_FAILURE; // means consume event } } diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index 0b308a9b751..4bd39d036f0 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -59,6 +59,7 @@ #include "nsVoidArray.h" #include "nsIScrollableFrame.h" #include "nsIDOMEventTarget.h" +#include "nsIDOMNSEvent.h" #include "nsGUIEvent.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" @@ -3363,8 +3364,13 @@ nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent) if (IsInDropDownMode() == PR_TRUE) { if (!IsClickingInCombobox(aMouseEvent)) { aMouseEvent->PreventDefault(); - aMouseEvent->PreventCapture(); - aMouseEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aMouseEvent)); + + if (nsevent) { + nsevent->PreventCapture(); + nsevent->PreventBubble(); + } } else { mButtonDown = PR_FALSE; CaptureMouseEvents(mPresContext, PR_FALSE); @@ -3547,8 +3553,13 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent) if (IsInDropDownMode()) { if (!IsClickingInCombobox(aMouseEvent)) { aMouseEvent->PreventDefault(); - aMouseEvent->PreventCapture(); - aMouseEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aMouseEvent)); + + if (nsevent) { + nsevent->PreventCapture(); + nsevent->PreventBubble(); + } } else { return NS_OK; } @@ -3988,8 +3999,13 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) mComboboxFrame->IsDroppedDown(&isDroppedDown); mComboboxFrame->ShowDropDown(!isDroppedDown); aKeyEvent->PreventDefault(); - aKeyEvent->PreventCapture(); - aKeyEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aKeyEvent)); + + if (nsevent) { + nsevent->PreventCapture(); + nsevent->PreventBubble(); + } } } #endif @@ -4013,9 +4029,14 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) } else { return rv; } - - // We are handling this so don't let it bubble up - aKeyEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aKeyEvent)); + + if (nsevent) { + // We are handling this so don't let it bubble up + + nsevent->PreventBubble(); + } // this tells us whether we need to process the new index that was set // DOM_VK_RETURN & DOM_VK_ESCAPE will leave this false diff --git a/mozilla/layout/xul/base/src/nsMenuBarListener.cpp b/mozilla/layout/xul/base/src/nsMenuBarListener.cpp index 9c84bbb076d..efb4d01ab86 100644 --- a/mozilla/layout/xul/base/src/nsMenuBarListener.cpp +++ b/mozilla/layout/xul/base/src/nsMenuBarListener.cpp @@ -30,6 +30,7 @@ #include "nsIDOMEventReceiver.h" #include "nsIDOMEventListener.h" #include "nsIDOMNSUIEvent.h" +#include "nsIDOMNSEvent.h" #include "nsGUIEvent.h" // Drag & Drop, Clipboard @@ -142,8 +143,13 @@ nsMenuBarListener::KeyUp(nsIDOMEvent* aKeyEvent) PRBool active = mMenuBarFrame->IsActive(); if (active) { - aKeyEvent->PreventBubble(); - aKeyEvent->PreventCapture(); + nsCOMPtr nsevent(do_QueryInterface(aKeyEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + nsevent->PreventCapture(); + } + aKeyEvent->PreventDefault(); return NS_ERROR_BASE; // I am consuming event } @@ -172,6 +178,8 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent) if (mAccessKey) { nsCOMPtr nsUIEvent = do_QueryInterface(aKeyEvent); + nsCOMPtr nsevent(do_QueryInterface(aKeyEvent)); + PRBool preventDefault; nsUIEvent->GetPreventDefault(&preventDefault); @@ -193,8 +201,11 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent) mMenuBarFrame->ShortcutNavigation(theChar, active); if (active) { - aKeyEvent->PreventBubble(); - aKeyEvent->PreventCapture(); + if (nsevent) { + nsevent->PreventBubble(); + nsevent->PreventCapture(); + } + aKeyEvent->PreventDefault(); retVal = NS_ERROR_BASE; // I am consuming event @@ -213,8 +224,11 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent) // In Windows, both of these activate the menu bar. mMenuBarFrame->ToggleMenuActiveState(); - aKeyEvent->PreventBubble(); - aKeyEvent->PreventCapture(); + if (nsevent) { + nsevent->PreventBubble(); + nsevent->PreventCapture(); + } + aKeyEvent->PreventDefault(); return NS_ERROR_BASE; // consume the event } diff --git a/mozilla/layout/xul/base/src/nsMenuListener.cpp b/mozilla/layout/xul/base/src/nsMenuListener.cpp index ac18401d713..3042b1f3932 100644 --- a/mozilla/layout/xul/base/src/nsMenuListener.cpp +++ b/mozilla/layout/xul/base/src/nsMenuListener.cpp @@ -30,6 +30,7 @@ #include "nsIDOMEventReceiver.h" #include "nsIDOMEventListener.h" #include "nsIDOMNSUIEvent.h" +#include "nsIDOMNSEvent.h" #include "nsGUIEvent.h" // Drag & Drop, Clipboard @@ -76,9 +77,14 @@ nsMenuListener::~nsMenuListener() //////////////////////////////////////////////////////////////////////// nsresult nsMenuListener::KeyUp(nsIDOMEvent* aKeyEvent) -{ - aKeyEvent->PreventBubble(); - aKeyEvent->PreventCapture(); +{ + nsCOMPtr nsevent(do_QueryInterface(aKeyEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + nsevent->PreventCapture(); + } + aKeyEvent->PreventDefault(); return NS_ERROR_BASE; // I am consuming event @@ -142,8 +148,13 @@ nsMenuListener::KeyDown(nsIDOMEvent* aKeyEvent) mMenuParent->DismissChain(); } - aKeyEvent->PreventBubble(); - aKeyEvent->PreventCapture(); + nsCOMPtr nsevent(do_QueryInterface(aKeyEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + nsevent->PreventCapture(); + } + aKeyEvent->PreventDefault(); return NS_ERROR_BASE; // I am consuming event @@ -209,8 +220,13 @@ nsMenuListener::KeyPress(nsIDOMEvent* aKeyEvent) } } - aKeyEvent->PreventBubble(); - aKeyEvent->PreventCapture(); + nsCOMPtr nsevent(do_QueryInterface(aKeyEvent)); + + if (nsevent) { + nsevent->PreventBubble(); + nsevent->PreventCapture(); + } + aKeyEvent->PreventDefault(); return NS_ERROR_BASE; // I am consuming event