WebEvent fails to convert synthetic WebMouseEvent for automation
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Apr 2018 20:12:06 +0000 (20:12 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Apr 2018 20:12:06 +0000 (20:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184824
rdar://problem/35377120

Reviewed by Brian Burg.

Add WebEvent conversions that existed in PlatformEventFactoryIOS for legacy WebKit,
but never got added in WebIOSEventFactory and NativeWebMouseEvent for modern WebKit.
This affected WebDriver, and some events not being deliverd to the page.

* Shared/NativeWebMouseEvent.h:
(WebKit::NativeWebMouseEvent::nativeEvent const):
* Shared/ios/NativeWebMouseEventIOS.mm: Added.
(WebKit::NativeWebMouseEvent::NativeWebMouseEvent):
* Shared/ios/WebIOSEventFactory.h:
* Shared/ios/WebIOSEventFactory.mm:
(WebIOSEventFactory::createWebMouseEvent):
* WebKit.xcodeproj/project.pbxproj:

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

Source/WebKit/ChangeLog
Source/WebKit/Shared/NativeWebMouseEvent.h
Source/WebKit/Shared/ios/NativeWebMouseEventIOS.mm [new file with mode: 0644]
Source/WebKit/Shared/ios/WebIOSEventFactory.h
Source/WebKit/Shared/ios/WebIOSEventFactory.mm
Source/WebKit/WebKit.xcodeproj/project.pbxproj

index 389e778..3b5873d 100644 (file)
@@ -1,3 +1,25 @@
+2018-04-20  Timothy Hatcher  <timothy@apple.com>
+
+        WebEvent fails to convert synthetic WebMouseEvent for automation
+
+        https://bugs.webkit.org/show_bug.cgi?id=184824
+        rdar://problem/35377120
+
+        Reviewed by Brian Burg.
+
+        Add WebEvent conversions that existed in PlatformEventFactoryIOS for legacy WebKit,
+        but never got added in WebIOSEventFactory and NativeWebMouseEvent for modern WebKit.
+        This affected WebDriver, and some events not being deliverd to the page.
+
+        * Shared/NativeWebMouseEvent.h:
+        (WebKit::NativeWebMouseEvent::nativeEvent const):
+        * Shared/ios/NativeWebMouseEventIOS.mm: Added.
+        (WebKit::NativeWebMouseEvent::NativeWebMouseEvent):
+        * Shared/ios/WebIOSEventFactory.h:
+        * Shared/ios/WebIOSEventFactory.mm:
+        (WebIOSEventFactory::createWebMouseEvent):
+        * WebKit.xcodeproj/project.pbxproj:
+
 2018-04-20  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Unreviewed, fix -Wformat warning
index 4b550ab..70e5805 100644 (file)
@@ -38,6 +38,11 @@ OBJC_CLASS NSView;
 typedef union _GdkEvent GdkEvent;
 #endif
 
+#if PLATFORM(IOS)
+#include <wtf/RetainPtr.h>
+OBJC_CLASS WebEvent;
+#endif
+
 #if PLATFORM(WPE)
 struct wpe_input_pointer_event;
 #endif
@@ -56,6 +61,8 @@ public:
 #elif PLATFORM(GTK)
     NativeWebMouseEvent(const NativeWebMouseEvent&);
     NativeWebMouseEvent(GdkEvent*, int);
+#elif PLATFORM(IOS)
+    NativeWebMouseEvent(::WebEvent *);
 #elif PLATFORM(WPE)
     NativeWebMouseEvent(struct wpe_input_pointer_event*, float deviceScaleFactor);
 #elif PLATFORM(WIN)
@@ -66,6 +73,8 @@ public:
     NSEvent* nativeEvent() const { return m_nativeEvent.get(); }
 #elif PLATFORM(GTK)
     const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
+#elif PLATFORM(IOS)
+    ::WebEvent* nativeEvent() const { return m_nativeEvent.get(); }
 #elif PLATFORM(WIN)
     const MSG* nativeEvent() const { return &m_nativeEvent; }
 #else
@@ -77,6 +86,8 @@ private:
     RetainPtr<NSEvent> m_nativeEvent;
 #elif PLATFORM(GTK)
     GUniquePtr<GdkEvent> m_nativeEvent;
+#elif PLATFORM(IOS)
+    RetainPtr<::WebEvent> m_nativeEvent;
 #elif PLATFORM(WIN)
     MSG m_nativeEvent;
 #endif
diff --git a/Source/WebKit/Shared/ios/NativeWebMouseEventIOS.mm b/Source/WebKit/Shared/ios/NativeWebMouseEventIOS.mm
new file mode 100644 (file)
index 0000000..f88d518
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2018 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 "NativeWebMouseEvent.h"
+
+#if PLATFORM(IOS)
+
+#import "WebIOSEventFactory.h"
+
+namespace WebKit {
+
+NativeWebMouseEvent::NativeWebMouseEvent(::WebEvent *event)
+    : WebMouseEvent(WebIOSEventFactory::createWebMouseEvent(event))
+    , m_nativeEvent(event)
+{
+}
+
+} // namespace WebKit
+
+#endif // PLATFORM(IOS)
index 7b6d0cf..fa45ee6 100644 (file)
@@ -33,7 +33,8 @@
 
 class WebIOSEventFactory {
 public:
-    static WebKit::WebKeyboardEvent createWebKeyboardEvent(::WebEvent *event);
+    static WebKit::WebKeyboardEvent createWebKeyboardEvent(::WebEvent *);
+    static WebKit::WebMouseEvent createWebMouseEvent(::WebEvent *);
 };
 
 #endif // PLATFORM(IOS)
index 90fbc28..171b1c0 100644 (file)
@@ -88,4 +88,23 @@ WebKit::WebKeyboardEvent WebIOSEventFactory::createWebKeyboardEvent(::WebEvent *
     return WebKit::WebKeyboardEvent(type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, WallTime::fromRawSeconds(timestamp));
 }
 
+WebKit::WebMouseEvent WebIOSEventFactory::createWebMouseEvent(::WebEvent *event)
+{
+    // This currently only supports synthetic mouse moved events with no button pressed.
+    ASSERT_ARG(event, event.type == WebEventMouseMoved);
+
+    auto type = WebKit::WebEvent::MouseMove;
+    auto button = WebKit::WebMouseEvent::NoButton;
+    unsigned short buttons = 0;
+    auto position = WebCore::IntPoint(event.locationInWindow);
+    float deltaX = 0;
+    float deltaY = 0;
+    float deltaZ = 0;
+    int clickCount = 0;
+    auto modifiers = static_cast<WebKit::WebEvent::Modifiers>(0);
+    double timestamp = event.timestamp;
+
+    return WebKit::WebMouseEvent(type, button, buttons, position, position, deltaX, deltaY, deltaZ, clickCount, modifiers, WallTime::fromRawSeconds(timestamp));
+}
+
 #endif // PLATFORM(IOS)
index 0edf2b2..882bb8a 100644 (file)
                1C8E293A12761E5B00BC7BD0 /* WKInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C8E293812761E5B00BC7BD0 /* WKInspector.cpp */; };
                1C8E2A351277852400BC7BD0 /* WebInspectorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C8E2A311277852400BC7BD0 /* WebInspectorMessageReceiver.cpp */; };
                1C8E2A361277852400BC7BD0 /* WebInspectorMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C8E2A321277852400BC7BD0 /* WebInspectorMessages.h */; };
+               1C9EBA5C2087E74F00054429 /* NativeWebMouseEventIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C9EBA5B2087E74E00054429 /* NativeWebMouseEventIOS.mm */; };
                1CA8B936127C774E00576C2B /* WebInspectorProxyMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CA8B935127C774E00576C2B /* WebInspectorProxyMac.mm */; };
                1CA8B945127C882A00576C2B /* WebInspectorProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CA8B943127C882A00576C2B /* WebInspectorProxyMessageReceiver.cpp */; };
                1CA8B946127C882A00576C2B /* WebInspectorProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CA8B944127C882A00576C2B /* WebInspectorProxyMessages.h */; };
                1C8E2A311277852400BC7BD0 /* WebInspectorMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorMessageReceiver.cpp; sourceTree = "<group>"; };
                1C8E2A321277852400BC7BD0 /* WebInspectorMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorMessages.h; sourceTree = "<group>"; };
                1C8E2DAD1278C5B200BC7BD0 /* WebInspectorUIMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebInspectorUIMac.mm; sourceTree = "<group>"; };
+               1C9EBA5B2087E74E00054429 /* NativeWebMouseEventIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NativeWebMouseEventIOS.mm; path = ios/NativeWebMouseEventIOS.mm; sourceTree = "<group>"; };
                1CA8B935127C774E00576C2B /* WebInspectorProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebInspectorProxyMac.mm; sourceTree = "<group>"; };
                1CA8B943127C882A00576C2B /* WebInspectorProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorProxyMessageReceiver.cpp; sourceTree = "<group>"; };
                1CA8B944127C882A00576C2B /* WebInspectorProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorProxyMessages.h; sourceTree = "<group>"; };
                                2D4D2C801DF60BF3002EB10C /* InteractionInformationRequest.cpp */,
                                2D4D2C7F1DF60BF3002EB10C /* InteractionInformationRequest.h */,
                                2DA944971884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm */,
+                               1C9EBA5B2087E74E00054429 /* NativeWebMouseEventIOS.mm */,
                                2DA944981884E4F000ED86DB /* NativeWebTouchEventIOS.mm */,
                                A118A9EC1907AD6F00F7C92B /* QuickLookDocumentData.cpp */,
                                A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */,
                                832AE2531BE2E8CD00FAAE10 /* NetworkCacheSpeculativeLoadManager.cpp in Sources */,
                                83BDCCB91AC5FDB6003F6441 /* NetworkCacheStatistics.cpp in Sources */,
                                E4436ED01A0D040B00EAD204 /* NetworkCacheStorage.cpp in Sources */,
+                               1C9EBA5C2087E74F00054429 /* NativeWebMouseEventIOS.mm in Sources */,
                                8310428C1BD6B66F00A715E4 /* NetworkCacheSubresourcesEntry.cpp in Sources */,
                                5302583D1DCBBD2200DA89C2 /* NetworkCaptureEvent.cpp in Sources */,
                                530258401DCBBD2200DA89C2 /* NetworkCaptureManager.cpp in Sources */,