| Differences between
and this patch
- a/Tools/ChangeLog +26 lines
Lines 1-3 a/Tools/ChangeLog_sec1
1
2022-02-15  Don Olmstead  <don.olmstead@sony.com>
2
3
        Share WebKitTestRunner code among USE(LIBWPE) ports
4
        https://bugs.webkit.org/show_bug.cgi?id=236651
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Modify PLATFORM(WPE) to USE(LIBWPE) in EventSenderProxy and PlatformWebView. The former
9
        just uses the libwpe API to send events so it can be shared. The later uses the
10
        WPEToolingBackend so it can also be shared.
11
12
        The WPE port was missing guards around ENABLE(TOUCH_EVENTS) so add those and organize the
13
        corresponding .cpp so the methods track with the ordering in the header.
14
15
        Also modernize the PlatformWebView code to prefer using over typedef.
16
17
        * WebKitTestRunner/EventSenderProxy.h:
18
        * WebKitTestRunner/PlatformWPE.cmake:
19
        * WebKitTestRunner/PlatformWebView.h:
20
        * WebKitTestRunner/libwpe/EventSenderProxyLibWPE.cpp: Renamed from Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp.
21
        (WTR::EventSenderProxy::getUpdatedTouchEvents):
22
        (WTR::EventSenderProxy::removeUpdatedTouchEvents):
23
        (WTR::EventSenderProxy::prepareAndDispatchTouchEvent):
24
        * WebKitTestRunner/libwpe/PlatformWebViewLibWPE.cpp: Renamed from Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp.
25
        (WTR::PlatformWebView::windowSnapshotImage):
26
1
2022-02-14  Jonathan Bedard  <jbedard@apple.com>
27
2022-02-14  Jonathan Bedard  <jbedard@apple.com>
2
28
3
        [EWS] Need /bin/sh equivalent on wincairo
29
        [EWS] Need /bin/sh equivalent on wincairo
- a/Tools/WebKitTestRunner/EventSenderProxy.h -3 / +5 lines
Lines 32-38 a/Tools/WebKitTestRunner/EventSenderProxy.h_sec1
32
#include <wtf/RetainPtr.h>
32
#include <wtf/RetainPtr.h>
33
#include <wtf/Vector.h>
33
#include <wtf/Vector.h>
34
34
35
#if PLATFORM(WPE)
35
#if USE(LIBWPE)
36
#include <wpe/wpe.h>
36
#include <wpe/wpe.h>
37
#endif
37
#endif
38
38
Lines 130-136 private: a/Tools/WebKitTestRunner/EventSenderProxy.h_sec2
130
    RetainPtr<NSEvent> pressureChangeEvent(int stage, float pressure, PressureChangeDirection);
130
    RetainPtr<NSEvent> pressureChangeEvent(int stage, float pressure, PressureChangeDirection);
131
#endif
131
#endif
132
132
133
#if PLATFORM(WPE)
133
#if ENABLE(TOUCH_EVENTS) && USE(LIBWPE)
134
    Vector<struct wpe_input_touch_event_raw> getUpdatedTouchEvents();
134
    Vector<struct wpe_input_touch_event_raw> getUpdatedTouchEvents();
135
    void removeUpdatedTouchEvents();
135
    void removeUpdatedTouchEvents();
136
    void prepareAndDispatchTouchEvent(enum wpe_input_touch_event_type);
136
    void prepareAndDispatchTouchEvent(enum wpe_input_touch_event_type);
Lines 155-165 private: a/Tools/WebKitTestRunner/EventSenderProxy.h_sec3
155
#if PLATFORM(GTK)
155
#if PLATFORM(GTK)
156
    bool m_hasPreciseDeltas { false };
156
    bool m_hasPreciseDeltas { false };
157
#endif
157
#endif
158
#if PLATFORM(WPE)
158
#if USE(LIBWPE)
159
    uint32_t m_buttonState { 0 };
159
    uint32_t m_buttonState { 0 };
160
#if ENABLE(TOUCH_EVENTS)
160
    Vector<struct wpe_input_touch_event_raw> m_touchEvents;
161
    Vector<struct wpe_input_touch_event_raw> m_touchEvents;
161
    HashSet<unsigned, DefaultHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> m_updatedTouchEvents;
162
    HashSet<unsigned, DefaultHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> m_updatedTouchEvents;
162
#endif
163
#endif
164
#endif
163
};
165
};
164
166
165
} // namespace WTR
167
} // namespace WTR
- a/Tools/WebKitTestRunner/PlatformWPE.cmake -2 / +3 lines
Lines 6-13 list(APPEND WebKitTestRunner_DEPENDENCIES WebKitTestRunner-forwarding-headers) a/Tools/WebKitTestRunner/PlatformWPE.cmake_sec1
6
list(APPEND WebKitTestRunner_SOURCES
6
list(APPEND WebKitTestRunner_SOURCES
7
    cairo/TestInvocationCairo.cpp
7
    cairo/TestInvocationCairo.cpp
8
8
9
    wpe/EventSenderProxyWPE.cpp
9
    libwpe/EventSenderProxyLibWPE.cpp
10
    wpe/PlatformWebViewWPE.cpp
10
    libwpe/PlatformWebViewLibWPE.cpp
11
11
    wpe/TestControllerWPE.cpp
12
    wpe/TestControllerWPE.cpp
12
    wpe/UIScriptControllerWPE.cpp
13
    wpe/UIScriptControllerWPE.cpp
13
    wpe/main.cpp
14
    wpe/main.cpp
- a/Tools/WebKitTestRunner/PlatformWebView.h -10 / +10 lines
Lines 40-67 OBJC_CLASS WKWebViewConfiguration; a/Tools/WebKitTestRunner/PlatformWebView.h_sec1
40
OBJC_CLASS WebKitTestRunnerWindow;
40
OBJC_CLASS WebKitTestRunnerWindow;
41
typedef struct CGImage *CGImageRef;
41
typedef struct CGImage *CGImageRef;
42
42
43
typedef TestRunnerWKWebView *PlatformWKView;
43
using PlatformWKView = *TestRunnerWKWebView;
44
typedef WebKitTestRunnerWindow *PlatformWindow;
44
using PlatformWindow = *WebKitTestRunnerWindow;
45
typedef RetainPtr<CGImageRef> PlatformImage;
45
using PlatformImage = RetainPtr<CGImageRef>;
46
#elif defined(BUILDING_GTK__)
46
#elif defined(BUILDING_GTK__)
47
typedef struct _GtkWidget GtkWidget;
47
typedef struct _GtkWidget GtkWidget;
48
typedef WKViewRef PlatformWKView;
48
typedef WKViewRef PlatformWKView;
49
typedef GtkWidget* PlatformWindow;
49
typedef GtkWidget* PlatformWindow;
50
#elif PLATFORM(WPE)
50
#elif USE(LIBWPE)
51
namespace WPEToolingBackends {
51
namespace WPEToolingBackends {
52
class HeadlessViewBackend;
52
class HeadlessViewBackend;
53
}
53
}
54
typedef WKViewRef PlatformWKView;
54
using PlatformWKView = WKViewRef;
55
typedef WPEToolingBackends::HeadlessViewBackend* PlatformWindow;
55
using PlatformWindow = WPEToolingBackends::HeadlessViewBackend*;
56
#elif PLATFORM(WIN)
56
#elif PLATFORM(WIN)
57
#include <cairo.h>
58
class TestRunnerWindow;
57
class TestRunnerWindow;
59
typedef HWND PlatformWindow;
58
using PlatformWKView = WKViewRef;
60
typedef WKViewRef PlatformWKView;
59
using PlatformWindow = HWND;
61
#endif
60
#endif
62
61
63
#if USE(CAIRO)
62
#if USE(CAIRO)
64
typedef cairo_surface_t* PlatformImage;
63
#include <cairo.h>
64
using PlatformImage = cairo_surface_t*;
65
#endif
65
#endif
66
66
67
namespace WTR {
67
namespace WTR {
- a/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp -30 / +34 lines
Lines 176-186 void EventSenderProxy::mouseScrollBy(int horizontal, int vertical) a/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp_sec1
176
        return;
176
        return;
177
177
178
    if (horizontal) {
178
    if (horizontal) {
179
        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};
179
        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 };
180
        wpe_view_backend_dispatch_axis_event(viewBackend(*m_testController), &event);
180
        wpe_view_backend_dispatch_axis_event(viewBackend(*m_testController), &event);
181
    }
181
    }
182
    if (vertical) {
182
    if (vertical) {
183
        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};
183
        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 };
184
        wpe_view_backend_dispatch_axis_event(viewBackend(*m_testController), &event);
184
        wpe_view_backend_dispatch_axis_event(viewBackend(*m_testController), &event);
185
    }
185
    }
186
}
186
}
Lines 320-326 void EventSenderProxy::keyDown(WKStringRef keyRef, WKEventModifiers wkModifiers, a/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp_sec2
320
    struct wpe_input_xkb_keymap_entry* entries;
320
    struct wpe_input_xkb_keymap_entry* entries;
321
    uint32_t entriesCount;
321
    uint32_t entriesCount;
322
    wpe_input_xkb_context_get_entries_for_key_code(wpe_input_xkb_context_get_default(), keySym, &entries, &entriesCount);
322
    wpe_input_xkb_context_get_entries_for_key_code(wpe_input_xkb_context_get_default(), keySym, &entries, &entriesCount);
323
    struct wpe_input_keyboard_event event { secToMsTimestamp(m_time), keySym, entriesCount ? entries[0].hardware_key_code : 0, true, modifiers};
323
    struct wpe_input_keyboard_event event { secToMsTimestamp(m_time), keySym, entriesCount ? entries[0].hardware_key_code : 0, true, modifiers };
324
    wpe_view_backend_dispatch_keyboard_event(viewBackend(*m_testController), &event);
324
    wpe_view_backend_dispatch_keyboard_event(viewBackend(*m_testController), &event);
325
    event.pressed = false;
325
    event.pressed = false;
326
    wpe_view_backend_dispatch_keyboard_event(viewBackend(*m_testController), &event);
326
    wpe_view_backend_dispatch_keyboard_event(viewBackend(*m_testController), &event);
Lines 335-340 void EventSenderProxy::rawKeyUp(WKStringRef key, WKEventModifiers modifiers, uns a/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp_sec3
335
{
335
{
336
}
336
}
337
337
338
#if ENABLE(TOUCH_EVENTS)
339
338
void EventSenderProxy::addTouchPoint(int x, int y)
340
void EventSenderProxy::addTouchPoint(int x, int y)
339
{
341
{
340
    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) };
342
    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) };
Lines 364-396 void EventSenderProxy::setTouchPointRadius(int, int) a/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp_sec4
364
    notImplemented();
366
    notImplemented();
365
}
367
}
366
368
367
Vector<struct wpe_input_touch_event_raw> EventSenderProxy::getUpdatedTouchEvents()
368
{
369
    Vector<wpe_input_touch_event_raw> events;
370
    for (auto id : m_updatedTouchEvents)
371
        events.append(m_touchEvents[id]);
372
    return events;
373
}
374
375
void EventSenderProxy::removeUpdatedTouchEvents()
376
{
377
    for (auto id : m_updatedTouchEvents)
378
        m_touchEvents[id].type = wpe_input_touch_event_type_null;
379
    m_touchEvents.removeAllMatching([] (auto current) {
380
        return current.type == wpe_input_touch_event_type_null;
381
        });
382
}
383
384
void EventSenderProxy::prepareAndDispatchTouchEvent(enum wpe_input_touch_event_type eventType)
385
{
386
    auto updatedEvents = getUpdatedTouchEvents();
387
    struct wpe_input_touch_event event = { updatedEvents.data(), updatedEvents.size(), eventType, 0, secToMsTimestamp(m_time), 0 };
388
    wpe_view_backend_dispatch_touch_event(viewBackend(*m_testController), &event);
389
    if (eventType == wpe_input_touch_event_type_up)
390
        removeUpdatedTouchEvents();
391
    m_updatedTouchEvents.clear();
392
}
393
394
void EventSenderProxy::touchStart()
369
void EventSenderProxy::touchStart()
395
{
370
{
396
    prepareAndDispatchTouchEvent(wpe_input_touch_event_type_down);
371
    prepareAndDispatchTouchEvent(wpe_input_touch_event_type_down);
Lines 432-435 void EventSenderProxy::cancelTouchPoint(int) a/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp_sec5
432
    notImplemented();
407
    notImplemented();
433
}
408
}
434
409
410
Vector<struct wpe_input_touch_event_raw> EventSenderProxy::getUpdatedTouchEvents()
411
{
412
    Vector<wpe_input_touch_event_raw> events;
413
    for (auto id : m_updatedTouchEvents)
414
        events.append(m_touchEvents[id]);
415
    return events;
416
}
417
418
void EventSenderProxy::removeUpdatedTouchEvents()
419
{
420
    for (auto id : m_updatedTouchEvents)
421
        m_touchEvents[id].type = wpe_input_touch_event_type_null;
422
    m_touchEvents.removeAllMatching([] (auto current) {
423
        return current.type == wpe_input_touch_event_type_null;
424
        });
425
}
426
427
void EventSenderProxy::prepareAndDispatchTouchEvent(enum wpe_input_touch_event_type eventType)
428
{
429
    auto updatedEvents = getUpdatedTouchEvents();
430
    struct wpe_input_touch_event event = { updatedEvents.data(), updatedEvents.size(), eventType, 0, secToMsTimestamp(m_time), 0 };
431
    wpe_view_backend_dispatch_touch_event(viewBackend(*m_testController), &event);
432
    if (eventType == wpe_input_touch_event_type_up)
433
        removeUpdatedTouchEvents();
434
    m_updatedTouchEvents.clear();
435
}
436
437
#endif // ENABLE(TOUCH_EVENTS)
438
435
} // namespace WTR
439
} // namespace WTR
- a/Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp -4 / +1 lines
Lines 27-36 a/Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp_sec1
27
#include "PlatformWebView.h"
27
#include "PlatformWebView.h"
28
28
29
#include <WPEToolingBackends/HeadlessViewBackend.h>
29
#include <WPEToolingBackends/HeadlessViewBackend.h>
30
#include <WebKit/WKImageCairo.h>
31
#include <cairo.h>
32
#include <cstdio>
30
#include <cstdio>
33
#include <glib.h>
34
#include <wtf/RunLoop.h>
31
#include <wtf/RunLoop.h>
35
#include <wtf/text/WTFString.h>
32
#include <wtf/text/WTFString.h>
36
33
Lines 115-121 void PlatformWebView::makeWebViewFirstResponder() a/Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp_sec2
115
{
112
{
116
}
113
}
117
114
118
cairo_surface_t* PlatformWebView::windowSnapshotImage()
115
PlatformImage PlatformWebView::windowSnapshotImage()
119
{
116
{
120
    {
117
    {
121
        struct TimeoutTimer {
118
        struct TimeoutTimer {

Return to Bug 236651