Bug 970199 - Switch mouse event button type from ushort to short according to spec change. r=smaug
authorMaksim Lebedev <alessarik@gmail.com>
Thu, 20 Feb 2014 10:38:13 -0800
changeset 170125 ac8adf61a96b73ad57d0b30fdebab5dc86154fc9
parent 170124 cf6a31bca4e0374128683c0ed35957cbb98e256d
child 170126 8991d3139e4064448de5c9c870b7aa7500912354
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerssmaug
bugs970199
milestone30.0a1
Bug 970199 - Switch mouse event button type from ushort to short according to spec change. r=smaug
content/xul/content/src/nsXULPopupListener.cpp
dom/events/nsDOMMouseEvent.cpp
dom/events/nsDOMMouseEvent.h
dom/events/nsEventStateManager.cpp
dom/events/nsIMEStateManager.cpp
dom/interfaces/events/nsIDOMMouseEvent.idl
dom/webidl/MouseEvent.webidl
dom/xbl/nsXBLPrototypeHandler.cpp
editor/libeditor/base/nsEditorEventListener.cpp
editor/libeditor/html/nsHTMLEditorEventListener.cpp
extensions/spellcheck/src/mozInlineSpellChecker.cpp
layout/forms/nsListControlFrame.cpp
layout/xul/nsSplitterFrame.cpp
toolkit/components/satchel/nsFormFillController.cpp
--- a/content/xul/content/src/nsXULPopupListener.cpp
+++ b/content/xul/content/src/nsXULPopupListener.cpp
@@ -101,17 +101,17 @@ nsXULPopupListener::HandleEvent(nsIDOMEv
 {
   nsAutoString eventType;
   aEvent->GetType(eventType);
 
   if(!((eventType.EqualsLiteral("mousedown") && !mIsContext) ||
        (eventType.EqualsLiteral("contextmenu") && mIsContext)))
     return NS_OK;
 
-  uint16_t button;
+  int16_t button;
 
   nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent);
   if (!mouseEvent) {
     //non-ui event passed in.  bad things.
     return NS_OK;
   }
 
   // Get the node that was clicked on.
--- a/dom/events/nsDOMMouseEvent.cpp
+++ b/dom/events/nsDOMMouseEvent.cpp
@@ -91,17 +91,17 @@ nsDOMMouseEvent::InitMouseEvent(const ns
                                 bool aCanBubble,
                                 bool aCancelable,
                                 nsIDOMWindow* aView,
                                 int32_t aDetail,
                                 int32_t aScreenX,
                                 int32_t aScreenY,
                                 int32_t aClientX,
                                 int32_t aClientY,
-                                uint16_t aButton,
+                                int16_t aButton,
                                 nsIDOMEventTarget *aRelatedTarget,
                                 const nsAString& aModifiersList)
 {
   Modifiers modifiers = ComputeModifierState(aModifiersList);
 
   nsresult rv = InitMouseEvent(aType, aCanBubble, aCancelable, aView,
                                aDetail, aScreenX, aScreenY, aClientX, aClientY,
                                (modifiers & MODIFIER_CONTROL) != 0,
@@ -174,24 +174,24 @@ nsDOMMouseEvent::InitNSMouseEvent(const 
 
   WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
   mouseEventBase->pressure = aPressure;
   mouseEventBase->inputSource = aInputSource;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetButton(uint16_t* aButton)
+nsDOMMouseEvent::GetButton(int16_t* aButton)
 {
   NS_ENSURE_ARG_POINTER(aButton);
   *aButton = Button();
   return NS_OK;
 }
 
-uint16_t
+int16_t
 nsDOMMouseEvent::Button()
 {
   switch(mEvent->eventStructType)
   {
     case NS_MOUSE_EVENT:
     case NS_MOUSE_SCROLL_EVENT:
     case NS_WHEEL_EVENT:
     case NS_DRAG_EVENT:
--- a/dom/events/nsDOMMouseEvent.h
+++ b/dom/events/nsDOMMouseEvent.h
@@ -42,17 +42,17 @@ public:
   int32_t ScreenX();
   int32_t ScreenY();
   int32_t ClientX();
   int32_t ClientY();
   bool CtrlKey();
   bool ShiftKey();
   bool AltKey();
   bool MetaKey();
-  uint16_t Button();
+  int16_t Button();
   uint16_t Buttons();
   already_AddRefed<mozilla::dom::EventTarget> GetRelatedTarget();
   void InitMouseEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
                       nsIDOMWindow* aView, int32_t aDetail, int32_t aScreenX,
                       int32_t aScreenY, int32_t aClientX, int32_t aClientY,
                       bool aCtrlKey, bool aAltKey, bool aShiftKey,
                       bool aMetaKey, uint16_t aButton,
                       mozilla::dom::EventTarget *aRelatedTarget,
@@ -103,17 +103,17 @@ protected:
                           bool aCanBubble,
                           bool aCancelable,
                           nsIDOMWindow* aView,
                           int32_t aDetail,
                           int32_t aScreenX,
                           int32_t aScreenY,
                           int32_t aClientX,
                           int32_t aClientY,
-                          uint16_t aButton,
+                          int16_t aButton,
                           nsIDOMEventTarget *aRelatedTarget,
                           const nsAString& aModifiersList);
 };
 
 #define NS_FORWARD_TO_NSDOMMOUSEEVENT         \
   NS_FORWARD_NSIDOMMOUSEEVENT(nsDOMMouseEvent::) \
   NS_FORWARD_TO_NSDOMUIEVENT
 
--- a/dom/events/nsEventStateManager.cpp
+++ b/dom/events/nsEventStateManager.cpp
@@ -4098,16 +4098,17 @@ nsEventStateManager::DispatchMouseOrPoin
     PROFILER_LABEL("Input", "DispatchMouseEvent");
     newMouseEvent =
       new WidgetMouseEvent(aMouseEvent->mFlags.mIsTrusted, aMessage,
                            aMouseEvent->widget, WidgetMouseEvent::eReal);
     event = newMouseEvent.get();
   }
   event->refPoint = aMouseEvent->refPoint;
   event->modifiers = aMouseEvent->modifiers;
+  event->button = aMouseEvent->button;
   event->buttons = aMouseEvent->buttons;
   event->pluginEvent = aMouseEvent->pluginEvent;
   event->relatedTarget = aRelatedContent;
   event->inputSource = aMouseEvent->inputSource;
 
   nsWeakFrame previousTarget = mCurrentTarget;
 
   mCurrentTargetContent = aTargetContent;
--- a/dom/events/nsIMEStateManager.cpp
+++ b/dom/events/nsIMEStateManager.cpp
@@ -308,17 +308,17 @@ nsIMEStateManager::OnClickInEditor(nsPre
 
   bool isTrusted;
   nsresult rv = aMouseEvent->GetIsTrusted(&isTrusted);
   NS_ENSURE_SUCCESS_VOID(rv);
   if (!isTrusted) {
     return; // ignore untrusted event.
   }
 
-  uint16_t button;
+  int16_t button;
   rv = aMouseEvent->GetButton(&button);
   NS_ENSURE_SUCCESS_VOID(rv);
   if (button != 0) {
     return; // not a left click event.
   }
 
   int32_t clickCount;
   rv = aMouseEvent->GetDetail(&clickCount);
--- a/dom/interfaces/events/nsIDOMMouseEvent.idl
+++ b/dom/interfaces/events/nsIDOMMouseEvent.idl
@@ -8,34 +8,34 @@
 /**
  * The nsIDOMMouseEvent interface is the datatype for all mouse events
  * in the Document Object Model.
  *
  * For more information on this interface please see
  * http://www.w3.org/TR/DOM-Level-2-Events/
  */
 
-[scriptable, builtinclass, uuid(afb2e57b-2822-4969-b2a9-0cada6859534)]
+[scriptable, builtinclass, uuid(df068636-9a5b-11e3-b71f-2c27d728e7f9)]
 interface nsIDOMMouseEvent : nsIDOMUIEvent
 {
   readonly attribute long               screenX;
   readonly attribute long               screenY;
 
   readonly attribute long               mozMovementX;
   readonly attribute long               mozMovementY;
 
   readonly attribute long               clientX;
   readonly attribute long               clientY;
 
   readonly attribute boolean            ctrlKey;
   readonly attribute boolean            shiftKey;
   readonly attribute boolean            altKey;
   readonly attribute boolean            metaKey;
 
-  readonly attribute unsigned short     button;
+  readonly attribute short              button;
   readonly attribute unsigned short     buttons;
   readonly attribute nsIDOMEventTarget  relatedTarget;
 
   void                      initMouseEvent(in DOMString typeArg,
                                            in boolean canBubbleArg,
                                            in boolean cancelableArg,
                                            in nsIDOMWindow viewArg,
                                            in long detailArg,
--- a/dom/webidl/MouseEvent.webidl
+++ b/dom/webidl/MouseEvent.webidl
@@ -14,17 +14,17 @@ interface MouseEvent : UIEvent {
   readonly attribute long           screenX;
   readonly attribute long           screenY;
   readonly attribute long           clientX;
   readonly attribute long           clientY;
   readonly attribute boolean        ctrlKey;
   readonly attribute boolean        shiftKey;
   readonly attribute boolean        altKey;
   readonly attribute boolean        metaKey;
-  readonly attribute unsigned short button;
+  readonly attribute short          button;
   readonly attribute unsigned short buttons;
   readonly attribute EventTarget?   relatedTarget;
   // Deprecated in DOM Level 3:
   [Throws]
   void                              initMouseEvent(DOMString typeArg, 
                                                    boolean canBubbleArg, 
                                                    boolean cancelableArg, 
                                                    WindowProxy? viewArg, 
@@ -32,17 +32,17 @@ interface MouseEvent : UIEvent {
                                                    long screenXArg, 
                                                    long screenYArg, 
                                                    long clientXArg, 
                                                    long clientYArg, 
                                                    boolean ctrlKeyArg, 
                                                    boolean altKeyArg, 
                                                    boolean shiftKeyArg, 
                                                    boolean metaKeyArg, 
-                                                   unsigned short buttonArg,
+                                                   short buttonArg,
                                                    EventTarget? relatedTargetArg);
   // Introduced in DOM Level 3:
   boolean                           getModifierState(DOMString keyArg);
 };
 
 
 // Event Constructor Syntax:
 [Constructor(DOMString typeArg, optional MouseEventInit mouseEventInitDict)]
@@ -64,17 +64,17 @@ dictionary MouseEventInit {
   long           screenX       = 0;
   long           screenY       = 0;
   long           clientX       = 0;
   long           clientY       = 0;
   boolean        ctrlKey       = false;
   boolean        shiftKey      = false;
   boolean        altKey        = false;
   boolean        metaKey       = false;
-  unsigned short button        = 0;
+  short          button        = 0;
   // Note: "buttons" was not previously initializable through initMouseEvent!
   unsigned short buttons       = 0;
   EventTarget?   relatedTarget = null;
 };
 
 // Mozilla extensions
 partial interface MouseEvent
 {
@@ -104,15 +104,15 @@ partial interface MouseEvent
                                        long screenXArg,
                                        long screenYArg,
                                        long clientXArg,
                                        long clientYArg,
                                        boolean ctrlKeyArg,
                                        boolean altKeyArg,
                                        boolean shiftKeyArg,
                                        boolean metaKeyArg,
-                                       unsigned short buttonArg,
+                                       short buttonArg,
                                        EventTarget? relatedTargetArg,
                                        float pressure,
                                        unsigned short inputSourceArg);
 
 };
 
--- a/dom/xbl/nsXBLPrototypeHandler.cpp
+++ b/dom/xbl/nsXBLPrototypeHandler.cpp
@@ -639,17 +639,17 @@ nsXBLPrototypeHandler::KeyEventMatched(n
 }
 
 bool
 nsXBLPrototypeHandler::MouseEventMatched(nsIDOMMouseEvent* aMouseEvent)
 {
   if (mDetail == -1 && mMisc == 0 && (mKeyMask & cAllModifiers) == 0)
     return true; // No filters set up. It's generic.
 
-  uint16_t button;
+  int16_t button;
   aMouseEvent->GetButton(&button);
   if (mDetail != -1 && (button != mDetail))
     return false;
 
   int32_t clickcount;
   aMouseEvent->GetDetail(&clickcount);
   if (mMisc != 0 && (clickcount != mMisc))
     return false;
--- a/editor/libeditor/base/nsEditorEventListener.cpp
+++ b/editor/libeditor/base/nsEditorEventListener.cpp
@@ -582,17 +582,17 @@ nsEditorEventListener::MouseClick(nsIDOM
     // We're done if 'preventdefault' is true (see for example bug 70698).
     return rv;
   }
 
   // If we got a mouse down inside the editing area, we should force the 
   // IME to commit before we change the cursor position
   mEditor->ForceCompositionEnd();
 
-  uint16_t button = (uint16_t)-1;
+  int16_t button = -1;
   mouseEvent->GetButton(&button);
   // middle-mouse click (paste);
   if (button == 1)
   {
     if (Preferences::GetBool("middlemouse.paste", false))
     {
       // Set the selection to the point under the mouse cursor:
       nsCOMPtr<nsIDOMNode> parent;
--- a/editor/libeditor/html/nsHTMLEditorEventListener.cpp
+++ b/editor/libeditor/html/nsHTMLEditorEventListener.cpp
@@ -86,17 +86,17 @@ nsHTMLEditorEventListener::MouseDown(nsI
     return NS_OK;
   }
 
   nsHTMLEditor* htmlEditor = GetHTMLEditor();
 
   // Detect only "context menu" click
   //XXX This should be easier to do!
   // But eDOMEvents_contextmenu and NS_CONTEXTMENU is not exposed in any event interface :-(
-  uint16_t buttonNumber;
+  int16_t buttonNumber;
   nsresult res = mouseEvent->GetButton(&buttonNumber);
   NS_ENSURE_SUCCESS(res, res);
 
   bool isContextClick = buttonNumber == 2;
 
   int32_t clickCount;
   res = mouseEvent->GetDetail(&clickCount);
   NS_ENSURE_SUCCESS(res, res);
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -1942,17 +1942,17 @@ nsresult mozInlineSpellChecker::Blur(nsI
 
 nsresult mozInlineSpellChecker::MouseClick(nsIDOMEvent *aMouseEvent)
 {
   nsCOMPtr<nsIDOMMouseEvent>mouseEvent = do_QueryInterface(aMouseEvent);
   NS_ENSURE_TRUE(mouseEvent, NS_OK);
 
   // ignore any errors from HandleNavigationEvent as we don't want to prevent 
   // anyone else from seeing this event.
-  uint16_t button;
+  int16_t button;
   mouseEvent->GetButton(&button);
   HandleNavigationEvent(button != 0);
   return NS_OK;
 }
 
 nsresult mozInlineSpellChecker::KeyPress(nsIDOMEvent* aKeyEvent)
 {
   nsCOMPtr<nsIDOMKeyEvent>keyEvent = do_QueryInterface(aKeyEvent);
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -1501,17 +1501,17 @@ nsListControlFrame::IsOptionDisabled(int
 // helper
 //----------------------------------------------------------------------
 bool
 nsListControlFrame::IsLeftButton(nsIDOMEvent* aMouseEvent)
 {
   // only allow selection with the left button
   nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aMouseEvent);
   if (mouseEvent) {
-    uint16_t whichButton;
+    int16_t whichButton;
     if (NS_SUCCEEDED(mouseEvent->GetButton(&whichButton))) {
       return whichButton != 0?false:true;
     }
   }
   return false;
 }
 
 nscoord
--- a/layout/xul/nsSplitterFrame.cpp
+++ b/layout/xul/nsSplitterFrame.cpp
@@ -597,17 +597,17 @@ nsSplitterFrameInner::MouseUp(nsIDOMEven
 nsresult
 nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
 {  
   NS_ENSURE_TRUE(mOuter, NS_OK);
   nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
   if (!mouseEvent)
     return NS_OK;
 
-  uint16_t button = 0;
+  int16_t button = 0;
   mouseEvent->GetButton(&button);
 
   // only if left button
   if (button != 0)
      return NS_OK;
 
   if (mOuter->GetContent()->
         AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
--- a/toolkit/components/satchel/nsFormFillController.cpp
+++ b/toolkit/components/satchel/nsFormFillController.cpp
@@ -957,17 +957,17 @@ nsFormFillController::MouseDown(nsIDOMEv
   if (!mouseEvent)
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIDOMHTMLInputElement> targetInput = do_QueryInterface(
     aEvent->InternalDOMEvent()->GetTarget());
   if (!targetInput)
     return NS_OK;
 
-  uint16_t button;
+  int16_t button;
   mouseEvent->GetButton(&button);
   if (button != 0)
     return NS_OK;
 
   bool isOpen = false;
   GetPopupOpen(&isOpen);
   if (isOpen)
     return NS_OK;