Title: [198792] trunk/Source
Revision
198792
Author
[email protected]
Date
2016-03-29 13:19:45 -0700 (Tue, 29 Mar 2016)

Log Message

Web Automation: implement Automation.performMouseInteraction
https://bugs.webkit.org/show_bug.cgi?id=155606
<rdar://problem/25227576>

Source/WebKit2:

Reviewed by Timothy Hatcher.

This method implements common mouse interactions by synthesizing native events.
The creation and dispatching of simulated events is implemented separately per
application/window/event framework. This patch adds an implementation for ports
that use AppKit.

The event is created synthetically in a platform-specific way and delivered to
the platform's window in the UIProcess. The event goes through all the
layers of processing that a real mouse event could go through once it reaches
WebKit itself.

* UIProcess/Automation/Automation.json: Add new enums and command.

* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::protocolModifierToWebEventModifier):
(WebKit::WebAutomationSession::performMouseInteraction): Added.
Clip the requested cursor position so that it stays within the selected window's
frame and doesn't wander off into other windows or applications. Fire it using
the platform-specific simulation method.

(WebKit::WebAutomationSession::platformSimulateMouseInteraction): Added.

* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Cocoa/WebAutomationSessionCocoa.mm:
(WebKit::WebAutomationSession::platformSimulateMouseInteraction): Added.
Convert Automation protocol values to AppKit values. Simulate and dispatch
one or more events depending on the desired interaction.
* WebKit2Prefix.h: Include AppKitCompatibilityDeclarations.h so newer
NSEventTypes can be used.

Source/WTF:

Reviewed by Timothy Hatcher.

* wtf/mac/AppKitCompatibilityDeclarations.h: Add missing some NSEventTypes.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (198791 => 198792)


--- trunk/Source/WTF/ChangeLog	2016-03-29 20:12:18 UTC (rev 198791)
+++ trunk/Source/WTF/ChangeLog	2016-03-29 20:19:45 UTC (rev 198792)
@@ -1,3 +1,13 @@
+2016-03-28  Brian Burg  <[email protected]>
+
+        Web Automation: implement Automation.performMouseInteraction
+        https://bugs.webkit.org/show_bug.cgi?id=155606
+        <rdar://problem/25227576>
+
+        Reviewed by Timothy Hatcher.
+
+        * wtf/mac/AppKitCompatibilityDeclarations.h: Add missing some NSEventTypes.
+
 2016-03-29  Yusuke Suzuki  <[email protected]>
 
         REGRESSION(r192914): 10% regression on Sunspider's date-format-tofte

Modified: trunk/Source/WTF/wtf/mac/AppKitCompatibilityDeclarations.h (198791 => 198792)


--- trunk/Source/WTF/wtf/mac/AppKitCompatibilityDeclarations.h	2016-03-29 20:12:18 UTC (rev 198791)
+++ trunk/Source/WTF/wtf/mac/AppKitCompatibilityDeclarations.h	2016-03-29 20:19:45 UTC (rev 198792)
@@ -78,8 +78,12 @@
 static const NSEventType NSEventTypeLeftMouseUp = NSLeftMouseUp;
 static const NSEventType NSEventTypeMouseMoved = NSMouseMoved;
 static const NSEventType NSEventTypeOtherMouseDown = NSOtherMouseDown;
+static const NSEventType NSEventTypeOtherMouseDragged = NSOtherMouseDragged;
+static const NSEventType NSEventTypeOtherMouseUp = NSOtherMouseUp;
 static const NSEventType NSEventTypePeriodic = NSPeriodic;
 static const NSEventType NSEventTypeRightMouseDown = NSRightMouseDown;
+static const NSEventType NSEventTypeRightMouseDragged = NSRightMouseDragged;
+static const NSEventType NSEventTypeRightMouseUp = NSRightMouseUp;
 static const NSEventType NSEventTypeScrollWheel = NSScrollWheel;
 static const NSEventType NSEventTypeSystemDefined = NSSystemDefined;
 

Modified: trunk/Source/WebKit2/ChangeLog (198791 => 198792)


--- trunk/Source/WebKit2/ChangeLog	2016-03-29 20:12:18 UTC (rev 198791)
+++ trunk/Source/WebKit2/ChangeLog	2016-03-29 20:19:45 UTC (rev 198792)
@@ -1,3 +1,40 @@
+2016-03-28  Brian Burg  <[email protected]>
+
+        Web Automation: implement Automation.performMouseInteraction
+        https://bugs.webkit.org/show_bug.cgi?id=155606
+        <rdar://problem/25227576>
+
+        Reviewed by Timothy Hatcher.
+
+        This method implements common mouse interactions by synthesizing native events.
+        The creation and dispatching of simulated events is implemented separately per
+        application/window/event framework. This patch adds an implementation for ports
+        that use AppKit.
+
+        The event is created synthetically in a platform-specific way and delivered to
+        the platform's window in the UIProcess. The event goes through all the
+        layers of processing that a real mouse event could go through once it reaches
+        WebKit itself.
+
+        * UIProcess/Automation/Automation.json: Add new enums and command.
+
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::protocolModifierToWebEventModifier):
+        (WebKit::WebAutomationSession::performMouseInteraction): Added.
+        Clip the requested cursor position so that it stays within the selected window's
+        frame and doesn't wander off into other windows or applications. Fire it using
+        the platform-specific simulation method.
+
+        (WebKit::WebAutomationSession::platformSimulateMouseInteraction): Added.
+
+        * UIProcess/Automation/WebAutomationSession.h:
+        * UIProcess/Cocoa/WebAutomationSessionCocoa.mm:
+        (WebKit::WebAutomationSession::platformSimulateMouseInteraction): Added.
+        Convert Automation protocol values to AppKit values. Simulate and dispatch
+        one or more events depending on the desired interaction.
+        * WebKit2Prefix.h: Include AppKitCompatibilityDeclarations.h so newer
+        NSEventTypes can be used.
+
 2016-03-29  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Follow up to r198580.

Modified: trunk/Source/WebKit2/UIProcess/Automation/Automation.json (198791 => 198792)


--- trunk/Source/WebKit2/UIProcess/Automation/Automation.json	2016-03-29 20:12:18 UTC (rev 198791)
+++ trunk/Source/WebKit2/UIProcess/Automation/Automation.json	2016-03-29 20:19:45 UTC (rev 198792)
@@ -68,6 +68,41 @@
                 { "name": "windowSize", "$ref": "Size", "description": "The current size of the browsing context's window." },
                 { "name": "windowOrigin", "$ref": "Point", "description": "The current (x, y) position of the browsing context's window relative to the top-left of the screen." }
             ]
+        },
+        {
+            "id": "MouseInteraction",
+            "type": "string",
+            "description": "Enumerates different ways of interacting with a mouse cursor.",
+            "enum": [
+                "Move",
+                "Down",
+                "Up",
+                "SingleClick",
+                "DoubleClick"
+            ]
+        },
+        {
+            "id": "MouseButton",
+            "type": "string",
+            "description": "Enumerates different mouse buttons that can be used.",
+            "enum": [
+                "None",
+                "Left",
+                "Middle",
+                "Right"
+            ]
+        },
+        {
+            "id": "KeyModifier",
+            "type": "string",
+            "description": "Enumerates different key modifiers that can remain pressed during other mouse/touch interactions.",
+            "enum": [
+                "CapsLock",
+                "Control",
+                "Shift",
+                "Meta",
+                "Alt"
+            ]
         }
     ],
     "commands": [
@@ -171,6 +206,20 @@
             "async": true
         },
         {
+            "name": "performMouseInteraction",
+            "description": "Simulates interaction with a mouse cursor.",
+            "parameters": [
+                { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The browsing context to be interacted with." },
+                { "name": "position", "$ref": "Point", "description": "The requested position for the mouse cursor, specified in viewport coordinates." },
+                { "name": "button", "$ref": "MouseButton", "description": "The button to use to perform the interaction. This parameter only has an effect for the <code>Down</code>, <code>Up</code>, <code>Click</code>, and <code>DoubleClick</code> mouse interactions." },
+                { "name": "interaction", "$ref": "MouseInteraction", "description": "The type of interaction to be performed with the mouse cursor." },
+                { "name": "modifiers", "type": "array", "items": { "$ref": "KeyModifier" }, "description": "Key modifiers to be active during the mouse interaction." }
+            ],
+            "returns": [
+                { "name": "position", "$ref": "Point", "description": "The updated position of the mouse cursor, specified in viewport coordinates." }
+            ]
+        },
+        {
             "name": "resolveChildFrameHandle",
             "description": "Determines the <code>FrameHandle</code> based on the ordinal, name or node handle of a child frame.",
             "parameters": [

Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (198791 => 198792)


--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp	2016-03-29 20:12:18 UTC (rev 198791)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp	2016-03-29 20:19:45 UTC (rev 198792)
@@ -35,6 +35,7 @@
 #include <_javascript_Core/InspectorFrontendRouter.h>
 #include <WebCore/URL.h>
 #include <WebCore/UUID.h>
+#include <algorithm>
 #include <wtf/HashMap.h>
 
 using namespace Inspector;
@@ -631,4 +632,86 @@
     m_client->setUserInputForCurrentJavaScriptPromptOnPage(this, page, promptValue);
 }
 
+#if USE(APPKIT)
+static WebEvent::Modifiers protocolModifierToWebEventModifier(Inspector::Protocol::Automation::KeyModifier modifier)
+{
+    switch (modifier) {
+    case Inspector::Protocol::Automation::KeyModifier::Alt:
+        return WebEvent::AltKey;
+    case Inspector::Protocol::Automation::KeyModifier::Meta:
+        return WebEvent::MetaKey;
+    case Inspector::Protocol::Automation::KeyModifier::Control:
+        return WebEvent::ControlKey;
+    case Inspector::Protocol::Automation::KeyModifier::Shift:
+        return WebEvent::ShiftKey;
+    case Inspector::Protocol::Automation::KeyModifier::CapsLock:
+        return WebEvent::CapsLockKey;
+    }
+}
+#endif // USE(APPKIT)
+
+void WebAutomationSession::performMouseInteraction(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& requestedPositionObject, const String& mouseButtonString, const String& mouseInteractionString, const Inspector::InspectorArray& keyModifierStrings, RefPtr<Inspector::Protocol::Automation::Point>& updatedPositionObject)
+{
+#if !USE(APPKIT)
+    FAIL_WITH_PREDEFINED_ERROR_MESSAGE(NotImplemented);
+#else
+    WebPageProxy* page = webPageProxyForHandle(handle);
+    if (!page)
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+    // FIXME <rdar://problem/25094106>: Specify what parameter was missing or invalid and how.
+    // This requires some changes to the other end's error handling. Right now it looks for an
+    // exact error message match. We could stuff this into the 'data' field on error object.
+    float x;
+    if (!requestedPositionObject.getDouble(WTF::ASCIILiteral("x"), x))
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(MissingParameter);
+
+    float y;
+    if (!requestedPositionObject.getDouble(WTF::ASCIILiteral("y"), y))
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(MissingParameter);
+
+    WebCore::FloatRect windowFrame;
+    page->getWindowFrame(windowFrame);
+
+    x = std::max(std::min(0.0f, x), windowFrame.size().width());
+    y = std::max(std::min(0.0f, y), windowFrame.size().height());
+
+    WebCore::IntPoint viewPosition = WebCore::IntPoint(static_cast<int>(x), static_cast<int>(y));
+
+    auto parsedInteraction = Inspector::Protocol::parseEnumValueFromString<Inspector::Protocol::Automation::MouseInteraction>(mouseInteractionString);
+    if (!parsedInteraction)
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InvalidParameter);
+
+    auto parsedButton = Inspector::Protocol::parseEnumValueFromString<Inspector::Protocol::Automation::MouseButton>(mouseButtonString);
+    if (!parsedButton)
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InvalidParameter);
+
+    WebEvent::Modifiers keyModifiers = (WebEvent::Modifiers)0;
+    for (auto it = keyModifierStrings.begin(); it != keyModifierStrings.end(); ++it) {
+        String modifierString;
+        if (!it->get()->asString(modifierString))
+            FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InvalidParameter);
+
+        auto parsedModifier = Inspector::Protocol::parseEnumValueFromString<Inspector::Protocol::Automation::KeyModifier>(modifierString);
+        if (!parsedModifier)
+            FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InvalidParameter);
+        WebEvent::Modifiers enumValue = protocolModifierToWebEventModifier(parsedModifier.value());
+        keyModifiers = (WebEvent::Modifiers)(enumValue | keyModifiers);
+    }
+
+    platformSimulateMouseInteraction(*page, viewPosition, parsedInteraction.value(), parsedButton.value(), keyModifiers);
+
+    updatedPositionObject = Inspector::Protocol::Automation::Point::create()
+        .setX(x)
+        .setY(y)
+        .release();
+#endif // USE(APPKIT)
+}
+
+#if !USE(APPKIT)
+void WebAutomationSession::platformSimulateMouseInteraction(WebKit::WebPageProxy&, const WebCore::IntPoint&, Inspector::Protocol::Automation::MouseInteraction, Inspector::Protocol::Automation::MouseButton, WebEvent::Modifiers)
+{
+}
+#endif // !USE(APPKIT)
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h (198791 => 198792)


--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h	2016-03-29 20:12:18 UTC (rev 198791)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h	2016-03-29 20:19:45 UTC (rev 198792)
@@ -23,12 +23,12 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebAutomationSession_h
-#define WebAutomationSession_h
+#pragma once
 
 #include "APIObject.h"
 #include "AutomationBackendDispatchers.h"
 #include "Connection.h"
+#include "WebEvent.h"
 #include <wtf/Forward.h>
 
 #if ENABLE(REMOTE_INSPECTOR)
@@ -48,6 +48,14 @@
 class IntRect;
 }
 
+namespace WebCore {
+class IntPoint;
+}
+
+#if USE(APPKIT)
+OBJC_CLASS NSArray;
+#endif
+
 namespace WebKit {
 
 class WebAutomationSessionClient;
@@ -94,6 +102,7 @@
     void goForwardInBrowsingContext(Inspector::ErrorString&, const String&) override;
     void reloadBrowsingContext(Inspector::ErrorString&, const String&) override;
     void evaluateJavaScriptFunction(Inspector::ErrorString&, const String& browsingContextHandle, const String* optionalFrameHandle, const String& function, const Inspector::InspectorArray& arguments, bool expectsImplicitCallbackArgument, Ref<Inspector::AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback>&&) override;
+    void performMouseInteraction(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& requestedPosition, const String& mouseButton, const String& mouseInteraction, const Inspector::InspectorArray& keyModifiers, RefPtr<Inspector::Protocol::Automation::Point>& updatedPosition) override;
     void resolveChildFrameHandle(Inspector::ErrorString&, const String& browsingContextHandle, const String* optionalFrameHandle, const int* optionalOrdinal, const String* optionalName, const String* optionalNodeHandle, Ref<ResolveChildFrameHandleCallback>&&) override;
     void resolveParentFrameHandle(Inspector::ErrorString&, const String& browsingContextHandle, const String& frameHandle, Ref<ResolveParentFrameHandleCallback>&&) override;
     void computeElementLayout(Inspector::ErrorString&, const String& browsingContextHandle, const String& frameHandle, const String& nodeHandle, const bool* optionalScrollIntoViewIfNeeded, const bool* useViewportCoordinates, Ref<Inspector::AutomationBackendDispatcherHandler::ComputeElementLayoutCallback>&&) override;
@@ -121,6 +130,13 @@
     void didResolveParentFrame(uint64_t callbackID, uint64_t frameID, const String& errorType);
     void didComputeElementLayout(uint64_t callbackID, WebCore::IntRect, const String& errorType);
 
+    // Platform-specific helper methods.
+    void platformSimulateMouseInteraction(WebPageProxy&, const WebCore::IntPoint& viewPosition, Inspector::Protocol::Automation::MouseInteraction, Inspector::Protocol::Automation::MouseButton, WebEvent::Modifiers);
+
+#if USE(APPKIT)
+    void sendSynthesizedEventsToPage(WebPageProxy&, NSArray *eventsToSend);
+#endif
+
     WebProcessPool* m_processPool { nullptr };
 
     std::unique_ptr<API::AutomationSessionClient> m_client;
@@ -154,5 +170,3 @@
 };
 
 } // namespace WebKit
-
-#endif // WebAutomationSession_h

Added: trunk/Source/WebKit2/UIProcess/Cocoa/WebAutomationSessionCocoa.mm (0 => 198792)


--- trunk/Source/WebKit2/UIProcess/Cocoa/WebAutomationSessionCocoa.mm	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebAutomationSessionCocoa.mm	2016-03-29 20:19:45 UTC (rev 198792)
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WebAutomationSession.h"
+
+#import "WebPageProxy.h"
+#import "_WKAutomationSession.h"
+#import <WebCore/IntPoint.h>
+#import <WebCore/IntSize.h>
+#import <WebCore/PlatformMouseEvent.h>
+#import <objc/runtime.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#if USE(APPKIT)
+
+void WebAutomationSession::sendSynthesizedEventsToPage(WebPageProxy& page, NSArray *eventsToSend)
+{
+    NSWindow *window = page.platformWindow();
+
+    for (NSEvent *event in eventsToSend) {
+        // FIXME: <https://www.webkit.org/b/155963> Set an associated object with a per-session identifier.
+        // This will allow a WebKit2 client to tell apart events synthesized on behalf of an automation command.
+        [window sendEvent:event];
+    }
+}
+
+void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, const WebCore::IntPoint& viewPosition, Inspector::Protocol::Automation::MouseInteraction interaction, Inspector::Protocol::Automation::MouseButton button, WebEvent::Modifiers keyModifiers)
+{
+    IntRect windowRect;
+    page.rootViewToWindow(IntRect(viewPosition, IntSize()), windowRect);
+    IntPoint windowPosition = windowRect.location();
+
+    NSEventModifierFlags modifiers = 0;
+    if (keyModifiers & WebEvent::MetaKey)
+        modifiers |= NSEventModifierFlagCommand;
+    if (keyModifiers & WebEvent::AltKey)
+        modifiers |= NSEventModifierFlagOption;
+    if (keyModifiers & WebEvent::ControlKey)
+        modifiers |= NSEventModifierFlagControl;
+    if (keyModifiers & WebEvent::ShiftKey)
+        modifiers |= NSEventModifierFlagShift;
+
+    NSTimeInterval timestamp = [NSDate timeIntervalSinceReferenceDate];
+    NSWindow *window = page.platformWindow();
+    NSInteger windowNumber = window.windowNumber;
+
+    NSEventType downEventType;
+    NSEventType dragEventType;
+    NSEventType upEventType;
+    switch (button) {
+    case Inspector::Protocol::Automation::MouseButton::None:
+        downEventType = upEventType = dragEventType = NSEventTypeMouseMoved;
+        break;
+    case Inspector::Protocol::Automation::MouseButton::Left:
+        downEventType = NSEventTypeLeftMouseDown;
+        dragEventType = NSEventTypeLeftMouseDragged;
+        upEventType = NSEventTypeLeftMouseUp;
+        break;
+    case Inspector::Protocol::Automation::MouseButton::Middle:
+        downEventType = NSEventTypeOtherMouseDown;
+        dragEventType = NSEventTypeLeftMouseDragged;
+        upEventType = NSEventTypeOtherMouseUp;
+        break;
+    case Inspector::Protocol::Automation::MouseButton::Right:
+        downEventType = NSEventTypeRightMouseDown;
+        upEventType = NSEventTypeRightMouseUp;
+        break;
+    }
+
+    NSMutableArray<NSEvent *> *eventsToBeSent = [NSMutableArray new];
+
+    switch (interaction) {
+    case Inspector::Protocol::Automation::MouseInteraction::Move:
+        [eventsToBeSent addObject:[NSEvent mouseEventWithType:dragEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:0 clickCount:0 pressure:0.0f]];
+        break;
+    case Inspector::Protocol::Automation::MouseInteraction::Down:
+        // Hard-code the click count to one, since clients don't expect successive simulated
+        // down/up events to be potentially counted as a double click event.
+        [eventsToBeSent addObject:[NSEvent mouseEventWithType:downEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:0 clickCount:1 pressure:WebCore::ForceAtClick]];
+        break;
+    case Inspector::Protocol::Automation::MouseInteraction::Up:
+        // Hard-code the click count to one, since clients don't expect successive simulated
+        // down/up events to be potentially counted as a double click event.
+        [eventsToBeSent addObject:[NSEvent mouseEventWithType:upEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:0 clickCount:1 pressure:0.0f]];
+        break;
+    case Inspector::Protocol::Automation::MouseInteraction::SingleClick:
+        // Send separate down and up events. WebCore will see this as a single-click event.
+        [eventsToBeSent addObject:[NSEvent mouseEventWithType:downEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:0 clickCount:1 pressure:WebCore::ForceAtClick]];
+        [eventsToBeSent addObject:[NSEvent mouseEventWithType:upEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:0 clickCount:1 pressure:0.0f]];
+        break;
+    case Inspector::Protocol::Automation::MouseInteraction::DoubleClick:
+        // Send multiple down and up events with proper click count.
+        // WebCore will see this as a single-click event then double-click event.
+        [eventsToBeSent addObject:[NSEvent mouseEventWithType:downEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:0 clickCount:1 pressure:WebCore::ForceAtClick]];
+        [eventsToBeSent addObject:[NSEvent mouseEventWithType:upEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:0 clickCount:1 pressure:0.0f]];
+        [eventsToBeSent addObject:[NSEvent mouseEventWithType:downEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:0 clickCount:2 pressure:WebCore::ForceAtClick]];
+        [eventsToBeSent addObject:[NSEvent mouseEventWithType:upEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:0 clickCount:2 pressure:0.0f]];
+    }
+
+    sendSynthesizedEventsToPage(page, eventsToBeSent);
+}
+
+#endif // USE(APPKIT)
+
+} // namespace WebKit

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (198791 => 198792)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2016-03-29 20:12:18 UTC (rev 198791)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2016-03-29 20:19:45 UTC (rev 198792)
@@ -1238,6 +1238,7 @@
 		9955A6F51C7986E000EB6A93 /* AutomationBackendDispatchers.h in Headers */ = {isa = PBXBuildFile; fileRef = 9955A6F11C79866400EB6A93 /* AutomationBackendDispatchers.h */; };
 		9955A6F61C7986E300EB6A93 /* AutomationProtocolObjects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9955A6F21C79866400EB6A93 /* AutomationProtocolObjects.cpp */; };
 		9955A6F71C7986E500EB6A93 /* AutomationProtocolObjects.h in Headers */ = {isa = PBXBuildFile; fileRef = 9955A6F31C79866400EB6A93 /* AutomationProtocolObjects.h */; };
+		9986BDD71CA9A22C004800AA /* WebAutomationSessionCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9986BDD61CA9A222004800AA /* WebAutomationSessionCocoa.mm */; };
 		99C81D591C20E1E5005C4C82 /* AutomationClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 99C81D561C20DFBE005C4C82 /* AutomationClient.mm */; };
 		99C81D5A1C20E7E2005C4C82 /* AutomationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 99C81D551C20DFBE005C4C82 /* AutomationClient.h */; };
 		99C81D5D1C21F38B005C4C82 /* APIAutomationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 99C81D5B1C20E817005C4C82 /* APIAutomationClient.h */; };
@@ -3271,6 +3272,7 @@
 		9955A6F11C79866400EB6A93 /* AutomationBackendDispatchers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutomationBackendDispatchers.h; sourceTree = "<group>"; };
 		9955A6F21C79866400EB6A93 /* AutomationProtocolObjects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AutomationProtocolObjects.cpp; sourceTree = "<group>"; };
 		9955A6F31C79866400EB6A93 /* AutomationProtocolObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutomationProtocolObjects.h; sourceTree = "<group>"; };
+		9986BDD61CA9A222004800AA /* WebAutomationSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAutomationSessionCocoa.mm; sourceTree = "<group>"; };
 		99C81D551C20DFBE005C4C82 /* AutomationClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutomationClient.h; sourceTree = "<group>"; };
 		99C81D561C20DFBE005C4C82 /* AutomationClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AutomationClient.mm; sourceTree = "<group>"; };
 		99C81D5B1C20E817005C4C82 /* APIAutomationClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIAutomationClient.h; sourceTree = "<group>"; };
@@ -4631,6 +4633,7 @@
 				1AFE436318B6C081009C7A48 /* UIDelegate.mm */,
 				E4E8648E1B1673FB00C82F40 /* VersionChecks.h */,
 				E4E8648F1B1673FB00C82F40 /* VersionChecks.mm */,
+				9986BDD61CA9A222004800AA /* WebAutomationSessionCocoa.mm */,
 				1AC0273E196622D600C12B75 /* WebPageProxyCocoa.mm */,
 				7C4694CB1A4B510A00AD5845 /* WebPasteboardProxyCocoa.mm */,
 				7CE4D2151A49148400C7F152 /* WebProcessPoolCocoa.mm */,
@@ -9455,6 +9458,7 @@
 				C5E1AFEA16B20B7B006CC1F2 /* WKWebArchiveResource.cpp in Sources */,
 				1AA2E56618D77508003814BD /* WKWebProcessBundleParameters.mm in Sources */,
 				BC989D81161A7E5D000D46D3 /* WKWebProcessPlugIn.mm in Sources */,
+				9986BDD71CA9A22C004800AA /* WebAutomationSessionCocoa.mm in Sources */,
 				BC8F2F2A16273A2C005FACB5 /* WKWebProcessPlugInBrowserContextController.mm in Sources */,
 				1F7506AD1859161C00EC0FF7 /* WKWebProcessPlugInFrame.mm in Sources */,
 				1F7506AE1859162200EC0FF7 /* WKWebProcessPlugInHitTestResult.mm in Sources */,

Modified: trunk/Source/WebKit2/WebKit2Prefix.h (198791 => 198792)


--- trunk/Source/WebKit2/WebKit2Prefix.h	2016-03-29 20:12:18 UTC (rev 198791)
+++ trunk/Source/WebKit2/WebKit2Prefix.h	2016-03-29 20:19:45 UTC (rev 198792)
@@ -51,6 +51,7 @@
 #import <Foundation/Foundation.h>
 #if USE(APPKIT)
 #import <Cocoa/Cocoa.h>
+#import <wtf/mac/AppKitCompatibilityDeclarations.h>
 #endif
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to