Enhance Windows DRT implementation to support platform scroll wheel events.
authorpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jul 2016 06:13:08 +0000 (06:13 +0000)
committerpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jul 2016 06:13:08 +0000 (06:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=36002

Reviewed by Brent Fulgham.

Tools:

Implement function continuousMouseScrollBy in Windows event sender.

* DumpRenderTree/win/EventSender.cpp:
(mouseScrollBy):
(continuousMouseScrollBy):

LayoutTests:

Update test expectations.

* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202849 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/win/TestExpectations
Tools/ChangeLog
Tools/DumpRenderTree/win/EventSender.cpp

index e3cdb20..553d70d 100644 (file)
@@ -1,5 +1,16 @@
 2016-07-05  Per Arne Vollan  <pvollan@apple.com>
 
+        Enhance Windows DRT implementation to support platform scroll wheel events.
+        https://bugs.webkit.org/show_bug.cgi?id=36002
+
+        Reviewed by Brent Fulgham.
+
+        Update test expectations.
+
+        * platform/win/TestExpectations:
+
+2016-07-05  Per Arne Vollan  <pvollan@apple.com>
+
         [Win] Layout Test http/tests/security/contentSecurityPolicy/source-list-parsing-10.html is failing
         https://bugs.webkit.org/show_bug.cgi?id=147646
 
index b7b5520..d2ed98f 100644 (file)
@@ -224,23 +224,13 @@ http/tests/misc/image-checks-for-accept.html [ Skip ]
 # TODO Need to add functionality to DumpRenderTree to handle enable/disable Spatial Navigation
 fast/spatial-navigation/ [ Skip ]
 
-# TODO mouseScrollBy() and continuousMouseScrollBy() are not yet implemented in the Windows EventSender API.
-webkit.org/b/36002 fast/events/remove-child-onscroll.html [ Skip ]
-webkit.org/b/36002 fast/events/platform-wheelevent-in-scrolling-div.html [ Skip ]
-webkit.org/b/36002 fast/events/platform-wheelevent-with-delta-zero-crash.html [ Skip ]
-webkit.org/b/36002 fast/events/continuous-platform-wheelevent-in-scrolling-div.html [ Skip ]
-webkit.org/b/36002 fast/events/scroll-in-scaled-page-with-overflow-hidden.html [ Skip ]
-webkit.org/b/36002 fast/events/wheelevent-direction-inverted-from-device.html [ Skip ]
-webkit.org/b/36002 fast/events/wheelevent-in-horizontal-scrollbar-in-rtl.html [ Skip ]
-webkit.org/b/36002 fast/events/wheelevent-in-text-node.html [ Skip ]
-webkit.org/b/36002 fast/events/wheelevent-in-vertical-scrollbar-in-rtl.html [ Skip ]
-webkit.org/b/36002 fast/forms/search/search-scroll-hidden-decoration-container-crash.html [ Skip ]
-webkit.org/b/36002 fast/repaint/overflow-auto-in-overflow-auto-scrolled.html [ Skip ]
-webkit.org/b/36002 fast/repaint/overflow-scroll-in-overflow-scroll-scrolled.html [ Skip ]
-webkit.org/b/36002 fast/repaint/table-overflow-auto-in-overflow-auto-scrolled.html [ Skip ]
-webkit.org/b/36002 fast/repaint/table-overflow-scroll-in-overflow-scroll-scrolled.html [ Skip ]
-webkit.org/b/36002 scrollbars/scrollevent-iframe-no-scrolling-wheel.html [ Skip ]
-webkit.org/b/36002 scrollbars/scroll-rtl-or-bt-layer.html [ Skip ]
+# TODO Investigate why these mouse scroll tests are failing.
+fast/events/platform-wheelevent-in-scrolling-div.html [ Failure ]
+fast/events/continuous-platform-wheelevent-in-scrolling-div.html [ Failure ]
+fast/events/scroll-in-scaled-page-with-overflow-hidden.html [ Failure ]
+fast/events/wheelevent-in-horizontal-scrollbar-in-rtl.html [ Failure ]
+fast/events/wheelevent-in-vertical-scrollbar-in-rtl.html [ Failure ]
+scrollbars/scroll-rtl-or-bt-layer.html [ Timeout ]
 
 # TODO Needs testRunner.enableAutoResizeMode()
 fast/autoresize/ [ Skip ]
index 65de426..b85feda 100644 (file)
@@ -1,3 +1,16 @@
+2016-07-05  Per Arne Vollan  <pvollan@apple.com>
+
+        Enhance Windows DRT implementation to support platform scroll wheel events.
+        https://bugs.webkit.org/show_bug.cgi?id=36002
+
+        Reviewed by Brent Fulgham.
+
+        Implement function continuousMouseScrollBy in Windows event sender.
+
+        * DumpRenderTree/win/EventSender.cpp:
+        (mouseScrollBy):
+        (continuousMouseScrollBy):
+
 2016-07-05  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [Sierra] Rebaseline tests to use un-mocked system font metrics
index 1a96ab2..5036be1 100644 (file)
@@ -781,18 +781,48 @@ static JSValueRef scalePageByCallback(JSContextRef context, JSObjectRef function
     return JSValueMakeUndefined(context);
 }
 
+void mouseScrollBy(double x, double y, bool continuous)
+{
+    RECT rect;
+    ::GetWindowRect(webViewWindow, &rect);
+
+    // This value is taken from Source/WebCore/platform/win/WheelEventWin.cpp
+    const float cScrollbarPixelsPerLine = 100.0f / 3.0f;
+
+    if (x) {
+        UINT scrollChars = 1;
+        ::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrollChars, 0);
+        x *= WHEEL_DELTA / scrollChars;
+        if (continuous)
+            x /= cScrollbarPixelsPerLine;
+        MSG msg = makeMsg(webViewWindow, WM_MOUSEHWHEEL, MAKEWPARAM(0, x), MAKELPARAM(rect.left + lastMousePosition.x, rect.top + lastMousePosition.y));
+        dispatchMessage(&msg);
+    }
+
+    if (y) {
+        UINT scrollLines = 3;
+        ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0);
+        y *= WHEEL_DELTA / scrollLines;
+        if (continuous)
+            y /= cScrollbarPixelsPerLine;
+        MSG msg = makeMsg(webViewWindow, WM_MOUSEWHEEL, MAKEWPARAM(0, y), MAKELPARAM(rect.left + lastMousePosition.x, rect.top + lastMousePosition.y));
+        dispatchMessage(&msg);
+    }
+}
+
 static JSValueRef mouseScrollBy(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    double delta = JSValueToNumber(context, arguments[1], exception);
+    double deltaX = JSValueToNumber(context, arguments[0], exception);
 
-    RECT rect;
-    ::GetWindowRect(webViewWindow, &rect);
+    double deltaY = 0;
 
-    MSG msg = makeMsg(webViewWindow, WM_MOUSEWHEEL, MAKEWPARAM(0, delta), MAKELPARAM(rect.left + lastMousePosition.x, rect.top + lastMousePosition.y));
-    dispatchMessage(&msg);
+    if (argumentCount >= 2)
+        deltaY = JSValueToNumber(context, arguments[1], exception);
+
+    mouseScrollBy(deltaX, deltaY, false);
 
     return JSValueMakeUndefined(context);
 }
@@ -802,6 +832,23 @@ static JSValueRef mouseScrollByWithWheelAndMomentumPhasesCallback(JSContextRef c
     return mouseScrollBy(context, function, thisObject, argumentCount, arguments, exception);
 }
 
+static JSValueRef continuousMouseScrollBy(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    double deltaX = JSValueToNumber(context, arguments[0], exception);
+
+    double deltaY = 0;
+
+    if (argumentCount >= 2)
+        deltaY = JSValueToNumber(context, arguments[1], exception);
+
+    mouseScrollBy(deltaX, deltaY, true);
+
+    return JSValueMakeUndefined(context);
+}
+
 static JSStaticFunction staticFunctions[] = {
     { "contextClick", contextClickCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "mouseDown", mouseDownCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -818,6 +865,7 @@ static JSStaticFunction staticFunctions[] = {
     { "scalePageBy", scalePageByCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "mouseScrollBy", mouseScrollBy, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "mouseScrollByWithWheelAndMomentumPhases", mouseScrollByWithWheelAndMomentumPhasesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+    { "continuousMouseScrollBy", continuousMouseScrollBy,  kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { 0, 0, 0 }
 };