Title: [289887] trunk/Tools
Revision
289887
Author
don.olmst...@sony.com
Date
2022-02-16 05:53:08 -0800 (Wed, 16 Feb 2022)

Log Message

Share WebKitTestRunner code among USE(LIBWPE) ports
https://bugs.webkit.org/show_bug.cgi?id=236651

Reviewed by Žan Doberšek.

Modify PLATFORM(WPE) to USE(LIBWPE) in EventSenderProxy and PlatformWebView. The former
just uses the libwpe API to send events so it can be shared. The later uses the
WPEToolingBackend so it can also be shared.

The WPE port was missing guards around ENABLE(TOUCH_EVENTS) so add those and organize the
corresponding .cpp so the methods track with the ordering in the header.

Also modernize the PlatformWebView code to prefer using over typedef.

* WebKitTestRunner/EventSenderProxy.h:
* WebKitTestRunner/PlatformWPE.cmake:
* WebKitTestRunner/PlatformWebView.h:
* WebKitTestRunner/libwpe/EventSenderProxyLibWPE.cpp: Renamed from Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp.
(WTR::EventSenderProxy::getUpdatedTouchEvents):
(WTR::EventSenderProxy::removeUpdatedTouchEvents):
(WTR::EventSenderProxy::prepareAndDispatchTouchEvent):
* WebKitTestRunner/libwpe/PlatformWebViewLibWPE.cpp: Renamed from Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp.
(WTR::PlatformWebView::windowSnapshotImage):

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Tools/ChangeLog (289886 => 289887)


--- trunk/Tools/ChangeLog	2022-02-16 12:38:35 UTC (rev 289886)
+++ trunk/Tools/ChangeLog	2022-02-16 13:53:08 UTC (rev 289887)
@@ -1,3 +1,29 @@
+2022-02-16  Don Olmstead  <don.olmst...@sony.com>
+
+        Share WebKitTestRunner code among USE(LIBWPE) ports
+        https://bugs.webkit.org/show_bug.cgi?id=236651
+
+        Reviewed by Žan Doberšek.
+
+        Modify PLATFORM(WPE) to USE(LIBWPE) in EventSenderProxy and PlatformWebView. The former
+        just uses the libwpe API to send events so it can be shared. The later uses the
+        WPEToolingBackend so it can also be shared.
+
+        The WPE port was missing guards around ENABLE(TOUCH_EVENTS) so add those and organize the
+        corresponding .cpp so the methods track with the ordering in the header.
+
+        Also modernize the PlatformWebView code to prefer using over typedef.
+
+        * WebKitTestRunner/EventSenderProxy.h:
+        * WebKitTestRunner/PlatformWPE.cmake:
+        * WebKitTestRunner/PlatformWebView.h:
+        * WebKitTestRunner/libwpe/EventSenderProxyLibWPE.cpp: Renamed from Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp.
+        (WTR::EventSenderProxy::getUpdatedTouchEvents):
+        (WTR::EventSenderProxy::removeUpdatedTouchEvents):
+        (WTR::EventSenderProxy::prepareAndDispatchTouchEvent):
+        * WebKitTestRunner/libwpe/PlatformWebViewLibWPE.cpp: Renamed from Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp.
+        (WTR::PlatformWebView::windowSnapshotImage):
+
 2022-02-15  Sihui Liu  <sihui_...@apple.com>
 
         Migrate IndexedDB and LocalStorage data to GeneralStorageDirectory

Modified: trunk/Tools/WebKitTestRunner/EventSenderProxy.h (289886 => 289887)


--- trunk/Tools/WebKitTestRunner/EventSenderProxy.h	2022-02-16 12:38:35 UTC (rev 289886)
+++ trunk/Tools/WebKitTestRunner/EventSenderProxy.h	2022-02-16 13:53:08 UTC (rev 289887)
@@ -32,7 +32,7 @@
 #include <wtf/RetainPtr.h>
 #include <wtf/Vector.h>
 
-#if PLATFORM(WPE)
+#if USE(LIBWPE)
 #include <wpe/wpe.h>
 #endif
 
@@ -130,7 +130,7 @@
     RetainPtr<NSEvent> pressureChangeEvent(int stage, float pressure, PressureChangeDirection);
 #endif
 
-#if PLATFORM(WPE)
+#if ENABLE(TOUCH_EVENTS) && USE(LIBWPE)
     Vector<struct wpe_input_touch_event_raw> getUpdatedTouchEvents();
     void removeUpdatedTouchEvents();
     void prepareAndDispatchTouchEvent(enum wpe_input_touch_event_type);
@@ -155,11 +155,13 @@
 #if PLATFORM(GTK)
     bool m_hasPreciseDeltas { false };
 #endif
-#if PLATFORM(WPE)
+#if USE(LIBWPE)
     uint32_t m_buttonState { 0 };
+#if ENABLE(TOUCH_EVENTS)
     Vector<struct wpe_input_touch_event_raw> m_touchEvents;
     HashSet<unsigned, DefaultHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> m_updatedTouchEvents;
 #endif
+#endif
 };
 
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/PlatformWPE.cmake (289886 => 289887)


--- trunk/Tools/WebKitTestRunner/PlatformWPE.cmake	2022-02-16 12:38:35 UTC (rev 289886)
+++ trunk/Tools/WebKitTestRunner/PlatformWPE.cmake	2022-02-16 13:53:08 UTC (rev 289887)
@@ -6,8 +6,9 @@
 list(APPEND WebKitTestRunner_SOURCES
     cairo/TestInvocationCairo.cpp
 
-    wpe/EventSenderProxyWPE.cpp
-    wpe/PlatformWebViewWPE.cpp
+    libwpe/EventSenderProxyLibWPE.cpp
+    libwpe/PlatformWebViewLibWPE.cpp
+
     wpe/TestControllerWPE.cpp
     wpe/UIScriptControllerWPE.cpp
     wpe/main.cpp

Modified: trunk/Tools/WebKitTestRunner/PlatformWebView.h (289886 => 289887)


--- trunk/Tools/WebKitTestRunner/PlatformWebView.h	2022-02-16 12:38:35 UTC (rev 289886)
+++ trunk/Tools/WebKitTestRunner/PlatformWebView.h	2022-02-16 13:53:08 UTC (rev 289887)
@@ -40,28 +40,27 @@
 OBJC_CLASS WebKitTestRunnerWindow;
 typedef struct CGImage *CGImageRef;
 
-typedef TestRunnerWKWebView *PlatformWKView;
-typedef WebKitTestRunnerWindow *PlatformWindow;
-typedef RetainPtr<CGImageRef> PlatformImage;
+using PlatformWKView = TestRunnerWKWebView*;
+using PlatformWindow = WebKitTestRunnerWindow*;
+using PlatformImage = RetainPtr<CGImageRef>;
 #elif defined(BUILDING_GTK__)
 typedef struct _GtkWidget GtkWidget;
 typedef WKViewRef PlatformWKView;
 typedef GtkWidget* PlatformWindow;
-#elif PLATFORM(WPE)
+#elif USE(LIBWPE)
 namespace WPEToolingBackends {
 class HeadlessViewBackend;
 }
-typedef WKViewRef PlatformWKView;
-typedef WPEToolingBackends::HeadlessViewBackend* PlatformWindow;
+using PlatformWKView = WKViewRef;
+using PlatformWindow = WPEToolingBackends::HeadlessViewBackend*;
 #elif PLATFORM(WIN)
-#include <cairo.h>
-class TestRunnerWindow;
-typedef HWND PlatformWindow;
-typedef WKViewRef PlatformWKView;
+using PlatformWKView = WKViewRef;
+using PlatformWindow = HWND;
 #endif
 
 #if USE(CAIRO)
-typedef cairo_surface_t* PlatformImage;
+#include <cairo.h>
+using PlatformImage = cairo_surface_t*;
 #endif
 
 namespace WTR {

Copied: trunk/Tools/WebKitTestRunner/libwpe/EventSenderProxyLibWPE.cpp (from rev 289886, trunk/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp) (0 => 289887)


--- trunk/Tools/WebKitTestRunner/libwpe/EventSenderProxyLibWPE.cpp	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/libwpe/EventSenderProxyLibWPE.cpp	2022-02-16 13:53:08 UTC (rev 289887)
@@ -0,0 +1,439 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "EventSenderProxy.h"
+
+#include "PlatformWebView.h"
+#include "TestController.h"
+#include <WPEToolingBackends/HeadlessViewBackend.h>
+#include <WebCore/NotImplemented.h>
+#include <wpe/wpe.h>
+#include <wtf/MonotonicTime.h>
+#include <wtf/UniqueArray.h>
+
+namespace WTR {
+
+// Key event location code defined in DOM Level 3.
+enum KeyLocationCode {
+    DOMKeyLocationStandard      = 0x00,
+    DOMKeyLocationLeft          = 0x01,
+    DOMKeyLocationRight         = 0x02,
+    DOMKeyLocationNumpad        = 0x03
+};
+
+enum ButtonState {
+    ButtonReleased = 0,
+    ButtonPressed = 1
+};
+
+enum PointerAxis {
+    VerticalScroll = 0,
+    HorizontalScroll = 1
+};
+
+struct wpe_view_backend* viewBackend(TestController& controller)
+{
+    return controller.mainWebView()->platformWindow()->backend();
+}
+
+static uint32_t secToMsTimestamp(double currentEventTime)
+{
+    return static_cast<uint32_t>(currentEventTime * 1000);
+}
+
+EventSenderProxy::EventSenderProxy(TestController* testController)
+    : m_testController(testController)
+    // WPE event timestamps are just MonotonicTime, not actual WallTime, so we can
+    // use any point of origin, as long as we are consistent.
+    , m_time(MonotonicTime::now().secondsSinceEpoch().value())
+    , m_leftMouseButtonDown(false)
+    , m_clickCount(0)
+    , m_clickTime(0)
+    , m_clickButton(kWKEventMouseButtonNoButton)
+    , m_buttonState(ButtonReleased)
+{
+}
+
+EventSenderProxy::~EventSenderProxy()
+{
+}
+
+static unsigned senderButtonToWPEButton(unsigned senderButton)
+{
+    // Tests using the EventSender have a different numbering ordering than the one
+    // that the WPE port expects. Shuffle these here.
+    switch (senderButton) {
+    case 0:
+        return 1;
+    case 1:
+        return 3;
+    case 2:
+        return 2;
+    default:
+        return senderButton;
+    }
+}
+
+static uint32_t modifierForButton(unsigned button)
+{
+    switch (button) {
+    case 1:
+        return wpe_input_pointer_modifier_button1;
+    case 2:
+        return wpe_input_pointer_modifier_button2;
+    case 3:
+        return wpe_input_pointer_modifier_button3;
+    case 4:
+        return wpe_input_pointer_modifier_button4;
+    case 5:
+        return wpe_input_pointer_modifier_button5;
+    default:
+        return 0;
+    }
+
+    RELEASE_ASSERT_NOT_REACHED();
+}
+
+static uint32_t wkEventModifiersToWPE(WKEventModifiers wkModifiers)
+{
+    uint32_t modifiers = 0;
+    if (wkModifiers & kWKEventModifiersShiftKey)
+        modifiers |=  wpe_input_keyboard_modifier_shift;
+    if (wkModifiers & kWKEventModifiersControlKey)
+        modifiers |= wpe_input_keyboard_modifier_control;
+    if (wkModifiers & kWKEventModifiersAltKey)
+        modifiers |= wpe_input_keyboard_modifier_alt;
+    if (wkModifiers & kWKEventModifiersMetaKey)
+        modifiers |= wpe_input_keyboard_modifier_meta;
+
+    return modifiers;
+}
+
+void EventSenderProxy::mouseDown(unsigned button, WKEventModifiers wkModifiers, WKStringRef pointerType)
+{
+    m_clickButton = button;
+    m_clickPosition = m_position;
+    m_clickTime = m_time;
+    m_buttonState = ButtonPressed;
+
+    auto wpeButton = senderButtonToWPEButton(button);
+    m_mouseButtonsCurrentlyDown |= modifierForButton(wpeButton);
+    uint32_t modifiers = wkEventModifiersToWPE(wkModifiers);
+
+    struct wpe_input_pointer_event event { wpe_input_pointer_event_type_button, secToMsTimestamp(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), wpeButton, m_buttonState, m_mouseButtonsCurrentlyDown | modifiers };
+    wpe_view_backend_dispatch_pointer_event(viewBackend(*m_testController), &event);
+}
+
+void EventSenderProxy::mouseUp(unsigned button, WKEventModifiers wkModifiers, WKStringRef pointerType)
+{
+    m_buttonState = ButtonReleased;
+    m_clickButton = kWKEventMouseButtonNoButton;
+
+    auto wpeButton = senderButtonToWPEButton(button);
+    m_mouseButtonsCurrentlyDown &= ~modifierForButton(wpeButton);
+    uint32_t modifiers = wkEventModifiersToWPE(wkModifiers);
+
+    struct wpe_input_pointer_event event { wpe_input_pointer_event_type_button, secToMsTimestamp(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), wpeButton, m_buttonState, m_mouseButtonsCurrentlyDown | modifiers };
+    wpe_view_backend_dispatch_pointer_event(viewBackend(*m_testController), &event);
+}
+
+void EventSenderProxy::mouseMoveTo(double x, double y, WKStringRef pointerType)
+{
+    m_position.x = x;
+    m_position.y = y;
+
+    struct wpe_input_pointer_event event { wpe_input_pointer_event_type_motion, secToMsTimestamp(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), static_cast<uint32_t>(m_clickButton), m_buttonState, m_mouseButtonsCurrentlyDown };
+    wpe_view_backend_dispatch_pointer_event(viewBackend(*m_testController), &event);
+}
+
+void EventSenderProxy::mouseScrollBy(int horizontal, int vertical)
+{
+    // Copy behaviour of GTK+ - just return in case of (0,0) mouse scroll
+    if (!horizontal && !vertical)
+        return;
+
+    if (horizontal) {
+        struct wpe_input_axis_event event = { wpe_input_axis_event_type_motion, secToMsTimestamp(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), HorizontalScroll, horizontal, 0 };
+        wpe_view_backend_dispatch_axis_event(viewBackend(*m_testController), &event);
+    }
+    if (vertical) {
+        struct wpe_input_axis_event event =  { wpe_input_axis_event_type_motion, secToMsTimestamp(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), VerticalScroll, vertical, 0 };
+        wpe_view_backend_dispatch_axis_event(viewBackend(*m_testController), &event);
+    }
+}
+
+void EventSenderProxy::mouseScrollByWithWheelAndMomentumPhases(int horizontal, int vertical, int, int)
+{
+    mouseScrollBy(horizontal, vertical);
+}
+
+void EventSenderProxy::continuousMouseScrollBy(int, int, bool)
+{
+}
+
+void EventSenderProxy::leapForward(int milliseconds)
+{
+    m_time += milliseconds / 1000.0;
+}
+
+static uint32_t wpeKeySymForKeyRef(WKStringRef keyRef, unsigned location, uint32_t* modifiers)
+{
+    if (location == DOMKeyLocationNumpad) {
+        if (WKStringIsEqualToUTF8CString(keyRef, "leftArrow"))
+            return WPE_KEY_KP_Left;
+        if (WKStringIsEqualToUTF8CString(keyRef, "rightArrow"))
+            return WPE_KEY_KP_Right;
+        if (WKStringIsEqualToUTF8CString(keyRef, "upArrow"))
+            return WPE_KEY_KP_Up;
+        if (WKStringIsEqualToUTF8CString(keyRef, "downArrow"))
+            return WPE_KEY_KP_Down;
+        if (WKStringIsEqualToUTF8CString(keyRef, "pageUp"))
+            return WPE_KEY_KP_Page_Up;
+        if (WKStringIsEqualToUTF8CString(keyRef, "pageDown"))
+            return WPE_KEY_KP_Page_Down;
+        if (WKStringIsEqualToUTF8CString(keyRef, "home"))
+            return WPE_KEY_KP_Home;
+        if (WKStringIsEqualToUTF8CString(keyRef, "end"))
+            return WPE_KEY_KP_End;
+        if (WKStringIsEqualToUTF8CString(keyRef, "insert"))
+            return WPE_KEY_KP_Insert;
+        if (WKStringIsEqualToUTF8CString(keyRef, "delete"))
+            return WPE_KEY_KP_Delete;
+
+        return WPE_KEY_VoidSymbol;
+    }
+
+    if (WKStringIsEqualToUTF8CString(keyRef, "leftControl"))
+        return WPE_KEY_Control_L;
+    if (WKStringIsEqualToUTF8CString(keyRef, "rightControl"))
+        return WPE_KEY_Control_R;
+    if (WKStringIsEqualToUTF8CString(keyRef, "leftShift"))
+        return WPE_KEY_Shift_L;
+    if (WKStringIsEqualToUTF8CString(keyRef, "rightShift"))
+        return WPE_KEY_Shift_R;
+    if (WKStringIsEqualToUTF8CString(keyRef, "leftMeta"))
+        return WPE_KEY_Meta_L;
+    if (WKStringIsEqualToUTF8CString(keyRef, "rightMeta"))
+        return WPE_KEY_Meta_R;
+    if (WKStringIsEqualToUTF8CString(keyRef, "leftAlt"))
+        return WPE_KEY_Alt_L;
+    if (WKStringIsEqualToUTF8CString(keyRef, "rightAlt"))
+        return WPE_KEY_Alt_R;
+    if (WKStringIsEqualToUTF8CString(keyRef, "leftArrow"))
+        return WPE_KEY_Left;
+    if (WKStringIsEqualToUTF8CString(keyRef, "rightArrow"))
+        return WPE_KEY_Right;
+    if (WKStringIsEqualToUTF8CString(keyRef, "upArrow"))
+        return WPE_KEY_Up;
+    if (WKStringIsEqualToUTF8CString(keyRef, "downArrow"))
+        return WPE_KEY_Down;
+    if (WKStringIsEqualToUTF8CString(keyRef, "pageUp"))
+        return WPE_KEY_Page_Up;
+    if (WKStringIsEqualToUTF8CString(keyRef, "pageDown"))
+        return WPE_KEY_Page_Down;
+    if (WKStringIsEqualToUTF8CString(keyRef, "home"))
+        return WPE_KEY_Home;
+    if (WKStringIsEqualToUTF8CString(keyRef, "end"))
+        return WPE_KEY_End;
+    if (WKStringIsEqualToUTF8CString(keyRef, "insert"))
+        return WPE_KEY_Insert;
+    if (WKStringIsEqualToUTF8CString(keyRef, "delete"))
+        return WPE_KEY_Delete;
+    if (WKStringIsEqualToUTF8CString(keyRef, "printScreen"))
+        return WPE_KEY_Print;
+    if (WKStringIsEqualToUTF8CString(keyRef, "menu"))
+        return WPE_KEY_Menu;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F1"))
+        return WPE_KEY_F1;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F2"))
+        return WPE_KEY_F2;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F3"))
+        return WPE_KEY_F3;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F4"))
+        return WPE_KEY_F4;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F5"))
+        return WPE_KEY_F5;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F6"))
+        return WPE_KEY_F6;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F7"))
+        return WPE_KEY_F7;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F8"))
+        return WPE_KEY_F8;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F9"))
+        return WPE_KEY_F9;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F10"))
+        return WPE_KEY_F10;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F11"))
+        return WPE_KEY_F11;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F12"))
+        return WPE_KEY_F12;
+    if (WKStringIsEqualToUTF8CString(keyRef, "escape"))
+        return WPE_KEY_Escape;
+
+    size_t bufferSize = WKStringGetMaximumUTF8CStringSize(keyRef);
+    auto buffer = makeUniqueArray<char>(bufferSize);
+    WKStringGetUTF8CString(keyRef, buffer.get(), bufferSize);
+    char charCode = buffer.get()[0];
+
+    if (charCode == '\n' || charCode == '\r')
+        return WPE_KEY_Return;
+    if (charCode == '\t')
+        return WPE_KEY_Tab;
+    if (charCode == '\x8')
+        return WPE_KEY_BackSpace;
+    if (charCode == 0x001B)
+        return WPE_KEY_Escape;
+
+    if (WTF::isASCIIUpper(charCode))
+        *modifiers |= wpe_input_keyboard_modifier_shift;
+
+    return wpe_unicode_to_key_code(static_cast<uint32_t>(charCode));
+}
+
+void EventSenderProxy::keyDown(WKStringRef keyRef, WKEventModifiers wkModifiers, unsigned location)
+{
+    uint32_t modifiers = wkEventModifiersToWPE(wkModifiers);
+    uint32_t keySym = wpeKeySymForKeyRef(keyRef, location, &modifiers);
+    struct wpe_input_xkb_keymap_entry* entries;
+    uint32_t entriesCount;
+    wpe_input_xkb_context_get_entries_for_key_code(wpe_input_xkb_context_get_default(), keySym, &entries, &entriesCount);
+    struct wpe_input_keyboard_event event { secToMsTimestamp(m_time), keySym, entriesCount ? entries[0].hardware_key_code : 0, true, modifiers };
+    wpe_view_backend_dispatch_keyboard_event(viewBackend(*m_testController), &event);
+    event.pressed = false;
+    wpe_view_backend_dispatch_keyboard_event(viewBackend(*m_testController), &event);
+    free(entries);
+}
+
+void EventSenderProxy::rawKeyDown(WKStringRef key, WKEventModifiers modifiers, unsigned keyLocation)
+{
+}
+
+void EventSenderProxy::rawKeyUp(WKStringRef key, WKEventModifiers modifiers, unsigned keyLocation)
+{
+}
+
+#if ENABLE(TOUCH_EVENTS)
+
+void EventSenderProxy::addTouchPoint(int x, int y)
+{
+    struct wpe_input_touch_event_raw rawEvent { wpe_input_touch_event_type_down, secToMsTimestamp(m_time), static_cast<int>(m_touchEvents.size()), static_cast<int32_t>(x), static_cast<int32_t>(y) };
+    m_touchEvents.append(rawEvent);
+    m_updatedTouchEvents.add(rawEvent.id);
+}
+
+void EventSenderProxy::updateTouchPoint(int index, int x, int y)
+{
+    ASSERT(index >= 0 && static_cast<size_t>(index) <= m_touchEvents.size());
+
+    auto& rawEvent = m_touchEvents[index];
+    rawEvent.x = x;
+    rawEvent.y = y;
+    rawEvent.time = secToMsTimestamp(m_time);
+    rawEvent.type = wpe_input_touch_event_type_motion;
+    m_updatedTouchEvents.add(index);
+}
+
+void EventSenderProxy::setTouchModifier(WKEventModifiers, bool)
+{
+    notImplemented();
+}
+
+void EventSenderProxy::setTouchPointRadius(int, int)
+{
+    notImplemented();
+}
+
+void EventSenderProxy::touchStart()
+{
+    prepareAndDispatchTouchEvent(wpe_input_touch_event_type_down);
+}
+
+void EventSenderProxy::touchMove()
+{
+    prepareAndDispatchTouchEvent(wpe_input_touch_event_type_motion);
+}
+
+void EventSenderProxy::touchEnd()
+{
+    prepareAndDispatchTouchEvent(wpe_input_touch_event_type_up);
+}
+
+void EventSenderProxy::touchCancel()
+{
+    notImplemented();
+}
+
+void EventSenderProxy::clearTouchPoints()
+{
+    m_touchEvents.clear();
+    m_updatedTouchEvents.clear();
+}
+
+void EventSenderProxy::releaseTouchPoint(int index)
+{
+    ASSERT(index >= 0 && static_cast<size_t>(index) <= m_touchEvents.size());
+
+    auto& rawEvent = m_touchEvents[index];
+    rawEvent.time = secToMsTimestamp(m_time);
+    rawEvent.type = wpe_input_touch_event_type_up;
+    m_updatedTouchEvents.add(index);
+}
+
+void EventSenderProxy::cancelTouchPoint(int)
+{
+    notImplemented();
+}
+
+Vector<struct wpe_input_touch_event_raw> EventSenderProxy::getUpdatedTouchEvents()
+{
+    Vector<wpe_input_touch_event_raw> events;
+    for (auto id : m_updatedTouchEvents)
+        events.append(m_touchEvents[id]);
+    return events;
+}
+
+void EventSenderProxy::removeUpdatedTouchEvents()
+{
+    for (auto id : m_updatedTouchEvents)
+        m_touchEvents[id].type = wpe_input_touch_event_type_null;
+    m_touchEvents.removeAllMatching([] (auto current) {
+        return current.type == wpe_input_touch_event_type_null;
+        });
+}
+
+void EventSenderProxy::prepareAndDispatchTouchEvent(enum wpe_input_touch_event_type eventType)
+{
+    auto updatedEvents = getUpdatedTouchEvents();
+    struct wpe_input_touch_event event = { updatedEvents.data(), updatedEvents.size(), eventType, 0, secToMsTimestamp(m_time), 0 };
+    wpe_view_backend_dispatch_touch_event(viewBackend(*m_testController), &event);
+    if (eventType == wpe_input_touch_event_type_up)
+        removeUpdatedTouchEvents();
+    m_updatedTouchEvents.clear();
+}
+
+#endif // ENABLE(TOUCH_EVENTS)
+
+} // namespace WTR

Copied: trunk/Tools/WebKitTestRunner/libwpe/PlatformWebViewLibWPE.cpp (from rev 289886, trunk/Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp) (0 => 289887)


--- trunk/Tools/WebKitTestRunner/libwpe/PlatformWebViewLibWPE.cpp	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/libwpe/PlatformWebViewLibWPE.cpp	2022-02-16 13:53:08 UTC (rev 289887)
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "PlatformWebView.h"
+
+#include <WPEToolingBackends/HeadlessViewBackend.h>
+#include <cstdio>
+#include <wtf/RunLoop.h>
+#include <wtf/text/WTFString.h>
+
+namespace WTR {
+
+PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration, const TestOptions& options)
+    : m_windowIsKey(true)
+    , m_options(options)
+{
+    m_window = new WPEToolingBackends::HeadlessViewBackend(800, 600);
+    m_view = WKViewCreate(m_window->backend(), configuration);
+}
+
+PlatformWebView::~PlatformWebView()
+{
+    delete m_window;
+}
+
+void PlatformWebView::resizeTo(unsigned, unsigned, WebViewSizingMode)
+{
+}
+
+WKPageRef PlatformWebView::page()
+{
+    return WKViewGetPage(m_view);
+}
+
+void PlatformWebView::focus()
+{
+}
+
+WKRect PlatformWebView::windowFrame()
+{
+    return { { 0, 0 }, { 1, 1 } };
+}
+
+void PlatformWebView::setWindowFrame(WKRect, WebViewSizingMode)
+{
+}
+
+void PlatformWebView::didInitializeClients()
+{
+}
+
+void PlatformWebView::addChromeInputField()
+{
+}
+
+void PlatformWebView::removeChromeInputField()
+{
+}
+
+void PlatformWebView::setTextInChromeInputField(const String&)
+{
+}
+
+void PlatformWebView::selectChromeInputField()
+{
+}
+
+String PlatformWebView::getSelectedTextInChromeInputField()
+{
+    return { };
+}
+
+void PlatformWebView::addToWindow()
+{
+    m_window->addActivityState(wpe_view_activity_state_in_window);
+}
+
+void PlatformWebView::removeFromWindow()
+{
+    m_window->removeActivityState(wpe_view_activity_state_in_window);
+}
+
+void PlatformWebView::setWindowIsKey(bool windowIsKey)
+{
+    m_windowIsKey = windowIsKey;
+}
+
+void PlatformWebView::makeWebViewFirstResponder()
+{
+}
+
+PlatformImage PlatformWebView::windowSnapshotImage()
+{
+    {
+        struct TimeoutTimer {
+            TimeoutTimer()
+                : timer(RunLoop::main(), this, &TimeoutTimer::fired)
+            {
+                timer.startOneShot(1_s / 60);
+            }
+
+            void fired() { RunLoop::main().stop(); }
+            RunLoop::Timer<TimeoutTimer> timer;
+        } timeoutTimer;
+
+        RunLoop::main().run();
+    }
+
+    return m_window->snapshot();
+}
+
+void PlatformWebView::changeWindowScaleIfNeeded(float)
+{
+}
+
+void PlatformWebView::setNavigationGesturesEnabled(bool)
+{
+}
+
+void PlatformWebView::forceWindowFramesChanged()
+{
+}
+
+bool PlatformWebView::drawsBackground() const
+{
+    return false;
+}
+
+void PlatformWebView::setDrawsBackground(bool)
+{
+}
+
+void PlatformWebView::setEditable(bool)
+{
+}
+
+} // namespace WTR

Deleted: trunk/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp (289886 => 289887)


--- trunk/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp	2022-02-16 12:38:35 UTC (rev 289886)
+++ trunk/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp	2022-02-16 13:53:08 UTC (rev 289887)
@@ -1,435 +0,0 @@
-/*
- * Copyright (C) 2014 Igalia S.L.
- *
- * 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.
- */
-
-#include "config.h"
-#include "EventSenderProxy.h"
-
-#include "PlatformWebView.h"
-#include "TestController.h"
-#include <WPEToolingBackends/HeadlessViewBackend.h>
-#include <WebCore/NotImplemented.h>
-#include <wpe/wpe.h>
-#include <wtf/MonotonicTime.h>
-#include <wtf/UniqueArray.h>
-
-namespace WTR {
-
-// Key event location code defined in DOM Level 3.
-enum KeyLocationCode {
-    DOMKeyLocationStandard      = 0x00,
-    DOMKeyLocationLeft          = 0x01,
-    DOMKeyLocationRight         = 0x02,
-    DOMKeyLocationNumpad        = 0x03
-};
-
-enum ButtonState {
-    ButtonReleased = 0,
-    ButtonPressed = 1
-};
-
-enum PointerAxis {
-    VerticalScroll = 0,
-    HorizontalScroll = 1
-};
-
-struct wpe_view_backend* viewBackend(TestController& controller)
-{
-    return controller.mainWebView()->platformWindow()->backend();
-}
-
-static uint32_t secToMsTimestamp(double currentEventTime)
-{
-    return static_cast<uint32_t>(currentEventTime * 1000);
-}
-
-EventSenderProxy::EventSenderProxy(TestController* testController)
-    : m_testController(testController)
-    // WPE event timestamps are just MonotonicTime, not actual WallTime, so we can
-    // use any point of origin, as long as we are consistent.
-    , m_time(MonotonicTime::now().secondsSinceEpoch().value())
-    , m_leftMouseButtonDown(false)
-    , m_clickCount(0)
-    , m_clickTime(0)
-    , m_clickButton(kWKEventMouseButtonNoButton)
-    , m_buttonState(ButtonReleased)
-{
-}
-
-EventSenderProxy::~EventSenderProxy()
-{
-}
-
-static unsigned senderButtonToWPEButton(unsigned senderButton)
-{
-    // Tests using the EventSender have a different numbering ordering than the one
-    // that the WPE port expects. Shuffle these here.
-    switch (senderButton) {
-    case 0:
-        return 1;
-    case 1:
-        return 3;
-    case 2:
-        return 2;
-    default:
-        return senderButton;
-    }
-}
-
-static uint32_t modifierForButton(unsigned button)
-{
-    switch (button) {
-    case 1:
-        return wpe_input_pointer_modifier_button1;
-    case 2:
-        return wpe_input_pointer_modifier_button2;
-    case 3:
-        return wpe_input_pointer_modifier_button3;
-    case 4:
-        return wpe_input_pointer_modifier_button4;
-    case 5:
-        return wpe_input_pointer_modifier_button5;
-    default:
-        return 0;
-    }
-
-    RELEASE_ASSERT_NOT_REACHED();
-}
-
-static uint32_t wkEventModifiersToWPE(WKEventModifiers wkModifiers)
-{
-    uint32_t modifiers = 0;
-    if (wkModifiers & kWKEventModifiersShiftKey)
-        modifiers |=  wpe_input_keyboard_modifier_shift;
-    if (wkModifiers & kWKEventModifiersControlKey)
-        modifiers |= wpe_input_keyboard_modifier_control;
-    if (wkModifiers & kWKEventModifiersAltKey)
-        modifiers |= wpe_input_keyboard_modifier_alt;
-    if (wkModifiers & kWKEventModifiersMetaKey)
-        modifiers |= wpe_input_keyboard_modifier_meta;
-
-    return modifiers;
-}
-
-void EventSenderProxy::mouseDown(unsigned button, WKEventModifiers wkModifiers, WKStringRef pointerType)
-{
-    m_clickButton = button;
-    m_clickPosition = m_position;
-    m_clickTime = m_time;
-    m_buttonState = ButtonPressed;
-
-    auto wpeButton = senderButtonToWPEButton(button);
-    m_mouseButtonsCurrentlyDown |= modifierForButton(wpeButton);
-    uint32_t modifiers = wkEventModifiersToWPE(wkModifiers);
-
-    struct wpe_input_pointer_event event { wpe_input_pointer_event_type_button, secToMsTimestamp(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), wpeButton, m_buttonState, m_mouseButtonsCurrentlyDown | modifiers };
-    wpe_view_backend_dispatch_pointer_event(viewBackend(*m_testController), &event);
-}
-
-void EventSenderProxy::mouseUp(unsigned button, WKEventModifiers wkModifiers, WKStringRef pointerType)
-{
-    m_buttonState = ButtonReleased;
-    m_clickButton = kWKEventMouseButtonNoButton;
-
-    auto wpeButton = senderButtonToWPEButton(button);
-    m_mouseButtonsCurrentlyDown &= ~modifierForButton(wpeButton);
-    uint32_t modifiers = wkEventModifiersToWPE(wkModifiers);
-
-    struct wpe_input_pointer_event event { wpe_input_pointer_event_type_button, secToMsTimestamp(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), wpeButton, m_buttonState, m_mouseButtonsCurrentlyDown | modifiers };
-    wpe_view_backend_dispatch_pointer_event(viewBackend(*m_testController), &event);
-}
-
-void EventSenderProxy::mouseMoveTo(double x, double y, WKStringRef pointerType)
-{
-    m_position.x = x;
-    m_position.y = y;
-
-    struct wpe_input_pointer_event event { wpe_input_pointer_event_type_motion, secToMsTimestamp(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), static_cast<uint32_t>(m_clickButton), m_buttonState, m_mouseButtonsCurrentlyDown };
-    wpe_view_backend_dispatch_pointer_event(viewBackend(*m_testController), &event);
-}
-
-void EventSenderProxy::mouseScrollBy(int horizontal, int vertical)
-{
-    // Copy behaviour of GTK+ - just return in case of (0,0) mouse scroll
-    if (!horizontal && !vertical)
-        return;
-
-    if (horizontal) {
-        struct wpe_input_axis_event event = { wpe_input_axis_event_type_motion, secToMsTimestamp(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), HorizontalScroll, horizontal, 0};
-        wpe_view_backend_dispatch_axis_event(viewBackend(*m_testController), &event);
-    }
-    if (vertical) {
-        struct wpe_input_axis_event event =  { wpe_input_axis_event_type_motion, secToMsTimestamp(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), VerticalScroll, vertical, 0};
-        wpe_view_backend_dispatch_axis_event(viewBackend(*m_testController), &event);
-    }
-}
-
-void EventSenderProxy::mouseScrollByWithWheelAndMomentumPhases(int horizontal, int vertical, int, int)
-{
-    mouseScrollBy(horizontal, vertical);
-}
-
-void EventSenderProxy::continuousMouseScrollBy(int, int, bool)
-{
-}
-
-void EventSenderProxy::leapForward(int milliseconds)
-{
-    m_time += milliseconds / 1000.0;
-}
-
-static uint32_t wpeKeySymForKeyRef(WKStringRef keyRef, unsigned location, uint32_t* modifiers)
-{
-    if (location == DOMKeyLocationNumpad) {
-        if (WKStringIsEqualToUTF8CString(keyRef, "leftArrow"))
-            return WPE_KEY_KP_Left;
-        if (WKStringIsEqualToUTF8CString(keyRef, "rightArrow"))
-            return WPE_KEY_KP_Right;
-        if (WKStringIsEqualToUTF8CString(keyRef, "upArrow"))
-            return WPE_KEY_KP_Up;
-        if (WKStringIsEqualToUTF8CString(keyRef, "downArrow"))
-            return WPE_KEY_KP_Down;
-        if (WKStringIsEqualToUTF8CString(keyRef, "pageUp"))
-            return WPE_KEY_KP_Page_Up;
-        if (WKStringIsEqualToUTF8CString(keyRef, "pageDown"))
-            return WPE_KEY_KP_Page_Down;
-        if (WKStringIsEqualToUTF8CString(keyRef, "home"))
-            return WPE_KEY_KP_Home;
-        if (WKStringIsEqualToUTF8CString(keyRef, "end"))
-            return WPE_KEY_KP_End;
-        if (WKStringIsEqualToUTF8CString(keyRef, "insert"))
-            return WPE_KEY_KP_Insert;
-        if (WKStringIsEqualToUTF8CString(keyRef, "delete"))
-            return WPE_KEY_KP_Delete;
-
-        return WPE_KEY_VoidSymbol;
-    }
-
-    if (WKStringIsEqualToUTF8CString(keyRef, "leftControl"))
-        return WPE_KEY_Control_L;
-    if (WKStringIsEqualToUTF8CString(keyRef, "rightControl"))
-        return WPE_KEY_Control_R;
-    if (WKStringIsEqualToUTF8CString(keyRef, "leftShift"))
-        return WPE_KEY_Shift_L;
-    if (WKStringIsEqualToUTF8CString(keyRef, "rightShift"))
-        return WPE_KEY_Shift_R;
-    if (WKStringIsEqualToUTF8CString(keyRef, "leftMeta"))
-        return WPE_KEY_Meta_L;
-    if (WKStringIsEqualToUTF8CString(keyRef, "rightMeta"))
-        return WPE_KEY_Meta_R;
-    if (WKStringIsEqualToUTF8CString(keyRef, "leftAlt"))
-        return WPE_KEY_Alt_L;
-    if (WKStringIsEqualToUTF8CString(keyRef, "rightAlt"))
-        return WPE_KEY_Alt_R;
-    if (WKStringIsEqualToUTF8CString(keyRef, "leftArrow"))
-        return WPE_KEY_Left;
-    if (WKStringIsEqualToUTF8CString(keyRef, "rightArrow"))
-        return WPE_KEY_Right;
-    if (WKStringIsEqualToUTF8CString(keyRef, "upArrow"))
-        return WPE_KEY_Up;
-    if (WKStringIsEqualToUTF8CString(keyRef, "downArrow"))
-        return WPE_KEY_Down;
-    if (WKStringIsEqualToUTF8CString(keyRef, "pageUp"))
-        return WPE_KEY_Page_Up;
-    if (WKStringIsEqualToUTF8CString(keyRef, "pageDown"))
-        return WPE_KEY_Page_Down;
-    if (WKStringIsEqualToUTF8CString(keyRef, "home"))
-        return WPE_KEY_Home;
-    if (WKStringIsEqualToUTF8CString(keyRef, "end"))
-        return WPE_KEY_End;
-    if (WKStringIsEqualToUTF8CString(keyRef, "insert"))
-        return WPE_KEY_Insert;
-    if (WKStringIsEqualToUTF8CString(keyRef, "delete"))
-        return WPE_KEY_Delete;
-    if (WKStringIsEqualToUTF8CString(keyRef, "printScreen"))
-        return WPE_KEY_Print;
-    if (WKStringIsEqualToUTF8CString(keyRef, "menu"))
-        return WPE_KEY_Menu;
-    if (WKStringIsEqualToUTF8CString(keyRef, "F1"))
-        return WPE_KEY_F1;
-    if (WKStringIsEqualToUTF8CString(keyRef, "F2"))
-        return WPE_KEY_F2;
-    if (WKStringIsEqualToUTF8CString(keyRef, "F3"))
-        return WPE_KEY_F3;
-    if (WKStringIsEqualToUTF8CString(keyRef, "F4"))
-        return WPE_KEY_F4;
-    if (WKStringIsEqualToUTF8CString(keyRef, "F5"))
-        return WPE_KEY_F5;
-    if (WKStringIsEqualToUTF8CString(keyRef, "F6"))
-        return WPE_KEY_F6;
-    if (WKStringIsEqualToUTF8CString(keyRef, "F7"))
-        return WPE_KEY_F7;
-    if (WKStringIsEqualToUTF8CString(keyRef, "F8"))
-        return WPE_KEY_F8;
-    if (WKStringIsEqualToUTF8CString(keyRef, "F9"))
-        return WPE_KEY_F9;
-    if (WKStringIsEqualToUTF8CString(keyRef, "F10"))
-        return WPE_KEY_F10;
-    if (WKStringIsEqualToUTF8CString(keyRef, "F11"))
-        return WPE_KEY_F11;
-    if (WKStringIsEqualToUTF8CString(keyRef, "F12"))
-        return WPE_KEY_F12;
-    if (WKStringIsEqualToUTF8CString(keyRef, "escape"))
-        return WPE_KEY_Escape;
-
-    size_t bufferSize = WKStringGetMaximumUTF8CStringSize(keyRef);
-    auto buffer = makeUniqueArray<char>(bufferSize);
-    WKStringGetUTF8CString(keyRef, buffer.get(), bufferSize);
-    char charCode = buffer.get()[0];
-
-    if (charCode == '\n' || charCode == '\r')
-        return WPE_KEY_Return;
-    if (charCode == '\t')
-        return WPE_KEY_Tab;
-    if (charCode == '\x8')
-        return WPE_KEY_BackSpace;
-    if (charCode == 0x001B)
-        return WPE_KEY_Escape;
-
-    if (WTF::isASCIIUpper(charCode))
-        *modifiers |= wpe_input_keyboard_modifier_shift;
-
-    return wpe_unicode_to_key_code(static_cast<uint32_t>(charCode));
-}
-
-void EventSenderProxy::keyDown(WKStringRef keyRef, WKEventModifiers wkModifiers, unsigned location)
-{
-    uint32_t modifiers = wkEventModifiersToWPE(wkModifiers);
-    uint32_t keySym = wpeKeySymForKeyRef(keyRef, location, &modifiers);
-    struct wpe_input_xkb_keymap_entry* entries;
-    uint32_t entriesCount;
-    wpe_input_xkb_context_get_entries_for_key_code(wpe_input_xkb_context_get_default(), keySym, &entries, &entriesCount);
-    struct wpe_input_keyboard_event event { secToMsTimestamp(m_time), keySym, entriesCount ? entries[0].hardware_key_code : 0, true, modifiers};
-    wpe_view_backend_dispatch_keyboard_event(viewBackend(*m_testController), &event);
-    event.pressed = false;
-    wpe_view_backend_dispatch_keyboard_event(viewBackend(*m_testController), &event);
-    free(entries);
-}
-
-void EventSenderProxy::rawKeyDown(WKStringRef key, WKEventModifiers modifiers, unsigned keyLocation)
-{
-}
-
-void EventSenderProxy::rawKeyUp(WKStringRef key, WKEventModifiers modifiers, unsigned keyLocation)
-{
-}
-
-void EventSenderProxy::addTouchPoint(int x, int y)
-{
-    struct wpe_input_touch_event_raw rawEvent { wpe_input_touch_event_type_down, secToMsTimestamp(m_time), static_cast<int>(m_touchEvents.size()), static_cast<int32_t>(x), static_cast<int32_t>(y) };
-    m_touchEvents.append(rawEvent);
-    m_updatedTouchEvents.add(rawEvent.id);
-}
-
-void EventSenderProxy::updateTouchPoint(int index, int x, int y)
-{
-    ASSERT(index >= 0 && static_cast<size_t>(index) <= m_touchEvents.size());
-
-    auto& rawEvent = m_touchEvents[index];
-    rawEvent.x = x;
-    rawEvent.y = y;
-    rawEvent.time = secToMsTimestamp(m_time);
-    rawEvent.type = wpe_input_touch_event_type_motion;
-    m_updatedTouchEvents.add(index);
-}
-
-void EventSenderProxy::setTouchModifier(WKEventModifiers, bool)
-{
-    notImplemented();
-}
-
-void EventSenderProxy::setTouchPointRadius(int, int)
-{
-    notImplemented();
-}
-
-Vector<struct wpe_input_touch_event_raw> EventSenderProxy::getUpdatedTouchEvents()
-{
-    Vector<wpe_input_touch_event_raw> events;
-    for (auto id : m_updatedTouchEvents)
-        events.append(m_touchEvents[id]);
-    return events;
-}
-
-void EventSenderProxy::removeUpdatedTouchEvents()
-{
-    for (auto id : m_updatedTouchEvents)
-        m_touchEvents[id].type = wpe_input_touch_event_type_null;
-    m_touchEvents.removeAllMatching([] (auto current) {
-        return current.type == wpe_input_touch_event_type_null;
-        });
-}
-
-void EventSenderProxy::prepareAndDispatchTouchEvent(enum wpe_input_touch_event_type eventType)
-{
-    auto updatedEvents = getUpdatedTouchEvents();
-    struct wpe_input_touch_event event = { updatedEvents.data(), updatedEvents.size(), eventType, 0, secToMsTimestamp(m_time), 0 };
-    wpe_view_backend_dispatch_touch_event(viewBackend(*m_testController), &event);
-    if (eventType == wpe_input_touch_event_type_up)
-        removeUpdatedTouchEvents();
-    m_updatedTouchEvents.clear();
-}
-
-void EventSenderProxy::touchStart()
-{
-    prepareAndDispatchTouchEvent(wpe_input_touch_event_type_down);
-}
-
-void EventSenderProxy::touchMove()
-{
-    prepareAndDispatchTouchEvent(wpe_input_touch_event_type_motion);
-}
-
-void EventSenderProxy::touchEnd()
-{
-    prepareAndDispatchTouchEvent(wpe_input_touch_event_type_up);
-}
-
-void EventSenderProxy::touchCancel()
-{
-    notImplemented();
-}
-
-void EventSenderProxy::clearTouchPoints()
-{
-    m_touchEvents.clear();
-    m_updatedTouchEvents.clear();
-}
-
-void EventSenderProxy::releaseTouchPoint(int index)
-{
-    ASSERT(index >= 0 && static_cast<size_t>(index) <= m_touchEvents.size());
-
-    auto& rawEvent = m_touchEvents[index];
-    rawEvent.time = secToMsTimestamp(m_time);
-    rawEvent.type = wpe_input_touch_event_type_up;
-    m_updatedTouchEvents.add(index);
-}
-
-void EventSenderProxy::cancelTouchPoint(int)
-{
-    notImplemented();
-}
-
-} // namespace WTR

Deleted: trunk/Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp (289886 => 289887)


--- trunk/Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp	2022-02-16 12:38:35 UTC (rev 289886)
+++ trunk/Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp	2022-02-16 13:53:08 UTC (rev 289887)
@@ -1,163 +0,0 @@
-/*
- * Copyright (C) 2014 Igalia S.L.
- *
- * 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.
- */
-
-#include "config.h"
-#include "PlatformWebView.h"
-
-#include <WPEToolingBackends/HeadlessViewBackend.h>
-#include <WebKit/WKImageCairo.h>
-#include <cairo.h>
-#include <cstdio>
-#include <glib.h>
-#include <wtf/RunLoop.h>
-#include <wtf/text/WTFString.h>
-
-namespace WTR {
-
-PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration, const TestOptions& options)
-    : m_windowIsKey(true)
-    , m_options(options)
-{
-    m_window = new WPEToolingBackends::HeadlessViewBackend(800, 600);
-    m_view = WKViewCreate(m_window->backend(), configuration);
-}
-
-PlatformWebView::~PlatformWebView()
-{
-    delete m_window;
-}
-
-void PlatformWebView::resizeTo(unsigned, unsigned, WebViewSizingMode)
-{
-}
-
-WKPageRef PlatformWebView::page()
-{
-    return WKViewGetPage(m_view);
-}
-
-void PlatformWebView::focus()
-{
-}
-
-WKRect PlatformWebView::windowFrame()
-{
-    return { { 0, 0 }, { 1, 1 } };
-}
-
-void PlatformWebView::setWindowFrame(WKRect, WebViewSizingMode)
-{
-}
-
-void PlatformWebView::didInitializeClients()
-{
-}
-
-void PlatformWebView::addChromeInputField()
-{
-}
-
-void PlatformWebView::removeChromeInputField()
-{
-}
-
-void PlatformWebView::setTextInChromeInputField(const String&)
-{
-}
-
-void PlatformWebView::selectChromeInputField()
-{
-}
-
-String PlatformWebView::getSelectedTextInChromeInputField()
-{
-    return { };
-}
-
-void PlatformWebView::addToWindow()
-{
-    m_window->addActivityState(wpe_view_activity_state_in_window);
-}
-
-void PlatformWebView::removeFromWindow()
-{
-    m_window->removeActivityState(wpe_view_activity_state_in_window);
-}
-
-void PlatformWebView::setWindowIsKey(bool windowIsKey)
-{
-    m_windowIsKey = windowIsKey;
-}
-
-void PlatformWebView::makeWebViewFirstResponder()
-{
-}
-
-cairo_surface_t* PlatformWebView::windowSnapshotImage()
-{
-    {
-        struct TimeoutTimer {
-            TimeoutTimer()
-                : timer(RunLoop::main(), this, &TimeoutTimer::fired)
-            {
-                timer.startOneShot(1_s / 60);
-            }
-
-            void fired() { RunLoop::main().stop(); }
-            RunLoop::Timer<TimeoutTimer> timer;
-        } timeoutTimer;
-
-        RunLoop::main().run();
-    }
-
-    return m_window->snapshot();
-}
-
-void PlatformWebView::changeWindowScaleIfNeeded(float)
-{
-}
-
-void PlatformWebView::setNavigationGesturesEnabled(bool)
-{
-}
-
-void PlatformWebView::forceWindowFramesChanged()
-{
-}
-
-bool PlatformWebView::drawsBackground() const
-{
-    return false;
-}
-
-void PlatformWebView::setDrawsBackground(bool)
-{
-}
-
-void PlatformWebView::setEditable(bool)
-{
-}
-
-} // namespace WTR
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to