Skip to content

Commit

Permalink
[Pointer Events] Implement getCoalescedEvents API (iOS)
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=277185
rdar://132210576

Reviewed by Abrar Rahman Protyasha.

Implements the necessary logic so that iOS also supports the `getCoalescedEvents` function.
This uses UIKit's `coalescedTouchesForTouch` method to facilitate getting the events that
are coalesced at the system level.

* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/dom/PointerEvent.cpp:
(WebCore::PointerEvent::getCoalescedEvents const):
* Source/WebCore/dom/PointerEvent.h:
* Source/WebCore/dom/ios/PointerEventIOS.cpp:
(WebCore::PointerEvent::create):
(WebCore::PointerEvent::PointerEvent):
(WebCore::m_coalescedEvents):
(WebCore::m_isPrimary): Deleted.
* Source/WebCore/page/PointerCaptureController.cpp:
(WebCore::PointerCaptureController::dispatchEventForTouchAtIndex):
* Source/WebCore/platform/ios/WebEvent.h:
* Source/WebKit/Shared/NativeWebTouchEvent.h:
* Source/WebKit/Shared/WebEvent.serialization.in:
* Source/WebKit/Shared/WebEventConversion.cpp:
(WebKit::WebKit2PlatformTouchEvent::WebKit2PlatformTouchEvent):
* Source/WebKit/Shared/WebTouchEvent.h:
(WebKit::WebTouchEvent::WebTouchEvent):
(WebKit::WebTouchEvent::coalescedEvents const):
(WebKit::WebTouchEvent::setCoalescedEvents):
* Source/WebKit/Shared/ios/NativeWebTouchEventIOS.mm:
(WebKit::NativeWebTouchEvent::extractWebTouchPoints):
(WebKit::NativeWebTouchEvent::extractCoalescedWebTouchEvents):
(WebKit::NativeWebTouchEvent::extractWebTouchPoint): Deleted.
* Source/WebKit/UIProcess/ios/WKTouchEventsGestureRecognizer.h:
* Source/WebKit/UIProcess/ios/WKTouchEventsGestureRecognizer.mm:
(-[WKTouchEventsGestureRecognizer reset]):
(-[WKTouchEventsGestureRecognizer _coalescedTouchEventForTouch:]):
(-[WKTouchEventsGestureRecognizer _recordTouches:type:coalescedTouches:]):
(-[WKTouchEventsGestureRecognizer _processTouches:withEvent:type:]):
(-[WKTouchEventsGestureRecognizer _recordTouches:type:]): Deleted.
* Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::takeQueuedTouchEventsForPage):
(WebKit::EventDispatcher::touchEvent):
(WebKit::EventDispatcher::dispatchTouchEvents):
* Source/WebKit/WebProcess/WebPage/EventDispatcher.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didCommitLoad):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::dispatchAsynchronousTouchEvents):
(WebKit::WebPage::cancelAsynchronousTouchEvents):
* Tools/TestWebKitAPI/Tests/ios/TouchEventTests.mm:

Canonical link: https://commits.webkit.org/281520@main
  • Loading branch information
rr-codes committed Jul 29, 2024
1 parent 1e8ea6e commit 40e9a76
Show file tree
Hide file tree
Showing 25 changed files with 178 additions and 61 deletions.
8 changes: 4 additions & 4 deletions Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2869,17 +2869,17 @@ GenericCueAPIEnabled:

GetCoalescedEventsEnabled:
type: bool
status: testable
status: stable
category: dom
humanReadableName: "Pointer Events getCoalescedEvents API"
humanReadableDescription: "Enable the `getCoalescedEvents` function of the Pointer Events API"
defaultValue:
WebKitLegacy:
default: false
default: true
WebKit:
default: false
default: true
WebCore:
default: false
default: true

GetUserMediaRequiresFocus:
type: bool
Expand Down
16 changes: 15 additions & 1 deletion Source/WebCore/dom/PointerEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,25 @@ PointerEvent::~PointerEvent() = default;
Vector<Ref<PointerEvent>> PointerEvent::getCoalescedEvents() const
{
#if ASSERT_ENABLED
if (isTrusted()) {
auto& names = eventNames();
if (type() == names.pointermoveEvent)
ASSERT(m_coalescedEvents.size() >= 1, "Trusted pointermove events must have more than zero coalesced events.");
else
ASSERT(m_coalescedEvents.size() == 0, "Trusted non-pointermove events must have zero coalesced events.");
}

auto timestampsAreMonotonicallyIncreasing = std::ranges::is_sorted(m_coalescedEvents, [](const auto& previousEvent, const auto& newEvent) {
return previousEvent->timeStamp() <= newEvent->timeStamp();
});

ASSERT(timestampsAreMonotonicallyIncreasing);
ASSERT(timestampsAreMonotonicallyIncreasing, "Coalesced event timestamps are not monotonically increasing.");

auto canBubbleOrIsCancelable = std::ranges::any_of(m_coalescedEvents, [](const auto& event) {
return event->bubbles() || event->cancelable();
});

ASSERT(!canBubbleOrIsCancelable, "Coalesced events must not bubble and must not be cancelable.");
#endif

return m_coalescedEvents;
Expand Down
7 changes: 4 additions & 3 deletions Source/WebCore/dom/PointerEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ class PointerEvent final : public MouseEvent {
static Ref<PointerEvent> create(const AtomString& type, PointerID, const String& pointerType, IsPrimary = IsPrimary::No);

#if ENABLE(TOUCH_EVENTS) && (PLATFORM(IOS_FAMILY) || PLATFORM(WPE))
static Ref<PointerEvent> create(const PlatformTouchEvent&, unsigned touchIndex, bool isPrimary, Ref<WindowProxy>&&, const IntPoint& touchDelta = { });
static Ref<PointerEvent> create(const AtomString& type, const PlatformTouchEvent&, unsigned touchIndex, bool isPrimary, Ref<WindowProxy>&&, const IntPoint& touchDelta = { });
static Ref<PointerEvent> create(const PlatformTouchEvent&, const Vector<Ref<PointerEvent>>& coalescedEvents, unsigned touchIndex, bool isPrimary, Ref<WindowProxy>&&, const IntPoint& touchDelta = { });
static Ref<PointerEvent> create(const PlatformTouchEvent&, const Vector<Ref<PointerEvent>>& coalescedEvents, CanBubble, IsCancelable, unsigned touchIndex, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta = { });
static Ref<PointerEvent> create(const AtomString& type, const PlatformTouchEvent&, const Vector<Ref<PointerEvent>>& coalescedEvents, unsigned touchIndex, bool isPrimary, Ref<WindowProxy>&&, const IntPoint& touchDelta = { });
#endif

virtual ~PointerEvent();
Expand Down Expand Up @@ -147,7 +148,7 @@ class PointerEvent final : public MouseEvent {
PointerEvent(const AtomString& type, MouseButton, const MouseEvent&, PointerID, const String& pointerType, CanBubble, IsCancelable);
PointerEvent(const AtomString& type, PointerID, const String& pointerType, IsPrimary);
#if ENABLE(TOUCH_EVENTS) && (PLATFORM(IOS_FAMILY) || PLATFORM(WPE))
PointerEvent(const AtomString& type, const PlatformTouchEvent&, IsCancelable isCancelable, unsigned touchIndex, bool isPrimary, Ref<WindowProxy>&&, const IntPoint& touchDelta = { });
PointerEvent(const AtomString& type, const PlatformTouchEvent&, const Vector<Ref<PointerEvent>>& coalescedEvents, CanBubble canBubble, IsCancelable isCancelable, unsigned touchIndex, bool isPrimary, Ref<WindowProxy>&&, const IntPoint& touchDelta = { });
#endif

PointerID m_pointerId { mousePointerID };
Expand Down
21 changes: 15 additions & 6 deletions Source/WebCore/dom/ios/PointerEventIOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,35 @@ static const AtomString& pointerEventType(PlatformTouchPoint::TouchPhaseType pha
return nullAtom();
}

Ref<PointerEvent> PointerEvent::create(const PlatformTouchEvent& event, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
Ref<PointerEvent> PointerEvent::create(const PlatformTouchEvent& event, const Vector<Ref<PointerEvent>>& coalescedEvents, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
{
const auto& type = pointerEventType(event.touchPhaseAtIndex(index));
return adoptRef(*new PointerEvent(type, event, typeIsCancelable(type), index, isPrimary, WTFMove(view), touchDelta));

return adoptRef(*new PointerEvent(type, event, coalescedEvents, typeCanBubble(type), typeIsCancelable(type), index, isPrimary, WTFMove(view), touchDelta));
}

Ref<PointerEvent> PointerEvent::create(const PlatformTouchEvent& event, const Vector<Ref<PointerEvent>>& coalescedEvents, CanBubble canBubble, IsCancelable isCancelable, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
{
const auto& type = pointerEventType(event.touchPhaseAtIndex(index));

return adoptRef(*new PointerEvent(type, event, coalescedEvents, canBubble, isCancelable, index, isPrimary, WTFMove(view), touchDelta));
}

Ref<PointerEvent> PointerEvent::create(const AtomString& type, const PlatformTouchEvent& event, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
Ref<PointerEvent> PointerEvent::create(const AtomString& type, const PlatformTouchEvent& event, const Vector<Ref<PointerEvent>>& coalescedEvents, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
{
return adoptRef(*new PointerEvent(type, event, typeIsCancelable(type), index, isPrimary, WTFMove(view), touchDelta));
return adoptRef(*new PointerEvent(type, event, coalescedEvents, typeCanBubble(type), typeIsCancelable(type), index, isPrimary, WTFMove(view), touchDelta));
}

PointerEvent::PointerEvent(const AtomString& type, const PlatformTouchEvent& event, IsCancelable isCancelable, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
: MouseEvent(EventInterfaceType::PointerEvent, type, typeCanBubble(type), isCancelable, typeIsComposed(type), event.timestamp().approximateMonotonicTime(), WTFMove(view), 0,
PointerEvent::PointerEvent(const AtomString& type, const PlatformTouchEvent& event, const Vector<Ref<PointerEvent>>& coalescedEvents, CanBubble canBubble, IsCancelable isCancelable, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
: MouseEvent(EventInterfaceType::PointerEvent, type, canBubble, isCancelable, typeIsComposed(type), event.timestamp().approximateMonotonicTime(), WTFMove(view), 0,
event.touchLocationAtIndex(index), event.touchLocationAtIndex(index), touchDelta.x(), touchDelta.y(), event.modifiers(), buttonForType(type), buttonsForType(type), nullptr, 0, SyntheticClickType::NoTap, { }, IsSimulated::No, IsTrusted::Yes)
, m_pointerId(event.touchIdentifierAtIndex(index))
, m_width(2 * event.radiusXAtIndex(index))
, m_height(2 * event.radiusYAtIndex(index))
, m_pressure(event.forceAtIndex(index))
, m_pointerType(event.touchTypeAtIndex(index) == PlatformTouchPoint::TouchType::Stylus ? penPointerEventType() : touchPointerEventType())
, m_isPrimary(isPrimary)
, m_coalescedEvents(coalescedEvents)
{
// See https://github.com/w3c/pointerevents/issues/274. We might expose the azimuth and altitude
// directly as well as the tilt.
Expand Down
19 changes: 13 additions & 6 deletions Source/WebCore/dom/wpe/PointerEventWPE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,32 @@ static const AtomString& pointerEventType(PlatformTouchPoint::State state)
return nullAtom();
}

Ref<PointerEvent> PointerEvent::create(const PlatformTouchEvent& event, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
Ref<PointerEvent> PointerEvent::create(const PlatformTouchEvent& event, const Vector<Ref<PointerEvent>>& coalescedEvents, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
{
const auto& type = pointerEventType(event.touchPoints().at(index).state());
return adoptRef(*new PointerEvent(type, event, typeIsCancelable(type), index, isPrimary, WTFMove(view), touchDelta));
return adoptRef(*new PointerEvent(type, event, coalescedEvents, typeCanBubble(type), typeIsCancelable(type), index, isPrimary, WTFMove(view), touchDelta));
}

Ref<PointerEvent> PointerEvent::create(const AtomString& type, const PlatformTouchEvent& event, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
Ref<PointerEvent> PointerEvent::create(const PlatformTouchEvent& event, const Vector<Ref<PointerEvent>>& coalescedEvents, CanBubble canBubble, IsCancelable isCancelable, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
{
return adoptRef(*new PointerEvent(type, event, typeIsCancelable(type), index, isPrimary, WTFMove(view), touchDelta));
const auto& type = pointerEventType(event.touchPoints().at(index).state());
return adoptRef(*new PointerEvent(type, event, coalescedEvents, canBubble, isCancelable, index, isPrimary, WTFMove(view), touchDelta));
}

Ref<PointerEvent> PointerEvent::create(const AtomString& type, const PlatformTouchEvent& event, const Vector<Ref<PointerEvent>>& coalescedEvents, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
{
return adoptRef(*new PointerEvent(type, event, coalescedEvents, typeCanBubble(type), typeIsCancelable(type), index, isPrimary, WTFMove(view), touchDelta));
}

PointerEvent::PointerEvent(const AtomString& type, const PlatformTouchEvent& event, IsCancelable isCancelable, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
: MouseEvent(EventInterfaceType::PointerEvent, type, typeCanBubble(type), isCancelable, typeIsComposed(type), event.timestamp().approximateMonotonicTime(), WTFMove(view), 0, event.touchPoints().at(index).pos(), event.touchPoints().at(index).pos(), touchDelta.x(), touchDelta.y(), event.modifiers(), buttonForType(type), buttonsForType(type), nullptr, 0, SyntheticClickType::NoTap, { }, IsSimulated::No, IsTrusted::Yes)
PointerEvent::PointerEvent(const AtomString& type, const PlatformTouchEvent& event, const Vector<Ref<PointerEvent>>& coalescedEvents, CanBubble canBubble, IsCancelable isCancelable, unsigned index, bool isPrimary, Ref<WindowProxy>&& view, const IntPoint& touchDelta)
: MouseEvent(EventInterfaceType::PointerEvent, type, canBubble, isCancelable, typeIsComposed(type), event.timestamp().approximateMonotonicTime(), WTFMove(view), 0, event.touchPoints().at(index).pos(), event.touchPoints().at(index).pos(), touchDelta.x(), touchDelta.y(), event.modifiers(), buttonForType(type), buttonsForType(type), nullptr, 0, SyntheticClickType::NoTap, { }, IsSimulated::No, IsTrusted::Yes)
, m_pointerId(event.touchPoints().at(index).id())
, m_width(2 * event.touchPoints().at(index).radiusX())
, m_height(2 * event.touchPoints().at(index).radiusY())
, m_pressure(event.touchPoints().at(index).force())
, m_pointerType(touchPointerEventType())
, m_isPrimary(isPrimary)
, m_coalescedEvents(coalescedEvents)
{
}

Expand Down
21 changes: 15 additions & 6 deletions Source/WebCore/page/PointerCaptureController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void PointerCaptureController::dispatchEventForTouchAtIndex(EventTarget& target,
RELEASE_ASSERT(is<Element>(target));

auto dispatchOverOrOutEvent = [&](const AtomString& type, EventTarget* target) {
dispatchEvent(PointerEvent::create(type, platformTouchEvent, index, isPrimary, view, touchDelta), target);
dispatchEvent(PointerEvent::create(type, platformTouchEvent, { }, index, isPrimary, view, touchDelta), target);
};

auto dispatchEnterOrLeaveEvent = [&](const AtomString& type, Element& targetElement) {
Expand All @@ -230,14 +230,23 @@ void PointerCaptureController::dispatchEventForTouchAtIndex(EventTarget& target,

if (type == eventNames().pointerenterEvent) {
for (auto& element : makeReversedRange(targetChain))
dispatchEvent(PointerEvent::create(type, platformTouchEvent, index, isPrimary, view, touchDelta), element.ptr());
dispatchEvent(PointerEvent::create(type, platformTouchEvent, { }, index, isPrimary, view, touchDelta), element.ptr());
} else {
for (auto& element : targetChain)
dispatchEvent(PointerEvent::create(type, platformTouchEvent, index, isPrimary, view, touchDelta), element.ptr());
dispatchEvent(PointerEvent::create(type, platformTouchEvent, { }, index, isPrimary, view, touchDelta), element.ptr());
}
};

auto pointerEvent = PointerEvent::create(platformTouchEvent, index, isPrimary, view, touchDelta);
auto coalescedEvents = [&] -> Vector<Ref<PointerEvent>> {
if (index)
return { PointerEvent::create(platformTouchEvent, { }, Event::CanBubble::No, Event::IsCancelable::No, index, isPrimary, view, touchDelta) };

return WTF::map(platformTouchEvent.coalescedEvents(), [&](const auto& event) {
return PointerEvent::create(event, { }, Event::CanBubble::No, Event::IsCancelable::No, index, isPrimary, view, touchDelta);
});
}();

auto pointerEvent = PointerEvent::create(platformTouchEvent, coalescedEvents, index, isPrimary, view, touchDelta);

Ref capturingData = ensureCapturingDataForPointerEvent(pointerEvent);

Expand Down Expand Up @@ -278,15 +287,15 @@ void PointerCaptureController::dispatchEventForTouchAtIndex(EventTarget& target,

for (auto& chain : leftElementsChain) {
if (hasCapturingPointerLeaveListener || chain->hasEventListeners(eventNames().pointerleaveEvent))
dispatchEvent(PointerEvent::create(eventNames().pointerleaveEvent, platformTouchEvent, index, isPrimary, view, touchDelta), chain.ptr());
dispatchEvent(PointerEvent::create(eventNames().pointerleaveEvent, platformTouchEvent, coalescedEvents, index, isPrimary, view, touchDelta), chain.ptr());
}

if (currentTarget)
dispatchOverOrOutEvent(eventNames().pointeroverEvent, currentTarget.get());

for (auto& chain : makeReversedRange(enteredElementsChain)) {
if (hasCapturingPointerEnterListener || chain->hasEventListeners(eventNames().pointerenterEvent))
dispatchEvent(PointerEvent::create(eventNames().pointerenterEvent, platformTouchEvent, index, isPrimary, view, touchDelta), chain.ptr());
dispatchEvent(PointerEvent::create(eventNames().pointerenterEvent, platformTouchEvent, coalescedEvents, index, isPrimary, view, touchDelta), chain.ptr());
}
}

Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/platform/PlatformTouchEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class PlatformTouchEvent : public PlatformEvent {

const Vector<PlatformTouchPoint>& touchPoints() const { return m_touchPoints; }

const Vector<PlatformTouchEvent>& coalescedEvents() const { return m_coalescedEvents; }

#if PLATFORM(WPE)
// FIXME: since WPE currently does not send touch stationary events, we need to be able to set
// TouchCancelled touchPoints subsequently
Expand All @@ -46,6 +48,7 @@ class PlatformTouchEvent : public PlatformEvent {

protected:
Vector<PlatformTouchPoint> m_touchPoints;
Vector<PlatformTouchEvent> m_coalescedEvents;
};

}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/ios/WebEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ WEBCORE_EXPORT @interface WebEvent : NSObject {
NSArray *_touchLocations;
NSArray *_touchIdentifiers;
NSArray *_touchPhases;

BOOL _isGesture;
float _gestureScale;
float _gestureRotation;
Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit/Shared/NativeWebTouchEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class NativeWebTouchEvent : public WebTouchEvent {

private:
#if PLATFORM(IOS_FAMILY) && defined(__OBJC__)
Vector<WebPlatformTouchPoint> extractWebTouchPoint(const WKTouchEvent&);
Vector<WebPlatformTouchPoint> extractWebTouchPoints(const WKTouchEvent&);
Vector<WebTouchEvent> extractCoalescedWebTouchEvents(const WKTouchEvent&, UIKeyModifierFlags);
#endif

#if PLATFORM(GTK) && USE(GTK4)
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/Shared/WebEvent.serialization.in
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class WebKit::WebKeyboardEvent : WebKit::WebEvent {
#if ENABLE(TOUCH_EVENTS)
class WebKit::WebTouchEvent : WebKit::WebEvent {
Vector<WebKit::WebPlatformTouchPoint> touchPoints();
Vector<WebKit::WebTouchEvent> coalescedEvents();
#if PLATFORM(IOS_FAMILY)
WebCore::IntPoint position();
bool isPotentialTap();
Expand Down
4 changes: 4 additions & 0 deletions Source/WebKit/Shared/WebEventConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ class WebKit2PlatformTouchEvent : public WebCore::PlatformTouchEvent {
return WebKit2PlatformTouchPoint(touchPoint);
});

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

m_gestureScale = webEvent.gestureScale();
m_gestureRotation = webEvent.gestureRotation();
m_canPreventNativeGestures = webEvent.canPreventNativeGestures();
Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit/Shared/WebTouchEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ namespace WebKit {

#if !PLATFORM(IOS_FAMILY)

WebTouchEvent::WebTouchEvent(WebEvent&& event, Vector<WebPlatformTouchPoint>&& touchPoints)
WebTouchEvent::WebTouchEvent(WebEvent&& event, Vector<WebPlatformTouchPoint>&& touchPoints, Vector<WebTouchEvent>&& coalescedEvents)
: WebEvent(WTFMove(event))
, m_touchPoints(WTFMove(touchPoints))
, m_coalescedEvents(WTFMove(coalescedEvents))
{
ASSERT(isTouchEventType(type()));
}
Expand Down
14 changes: 11 additions & 3 deletions Source/WebKit/Shared/WebTouchEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ class WebPlatformTouchPoint {

class WebTouchEvent : public WebEvent {
public:
WebTouchEvent(WebEvent&& event, const Vector<WebPlatformTouchPoint>& touchPoints, WebCore::IntPoint position, bool isPotentialTap, bool isGesture, float gestureScale, float gestureRotation, bool canPreventNativeGestures = true)
WebTouchEvent(WebEvent&& event, const Vector<WebPlatformTouchPoint>& touchPoints, const Vector<WebTouchEvent>& coalescedEvents, WebCore::IntPoint position, bool isPotentialTap, bool isGesture, float gestureScale, float gestureRotation, bool canPreventNativeGestures = true)
: WebEvent(WTFMove(event))
, m_touchPoints(touchPoints)
, m_coalescedEvents(coalescedEvents)
, m_position(position)
, m_canPreventNativeGestures(canPreventNativeGestures)
, m_isPotentialTap(isPotentialTap)
Expand All @@ -129,6 +130,9 @@ class WebTouchEvent : public WebEvent {

const Vector<WebPlatformTouchPoint>& touchPoints() const { return m_touchPoints; }

const Vector<WebTouchEvent>& coalescedEvents() const { return m_coalescedEvents; }
void setCoalescedEvents(const Vector<WebTouchEvent>& coalescedEvents) { m_coalescedEvents = coalescedEvents; }

WebCore::IntPoint position() const { return m_position; }
void setPosition(WebCore::IntPoint position) { m_position = position; }

Expand All @@ -145,7 +149,8 @@ class WebTouchEvent : public WebEvent {

private:
Vector<WebPlatformTouchPoint> m_touchPoints;

Vector<WebTouchEvent> m_coalescedEvents;

WebCore::IntPoint m_position;
bool m_canPreventNativeGestures { false };
bool m_isPotentialTap { false };
Expand Down Expand Up @@ -196,16 +201,19 @@ class WebPlatformTouchPoint {

class WebTouchEvent : public WebEvent {
public:
WebTouchEvent(WebEvent&&, Vector<WebPlatformTouchPoint>&&);
WebTouchEvent(WebEvent&&, Vector<WebPlatformTouchPoint>&&, Vector<WebTouchEvent>&&);

const Vector<WebPlatformTouchPoint>& touchPoints() const { return m_touchPoints; }

const Vector<WebTouchEvent>& coalescedEvents() const { return m_coalescedEvents; }

bool allTouchPointsAreReleased() const;

private:
static bool isTouchEventType(WebEventType);

Vector<WebPlatformTouchPoint> m_touchPoints;
Vector<WebTouchEvent> m_coalescedEvents;
};

#endif // PLATFORM(IOS_FAMILY)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/Shared/gtk/WebEventFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ WebTouchEvent WebEventFactory::createWebTouchEvent(const GdkEvent* event, Vector
ASSERT_NOT_REACHED();
}

return WebTouchEvent({ type, modifiersForEvent(event), wallTimeForEvent(event) }, WTFMove(touchPoints));
return WebTouchEvent({ type, modifiersForEvent(event), wallTimeForEvent(event) }, WTFMove(touchPoints), { });
}
#endif

Expand Down
Loading

0 comments on commit 40e9a76

Please sign in to comment.