From: weinig@apple.com Date: Sat, 1 Oct 2011 00:16:48 +0000 (+0000) Subject: Add support for eventSender.mouseScrollBy in WTR X-Git-Tag: 070512121124~23255 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c37390f2600e017c88710dd4ac7bdbf9864b9295;p=profile%2Fivi%2Fwebkit-efl.git 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. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96439 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index a3c399f..f2e0aa92a 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +2011-09-30 Sam Weinig + + 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 Support -webkit-tap-highlight-color in WebCore when enabling touch events support. diff --git a/LayoutTests/platform/mac-wk2/Skipped b/LayoutTests/platform/mac-wk2/Skipped index cd1ed0d..5f5bb3a 100644 --- a/LayoutTests/platform/mac-wk2/Skipped +++ b/LayoutTests/platform/mac-wk2/Skipped @@ -147,14 +147,11 @@ fast/events/mouseup-from-button2.html 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 diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index 695d502..a1631b5 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,18 @@ +2011-09-30 Sam Weinig + + 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 [Qt] Add missing include for QMimeData diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp index 88e1462..6c0447e 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp @@ -869,7 +869,13 @@ void WebPageProxy::handleWheelEvent(const NativeWebWheelEvent& event) 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) diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index d4c6fbe..e9265bd 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -1133,6 +1133,20 @@ void WebPage::wheelEvent(const WebWheelEvent& wheelEvent) send(Messages::WebPageProxy::DidReceiveEvent(static_cast(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()) diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h index d50cde3..e5d0b99 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h @@ -489,6 +489,7 @@ private: 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) diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in index c26f2e3..924f00d 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in @@ -37,6 +37,7 @@ messages -> WebPage { 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 diff --git a/Tools/ChangeLog b/Tools/ChangeLog index 5102099..6a79e0f 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,23 @@ +2011-09-30 Sam Weinig + + 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 fast/forms/text-control-intrinsic-widths.html fails on Mac if Word/Office fonts are installed diff --git a/Tools/WebKitTestRunner/EventSenderProxy.h b/Tools/WebKitTestRunner/EventSenderProxy.h index d4eb9c8..e550228 100644 --- a/Tools/WebKitTestRunner/EventSenderProxy.h +++ b/Tools/WebKitTestRunner/EventSenderProxy.h @@ -38,6 +38,8 @@ public: 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); diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl index 3268278..66c4f71 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl @@ -29,6 +29,8 @@ module WTR { 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); diff --git a/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp b/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp index 4d63513..41265eb 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp @@ -217,6 +217,53 @@ void EventSendingController::leapForward(int milliseconds) #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 EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender")); + WKRetainPtr EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate()); + + WKRetainPtr subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage")); + WKRetainPtr subMessageName(AdoptWK, WKStringCreateWithUTF8CString("KeyDown")); + WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get()); + + WKRetainPtr keyKey = adoptWK(WKStringCreateWithUTF8CString("Key")); + WKDictionaryAddItem(EventSenderMessageBody.get(), keyKey.get(), toWK(key).get()); + + WKRetainPtr modifiersKey = adoptWK(WKStringCreateWithUTF8CString("Modifiers")); + WKRetainPtr modifiersRef = WKUInt64Create(modifiers); + WKDictionaryAddItem(EventSenderMessageBody.get(), modifiersKey.get(), modifiersRef.get()); + + WKRetainPtr locationKey = adoptWK(WKStringCreateWithUTF8CString("Location")); + WKRetainPtr 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 EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender")); + WKRetainPtr EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate()); + + WKRetainPtr subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage")); + WKRetainPtr subMessageName(AdoptWK, WKStringCreateWithUTF8CString("MouseScrollBy")); + WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get()); + + WKRetainPtr xKey = adoptWK(WKStringCreateWithUTF8CString("X")); + WKRetainPtr xRef = WKDoubleCreate(x); + WKDictionaryAddItem(EventSenderMessageBody.get(), xKey.get(), xRef.get()); + + WKRetainPtr yKey = adoptWK(WKStringCreateWithUTF8CString("Y")); + WKRetainPtr 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 @@ void EventSendingController::makeWindowObject(JSContextRef context, JSObjectRef 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 EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender")); - WKRetainPtr EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate()); - - WKRetainPtr subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage")); - WKRetainPtr subMessageName(AdoptWK, WKStringCreateWithUTF8CString("KeyDown")); - WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get()); - - WKRetainPtr keyKey = adoptWK(WKStringCreateWithUTF8CString("Key")); - WKDictionaryAddItem(EventSenderMessageBody.get(), keyKey.get(), toWK(key).get()); - - WKRetainPtr modifiersKey = adoptWK(WKStringCreateWithUTF8CString("Modifiers")); - WKRetainPtr modifiersRef = WKUInt64Create(modifiers); - WKDictionaryAddItem(EventSenderMessageBody.get(), modifiersKey.get(), modifiersRef.get()); - - WKRetainPtr locationKey = adoptWK(WKStringCreateWithUTF8CString("Location")); - WKRetainPtr locationRef = WKUInt64Create(location); - WKDictionaryAddItem(EventSenderMessageBody.get(), locationKey.get(), locationRef.get()); - - WKBundlePostSynchronousMessage(InjectedBundle::shared().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0); -} - } // namespace WTR diff --git a/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h b/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h index 0be315c..5a6fa1a 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h +++ b/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h @@ -50,6 +50,7 @@ public: 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); diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp index 132397d..771c762 100644 --- a/Tools/WebKitTestRunner/TestController.cpp +++ b/Tools/WebKitTestRunner/TestController.cpp @@ -574,6 +574,20 @@ WKRetainPtr TestController::didReceiveSynchronousMessageFromInjectedB return 0; } + if (WKStringIsEqualToUTF8CString(subMessageName, "MouseScrollBy")) { + WKRetainPtr xKey = adoptWK(WKStringCreateWithUTF8CString("X")); + double x = WKDoubleGetValue(static_cast(WKDictionaryGetItemForKey(messageBodyDictionary, xKey.get()))); + + WKRetainPtr yKey = adoptWK(WKStringCreateWithUTF8CString("Y")); + double y = WKDoubleGetValue(static_cast(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 timeKey = adoptWK(WKStringCreateWithUTF8CString("TimeInMilliseconds")); unsigned time = static_cast(WKUInt64GetValue(static_cast(WKDictionaryGetItemForKey(messageBodyDictionary, timeKey.get())))); diff --git a/Tools/WebKitTestRunner/mac/EventSenderProxy.mm b/Tools/WebKitTestRunner/mac/EventSenderProxy.mm index 9a18dbb..7139550 100644 --- a/Tools/WebKitTestRunner/mac/EventSenderProxy.mm +++ b/Tools/WebKitTestRunner/mac/EventSenderProxy.mm @@ -27,9 +27,10 @@ #import "config.h" #import "EventSenderProxy.h" -#import "StringFunctions.h" #import "PlatformWebView.h" +#import "StringFunctions.h" #import "TestController.h" +#import #import namespace WTR { @@ -351,4 +352,21 @@ void EventSenderProxy::keyDown(WKStringRef key, WKEventModifiers modifiers, unsi [[m_testController->mainWebView()->platformWindow() firstResponder] keyUp:event]; } +void EventSenderProxy::mouseScrollBy(int x, int y) +{ + RetainPtr 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 diff --git a/Tools/WebKitTestRunner/qt/EventSenderProxyQt.cpp b/Tools/WebKitTestRunner/qt/EventSenderProxyQt.cpp index f897b61..a1aeb05 100644 --- a/Tools/WebKitTestRunner/qt/EventSenderProxyQt.cpp +++ b/Tools/WebKitTestRunner/qt/EventSenderProxyQt.cpp @@ -295,6 +295,11 @@ void EventSenderProxy::mouseMoveTo(double x, double y) sendOrQueueEvent(event); } +void EventSenderProxy::mouseScrollBy(int, int) +{ + // FIXME: Implement this. +} + void EventSenderProxy::leapForward(int ms) { eventQueue[endOfQueue].m_delay = ms;