Bug 719320 part.8-8 widget should be able to speicify the scroll type r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Sun, 12 Aug 2012 10:42:36 +0900
changeset 107535 c648f9903e5893638281098a3d370d5e8f58ef13
parent 107534 b9472dc9837c337f85b48e2ef465088516edea20
child 107536 db912be9bc19cd1fa19664a29651fa307225b6b2
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.8-8 widget should be able to speicify the scroll type r=smaug
content/events/src/nsDOMEvent.cpp
content/events/src/nsEventStateManager.cpp
widget/nsGUIEvent.h
widget/nsGUIEventIPC.h
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -750,16 +750,17 @@ nsDOMEvent::DuplicatePrivateData()
       wheelEvent->buttons = oldWheelEvent->buttons;
       wheelEvent->modifiers = oldWheelEvent->modifiers;
       wheelEvent->inputSource = oldWheelEvent->inputSource;
       wheelEvent->customizedByUserPrefs = oldWheelEvent->customizedByUserPrefs;
       wheelEvent->isMomentum = oldWheelEvent->isMomentum;
       wheelEvent->isPixelOnlyDevice = oldWheelEvent->isPixelOnlyDevice;
       wheelEvent->lineOrPageDeltaX = oldWheelEvent->lineOrPageDeltaX;
       wheelEvent->lineOrPageDeltaY = oldWheelEvent->lineOrPageDeltaY;
+      wheelEvent->scrollType = oldWheelEvent->scrollType;
       wheelEvent->overflowDeltaX = oldWheelEvent->overflowDeltaX;
       wheelEvent->overflowDeltaY = oldWheelEvent->overflowDeltaY;
       newEvent = wheelEvent;
       break;
     }
     case NS_SCROLLPORT_EVENT:
     {
       newEvent = new nsScrollPortEvent(false, msg, nullptr);
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -2896,18 +2896,38 @@ nsEventStateManager::DoScrollText(nsIScr
   }
 
   if (NS_ABS(actualDevPixelScrollAmount.y) > devPixelPageSize.height) {
     actualDevPixelScrollAmount.y =
       (actualDevPixelScrollAmount.y >= 0) ? devPixelPageSize.height :
                                             -devPixelPageSize.height;
   }
 
-  nsIScrollableFrame::ScrollMode mode =
-    isDeltaModePixel ? nsIScrollableFrame::NORMAL : nsIScrollableFrame::SMOOTH;
+  nsIScrollableFrame::ScrollMode mode;
+  switch (aEvent->scrollType) {
+    case widget::WheelEvent::SCROLL_DEFAULT:
+      if (isDeltaModePixel) {
+        mode = nsIScrollableFrame::NORMAL;
+      } else {
+        mode = nsIScrollableFrame::SMOOTH;
+      }
+      break;
+    case widget::WheelEvent::SCROLL_SYNCHRONOUSLY:
+      mode = nsIScrollableFrame::INSTANT;
+      break;
+    case widget::WheelEvent::SCROLL_ASYNCHRONOUSELY:
+      mode = nsIScrollableFrame::NORMAL;
+      break;
+    case widget::WheelEvent::SCROLL_SMOOTHLY:
+      mode = nsIScrollableFrame::SMOOTH;
+      break;
+    default:
+      MOZ_NOT_REACHED("Invalid scrollType value comes");
+      return;
+  }
 
   nsIntPoint overflow;
   aScrollableFrame->ScrollBy(actualDevPixelScrollAmount,
                              nsIScrollableFrame::DEVICE_PIXELS,
                              mode, &overflow, origin);
 
   if (isDeltaModePixel) {
     aEvent->overflowDeltaX = overflow.x;
--- a/widget/nsGUIEvent.h
+++ b/widget/nsGUIEvent.h
@@ -1404,17 +1404,17 @@ private:
   }
 
 public:
   WheelEvent(bool aIsTrusted, PRUint32 aMessage, nsIWidget* aWidget) :
     nsMouseEvent_base(aIsTrusted, aMessage, aWidget, NS_WHEEL_EVENT),
     deltaX(0.0), deltaY(0.0), deltaZ(0.0),
     deltaMode(nsIDOMWheelEvent::DOM_DELTA_PIXEL),
     customizedByUserPrefs(false), isMomentum(false), isPixelOnlyDevice(false),
-    lineOrPageDeltaX(0), lineOrPageDeltaY(0),
+    lineOrPageDeltaX(0), lineOrPageDeltaY(0), scrollType(SCROLL_DEFAULT),
     overflowDeltaX(0.0), overflowDeltaY(0.0)
   {
   }
 
   double deltaX;
   double deltaY;
   double deltaZ;
 
@@ -1458,16 +1458,27 @@ public:
     if ((lineOrPageDeltaX < 0 && lineOrPageDeltaY > 0) ||
         (lineOrPageDeltaX > 0 && lineOrPageDeltaY < 0)) {
       return 0; // We cannot guess the answer in this case.
     }
     return (NS_ABS(lineOrPageDeltaX) > NS_ABS(lineOrPageDeltaY)) ?
              lineOrPageDeltaX : lineOrPageDeltaY;
   }
 
+  // Scroll type
+  // The default value is SCROLL_DEFAULT, which means nsEventStateManager will
+  // select preferred scroll type automatically.
+  enum ScrollType {
+    SCROLL_DEFAULT,
+    SCROLL_SYNCHRONOUSLY,
+    SCROLL_ASYNCHRONOUSELY,
+    SCROLL_SMOOTHLY
+  };
+  ScrollType scrollType;
+
   // overflowed delta values, these values are the result of dispatching this
   // event.
   double overflowDeltaX;
   double overflowDeltaY;
 };
 
 } // namespace widget
 } // namespace mozilla
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -129,34 +129,41 @@ struct ParamTraits<mozilla::widget::Whee
     WriteParam(aMsg, aParam.deltaY);
     WriteParam(aMsg, aParam.deltaZ);
     WriteParam(aMsg, aParam.deltaMode);
     WriteParam(aMsg, aParam.customizedByUserPrefs);
     WriteParam(aMsg, aParam.isMomentum);
     WriteParam(aMsg, aParam.isPixelOnlyDevice);
     WriteParam(aMsg, aParam.lineOrPageDeltaX);
     WriteParam(aMsg, aParam.lineOrPageDeltaY);
+    WriteParam(aMsg, static_cast<PRInt32>(aParam.scrollType));
     WriteParam(aMsg, aParam.overflowDeltaX);
     WriteParam(aMsg, aParam.overflowDeltaY);
   }
 
   static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   {
-    return ReadParam(aMsg, aIter, static_cast<nsMouseEvent_base*>(aResult)) &&
-           ReadParam(aMsg, aIter, &aResult->deltaX) &&
-           ReadParam(aMsg, aIter, &aResult->deltaY) &&
-           ReadParam(aMsg, aIter, &aResult->deltaZ) &&
-           ReadParam(aMsg, aIter, &aResult->deltaMode) &&
-           ReadParam(aMsg, aIter, &aResult->customizedByUserPrefs) &&
-           ReadParam(aMsg, aIter, &aResult->isMomentum) &&
-           ReadParam(aMsg, aIter, &aResult->isPixelOnlyDevice) &&
-           ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaX) &&
-           ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaY) &&
-           ReadParam(aMsg, aIter, &aResult->overflowDeltaX) &&
-           ReadParam(aMsg, aIter, &aResult->overflowDeltaY);
+    PRInt32 scrollType;
+    bool rv =
+      ReadParam(aMsg, aIter, static_cast<nsMouseEvent_base*>(aResult)) &&
+      ReadParam(aMsg, aIter, &aResult->deltaX) &&
+      ReadParam(aMsg, aIter, &aResult->deltaY) &&
+      ReadParam(aMsg, aIter, &aResult->deltaZ) &&
+      ReadParam(aMsg, aIter, &aResult->deltaMode) &&
+      ReadParam(aMsg, aIter, &aResult->customizedByUserPrefs) &&
+      ReadParam(aMsg, aIter, &aResult->isMomentum) &&
+      ReadParam(aMsg, aIter, &aResult->isPixelOnlyDevice) &&
+      ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaX) &&
+      ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaY) &&
+      ReadParam(aMsg, aIter, &scrollType) &&
+      ReadParam(aMsg, aIter, &aResult->overflowDeltaX) &&
+      ReadParam(aMsg, aIter, &aResult->overflowDeltaY);
+    aResult->scrollType =
+      static_cast<mozilla::widget::WheelEvent::ScrollType>(scrollType);
+    return rv;
   }
 };
 
 template<>
 struct ParamTraits<nsMouseEvent>
 {
   typedef nsMouseEvent paramType;