File: WebEventConversion.cpp

package info (click to toggle)
webkit2gtk 2.49.90-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 445,664 kB
  • sloc: cpp: 3,797,881; javascript: 197,914; ansic: 161,337; python: 49,141; asm: 21,979; ruby: 18,539; perl: 16,723; xml: 4,623; yacc: 2,360; sh: 2,246; java: 2,019; lex: 1,327; pascal: 366; makefile: 295
file content (542 lines) | stat: -rw-r--r-- 20,067 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
/*
 * Copyright (C) 2010-2022 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.
 */

#include "config.h"
#include "WebEventConversion.h"

#include "WebKeyboardEvent.h"
#include "WebMouseEvent.h"
#include "WebTouchEvent.h"
#include "WebWheelEvent.h"
#include <WebCore/PlatformMouseEvent.h>

#if ENABLE(MAC_GESTURE_EVENTS)
#include "WebGestureEvent.h"
#endif

namespace WebKit {

WebCore::MouseButton platform(WebMouseEventButton button)
{
    switch (button) {
    case WebMouseEventButton::None:
        return WebCore::MouseButton::None;
    case WebMouseEventButton::Left:
        return WebCore::MouseButton::Left;
    case WebMouseEventButton::Middle:
        return WebCore::MouseButton::Middle;
    case WebMouseEventButton::Right:
        return WebCore::MouseButton::Right;
    default:
        RELEASE_ASSERT_NOT_REACHED();
    }
}

WebMouseEventButton kit(WebCore::MouseButton button)
{
    switch (button) {
    case WebCore::MouseButton::None:
        return WebMouseEventButton::None;
    case WebCore::MouseButton::Left:
        return WebMouseEventButton::Left;
    case WebCore::MouseButton::Middle:
        return WebMouseEventButton::Middle;
    case WebCore::MouseButton::Right:
        return WebMouseEventButton::Right;
    default:
        RELEASE_ASSERT_NOT_REACHED();
    }
}

WebCore::PlatformEvent::Type platform(WebEventType type)
{
    switch (type) {
    // Mouse
    case WebEventType::MouseDown:
        return WebCore::PlatformEvent::Type::MousePressed;
    case WebEventType::MouseUp:
        return WebCore::PlatformEvent::Type::MouseReleased;
    case WebEventType::MouseMove:
        return WebCore::PlatformEvent::Type::MouseMoved;
    case WebEventType::MouseForceChanged:
        return WebCore::PlatformEvent::Type::MouseForceChanged;
    case WebEventType::MouseForceDown:
        return WebCore::PlatformEvent::Type::MouseForceDown;
    case WebEventType::MouseForceUp:
        return WebCore::PlatformEvent::Type::MouseForceUp;

    // Wheel
    case WebEventType::Wheel:
        return WebCore::PlatformEvent::Type::Wheel;

    // Keyboard
    case WebEventType::KeyDown:
        return WebCore::PlatformEvent::Type::KeyDown;
    case WebEventType::KeyUp:
        return WebCore::PlatformEvent::Type::KeyUp;
    case WebEventType::RawKeyDown:
        return WebCore::PlatformEvent::Type::RawKeyDown;
    case WebEventType::Char:
        return WebCore::PlatformEvent::Type::Char;

#if ENABLE(TOUCH_EVENTS)
    // Touch
    case WebEventType::TouchStart:
        return WebCore::PlatformEvent::Type::TouchStart;
    case WebEventType::TouchMove:
        return WebCore::PlatformEvent::Type::TouchMove;
    case WebEventType::TouchEnd:
        return WebCore::PlatformEvent::Type::TouchEnd;
    case WebEventType::TouchCancel:
        return WebCore::PlatformEvent::Type::TouchCancel;
#endif

#if ENABLE(MAC_GESTURE_EVENTS)
    // Gesture
    case WebEventType::GestureStart:
        return WebCore::PlatformEvent::Type::GestureStart;
    case WebEventType::GestureChange:
        return WebCore::PlatformEvent::Type::GestureChange;
    case WebEventType::GestureEnd:
        return WebCore::PlatformEvent::Type::GestureEnd;
#endif

    default:
        RELEASE_ASSERT_NOT_REACHED();
    }
}

WebEventType kit(WebCore::PlatformEvent::Type type)
{
    switch (type) {
    // Mouse
    case WebCore::PlatformEvent::Type::MousePressed:
        return WebEventType::MouseDown;
    case WebCore::PlatformEvent::Type::MouseReleased:
        return WebEventType::MouseUp;
    case WebCore::PlatformEvent::Type::MouseMoved:
        return WebEventType::MouseMove;
    case WebCore::PlatformEvent::Type::MouseForceChanged:
        return WebEventType::MouseForceChanged;
    case WebCore::PlatformEvent::Type::MouseForceDown:
        return WebEventType::MouseForceDown;
    case WebCore::PlatformEvent::Type::MouseForceUp:
        return WebEventType::MouseForceUp;

    // Wheel
    case WebCore::PlatformEvent::Type::Wheel:
        return WebEventType::Wheel;

    // Keyboard
    case WebCore::PlatformEvent::Type::KeyDown:
        return WebEventType::KeyDown;
    case WebCore::PlatformEvent::Type::KeyUp:
        return WebEventType::KeyUp;
    case WebCore::PlatformEvent::Type::RawKeyDown:
        return WebEventType::RawKeyDown;
    case WebCore::PlatformEvent::Type::Char:
        return WebEventType::Char;

#if ENABLE(TOUCH_EVENTS)
    // Touch
    case WebCore::PlatformEvent::Type::TouchStart:
        return WebEventType::TouchStart;
    case WebCore::PlatformEvent::Type::TouchMove:
        return WebEventType::TouchMove;
    case WebCore::PlatformEvent::Type::TouchEnd:
        return WebEventType::TouchEnd;
    case WebCore::PlatformEvent::Type::TouchCancel:
        return WebEventType::TouchCancel;
#endif

#if ENABLE(MAC_GESTURE_EVENTS)
    // Gesture
    case WebCore::PlatformEvent::Type::GestureStart:
        return WebEventType::GestureStart;
    case WebCore::PlatformEvent::Type::GestureChange:
        return WebEventType::GestureChange;
    case WebCore::PlatformEvent::Type::GestureEnd:
        return WebEventType::GestureEnd;
#endif

    default:
        RELEASE_ASSERT_NOT_REACHED();
    }
}

OptionSet<WebCore::PlatformEvent::Modifier> platform(OptionSet<WebEventModifier> modifiers)
{
    OptionSet<WebCore::PlatformEvent::Modifier> result;
    if (modifiers.contains(WebEventModifier::ShiftKey))
        result.add(WebCore::PlatformEvent::Modifier::ShiftKey);
    if (modifiers.contains(WebEventModifier::ControlKey))
        result.add(WebCore::PlatformEvent::Modifier::ControlKey);
    if (modifiers.contains(WebEventModifier::AltKey))
        result.add(WebCore::PlatformEvent::Modifier::AltKey);
    if (modifiers.contains(WebEventModifier::MetaKey))
        result.add(WebCore::PlatformEvent::Modifier::MetaKey);
    if (modifiers.contains(WebEventModifier::CapsLockKey))
        result.add(WebCore::PlatformEvent::Modifier::CapsLockKey);
    return result;
}

OptionSet<WebEventModifier> kit(OptionSet<WebCore::PlatformEvent::Modifier> modifiers)
{
    OptionSet<WebEventModifier> result;
    if (modifiers.contains(WebCore::PlatformEvent::Modifier::ShiftKey))
        result.add(WebEventModifier::ShiftKey);
    if (modifiers.contains(WebCore::PlatformEvent::Modifier::ControlKey))
        result.add(WebEventModifier::ControlKey);
    if (modifiers.contains(WebCore::PlatformEvent::Modifier::AltKey))
        result.add(WebEventModifier::AltKey);
    if (modifiers.contains(WebCore::PlatformEvent::Modifier::MetaKey))
        result.add(WebEventModifier::MetaKey);
    if (modifiers.contains(WebCore::PlatformEvent::Modifier::CapsLockKey))
        result.add(WebEventModifier::CapsLockKey);
    return result;
}

static double forceForEvent(const WebMouseEvent& webEvent)
{
    switch (webEvent.type()) {
    case WebEventType::MouseDown:
        return WebCore::ForceAtClick;
    case WebEventType::MouseForceDown:
        return WebCore::ForceAtForceClick;
    case WebEventType::MouseMove:
    case WebEventType::MouseForceChanged:
        return webEvent.force();
    case WebEventType::MouseUp:
    case WebEventType::MouseForceUp:
        return 0;
    default:
        ASSERT_NOT_REACHED();
        return 0;
    }
}

class WebKit2PlatformMouseEvent : public WebCore::PlatformMouseEvent {
public:
    WebKit2PlatformMouseEvent(const WebMouseEvent& webEvent)
    {
        // PlatformEvent
        m_type = platform(webEvent.type());
        m_modifiers = platform(webEvent.modifiers());
        m_timestamp = webEvent.timestamp();
        m_authorizationToken = webEvent.authorizationToken();

        // PlatformMouseEvent
        m_button = platform(webEvent.button());
        m_buttons = webEvent.buttons();

        m_position = webEvent.position();
        m_movementDelta = WebCore::IntPoint(webEvent.deltaX(), webEvent.deltaY());
        m_unadjustedMovementDelta = webEvent.unadjustedMovementDelta();
        m_globalPosition = webEvent.globalPosition();
        m_clickCount = webEvent.clickCount();
        m_force = forceForEvent(webEvent);
        m_coalescedEvents = WTF::map(webEvent.coalescedEvents(), [&](const auto& event) {
            return platform(event);
        });
        m_predictedEvents = WTF::map(webEvent.predictedEvents(), [&](const auto& event) {
            return platform(event);
        });

#if PLATFORM(MAC)
        m_eventNumber = webEvent.eventNumber();
        m_menuTypeForEvent = webEvent.menuTypeForEvent();
#elif PLATFORM(GTK)
        m_isTouchEvent = webEvent.isTouchEvent();
#elif PLATFORM(WPE)
        m_syntheticClickType = static_cast<WebCore::SyntheticClickType>(webEvent.syntheticClickType());
#endif
        m_modifierFlags = 0;
        if (webEvent.shiftKey())
            m_modifierFlags |= static_cast<unsigned>(WebEventModifier::ShiftKey);
        if (webEvent.controlKey())
            m_modifierFlags |= static_cast<unsigned>(WebEventModifier::ControlKey);
        if (webEvent.altKey())
            m_modifierFlags |= static_cast<unsigned>(WebEventModifier::AltKey);
        if (webEvent.metaKey())
            m_modifierFlags |= static_cast<unsigned>(WebEventModifier::MetaKey);

        m_pointerId = webEvent.pointerId();
        m_pointerType = webEvent.pointerType();
    }
};

WebCore::PlatformMouseEvent platform(const WebMouseEvent& webEvent)
{
    return WebKit2PlatformMouseEvent(webEvent);
}

class WebKit2PlatformWheelEvent : public WebCore::PlatformWheelEvent {
public:
    WebKit2PlatformWheelEvent(const WebWheelEvent& webEvent)
    {
        // PlatformEvent
        m_type = platform(webEvent.type());
        m_modifiers = platform(webEvent.modifiers());
        m_timestamp = webEvent.timestamp();

        // PlatformWheelEvent
        m_position = webEvent.position();
        m_globalPosition = webEvent.globalPosition();
        m_deltaX = webEvent.delta().width();
        m_deltaY = webEvent.delta().height();
        m_wheelTicksX = webEvent.wheelTicks().width();
        m_wheelTicksY = webEvent.wheelTicks().height();
        m_granularity = (webEvent.granularity() == WebWheelEvent::ScrollByPageWheelEvent) ? WebCore::ScrollByPageWheelEvent : WebCore::ScrollByPixelWheelEvent;
        m_directionInvertedFromDevice = webEvent.directionInvertedFromDevice();
#if ENABLE(KINETIC_SCROLLING)
        m_phase = static_cast<WebCore::PlatformWheelEventPhase>(webEvent.phase());
        m_momentumPhase = static_cast<WebCore::PlatformWheelEventPhase>(webEvent.momentumPhase());
#endif
#if PLATFORM(COCOA) || PLATFORM(GTK) || USE(LIBWPE)
        m_hasPreciseScrollingDeltas = webEvent.hasPreciseScrollingDeltas();
#endif
#if PLATFORM(COCOA)
        m_ioHIDEventTimestamp = webEvent.ioHIDEventTimestamp();
        m_rawPlatformDelta = webEvent.rawPlatformDelta();
        m_scrollCount = webEvent.scrollCount();
        m_unacceleratedScrollingDeltaX = webEvent.unacceleratedScrollingDelta().width();
        m_unacceleratedScrollingDeltaY = webEvent.unacceleratedScrollingDelta().height();
#endif
    }
};

WebCore::PlatformWheelEvent platform(const WebWheelEvent& webEvent)
{
    return WebKit2PlatformWheelEvent(webEvent);
}

class WebKit2PlatformKeyboardEvent : public WebCore::PlatformKeyboardEvent {
public:
    WebKit2PlatformKeyboardEvent(const WebKeyboardEvent& webEvent)
    {
        // PlatformEvent
        m_type = platform(webEvent.type());
        m_modifiers = platform(webEvent.modifiers());
        m_timestamp = webEvent.timestamp();

        // PlatformKeyboardEvent
        m_text = webEvent.text();
        m_unmodifiedText = webEvent.unmodifiedText();
        m_key = webEvent.key();
        m_code = webEvent.code();
        m_keyIdentifier = webEvent.keyIdentifier();
        m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode();
#if USE(APPKIT) || PLATFORM(IOS_FAMILY) || PLATFORM(GTK) || USE(LIBWPE)
        m_handledByInputMethod = webEvent.handledByInputMethod();
#endif
#if PLATFORM(GTK) || USE(LIBWPE)
        m_preeditUnderlines = webEvent.preeditUnderlines();
        if (auto preeditSelectionRange = webEvent.preeditSelectionRange()) {
            m_preeditSelectionRangeStart = preeditSelectionRange->location;
            m_preeditSelectionRangeLength = preeditSelectionRange->length;
        }
#endif
#if USE(APPKIT) || PLATFORM(GTK)
        m_commands = webEvent.commands();
#endif
        m_autoRepeat = webEvent.isAutoRepeat();
        m_isKeypad = webEvent.isKeypad();
        m_isSystemKey = webEvent.isSystemKey();
        m_authorizationToken = webEvent.authorizationToken();
    }
};

WebCore::PlatformKeyboardEvent platform(const WebKeyboardEvent& webEvent)
{
    return WebKit2PlatformKeyboardEvent(webEvent);
}

#if ENABLE(TOUCH_EVENTS)

#if PLATFORM(IOS_FAMILY)

static WebCore::PlatformTouchPoint::TouchPhaseType touchEventType(const WebPlatformTouchPoint& webTouchPoint)
{
    switch (webTouchPoint.phase()) {
    case WebPlatformTouchPoint::State::Released:
        return WebCore::PlatformTouchPoint::TouchPhaseEnded;
    case WebPlatformTouchPoint::State::Pressed:
        return WebCore::PlatformTouchPoint::TouchPhaseBegan;
    case WebPlatformTouchPoint::State::Moved:
        return WebCore::PlatformTouchPoint::TouchPhaseMoved;
    case WebPlatformTouchPoint::State::Stationary:
        return WebCore::PlatformTouchPoint::TouchPhaseStationary;
    case WebPlatformTouchPoint::State::Cancelled:
        return WebCore::PlatformTouchPoint::TouchPhaseCancelled;
    }
}

static WebCore::PlatformTouchPoint::TouchType webPlatformTouchTypeToPlatform(const WebPlatformTouchPoint::TouchType& webTouchType)
{
    switch (webTouchType) {
    case WebPlatformTouchPoint::TouchType::Direct:
        return WebCore::PlatformTouchPoint::TouchType::Direct;
    case WebPlatformTouchPoint::TouchType::Stylus:
        return WebCore::PlatformTouchPoint::TouchType::Stylus;
    }
}

class WebKit2PlatformTouchPoint : public WebCore::PlatformTouchPoint {
public:
WebKit2PlatformTouchPoint(const WebPlatformTouchPoint& webTouchPoint)
    : PlatformTouchPoint(webTouchPoint.identifier(), webTouchPoint.locationInRootView(), webTouchPoint.locationInViewport(), touchEventType(webTouchPoint)
#if ENABLE(IOS_TOUCH_EVENTS)
        , webTouchPoint.radiusX(), webTouchPoint.radiusY(), webTouchPoint.rotationAngle(), webTouchPoint.force(), webTouchPoint.altitudeAngle(), webTouchPoint.azimuthAngle(), webPlatformTouchTypeToPlatform(webTouchPoint.touchType())
#endif
    )
{
}
};

#else

class WebKit2PlatformTouchPoint : public WebCore::PlatformTouchPoint {
public:
    WebKit2PlatformTouchPoint(const WebPlatformTouchPoint& webTouchPoint)
    {
        m_id = webTouchPoint.id();

        switch (webTouchPoint.state()) {
        case WebPlatformTouchPoint::State::Released:
            m_state = PlatformTouchPoint::TouchReleased;
            break;
        case WebPlatformTouchPoint::State::Pressed:
            m_state = PlatformTouchPoint::TouchPressed;
            break;
        case WebPlatformTouchPoint::State::Moved:
            m_state = PlatformTouchPoint::TouchMoved;
            break;
        case WebPlatformTouchPoint::State::Stationary:
            m_state = PlatformTouchPoint::TouchStationary;
            break;
        case WebPlatformTouchPoint::State::Cancelled:
            m_state = PlatformTouchPoint::TouchCancelled;
            break;
        default:
            ASSERT_NOT_REACHED();
        }

        m_screenPos = webTouchPoint.screenPosition();
        m_pos = webTouchPoint.position();
        m_radiusX = webTouchPoint.radius().width();
        m_radiusY = webTouchPoint.radius().height();
        m_force = webTouchPoint.force();
        m_rotationAngle = webTouchPoint.rotationAngle();
    }
};
#endif // PLATFORM(IOS_FAMILY)

class WebKit2PlatformTouchEvent : public WebCore::PlatformTouchEvent {
public:
    WebKit2PlatformTouchEvent(const WebTouchEvent& webEvent)
    {
        // PlatformEvent
        m_type = platform(webEvent.type());
        m_modifiers = platform(webEvent.modifiers());
        m_timestamp = webEvent.timestamp();

#if PLATFORM(IOS_FAMILY)
        m_touchPoints = WTF::map(webEvent.touchPoints(), [&](auto& touchPoint) -> WebCore::PlatformTouchPoint {
            return WebKit2PlatformTouchPoint(touchPoint);
        });

        m_coalescedEvents = WTF::map(webEvent.coalescedEvents(), [&](auto& event) {
            return platform(event);
        });

        m_predictedEvents = WTF::map(webEvent.predictedEvents(), [&](auto& event) {
            return platform(event);
        });

        m_gestureScale = webEvent.gestureScale();
        m_gestureRotation = webEvent.gestureRotation();
        m_canPreventNativeGestures = webEvent.canPreventNativeGestures();
        m_isGesture = webEvent.isGesture();
        m_isPotentialTap = webEvent.isPotentialTap();
        m_position = webEvent.position();
        m_globalPosition = webEvent.position();
        m_authorizationToken = webEvent.authorizationToken();
#else
        // PlatformTouchEvent
        for (size_t i = 0; i < webEvent.touchPoints().size(); ++i)
            m_touchPoints.append(WebKit2PlatformTouchPoint(webEvent.touchPoints().at(i)));
#endif //PLATFORM(IOS_FAMILY)
    }
};

WebCore::PlatformTouchEvent platform(const WebTouchEvent& webEvent)
{
    return WebKit2PlatformTouchEvent(webEvent);
}
#endif

#if ENABLE(MAC_GESTURE_EVENTS)
class WebKit2PlatformGestureEvent : public WebCore::PlatformGestureEvent {
public:
    WebKit2PlatformGestureEvent(const WebGestureEvent& webEvent)
    {
        m_type = platform(webEvent.type());
        m_modifiers = platform(webEvent.modifiers());
        m_timestamp = webEvent.timestamp();

        m_gestureScale = webEvent.gestureScale();
        m_gestureRotation = webEvent.gestureRotation();
        m_position = webEvent.position();
        m_globalPosition = webEvent.position();
    }
};

WebCore::PlatformGestureEvent platform(const WebGestureEvent& webEvent)
{
    return WebKit2PlatformGestureEvent(webEvent);
}
#endif

#if PLATFORM(GTK) || PLATFORM(WPE) || USE(LIBWPE)
WallTime wallTimeForEventTimeInMilliseconds(uint64_t timestamp)
{
    if (!timestamp)
        return WallTime::now();

    // GTK and WPE events provide a timestamp as uint32_t, which is too small for full millisecond timestamps since
    // the epoch. They are expected to be just timestamps with monotonic behavior to be compared among themselves,
    // not against WallTime-like measurements. Thus the need to define a reference origin based on the first event
    // received.
    static WallTime firstEventWallTime;
    static uint64_t firstEventTimestamp = 0;
    if (!firstEventTimestamp) {
        firstEventTimestamp = timestamp;
        firstEventWallTime = WallTime::now();
    }
    return firstEventWallTime + Seconds::fromMilliseconds(timestamp - firstEventTimestamp);
}
#endif

} // namespace WebKit