Bug 719320 part.18 Clean up legacy mouse scroll event r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Sun, 12 Aug 2012 10:42:37 +0900
changeset 107548 83eeedda95c20ed9b868befd746a74ba9b1b9b9d
parent 107547 07819a70a6a5361549855a667f31a055223a2f86
child 107631 9d086534903aefa26ae7d1421b9677161dac7d98
push id1490
push userakeybl@mozilla.com
push dateMon, 08 Oct 2012 18:29:50 +0000
treeherdermozilla-beta@f335e7dacdc1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs719320
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 719320 part.18 Clean up legacy mouse scroll event r=smaug
content/events/src/nsDOMEvent.cpp
content/events/src/nsDOMMouseScrollEvent.cpp
content/events/src/nsEventStateManager.cpp
widget/nsGUIEvent.h
widget/nsGUIEventIPC.h
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -715,21 +715,20 @@ nsDOMEvent::DuplicatePrivateData()
       compositionEvent->data = oldCompositionEvent->data;
       newEvent = compositionEvent;
       break;
     }
     case NS_MOUSE_SCROLL_EVENT:
     {
       nsMouseScrollEvent* mouseScrollEvent =
         new nsMouseScrollEvent(false, msg, nullptr);
-      NS_ENSURE_TRUE(mouseScrollEvent, NS_ERROR_OUT_OF_MEMORY);
       isInputEvent = true;
       nsMouseScrollEvent* oldMouseScrollEvent =
         static_cast<nsMouseScrollEvent*>(mEvent);
-      mouseScrollEvent->scrollFlags = oldMouseScrollEvent->scrollFlags;
+      mouseScrollEvent->isHorizontal = oldMouseScrollEvent->isHorizontal;
       mouseScrollEvent->delta = oldMouseScrollEvent->delta;
       mouseScrollEvent->relatedTarget = oldMouseScrollEvent->relatedTarget;
       mouseScrollEvent->button = oldMouseScrollEvent->button;
       mouseScrollEvent->buttons = oldMouseScrollEvent->buttons;
       static_cast<nsMouseEvent_base*>(mouseScrollEvent)->inputSource =
         static_cast<nsMouseEvent_base*>(oldMouseScrollEvent)->inputSource;
       newEvent = mouseScrollEvent;
       break;
--- a/content/events/src/nsDOMMouseScrollEvent.cpp
+++ b/content/events/src/nsDOMMouseScrollEvent.cpp
@@ -16,18 +16,17 @@ nsDOMMouseScrollEvent::nsDOMMouseScrollE
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->refPoint.x = mEvent->refPoint.y = 0;
     static_cast<nsMouseEvent*>(mEvent)->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
   }
 
   if(mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) {
-    nsMouseScrollEvent* mouseEvent = static_cast<nsMouseScrollEvent*>(mEvent);
-    mDetail = mouseEvent->delta;
+    mDetail = static_cast<nsMouseScrollEvent*>(mEvent)->delta;
   }
 }
 
 nsDOMMouseScrollEvent::~nsDOMMouseScrollEvent()
 {
   if (mEventIsInternal && mEvent) {
     switch (mEvent->eventStructType)
     {
@@ -61,34 +60,33 @@ nsDOMMouseScrollEvent::InitMouseScrollEv
                                 PRInt32 aAxis)
 {
   nsresult rv = nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
                                                 aScreenX, aScreenY, aClientX, aClientY, aCtrlKey,
                                                 aAltKey, aShiftKey, aMetaKey, aButton, aRelatedTarget);
   NS_ENSURE_SUCCESS(rv, rv);
   
   if (mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) {
-    static_cast<nsMouseScrollEvent*>(mEvent)->scrollFlags =
-        (aAxis == HORIZONTAL_AXIS) ? nsMouseScrollEvent::kIsHorizontal
-                                   : nsMouseScrollEvent::kIsVertical;
+    static_cast<nsMouseScrollEvent*>(mEvent)->isHorizontal =
+                                                (aAxis == HORIZONTAL_AXIS);
   }
 
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsDOMMouseScrollEvent::GetAxis(PRInt32* aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
 
   if (mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) {
-    PRUint32 flags = static_cast<nsMouseScrollEvent*>(mEvent)->scrollFlags;
-    *aResult = (flags & nsMouseScrollEvent::kIsHorizontal)
-         ? PRInt32(HORIZONTAL_AXIS) : PRInt32(VERTICAL_AXIS);
+    *aResult = static_cast<nsMouseScrollEvent*>(mEvent)->isHorizontal ?
+                 static_cast<PRInt32>(HORIZONTAL_AXIS) :
+                 static_cast<PRInt32>(VERTICAL_AXIS);
   } else {
     *aResult = 0;
   }
   return NS_OK;
 }
 
 nsresult NS_NewDOMMouseScrollEvent(nsIDOMEvent** aInstancePtrResult,
                                    nsPresContext* aPresContext,
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -2631,21 +2631,17 @@ nsEventStateManager::SendLineScrollEvent
   if (*aStatus == nsEventStatus_eConsumeNoDefault) {
     event.flags |= NS_EVENT_FLAG_NO_DEFAULT;
   }
   event.refPoint = aEvent->refPoint;
   event.widget = aEvent->widget;
   event.time = aEvent->time;
   event.modifiers = aEvent->modifiers;
   event.buttons = aEvent->buttons;
-  event.scrollFlags = (aDeltaDirection == DELTA_DIRECTION_Y) ?
-    nsMouseScrollEvent::kIsVertical : nsMouseScrollEvent::kIsHorizontal;
-  if (aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_PAGE) {
-    event.scrollFlags |= nsMouseScrollEvent::kIsFullPage;
-  }
+  event.isHorizontal = (aDeltaDirection == DELTA_DIRECTION_X);
   event.delta = aDelta;
   event.inputSource = aEvent->inputSource;
 
   nsEventDispatcher::Dispatch(targetContent, aTargetFrame->PresContext(),
                               &event, nullptr, aStatus);
 }
 
 void
@@ -2671,21 +2667,17 @@ nsEventStateManager::SendPixelScrollEven
   if (*aStatus == nsEventStatus_eConsumeNoDefault) {
     event.flags |= NS_EVENT_FLAG_NO_DEFAULT;
   }
   event.refPoint = aEvent->refPoint;
   event.widget = aEvent->widget;
   event.time = aEvent->time;
   event.modifiers = aEvent->modifiers;
   event.buttons = aEvent->buttons;
-  event.scrollFlags = (aDeltaDirection == DELTA_DIRECTION_Y) ?
-    nsMouseScrollEvent::kIsVertical : nsMouseScrollEvent::kIsHorizontal;
-  if (aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_PAGE) {
-    event.scrollFlags |= nsMouseScrollEvent::kIsFullPage;
-  }
+  event.isHorizontal = (aDeltaDirection == DELTA_DIRECTION_X);
   event.delta = aPixelDelta;
   event.inputSource = aEvent->inputSource;
 
   nsEventDispatcher::Dispatch(targetContent, aTargetFrame->PresContext(),
                               &event, nullptr, aStatus);
 }
 
 nsIScrollableFrame*
--- a/widget/nsGUIEvent.h
+++ b/widget/nsGUIEvent.h
@@ -1284,78 +1284,38 @@ public:
     //     However, it doesn't make sense for us, we cannot cancel composition
     //     when we send compositionstart event.
     flags |= NS_EVENT_FLAG_CANT_CANCEL;
   }
 
   nsString data;
 };
 
-/* Mouse Scroll Events: Line Scrolling, Pixel Scrolling and Common Event Flows
- *
- * There are two common event flows:
- *  (1) Normal line scrolling:
- *      1. An NS_MOUSE_SCROLL event without kHasPixels is dispatched to Gecko.
- *      2. A DOMMouseScroll event is sent into the DOM.
- *      3. A MozMousePixelScroll event is sent into the DOM.
- *      4. If neither event has been consumed, the default handling of the
- *         NS_MOUSE_SCROLL event is executed.
- *
- *  (2) Pixel scrolling:
- *      1. An NS_MOUSE_SCROLL event with kHasPixels is dispatched to Gecko.
- *      2. A DOMMouseScroll event is sent into the DOM.
- *      3. No scrolling takes place in the default handler.
- *      4. An NS_MOUSE_PIXEL_SCROLL event is dispatched to Gecko.
- *      5. A MozMousePixelScroll event is sent into the DOM.
- *      6. If neither the NS_MOUSE_PIXELSCROLL event nor the preceding
- *         NS_MOUSE_SCROLL event have been consumed, the default handler scrolls.
- *      7. Steps 4.-6. are repeated for every pixel scroll that belongs to
- *         the announced line scroll. Once enough pixels have been sent to
- *         complete a line, a new NS_MOUSE_SCROLL event is sent (goto step 1.).
- *
- * If a DOMMouseScroll event has been preventDefaulted, the associated
- * following MozMousePixelScroll events are still sent - they just don't result
- * in any scrolling (their default handler isn't executed).
- *
- * How many pixel scrolls make up one line scroll is decided in the widget layer
- * where the NS_MOUSE(_PIXEL)_SCROLL events are created.
- *
- * This event flow model satisfies several requirements:
- *  - DOMMouseScroll handlers don't need to be aware of the existence of pixel
- *    scrolling.
- *  - preventDefault on a DOMMouseScroll event results in no scrolling.
- *  - DOMMouseScroll events aren't polluted with a kHasPixels flag.
- *  - You can make use of pixel scroll DOM events (MozMousePixelScroll).
+/**
+ * nsMouseScrollEvent is used for legacy DOM mouse scroll events, i.e.,
+ * DOMMouseScroll and MozMousePixelScroll event.  These events are NOT hanbled
+ * by ESM even if widget dispatches them.  Use new widget::WheelEvent instead.
  */
 
 class nsMouseScrollEvent : public nsMouseEvent_base
 {
 private:
-  friend class mozilla::dom::PBrowserParent;
-  friend class mozilla::dom::PBrowserChild;
-
   nsMouseScrollEvent()
   {
   }
 
 public:
-  enum nsMouseScrollFlags {
-    kIsFullPage =   1 << 0,
-    kIsVertical =   1 << 1,
-    kIsHorizontal = 1 << 2
-  };
-
   nsMouseScrollEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
     : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_SCROLL_EVENT),
-      scrollFlags(0), delta(0)
+      delta(0), isHorizontal(false)
   {
   }
 
-  PRInt32               scrollFlags;
   PRInt32               delta;
+  bool                  isHorizontal;
 };
 
 /**
  * WheelEvent is used only for DOM Level 3 WheelEvent (dom::DOMWheelEvent).
  */
 
 namespace mozilla {
 namespace widget {
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -91,36 +91,16 @@ struct ParamTraits<nsMouseEvent_base>
            ReadParam(aMsg, aIter, &aResult->button) &&
            ReadParam(aMsg, aIter, &aResult->buttons) &&
            ReadParam(aMsg, aIter, &aResult->pressure) &&
            ReadParam(aMsg, aIter, &aResult->inputSource);
   }
 };
 
 template<>
-struct ParamTraits<nsMouseScrollEvent>
-{
-  typedef nsMouseScrollEvent paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam)
-  {
-    WriteParam(aMsg, static_cast<nsMouseEvent_base>(aParam));
-    WriteParam(aMsg, aParam.scrollFlags);
-    WriteParam(aMsg, aParam.delta);
-  }
-
-  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
-  {
-    return ReadParam(aMsg, aIter, static_cast<nsMouseEvent_base*>(aResult)) &&
-           ReadParam(aMsg, aIter, &aResult->scrollFlags) &&
-           ReadParam(aMsg, aIter, &aResult->delta);
-  }
-};
-
-template<>
 struct ParamTraits<mozilla::widget::WheelEvent>
 {
   typedef mozilla::widget::WheelEvent paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, static_cast<nsMouseEvent_base>(aParam));
     WriteParam(aMsg, aParam.deltaX);