Title: [273296] trunk/Source
Revision
273296
Author
[email protected]
Date
2021-02-22 19:16:32 -0800 (Mon, 22 Feb 2021)

Log Message

WebMouseEvent.h should avoid pulling in WebCore headers that know about DOM nodes
https://bugs.webkit.org/show_bug.cgi?id=222291

Reviewed by Darin Adler.

Source/WebCore:

Refactor `PointerEvent.h` so that the static class helper methods for getting the names of mouse, pen and touch
pointer event types are instead separate functions in `PointerEventTypeNames.h`. This allows us to just import
`PointerEventTypeNames.h` instead of `PointerEvent.h` in WebKit -- and, in particular, within WebKit headers
that are exclusive to the UI process.

No change in behavior.

* Headers.cmake:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* dom/PointerEvent.cpp:
(WebCore::PointerEvent::mousePointerType): Deleted.
(WebCore::PointerEvent::penPointerType): Deleted.
(WebCore::PointerEvent::touchPointerType): Deleted.
* dom/PointerEvent.h:

Drive-by fix: also forward declare `Node` instead of including `Node.h`; `WebCore::Node` is only used in this
header in the context of `RefPtr<Node>`, so the forward declaration is sufficient.

* dom/PointerEventTypeNames.cpp: Added.
(WebCore::mousePointerEventType):
(WebCore::penPointerEventType):
(WebCore::touchPointerEventType):
* dom/PointerEventTypeNames.h: Added.
* dom/ios/PointerEventIOS.cpp:
* page/PointerCaptureController.cpp:
(WebCore::PointerCaptureController::reset):
(WebCore::PointerCaptureController::pointerEventForMouseEvent):
(WebCore::PointerCaptureController::dispatchEvent):
(WebCore::PointerCaptureController::pointerEventWillBeDispatched):
(WebCore::PointerCaptureController::pointerEventWasDispatched):
(WebCore::PointerCaptureController::processPendingPointerCapture):

Source/WebKit:

Import `PointerEventTypeNames.h` instead of `PointerEvent.h` in several UI process and shared headers.

* Shared/WebMouseEvent.h:
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(primaryPointerForType):
(webkitWebViewBaseSynthesizeMouseEvent):
* UIProcess/Automation/SimulatedInputDispatcher.cpp:
(WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::performMouseInteraction):
* UIProcess/gtk/PointerLockManager.cpp:
(WebKit::PointerLockManager::handleMotion):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (273295 => 273296)


--- trunk/Source/WebCore/ChangeLog	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebCore/ChangeLog	2021-02-23 03:16:32 UTC (rev 273296)
@@ -1,3 +1,43 @@
+2021-02-22  Wenson Hsieh  <[email protected]>
+
+        WebMouseEvent.h should avoid pulling in WebCore headers that know about DOM nodes
+        https://bugs.webkit.org/show_bug.cgi?id=222291
+
+        Reviewed by Darin Adler.
+
+        Refactor `PointerEvent.h` so that the static class helper methods for getting the names of mouse, pen and touch
+        pointer event types are instead separate functions in `PointerEventTypeNames.h`. This allows us to just import
+        `PointerEventTypeNames.h` instead of `PointerEvent.h` in WebKit -- and, in particular, within WebKit headers
+        that are exclusive to the UI process.
+
+        No change in behavior.
+
+        * Headers.cmake:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/PointerEvent.cpp:
+        (WebCore::PointerEvent::mousePointerType): Deleted.
+        (WebCore::PointerEvent::penPointerType): Deleted.
+        (WebCore::PointerEvent::touchPointerType): Deleted.
+        * dom/PointerEvent.h:
+
+        Drive-by fix: also forward declare `Node` instead of including `Node.h`; `WebCore::Node` is only used in this
+        header in the context of `RefPtr<Node>`, so the forward declaration is sufficient.
+
+        * dom/PointerEventTypeNames.cpp: Added.
+        (WebCore::mousePointerEventType):
+        (WebCore::penPointerEventType):
+        (WebCore::touchPointerEventType):
+        * dom/PointerEventTypeNames.h: Added.
+        * dom/ios/PointerEventIOS.cpp:
+        * page/PointerCaptureController.cpp:
+        (WebCore::PointerCaptureController::reset):
+        (WebCore::PointerCaptureController::pointerEventForMouseEvent):
+        (WebCore::PointerCaptureController::dispatchEvent):
+        (WebCore::PointerCaptureController::pointerEventWillBeDispatched):
+        (WebCore::PointerCaptureController::pointerEventWasDispatched):
+        (WebCore::PointerCaptureController::processPendingPointerCapture):
+
 2021-02-22  Said Abou-Hallawa  <[email protected]>
 
         [GPU Process] Implement the ClipToDrawingCommands item by using begin and end markers

Modified: trunk/Source/WebCore/Headers.cmake (273295 => 273296)


--- trunk/Source/WebCore/Headers.cmake	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebCore/Headers.cmake	2021-02-23 03:16:32 UTC (rev 273296)
@@ -491,6 +491,7 @@
     dom/NodeTraversal.h
     dom/OverflowEvent.h
     dom/PointerEvent.h
+    dom/PointerEventTypeNames.h
     dom/Position.h
     dom/ProcessingInstruction.h
     dom/ProgressEvent.h

Modified: trunk/Source/WebCore/Sources.txt (273295 => 273296)


--- trunk/Source/WebCore/Sources.txt	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebCore/Sources.txt	2021-02-23 03:16:32 UTC (rev 273296)
@@ -978,6 +978,7 @@
 dom/PageTransitionEvent.cpp
 dom/PendingScript.cpp
 dom/PointerEvent.cpp
+dom/PointerEventTypeNames.cpp
 dom/PopStateEvent.cpp
 dom/Position.cpp
 dom/PositionIterator.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (273295 => 273296)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-02-23 03:16:32 UTC (rev 273296)
@@ -5282,6 +5282,7 @@
 		F403E7872363B58C00044550 /* EnterKeyHint.h in Headers */ = {isa = PBXBuildFile; fileRef = F403E7852363B58C00044550 /* EnterKeyHint.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		F40DAAEC25D9F25E0011B4FA /* PasteboardContext.h in Headers */ = {isa = PBXBuildFile; fileRef = F40DAAEB25D9F25E0011B4FA /* PasteboardContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		F40DAAEF25D9F3BF0011B4FA /* PagePasteboardContext.h in Headers */ = {isa = PBXBuildFile; fileRef = F40DAAEE25D9F3BF0011B4FA /* PagePasteboardContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		F420F00A25E47791009251EF /* PointerEventTypeNames.h in Headers */ = {isa = PBXBuildFile; fileRef = F420F00825E47791009251EF /* PointerEventTypeNames.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		F429261825264D4400007898 /* MediaPlayerIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = F429261725264D4400007898 /* MediaPlayerIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		F433E9031DBBDBA200EF0D14 /* StaticPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F433E9021DBBDBA200EF0D14 /* StaticPasteboard.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		F4377D572551C9C60080ABFE /* DisplayListItemType.h in Headers */ = {isa = PBXBuildFile; fileRef = F4377D552551C9C60080ABFE /* DisplayListItemType.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -16634,6 +16635,8 @@
 		F403E7862363B58C00044550 /* EnterKeyHint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EnterKeyHint.cpp; sourceTree = "<group>"; };
 		F40DAAEB25D9F25E0011B4FA /* PasteboardContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PasteboardContext.h; sourceTree = "<group>"; };
 		F40DAAEE25D9F3BF0011B4FA /* PagePasteboardContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PagePasteboardContext.h; sourceTree = "<group>"; };
+		F420F00825E47791009251EF /* PointerEventTypeNames.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PointerEventTypeNames.h; sourceTree = "<group>"; };
+		F420F00925E47791009251EF /* PointerEventTypeNames.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PointerEventTypeNames.cpp; sourceTree = "<group>"; };
 		F422B8B5253F7065004E77E8 /* DisplayListItemBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayListItemBuffer.h; sourceTree = "<group>"; };
 		F422B8B6253F7065004E77E8 /* DisplayListItemBuffer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListItemBuffer.cpp; sourceTree = "<group>"; };
 		F429261725264D4400007898 /* MediaPlayerIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaPlayerIdentifier.h; sourceTree = "<group>"; };
@@ -30407,6 +30410,8 @@
 				317D3FF1215599E20034E3B9 /* PointerEvent.cpp */,
 				317D3FF2215599E30034E3B9 /* PointerEvent.h */,
 				317D3FEF215599E10034E3B9 /* PointerEvent.idl */,
+				F420F00925E47791009251EF /* PointerEventTypeNames.cpp */,
+				F420F00825E47791009251EF /* PointerEventTypeNames.h */,
 				5189F0DD10B46B0E00F3C739 /* PopStateEvent.cpp */,
 				5174E20810A1F44F00F95E6F /* PopStateEvent.h */,
 				5174E20B10A1F49A00F95E6F /* PopStateEvent.idl */,
@@ -34254,6 +34259,7 @@
 				95DF9D25252BEDB2000D7F46 /* PointerCharacteristics.h in Headers */,
 				317D3FF3215599F40034E3B9 /* PointerEvent.h in Headers */,
 				B2B1F7170D00CAA8004AEA64 /* PointerEventsHitRules.h in Headers */,
+				F420F00A25E47791009251EF /* PointerEventTypeNames.h in Headers */,
 				71EADCD822087E720065A45F /* PointerID.h in Headers */,
 				3FF813A71DBA8640009BF001 /* PointerLockController.h in Headers */,
 				84730D921248F0B300D3A9C9 /* PointLightSource.h in Headers */,

Modified: trunk/Source/WebCore/dom/PointerEvent.cpp (273295 => 273296)


--- trunk/Source/WebCore/dom/PointerEvent.cpp	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebCore/dom/PointerEvent.cpp	2021-02-23 03:16:32 UTC (rev 273296)
@@ -27,6 +27,7 @@
 #include "PointerEvent.h"
 
 #include "EventNames.h"
+#include "Node.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {
@@ -33,24 +34,6 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(PointerEvent);
 
-const String& PointerEvent::mousePointerType()
-{
-    static NeverDestroyed<const String> mouseType(MAKE_STATIC_STRING_IMPL("mouse"));
-    return mouseType;
-}
-
-const String& PointerEvent::penPointerType()
-{
-    static NeverDestroyed<const String> penType(MAKE_STATIC_STRING_IMPL("pen"));
-    return penType;
-}
-
-const String& PointerEvent::touchPointerType()
-{
-    static NeverDestroyed<const String> touchType(MAKE_STATIC_STRING_IMPL("touch"));
-    return touchType;
-}
-
 static AtomString pointerEventType(const AtomString& mouseEventType)
 {
     auto& names = eventNames();

Modified: trunk/Source/WebCore/dom/PointerEvent.h (273295 => 273296)


--- trunk/Source/WebCore/dom/PointerEvent.h	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebCore/dom/PointerEvent.h	2021-02-23 03:16:32 UTC (rev 273296)
@@ -27,7 +27,7 @@
 
 #include "EventNames.h"
 #include "MouseEvent.h"
-#include "Node.h"
+#include "PointerEventTypeNames.h"
 #include "PointerID.h"
 #include <wtf/text/WTFString.h>
 
@@ -37,6 +37,8 @@
 
 namespace WebCore {
 
+class Node;
+
 class PointerEvent final : public MouseEvent {
     WTF_MAKE_ISO_ALLOCATED(PointerEvent);
 public:
@@ -49,7 +51,7 @@
         long tiltX { 0 };
         long tiltY { 0 };
         long twist { 0 };
-        String pointerType { PointerEvent::mousePointerType() };
+        String pointerType { mousePointerEventType() };
         bool isPrimary { false };
     };
 
@@ -84,10 +86,6 @@
     static Ref<PointerEvent> create(const String& type, const PlatformTouchEvent&, unsigned touchIndex, bool isPrimary, Ref<WindowProxy>&&);
 #endif
 
-    WEBCORE_EXPORT static const String& mousePointerType();
-    WEBCORE_EXPORT static const String& penPointerType();
-    static const String& touchPointerType();
-
     virtual ~PointerEvent();
 
     PointerID pointerId() const { return m_pointerId; }
@@ -135,7 +133,7 @@
     long m_tiltX { 0 };
     long m_tiltY { 0 };
     long m_twist { 0 };
-    String m_pointerType { PointerEvent::mousePointerType() };
+    String m_pointerType { mousePointerEventType() };
     bool m_isPrimary { false };
 };
 

Added: trunk/Source/WebCore/dom/PointerEventTypeNames.cpp (0 => 273296)


--- trunk/Source/WebCore/dom/PointerEventTypeNames.cpp	                        (rev 0)
+++ trunk/Source/WebCore/dom/PointerEventTypeNames.cpp	2021-02-23 03:16:32 UTC (rev 273296)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2021 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 "PointerEventTypeNames.h"
+
+#include <wtf/NeverDestroyed.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+const String& mousePointerEventType()
+{
+    static NeverDestroyed<const String> mouseType(MAKE_STATIC_STRING_IMPL("mouse"));
+    return mouseType;
+}
+
+const String& penPointerEventType()
+{
+    static NeverDestroyed<const String> penType(MAKE_STATIC_STRING_IMPL("pen"));
+    return penType;
+}
+
+const String& touchPointerEventType()
+{
+    static NeverDestroyed<const String> touchType(MAKE_STATIC_STRING_IMPL("touch"));
+    return touchType;
+}
+
+} // namespace WebCore

Added: trunk/Source/WebCore/dom/PointerEventTypeNames.h (0 => 273296)


--- trunk/Source/WebCore/dom/PointerEventTypeNames.h	                        (rev 0)
+++ trunk/Source/WebCore/dom/PointerEventTypeNames.h	2021-02-23 03:16:32 UTC (rev 273296)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#pragma once
+
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+WEBCORE_EXPORT const String& mousePointerEventType();
+WEBCORE_EXPORT const String& penPointerEventType();
+const String& touchPointerEventType();
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/dom/ios/PointerEventIOS.cpp (273295 => 273296)


--- trunk/Source/WebCore/dom/ios/PointerEventIOS.cpp	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebCore/dom/ios/PointerEventIOS.cpp	2021-02-23 03:16:32 UTC (rev 273296)
@@ -78,7 +78,7 @@
     , 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 ? PointerEvent::penPointerType() : PointerEvent::touchPointerType())
+    , m_pointerType(event.touchTypeAtIndex(index) == PlatformTouchPoint::TouchType::Stylus ? penPointerEventType() : touchPointerEventType())
     , m_isPrimary(isPrimary)
 {
     // See https://github.com/w3c/pointerevents/issues/274. We might expose the azimuth and altitude

Modified: trunk/Source/WebCore/page/PointerCaptureController.cpp (273295 => 273296)


--- trunk/Source/WebCore/page/PointerCaptureController.cpp	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebCore/page/PointerCaptureController.cpp	2021-02-23 03:16:32 UTC (rev 273296)
@@ -173,7 +173,7 @@
     m_haveAnyCapturingElement = false;
 
     CapturingData capturingData;
-    capturingData.pointerType = PointerEvent::mousePointerType();
+    capturingData.pointerType = mousePointerEventType();
     m_activePointerIdsToCapturingData.add(mousePointerID, capturingData);
 }
 
@@ -327,7 +327,7 @@
     // If we already have known touches then we cannot dispatch a mouse event,
     // for instance in the case of a long press to initiate a system drag.
     for (auto& capturingData : m_activePointerIdsToCapturingData.values()) {
-        if (capturingData.pointerType == PointerEvent::touchPointerType() && capturingData.pointerIsPressed && !capturingData.cancelled)
+        if (capturingData.pointerType == touchPointerEventType() && capturingData.pointerIsPressed && !capturingData.cancelled)
             return nullptr;
     }
 
@@ -376,7 +376,7 @@
     // https://w3c.github.io/pointerevents/#firing-events-using-the-pointerevent-interface
     // If the event is not gotpointercapture or lostpointercapture, run Process Pending Pointer Capture steps for this PointerEvent.
     // We only need to do this for non-mouse type since for mouse events this method will be called in Document::prepareMouseEvent().
-    if (event.pointerType() != PointerEvent::mousePointerType())
+    if (event.pointerType() != mousePointerEventType())
         processPendingPointerCapture(event.pointerId());
 
     pointerEventWillBeDispatched(event, target);
@@ -396,7 +396,7 @@
 
     auto pointerId = event.pointerId();
 
-    if (event.pointerType() != PointerEvent::touchPointerType()) {
+    if (event.pointerType() != touchPointerEventType()) {
         auto iterator = m_activePointerIdsToCapturingData.find(pointerId);
         if (iterator != m_activePointerIdsToCapturingData.end())
             iterator->value.pointerIsPressed = isPointerdown;
@@ -450,7 +450,7 @@
 
         // If a mouse pointer has moved while it isn't pressed, make sure we reset the preventsCompatibilityMouseEvents flag since
         // we could otherwise prevent compatibility mouse events while those are only supposed to be prevented while the pointer is pressed.
-        if (event.type() == eventNames().pointermoveEvent && capturingData.pointerType == PointerEvent::mousePointerType() && !capturingData.pointerIsPressed)
+        if (event.type() == eventNames().pointermoveEvent && capturingData.pointerType == mousePointerEventType() && !capturingData.pointerIsPressed)
             capturingData.preventsCompatibilityMouseEvents = false;
 
         // If the pointer event dispatched was pointerdown and the event was canceled, then set the PREVENT MOUSE EVENT flag for this pointerType.
@@ -536,7 +536,7 @@
     if (capturingData.targetOverride && capturingData.targetOverride != pendingTargetOverride) {
         if (capturingData.targetOverride->isConnected())
             capturingData.targetOverride->dispatchEvent(PointerEvent::createForPointerCapture(eventNames().lostpointercaptureEvent, pointerId, capturingData.isPrimary, capturingData.pointerType));
-        if (capturingData.pointerType == PointerEvent::mousePointerType()) {
+        if (capturingData.pointerType == mousePointerEventType()) {
             if (auto* frame = capturingData.targetOverride->document().frame())
                 frame->eventHandler().pointerCaptureElementDidChange(nullptr);
         }
@@ -545,7 +545,7 @@
     // 2. If the pending pointer capture target override for this pointer is set and is not equal to the pointer capture target override,
     // then fire a pointer event named gotpointercapture at the pending pointer capture target override.
     if (capturingData.pendingTargetOverride && capturingData.targetOverride != pendingTargetOverride) {
-        if (capturingData.pointerType == PointerEvent::mousePointerType()) {
+        if (capturingData.pointerType == mousePointerEventType()) {
             if (auto* frame = pendingTargetOverride->document().frame())
                 frame->eventHandler().pointerCaptureElementDidChange(pendingTargetOverride.get());
         }

Modified: trunk/Source/WebKit/ChangeLog (273295 => 273296)


--- trunk/Source/WebKit/ChangeLog	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebKit/ChangeLog	2021-02-23 03:16:32 UTC (rev 273296)
@@ -1,3 +1,23 @@
+2021-02-22  Wenson Hsieh  <[email protected]>
+
+        WebMouseEvent.h should avoid pulling in WebCore headers that know about DOM nodes
+        https://bugs.webkit.org/show_bug.cgi?id=222291
+
+        Reviewed by Darin Adler.
+
+        Import `PointerEventTypeNames.h` instead of `PointerEvent.h` in several UI process and shared headers.
+
+        * Shared/WebMouseEvent.h:
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (primaryPointerForType):
+        (webkitWebViewBaseSynthesizeMouseEvent):
+        * UIProcess/Automation/SimulatedInputDispatcher.cpp:
+        (WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::WebAutomationSession::performMouseInteraction):
+        * UIProcess/gtk/PointerLockManager.cpp:
+        (WebKit::PointerLockManager::handleMotion):
+
 2021-02-22  Chris Dumez  <[email protected]>
 
         Add assertions to help identify to source of <rdar://68340471>

Modified: trunk/Source/WebKit/Shared/WebMouseEvent.h (273295 => 273296)


--- trunk/Source/WebKit/Shared/WebMouseEvent.h	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebKit/Shared/WebMouseEvent.h	2021-02-23 03:16:32 UTC (rev 273296)
@@ -31,7 +31,7 @@
 
 #include "WebEvent.h"
 #include <WebCore/IntPoint.h>
-#include <WebCore/PointerEvent.h>
+#include <WebCore/PointerEventTypeNames.h>
 #include <WebCore/PointerID.h>
 
 namespace WebKit {
@@ -52,7 +52,7 @@
 #if PLATFORM(MAC)
     WebMouseEvent(Type, Button, unsigned short buttons, const WebCore::IntPoint& positionInView, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, OptionSet<Modifier>, WallTime timestamp, double force, SyntheticClickType = NoTap, int eventNumber = -1, int menuType = 0);
 #else
-    WebMouseEvent(Type, Button, unsigned short buttons, const WebCore::IntPoint& positionInView, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, OptionSet<Modifier>, WallTime timestamp, double force = 0, SyntheticClickType = NoTap, WebCore::PointerID = WebCore::mousePointerID, const String& pointerType = WebCore::PointerEvent::mousePointerType());
+    WebMouseEvent(Type, Button, unsigned short buttons, const WebCore::IntPoint& positionInView, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, OptionSet<Modifier>, WallTime timestamp, double force = 0, SyntheticClickType = NoTap, WebCore::PointerID = WebCore::mousePointerID, const String& pointerType = WebCore::mousePointerEventType());
 #endif
 
     Button button() const { return static_cast<Button>(m_button); }
@@ -93,7 +93,7 @@
     double m_force { 0 };
     uint32_t m_syntheticClickType { NoTap };
     WebCore::PointerID m_pointerId { WebCore::mousePointerID };
-    String m_pointerType { WebCore::PointerEvent::mousePointerType() };
+    String m_pointerType { WebCore::mousePointerEventType() };
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (273295 => 273296)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp	2021-02-23 03:16:32 UTC (rev 273296)
@@ -2527,10 +2527,10 @@
 
 static inline PointerID primaryPointerForType(const String& pointerType)
 {
-    if (pointerType == PointerEvent::mousePointerType())
+    if (pointerType == mousePointerEventType())
         return mousePointerID;
 
-    if (pointerType == PointerEvent::penPointerType())
+    if (pointerType == penPointerEventType())
         return 2;
 
     return mousePointerID;
@@ -2619,7 +2619,7 @@
 
     priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(webEventType, webEventButton, webEventButtons, { x, y },
         widgetRootCoords(GTK_WIDGET(webViewBase), x, y), clickCount, toWebKitModifiers(modifiers), movementDelta,
-        primaryPointerForType(pointerType), pointerType.isNull() ? PointerEvent::mousePointerType() : pointerType));
+        primaryPointerForType(pointerType), pointerType.isNull() ? mousePointerEventType() : pointerType));
 }
 
 void webkitWebViewBaseSynthesizeKeyEvent(WebKitWebViewBase* webViewBase, KeyEventType type, unsigned keyval, unsigned modifiers, ShouldTranslateKeyboardState shouldTranslate)

Modified: trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp (273295 => 273296)


--- trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp	2021-02-23 03:16:32 UTC (rev 273296)
@@ -32,7 +32,7 @@
 #include "Logging.h"
 #include "WebAutomationSession.h"
 #include "WebAutomationSessionMacros.h"
-#include <WebCore/PointerEvent.h>
+#include <WebCore/PointerEventTypeNames.h>
 #include <wtf/Variant.h>
 
 namespace WebKit {
@@ -286,7 +286,7 @@
                 return;
             }
 
-            const String& pointerType = inputSource == SimulatedInputSourceType::Mouse ? WebCore::PointerEvent::mousePointerType() : WebCore::PointerEvent::penPointerType();
+            const String& pointerType = inputSource == SimulatedInputSourceType::Mouse ? WebCore::mousePointerEventType() : WebCore::penPointerEventType();
 
             b.location = location;
             // The "dispatch a pointer{Down,Up,Move} action" algorithms (ยง17.4 Dispatching Actions).

Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp (273295 => 273296)


--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp	2021-02-23 03:16:32 UTC (rev 273296)
@@ -45,7 +45,7 @@
 #include <_javascript_Core/InspectorBackendDispatcher.h>
 #include <_javascript_Core/InspectorFrontendRouter.h>
 #include <WebCore/MIMETypeRegistry.h>
-#include <WebCore/PointerEvent.h>
+#include <WebCore/PointerEventTypeNames.h>
 #include <algorithm>
 #include <wtf/FileSystem.h>
 #include <wtf/HashMap.h>
@@ -1793,7 +1793,7 @@
             callbackInMap(AUTOMATION_COMMAND_ERROR_WITH_NAME(Timeout));
         callbackInMap = WTFMove(mouseEventsFlushedCallback);
 
-        platformSimulateMouseInteraction(page, mouseInteraction, mouseButton, locationInViewport, keyModifiers, WebCore::PointerEvent::mousePointerType());
+        platformSimulateMouseInteraction(page, mouseInteraction, mouseButton, locationInViewport, keyModifiers, WebCore::mousePointerEventType());
 
         // If the event location was previously clipped and does not hit test anything in the window, then it will not be processed.
         // For compatibility with pre-W3C driver implementations, don't make this a hard error; just do nothing silently.

Modified: trunk/Source/WebKit/UIProcess/gtk/PointerLockManager.cpp (273295 => 273296)


--- trunk/Source/WebKit/UIProcess/gtk/PointerLockManager.cpp	2021-02-23 02:32:15 UTC (rev 273295)
+++ trunk/Source/WebKit/UIProcess/gtk/PointerLockManager.cpp	2021-02-23 03:16:32 UTC (rev 273296)
@@ -93,7 +93,7 @@
 
 void PointerLockManager::handleMotion(FloatSize&& delta)
 {
-    m_webPage.handleMouseEvent(NativeWebMouseEvent(WebEvent::MouseMove, m_button, m_buttons, IntPoint(m_position), IntPoint(m_initialPoint), 0, m_modifiers, delta, mousePointerID, PointerEvent::mousePointerType()));
+    m_webPage.handleMouseEvent(NativeWebMouseEvent(WebEvent::MouseMove, m_button, m_buttons, IntPoint(m_position), IntPoint(m_initialPoint), 0, m_modifiers, delta, mousePointerID, mousePointerEventType()));
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to