Title: [96439] trunk
Revision
96439
Author
wei...@apple.com
Date
2011-09-30 17:16:48 -0700 (Fri, 30 Sep 2011)

Log Message

Add support for eventSender.mouseScrollBy in WTR
https://bugs.webkit.org/show_bug.cgi?id=69189

Source/WebKit2: 

Reviewed by Simon Fraser.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::handleWheelEvent):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::wheelEventSyncForTesting):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
Add sync version of wheel event handling for use in testing.

Tools: 

Add implementation of eventSender.mouseScrollBy for the mac.

Reviewed by Simon Fraser.

* WebKitTestRunner/EventSenderProxy.h:
* WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl:
* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::EventSendingController::keyDown):
(WTR::EventSendingController::mouseScrollBy):
* WebKitTestRunner/InjectedBundle/EventSendingController.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle):
* WebKitTestRunner/mac/EventSenderProxy.mm:
(WTR::EventSenderProxy::mouseScrollBy):

LayoutTests: 

Reviewed by Simon Fraser.

* platform/mac-wk2/Skipped:
Removes tests that used eventSender.mouseScrollBy.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (96438 => 96439)


--- trunk/LayoutTests/ChangeLog	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/LayoutTests/ChangeLog	2011-10-01 00:16:48 UTC (rev 96439)
@@ -1,3 +1,13 @@
+2011-09-30  Sam Weinig  <s...@webkit.org>
+
+        Add support for eventSender.mouseScrollBy in WTR
+        https://bugs.webkit.org/show_bug.cgi?id=69189
+
+        Reviewed by Simon Fraser.
+
+        * platform/mac-wk2/Skipped:
+        Removes tests that used eventSender.mouseScrollBy.
+
 2011-09-30  Johnny Ding  <j...@chromium.org>
 
         Support -webkit-tap-highlight-color in WebCore when enabling touch events support. 

Modified: trunk/LayoutTests/platform/mac-wk2/Skipped (96438 => 96439)


--- trunk/LayoutTests/platform/mac-wk2/Skipped	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/LayoutTests/platform/mac-wk2/Skipped	2011-10-01 00:16:48 UTC (rev 96439)
@@ -147,14 +147,11 @@
 fast/events/node-event-anchor-lock.html
 fast/events/ondragenter.html
 fast/events/open-window-from-another-frame.html
-fast/events/platform-wheelevent-in-scrolling-div.html
 fast/events/popup-blocking-click-in-iframe.html
 fast/events/popup-when-select-change.html
 fast/events/prevent-drag-to-navigate.html
-fast/events/remove-child-onscroll.html
 fast/events/right-click-focus.html
 fast/events/scroll-after-click-on-tab-index.html
-fast/events/scroll-in-scaled-page-with-overflow-hidden.html
 fast/events/selectstart-by-drag.html
 fast/events/selectstart-prevent-selection-on-right-click.html
 fast/events/standalone-image-drag-to-editable.html

Modified: trunk/Source/WebKit2/ChangeLog (96438 => 96439)


--- trunk/Source/WebKit2/ChangeLog	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/Source/WebKit2/ChangeLog	2011-10-01 00:16:48 UTC (rev 96439)
@@ -1,3 +1,18 @@
+2011-09-30  Sam Weinig  <s...@webkit.org>
+
+        Add support for eventSender.mouseScrollBy in WTR
+        https://bugs.webkit.org/show_bug.cgi?id=69189
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::handleWheelEvent):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::wheelEventSyncForTesting):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        Add sync version of wheel event handling for use in testing.
+
 2011-09-30  Caio Marcelo de Oliveira Filho  <caio.olive...@openbossa.org>
 
         [Qt] Add missing include for QMimeData

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (96438 => 96439)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-10-01 00:16:48 UTC (rev 96439)
@@ -869,7 +869,13 @@
     m_currentlyProcessedWheelEvents.append(event);
 
     process()->responsivenessTimer()->start();
-    process()->send(Messages::WebPage::WheelEvent(event), m_pageID);
+
+    if (m_shouldSendEventsSynchronously) {
+        bool handled = false;
+        process()->sendSync(Messages::WebPage::WheelEventSyncForTesting(event), Messages::WebPage::WheelEventSyncForTesting::Reply(handled), m_pageID);
+        didReceiveEvent(event.type(), handled);
+    } else
+        process()->send(Messages::WebPage::WheelEvent(event), m_pageID);
 }
 
 void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (96438 => 96439)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2011-10-01 00:16:48 UTC (rev 96439)
@@ -1133,6 +1133,20 @@
     send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(wheelEvent.type()), handled));
 }
 
+void WebPage::wheelEventSyncForTesting(const WebWheelEvent& wheelEvent, bool& handled)
+{
+    CurrentEvent currentEvent(wheelEvent);
+
+#if PLATFORM(MAC)
+    if (wheelEvent.momentumPhase() == WebWheelEvent::PhaseBegan || wheelEvent.phase() == WebWheelEvent::PhaseBegan)
+        m_drawingArea->disableDisplayThrottling();
+    else if (wheelEvent.momentumPhase() == WebWheelEvent::PhaseEnded || wheelEvent.phase() == WebWheelEvent::PhaseEnded)
+        m_drawingArea->enableDisplayThrottling();
+#endif
+
+    handled = handleWheelEvent(wheelEvent, m_page.get());
+}
+
 static bool handleKeyEvent(const WebKeyboardEvent& keyboardEvent, Page* page)
 {
     if (!page->mainFrame()->view())

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (96438 => 96439)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2011-10-01 00:16:48 UTC (rev 96439)
@@ -489,6 +489,7 @@
     void mouseEvent(const WebMouseEvent&);
     void mouseEventSyncForTesting(const WebMouseEvent&, bool&);
     void wheelEvent(const WebWheelEvent&);
+    void wheelEventSyncForTesting(const WebWheelEvent&, bool&);
     void keyEvent(const WebKeyboardEvent&);
     void keyEventSyncForTesting(const WebKeyboardEvent&, bool&);
 #if ENABLE(GESTURE_EVENTS)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (96438 => 96439)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2011-10-01 00:16:48 UTC (rev 96439)
@@ -37,6 +37,7 @@
     MouseEvent(WebKit::WebMouseEvent event)
     MouseEventSyncForTesting(WebKit::WebMouseEvent event) -> (bool handled)
     WheelEvent(WebKit::WebWheelEvent event)
+    WheelEventSyncForTesting(WebKit::WebWheelEvent event) -> (bool handled)
 #if ENABLE(GESTURE_EVENTS)
     GestureEvent(WebKit::WebGestureEvent event)
 #endif

Modified: trunk/Tools/ChangeLog (96438 => 96439)


--- trunk/Tools/ChangeLog	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/Tools/ChangeLog	2011-10-01 00:16:48 UTC (rev 96439)
@@ -1,3 +1,23 @@
+2011-09-30  Sam Weinig  <s...@webkit.org>
+
+        Add support for eventSender.mouseScrollBy in WTR
+        https://bugs.webkit.org/show_bug.cgi?id=69189
+
+        Add implementation of eventSender.mouseScrollBy for the mac.
+
+        Reviewed by Simon Fraser.
+
+        * WebKitTestRunner/EventSenderProxy.h:
+        * WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl:
+        * WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
+        (WTR::EventSendingController::keyDown):
+        (WTR::EventSendingController::mouseScrollBy):
+        * WebKitTestRunner/InjectedBundle/EventSendingController.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle):
+        * WebKitTestRunner/mac/EventSenderProxy.mm:
+        (WTR::EventSenderProxy::mouseScrollBy):
+
 2011-09-30  Simon Fraser  <simon.fra...@apple.com>
 
         fast/forms/text-control-intrinsic-widths.html fails on Mac if Word/Office fonts are installed

Modified: trunk/Tools/WebKitTestRunner/EventSenderProxy.h (96438 => 96439)


--- trunk/Tools/WebKitTestRunner/EventSenderProxy.h	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/Tools/WebKitTestRunner/EventSenderProxy.h	2011-10-01 00:16:48 UTC (rev 96439)
@@ -38,6 +38,8 @@
     void mouseDown(unsigned button, WKEventModifiers);
     void mouseUp(unsigned button, WKEventModifiers);
     void mouseMoveTo(double x, double y);
+    void mouseScrollBy(int x, int y);
+
     void leapForward(int milliseconds);
 
     void keyDown(WKStringRef key, WKEventModifiers, unsigned location);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl (96438 => 96439)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl	2011-10-01 00:16:48 UTC (rev 96439)
@@ -29,6 +29,8 @@
         void mouseDown(in long buttonNumber, in object modifierArray);
         void mouseUp(in long buttonNumber, in object modifierArray);
         void mouseMoveTo(in long x, in long y);
+        void mouseScrollBy(in long x, in long y);
+
         void leapForward(in long milliseconds);
 
         void keyDown(in DOMString key, in object modifierArray, in long location);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp (96438 => 96439)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp	2011-10-01 00:16:48 UTC (rev 96439)
@@ -217,7 +217,54 @@
 #endif
 }
 
+void EventSendingController::keyDown(JSStringRef key, JSValueRef modifierArray, int location)
+{
+    WKBundlePageRef page = InjectedBundle::shared().page()->page();
+    WKBundleFrameRef frame = WKBundlePageGetMainFrame(page);
+    JSContextRef context = WKBundleFrameGetJavaScriptContext(frame);
+    WKEventModifiers modifiers = parseModifierArray(context, modifierArray);
 
+    WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender"));
+    WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate());
+
+    WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage"));
+    WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("KeyDown"));
+    WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get());
+
+    WKRetainPtr<WKStringRef> keyKey = adoptWK(WKStringCreateWithUTF8CString("Key"));
+    WKDictionaryAddItem(EventSenderMessageBody.get(), keyKey.get(), toWK(key).get());
+
+    WKRetainPtr<WKStringRef> modifiersKey = adoptWK(WKStringCreateWithUTF8CString("Modifiers"));
+    WKRetainPtr<WKUInt64Ref> modifiersRef = WKUInt64Create(modifiers);
+    WKDictionaryAddItem(EventSenderMessageBody.get(), modifiersKey.get(), modifiersRef.get());
+
+    WKRetainPtr<WKStringRef> locationKey = adoptWK(WKStringCreateWithUTF8CString("Location"));
+    WKRetainPtr<WKUInt64Ref> locationRef = WKUInt64Create(location);
+    WKDictionaryAddItem(EventSenderMessageBody.get(), locationKey.get(), locationRef.get());
+
+    WKBundlePostSynchronousMessage(InjectedBundle::shared().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+}
+
+void EventSendingController::mouseScrollBy(int x, int y)
+{
+    WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender"));
+    WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate());
+
+    WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage"));
+    WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("MouseScrollBy"));
+    WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get());
+
+    WKRetainPtr<WKStringRef> xKey = adoptWK(WKStringCreateWithUTF8CString("X"));
+    WKRetainPtr<WKDoubleRef> xRef = WKDoubleCreate(x);
+    WKDictionaryAddItem(EventSenderMessageBody.get(), xKey.get(), xRef.get());
+
+    WKRetainPtr<WKStringRef> yKey = adoptWK(WKStringCreateWithUTF8CString("Y"));
+    WKRetainPtr<WKDoubleRef> yRef = WKDoubleCreate(y);
+    WKDictionaryAddItem(EventSenderMessageBody.get(), yKey.get(), yRef.get());
+
+    WKBundlePostSynchronousMessage(InjectedBundle::shared().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+}
+
 #ifdef USE_WEBPROCESS_EVENT_SIMULATION
 void EventSendingController::updateClickCount(WKEventMouseButton button)
 {
@@ -283,32 +330,4 @@
     setProperty(context, windowObject, "eventSender", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
 }
 
-void EventSendingController::keyDown(JSStringRef key, JSValueRef modifierArray, int location)
-{
-    WKBundlePageRef page = InjectedBundle::shared().page()->page();
-    WKBundleFrameRef frame = WKBundlePageGetMainFrame(page);
-    JSContextRef context = WKBundleFrameGetJavaScriptContext(frame);
-    WKEventModifiers modifiers = parseModifierArray(context, modifierArray);
-
-    WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender"));
-    WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate());
-
-    WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage"));
-    WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("KeyDown"));
-    WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get());
-
-    WKRetainPtr<WKStringRef> keyKey = adoptWK(WKStringCreateWithUTF8CString("Key"));
-    WKDictionaryAddItem(EventSenderMessageBody.get(), keyKey.get(), toWK(key).get());
-
-    WKRetainPtr<WKStringRef> modifiersKey = adoptWK(WKStringCreateWithUTF8CString("Modifiers"));
-    WKRetainPtr<WKUInt64Ref> modifiersRef = WKUInt64Create(modifiers);
-    WKDictionaryAddItem(EventSenderMessageBody.get(), modifiersKey.get(), modifiersRef.get());
-
-    WKRetainPtr<WKStringRef> locationKey = adoptWK(WKStringCreateWithUTF8CString("Location"));
-    WKRetainPtr<WKUInt64Ref> locationRef = WKUInt64Create(location);
-    WKDictionaryAddItem(EventSenderMessageBody.get(), locationKey.get(), locationRef.get());
-
-    WKBundlePostSynchronousMessage(InjectedBundle::shared().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
-}
-
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h (96438 => 96439)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h	2011-10-01 00:16:48 UTC (rev 96439)
@@ -50,6 +50,7 @@
     void mouseDown(int button, JSValueRef modifierArray);
     void mouseUp(int button, JSValueRef modifierArray);
     void mouseMoveTo(int x, int y);
+    void mouseScrollBy(int x, int y);
     void leapForward(int milliseconds);
 
     void keyDown(JSStringRef key, JSValueRef modifierArray, int location);

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (96438 => 96439)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2011-10-01 00:16:48 UTC (rev 96439)
@@ -574,6 +574,20 @@
             return 0;
         }
 
+        if (WKStringIsEqualToUTF8CString(subMessageName, "MouseScrollBy")) {
+            WKRetainPtr<WKStringRef> xKey = adoptWK(WKStringCreateWithUTF8CString("X"));
+            double x = WKDoubleGetValue(static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, xKey.get())));
+
+            WKRetainPtr<WKStringRef> yKey = adoptWK(WKStringCreateWithUTF8CString("Y"));
+            double y = WKDoubleGetValue(static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, yKey.get())));
+
+            // Forward to WebProcess
+            WKPageSetShouldSendEventsSynchronously(mainWebView()->page(), true);
+            m_eventSenderProxy->mouseScrollBy(x, y);
+            WKPageSetShouldSendEventsSynchronously(mainWebView()->page(), false);
+            return 0;
+        }
+
         if (WKStringIsEqualToUTF8CString(subMessageName, "LeapForward")) {
             WKRetainPtr<WKStringRef> timeKey = adoptWK(WKStringCreateWithUTF8CString("TimeInMilliseconds"));
             unsigned time = static_cast<unsigned>(WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, timeKey.get()))));

Modified: trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm (96438 => 96439)


--- trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm	2011-10-01 00:16:48 UTC (rev 96439)
@@ -27,9 +27,10 @@
 #import "config.h"
 #import "EventSenderProxy.h"
 
+#import "PlatformWebView.h"
 #import "StringFunctions.h"
-#import "PlatformWebView.h"
 #import "TestController.h"
+#import <_javascript_Core/RetainPtr.h>
 #import <WebKit2/WKString.h>
 
 namespace WTR {
@@ -351,4 +352,21 @@
     [[m_testController->mainWebView()->platformWindow() firstResponder] keyUp:event];
 }
 
+void EventSenderProxy::mouseScrollBy(int x, int y)
+{
+    RetainPtr<CGEventRef> cgScrollEvent(AdoptCF, CGEventCreateScrollWheelEvent(0, kCGScrollEventUnitLine, 2, y, x));
+
+    // CGEvent locations are in global display coordinates.
+    CGPoint lastGlobalMousePosition = {
+        m_position.x,
+        [[NSScreen mainScreen] frame].size.height - m_position.y
+    };
+    CGEventSetLocation(cgScrollEvent.get(), lastGlobalMousePosition);
+
+    NSEvent *event = [NSEvent eventWithCGEvent:cgScrollEvent.get()];
+    NSView *targetView = [m_testController->mainWebView()->platformView() hitTest:[event locationInWindow]];
+    if (targetView)
+        [targetView scrollWheel:event];
+}
+
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/qt/EventSenderProxyQt.cpp (96438 => 96439)


--- trunk/Tools/WebKitTestRunner/qt/EventSenderProxyQt.cpp	2011-09-30 23:54:44 UTC (rev 96438)
+++ trunk/Tools/WebKitTestRunner/qt/EventSenderProxyQt.cpp	2011-10-01 00:16:48 UTC (rev 96439)
@@ -295,6 +295,11 @@
     sendOrQueueEvent(event);
 }
 
+void EventSenderProxy::mouseScrollBy(int, int)
+{
+    // FIXME: Implement this.
+}
+
 void EventSenderProxy::leapForward(int ms)
 {
     eventQueue[endOfQueue].m_delay = ms;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to