Add a method to dispatch a PointerEvent based on a PlatformTouchEvent
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Feb 2019 22:18:36 +0000 (22:18 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Feb 2019 22:18:36 +0000 (22:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194702
<rdar://problem/48109355>

Reviewed by Dean Jackson.

* page/EventHandler.cpp:
(WebCore::EventHandler::dispatchPointerEventForTouchAtIndex):
* page/EventHandler.h:

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

Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h

index 2e85420..c4b5bc8 100644 (file)
@@ -1,3 +1,15 @@
+2019-02-15  Antoine Quint  <graouts@apple.com>
+
+        Add a method to dispatch a PointerEvent based on a PlatformTouchEvent
+        https://bugs.webkit.org/show_bug.cgi?id=194702
+        <rdar://problem/48109355>
+
+        Reviewed by Dean Jackson.
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::dispatchPointerEventForTouchAtIndex):
+        * page/EventHandler.h:
+
 2019-02-15  Per Arne Vollan  <pvollan@apple.com>
 
         [WebVTT] Inline WebVTT styles should start with '::cue'
index 59fd3e0..2024a76 100644 (file)
 #include "TouchList.h"
 #endif
 
+#if ENABLE(TOUCH_EVENTS) && ENABLE(POINTER_EVENTS)
+#include "PointerCaptureController.h"
+#include "PointerEvent.h"
+#endif
+
 #if ENABLE(TOUCH_EVENTS) && !ENABLE(IOS_TOUCH_EVENTS)
 #include "PlatformTouchEvent.h"
 #endif
@@ -4266,6 +4271,18 @@ bool EventHandler::dispatchSyntheticTouchEventIfEnabled(const PlatformMouseEvent
 }
 #endif // ENABLE(TOUCH_EVENTS)
 
+#if ENABLE(TOUCH_EVENTS) && ENABLE(POINTER_EVENTS)
+Ref<PointerEvent> EventHandler::dispatchPointerEventForTouchAtIndex(EventTarget& target, const PlatformTouchEvent& platformTouchEvent, unsigned index, bool isPrimary)
+{
+    auto& pointerCaptureController = m_frame.page()->pointerCaptureController();
+    auto pointerEvent = PointerEvent::create(platformTouchEvent, index, isPrimary, m_frame.windowProxy());
+    pointerCaptureController.pointerEventWillBeDispatched(pointerEvent, &target);
+    target.dispatchEvent(pointerEvent);
+    pointerCaptureController.pointerEventWasDispatched(pointerEvent);
+    return pointerEvent;
+}
+#endif // ENABLE(TOUCH_EVENTS) && ENABLE(POINTER_EVENTS)
+
 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event)
 {
     m_mousePositionIsUnknown = false;
index 9ea9e0c..43720db 100644 (file)
@@ -81,6 +81,7 @@ class PlatformGestureEvent;
 class PlatformKeyboardEvent;
 class PlatformTouchEvent;
 class PlatformWheelEvent;
+class PointerEvent;
 class RenderBox;
 class RenderElement;
 class RenderLayer;
@@ -319,6 +320,10 @@ public:
     WEBCORE_EXPORT bool handleTouchEvent(const PlatformTouchEvent&);
 #endif
 
+#if ENABLE(TOUCH_EVENTS) && ENABLE(POINTER_EVENTS)
+    Ref<PointerEvent> dispatchPointerEventForTouchAtIndex(EventTarget&, const PlatformTouchEvent&, unsigned, bool isPrimary);
+#endif
+
     bool useHandCursor(Node*, bool isOverLink, bool shiftKey);
     void updateCursor();