Bug 1409580 - Use different scroll delta modes on different platforms in headless. r=jrmuizel
authorBrendan Dahl <brendan.dahl@gmail.com>
Thu, 19 Oct 2017 15:57:39 -0700
changeset 436953 914b07533a33593b76a182014f77fc8e8bff337d
parent 436952 2bd51020fa81ad8fd79c196e1f9ba47ebbcd6b26
child 436954 d3d90cd557e6001cc7efea60cd1f9fae021b52b5
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewersjrmuizel
bugs1409580
milestone59.0a1
Bug 1409580 - Use different scroll delta modes on different platforms in headless. r=jrmuizel Fixes test_group_wheelevents.html MozReview-Commit-ID: Ctq0WngKG15
widget/headless/HeadlessWidget.cpp
widget/headless/HeadlessWidget.h
--- a/widget/headless/HeadlessWidget.cpp
+++ b/widget/headless/HeadlessWidget.cpp
@@ -504,20 +504,21 @@ HeadlessWidget::SynthesizeNativeMouseScr
                                                  double aDeltaX,
                                                  double aDeltaY,
                                                  double aDeltaZ,
                                                  uint32_t aModifierFlags,
                                                  uint32_t aAdditionalFlags,
                                                  nsIObserver* aObserver)
 {
   AutoObserverNotifier notifier(aObserver, "mousescrollevent");
+  printf(">>> DEBUG_ME: Synth: aDeltaY=%f\n", aDeltaY);
   // The various platforms seem to handle scrolling deltas differently,
   // but the following seems to emulate it well enough.
   WidgetWheelEvent event(true, eWheel, this);
-  event.mDeltaMode = nsIDOMWheelEvent::DOM_DELTA_LINE;
+  event.mDeltaMode = MOZ_HEADLESS_SCROLL_DELTA_MODE;
   event.mIsNoLineOrPageDelta = true;
   event.mDeltaX = -aDeltaX * MOZ_HEADLESS_SCROLL_MULTIPLIER;
   event.mDeltaY = -aDeltaY * MOZ_HEADLESS_SCROLL_MULTIPLIER;
   event.mDeltaZ = -aDeltaZ * MOZ_HEADLESS_SCROLL_MULTIPLIER;
   event.mRefPoint = aPoint - WidgetToScreenOffset();
   event.AssignEventTime(WidgetEventTime());
   DispatchInputEvent(&event);
   return NS_OK;
--- a/widget/headless/HeadlessWidget.h
+++ b/widget/headless/HeadlessWidget.h
@@ -13,36 +13,41 @@
 
 // The various synthesized event values are hardcoded to avoid pulling
 // in the platform specific widget code.
 #if defined(MOZ_WIDGET_GTK)
 #define MOZ_HEADLESS_MOUSE_MOVE 3 // GDK_MOTION_NOTIFY
 #define MOZ_HEADLESS_MOUSE_DOWN 4 // GDK_BUTTON_PRESS
 #define MOZ_HEADLESS_MOUSE_UP   7 // GDK_BUTTON_RELEASE
 #define MOZ_HEADLESS_SCROLL_MULTIPLIER 3
+#define MOZ_HEADLESS_SCROLL_DELTA_MODE nsIDOMWheelEvent::DOM_DELTA_LINE
 #elif defined(XP_WIN)
 #define MOZ_HEADLESS_MOUSE_MOVE 1 // MOUSEEVENTF_MOVE
 #define MOZ_HEADLESS_MOUSE_DOWN 2 // MOUSEEVENTF_LEFTDOWN
 #define MOZ_HEADLESS_MOUSE_UP   4 // MOUSEEVENTF_LEFTUP
 #define MOZ_HEADLESS_SCROLL_MULTIPLIER .025 // default scroll lines (3) / WHEEL_DELTA (120)
+#define MOZ_HEADLESS_SCROLL_DELTA_MODE nsIDOMWheelEvent::DOM_DELTA_LINE
 #elif defined(XP_MACOSX)
 #define MOZ_HEADLESS_MOUSE_MOVE 5 // NSMouseMoved
 #define MOZ_HEADLESS_MOUSE_DOWN 1 // NSLeftMouseDown
 #define MOZ_HEADLESS_MOUSE_UP   2 // NSLeftMouseUp
 #define MOZ_HEADLESS_SCROLL_MULTIPLIER 1
+#define MOZ_HEADLESS_SCROLL_DELTA_MODE nsIDOMWheelEvent::DOM_DELTA_PIXEL
 #elif defined(ANDROID)
 #define MOZ_HEADLESS_MOUSE_MOVE 7 // ACTION_HOVER_MOVE
 #define MOZ_HEADLESS_MOUSE_DOWN 5 // ACTION_POINTER_DOWN
 #define MOZ_HEADLESS_MOUSE_UP   6 // ACTION_POINTER_UP
 #define MOZ_HEADLESS_SCROLL_MULTIPLIER 1
+#define MOZ_HEADLESS_SCROLL_DELTA_MODE nsIDOMWheelEvent::DOM_DELTA_LINE
 #else
 #define MOZ_HEADLESS_MOUSE_MOVE -1
 #define MOZ_HEADLESS_MOUSE_DOWN -1
 #define MOZ_HEADLESS_MOUSE_UP   -1
-#define MOZ_HEADLESS_SCROLL_MULTIPLIER = -1
+#define MOZ_HEADLESS_SCROLL_MULTIPLIER -1
+#define MOZ_HEADLESS_SCROLL_DELTA_MODE -1
 #endif
 
 namespace mozilla {
 namespace widget {
 
 class HeadlessWidget : public nsBaseWidget
 {
 public: