diff --git a/mozilla/accessible/src/base/nsRootAccessible.cpp b/mozilla/accessible/src/base/nsRootAccessible.cpp index 919912d9744..a4e1039d206 100644 --- a/mozilla/accessible/src/base/nsRootAccessible.cpp +++ b/mozilla/accessible/src/base/nsRootAccessible.cpp @@ -47,6 +47,7 @@ #include "nsIFrame.h" #include "nsIDOMEventTarget.h" #include "nsIDOMElement.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMEventReceiver.h" #include "nsIDOMEventListener.h" #include "nsReadableUtils.h" @@ -389,7 +390,11 @@ 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/accessible/src/nsRootAccessible.cpp b/mozilla/accessible/src/nsRootAccessible.cpp index 919912d9744..a84ab965bc8 100644 --- a/mozilla/accessible/src/nsRootAccessible.cpp +++ b/mozilla/accessible/src/nsRootAccessible.cpp @@ -47,6 +47,7 @@ #include "nsIFrame.h" #include "nsIDOMEventTarget.h" #include "nsIDOMElement.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMEventReceiver.h" #include "nsIDOMEventListener.h" #include "nsReadableUtils.h" @@ -389,7 +390,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/events/src/nsDOMEvent.cpp b/mozilla/content/events/src/nsDOMEvent.cpp index 92c78b871c8..6e61be6839c 100644 --- a/mozilla/content/events/src/nsDOMEvent.cpp +++ b/mozilla/content/events/src/nsDOMEvent.cpp @@ -285,6 +285,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 8c61fd7af3b..cc067caa08d 100644 --- a/mozilla/content/events/src/nsDOMEvent.h +++ b/mozilla/content/events/src/nsDOMEvent.h @@ -42,6 +42,7 @@ #include "nsIDOMKeyEvent.h" #include "nsIDOMMouseEvent.h" #include "nsIDOMNSUIEvent.h" +#include "nsIDOMNSEvent.h" #include "nsISupports.h" #include "nsIPrivateDOMEvent.h" #include "nsIPrivateCompositionEvent.h" @@ -55,15 +56,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, @@ -124,27 +126,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 44d28b4125e..99e67e27ab3 100644 --- a/mozilla/content/events/src/nsEventListenerManager.cpp +++ b/mozilla/content/events/src/nsEventListenerManager.cpp @@ -40,6 +40,7 @@ #include "nsGUIEvent.h" #include "nsDOMEvent.h" #include "nsEventListenerManager.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMEventListener.h" #include "nsIDOMMouseListener.h" #include "nsIDOMMouseMotionListener.h" @@ -2379,7 +2380,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) { @@ -2388,7 +2389,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) { @@ -2397,7 +2398,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) { @@ -2406,7 +2407,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) { @@ -2415,7 +2416,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) { @@ -2424,7 +2425,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) { @@ -2433,7 +2434,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) { @@ -2442,7 +2443,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) { @@ -2451,7 +2452,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) { @@ -2460,7 +2461,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) { @@ -2469,7 +2470,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) { @@ -2478,7 +2479,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) { @@ -2487,7 +2488,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) { @@ -2496,7 +2497,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) { @@ -2505,7 +2506,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) { @@ -2514,7 +2515,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) { @@ -2523,7 +2524,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) { @@ -2532,7 +2533,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) { @@ -2541,7 +2542,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) { @@ -2550,7 +2551,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) { @@ -2559,7 +2560,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) { @@ -2568,7 +2569,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) { @@ -2577,7 +2578,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) { @@ -2586,7 +2587,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) { diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp index 970ccc87935..09352913af6 100644 --- a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp @@ -54,6 +54,7 @@ #include "nsIFormControlFrame.h" #include "nsIEventStateManager.h" #include "nsIDOMEvent.h" +#include "nsIDOMNSEvent.h" #include "nsISizeOfHandler.h" #include "nsIDocument.h" #include "nsGUIEvent.h" @@ -496,11 +497,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 01c345aa293..092c1c0a2e3 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -75,6 +75,7 @@ #include "nsIPresState.h" #include "nsIDOMEvent.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMNodeList.h" #include "nsIDOMHTMLCollection.h" #include "nsICheckboxControlFrame.h" @@ -1074,7 +1075,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); } @@ -1299,8 +1306,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; } diff --git a/mozilla/content/xul/content/src/nsXULPopupListener.cpp b/mozilla/content/xul/content/src/nsXULPopupListener.cpp index 300e45ac7e9..440aefd9f8a 100644 --- a/mozilla/content/xul/content/src/nsXULPopupListener.cpp +++ b/mozilla/content/xul/content/src/nsXULPopupListener.cpp @@ -65,6 +65,7 @@ #include "nsIDOMMouseEvent.h" #include "nsIDOMNSUIEvent.h" #include "nsIDOMEventTarget.h" +#include "nsIDOMNSEvent.h" #include "nsIBoxObject.h" #include "nsIPopupBoxObject.h" @@ -269,6 +270,8 @@ XULPopupListenerImpl::PreLaunchPopup(nsIDOMEvent* aMouseEvent) // Store clicked-on node in xul document for context menus and menu popups. xulDocument->SetPopupNode( targetNode ); + nsCOMPtr nsevent(do_QueryInterface(aMouseEvent)); + switch (popupType) { case eXULPopupType_popup: // Check for left mouse button down @@ -276,7 +279,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; @@ -289,7 +296,11 @@ XULPopupListenerImpl::PreLaunchPopup(nsIDOMEvent* aMouseEvent) FireFocusOnTargetContent(targetNode); #endif LaunchPopup(aMouseEvent); - aMouseEvent->PreventBubble(); + + if (nsevent) { + nsevent->PreventBubble(); + } + aMouseEvent->PreventDefault(); break; } diff --git a/mozilla/dom/public/idl/events/nsIDOMDocumentEvent.idl b/mozilla/dom/public/idl/events/nsIDOMDocumentEvent.idl index 9e040da254c..c5004e9be58 100644 --- a/mozilla/dom/public/idl/events/nsIDOMDocumentEvent.idl +++ b/mozilla/dom/public/idl/events/nsIDOMDocumentEvent.idl @@ -40,6 +40,16 @@ #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 { diff --git a/mozilla/dom/public/idl/events/nsIDOMEvent.idl b/mozilla/dom/public/idl/events/nsIDOMEvent.idl index f4ecec26241..22e9607d350 100644 --- a/mozilla/dom/public/idl/events/nsIDOMEvent.idl +++ b/mozilla/dom/public/idl/events/nsIDOMEvent.idl @@ -42,63 +42,33 @@ 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 15469b10624..92fc8dca7f7 100644 --- a/mozilla/dom/public/idl/events/nsIDOMEventListener.idl +++ b/mozilla/dom/public/idl/events/nsIDOMEventListener.idl @@ -40,6 +40,16 @@ #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 7407db2a848..6094a985f53 100644 --- a/mozilla/dom/public/idl/events/nsIDOMEventTarget.idl +++ b/mozilla/dom/public/idl/events/nsIDOMEventTarget.idl @@ -40,6 +40,16 @@ #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 { diff --git a/mozilla/dom/public/idl/events/nsIDOMNSEvent.idl b/mozilla/dom/public/idl/events/nsIDOMNSEvent.idl index 6dd85d7d63a..1fd6cf800bc 100644 --- a/mozilla/dom/public/idl/events/nsIDOMNSEvent.idl +++ b/mozilla/dom/public/idl/events/nsIDOMNSEvent.idl @@ -20,8 +20,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Tom Pixley (original author) - * Johnny Stenback + * Johnny Stenback (original author) * * * Alternatively, the contents of this file may be used under the terms of diff --git a/mozilla/dom/src/base/nsDOMClassInfo.cpp b/mozilla/dom/src/base/nsDOMClassInfo.cpp index f42cc179f79..4bc7b6e9059 100644 --- a/mozilla/dom/src/base/nsDOMClassInfo.cpp +++ b/mozilla/dom/src/base/nsDOMClassInfo.cpp @@ -61,6 +61,7 @@ #include "nsIDOMXMLDocument.h" #include "nsIDOMNSDocument.h" #include "nsIDOMEvent.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMKeyEvent.h" #include "nsIDOMEventListener.h" @@ -1115,6 +1116,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) @@ -2779,6 +2781,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 e9c7290aa0b..17eadbdfe2d 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/editor/libeditor/html/nsHTMLDataTransfer.cpp b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp index 06b8e7026d3..d94cffec223 100644 --- a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -51,6 +51,7 @@ #include "nsIDOMAttr.h" #include "nsIDocument.h" #include "nsIDOMEventReceiver.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMKeyEvent.h" #include "nsIDOMKeyListener.h" #include "nsIDOMMouseListener.h" @@ -1056,8 +1057,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); @@ -1227,7 +1236,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 faa35941231..9b8dd5b383a 100644 --- a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp +++ b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp @@ -42,6 +42,7 @@ #include "nsString.h" #include "nsIDOMEvent.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMDocument.h" #include "nsIDocument.h" #include "nsIPresShell.h" @@ -448,7 +449,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 @@ -756,7 +762,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 @@ -1093,7 +1104,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 @@ -1154,7 +1171,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); diff --git a/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp b/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp index 5b285362e2e..069d462033d 100644 --- a/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp +++ b/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp @@ -47,6 +47,7 @@ #include "nsIDOMAttr.h" #include "nsIDocument.h" #include "nsIDOMEventReceiver.h" +#include "nsIDOMNSEvent.h" #include "nsIDOMKeyEvent.h" #include "nsIDOMKeyListener.h" #include "nsIDOMMouseListener.h" @@ -403,8 +404,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); @@ -536,7 +545,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/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index fb3eb72785b..c270d385bd8 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -74,6 +74,7 @@ #include "nsVoidArray.h" #include "nsIScrollableFrame.h" #include "nsIDOMEventTarget.h" +#include "nsIDOMNSEvent.h" #include "nsGUIEvent.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" @@ -2551,8 +2552,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 { CaptureMouseEvents(mPresContext, PR_FALSE); return NS_OK; @@ -2597,8 +2603,14 @@ nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent) IsOptionDisabled(selectedIndex, isDisabled); if (isDisabled) { aMouseEvent->PreventDefault(); - aMouseEvent->PreventCapture(); - aMouseEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aMouseEvent)); + + if (nsevent) { + nsevent->PreventCapture(); + nsevent->PreventBubble(); + } + CaptureMouseEvents(mPresContext, PR_FALSE); return NS_ERROR_FAILURE; } @@ -2725,8 +2737,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; } @@ -3068,8 +3085,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 @@ -3093,9 +3115,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 is the new index to set // DOM_VK_RETURN & DOM_VK_ESCAPE will not set this @@ -3175,7 +3202,7 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) default: { // Select option with this as the first character // XXX Not I18N compliant - code = (PRUint32)nsCRT::ToLower((PRUnichar)code); + code = (PRUint32)nsCRT::ToLower((char)code); PRInt32 selectedIndex; GetSelectedIndex(&selectedIndex); if (selectedIndex == kNothingSelected) { diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index bd3795c7347..19c0adce17c 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -79,6 +79,7 @@ #include "nsIDOMMouseMotionListener.h" #include "nsIDOMFocusListener.h" #include "nsIDOMEventReceiver.h" +#include "nsIDOMNSEvent.h" #include "nsIPrivateDOMEvent.h" #include "nsIDocumentEncoder.h" #include "nsXPIDLString.h" @@ -3075,7 +3076,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 } } @@ -3105,7 +3112,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; @@ -3123,7 +3136,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 } } @@ -3239,7 +3258,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/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index bd3795c7347..19c0adce17c 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -79,6 +79,7 @@ #include "nsIDOMMouseMotionListener.h" #include "nsIDOMFocusListener.h" #include "nsIDOMEventReceiver.h" +#include "nsIDOMNSEvent.h" #include "nsIPrivateDOMEvent.h" #include "nsIDocumentEncoder.h" #include "nsXPIDLString.h" @@ -3075,7 +3076,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 } } @@ -3105,7 +3112,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; @@ -3123,7 +3136,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 } } @@ -3239,7 +3258,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 fb3eb72785b..c270d385bd8 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -74,6 +74,7 @@ #include "nsVoidArray.h" #include "nsIScrollableFrame.h" #include "nsIDOMEventTarget.h" +#include "nsIDOMNSEvent.h" #include "nsGUIEvent.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" @@ -2551,8 +2552,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 { CaptureMouseEvents(mPresContext, PR_FALSE); return NS_OK; @@ -2597,8 +2603,14 @@ nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent) IsOptionDisabled(selectedIndex, isDisabled); if (isDisabled) { aMouseEvent->PreventDefault(); - aMouseEvent->PreventCapture(); - aMouseEvent->PreventBubble(); + + nsCOMPtr nsevent(do_QueryInterface(aMouseEvent)); + + if (nsevent) { + nsevent->PreventCapture(); + nsevent->PreventBubble(); + } + CaptureMouseEvents(mPresContext, PR_FALSE); return NS_ERROR_FAILURE; } @@ -2725,8 +2737,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; } @@ -3068,8 +3085,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 @@ -3093,9 +3115,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 is the new index to set // DOM_VK_RETURN & DOM_VK_ESCAPE will not set this @@ -3175,7 +3202,7 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) default: { // Select option with this as the first character // XXX Not I18N compliant - code = (PRUint32)nsCRT::ToLower((PRUnichar)code); + code = (PRUint32)nsCRT::ToLower((char)code); PRInt32 selectedIndex; GetSelectedIndex(&selectedIndex); if (selectedIndex == kNothingSelected) { diff --git a/mozilla/layout/xul/base/src/nsMenuBarListener.cpp b/mozilla/layout/xul/base/src/nsMenuBarListener.cpp index f53905ce565..cf9178890d2 100644 --- a/mozilla/layout/xul/base/src/nsMenuBarListener.cpp +++ b/mozilla/layout/xul/base/src/nsMenuBarListener.cpp @@ -44,6 +44,7 @@ #include "nsIDOMEventReceiver.h" #include "nsIDOMEventListener.h" #include "nsIDOMNSUIEvent.h" +#include "nsIDOMNSEvent.h" #include "nsGUIEvent.h" // Drag & Drop, Clipboard @@ -156,8 +157,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 } @@ -186,6 +192,8 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent) if (mAccessKey) { nsCOMPtr nsUIEvent = do_QueryInterface(aKeyEvent); + nsCOMPtr nsevent(do_QueryInterface(aKeyEvent)); + PRBool preventDefault; nsUIEvent->GetPreventDefault(&preventDefault); @@ -207,8 +215,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 @@ -227,8 +238,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 a065a3b174e..78057d956f9 100644 --- a/mozilla/layout/xul/base/src/nsMenuListener.cpp +++ b/mozilla/layout/xul/base/src/nsMenuListener.cpp @@ -44,6 +44,7 @@ #include "nsIDOMEventReceiver.h" #include "nsIDOMEventListener.h" #include "nsIDOMNSUIEvent.h" +#include "nsIDOMNSEvent.h" #include "nsGUIEvent.h" // Drag & Drop, Clipboard @@ -91,9 +92,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 @@ -157,8 +163,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 @@ -235,8 +246,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