Bug 1409580 - Use different scroll delta modes on different platforms in headless. r?jrmuizel draft
authorBrendan Dahl <brendan.dahl@gmail.com>
Thu, 19 Oct 2017 15:57:39 -0700
changeset 699280 89bbbb7e58e84f62101ae006aca5bbdd0d326474
parent 699279 0feccba425b13d5f9cc94d0bd0717dd696ad95a1
child 699281 ab738ec640a3f0e464310ad4d928af51072a9387
push id89521
push userbmo:bdahl@mozilla.com
push dateThu, 16 Nov 2017 23:49:56 +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: