Use a dedicated type instead of int32_t for pointer identifiers
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Feb 2019 16:22:49 +0000 (16:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Feb 2019 16:22:49 +0000 (16:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194217

Patch by Antoine Quint <graouts@apple.com> on 2019-02-04
Reviewed by Antti Koivisto.

Source/WebCore:

* WebCore.xcodeproj/project.pbxproj:
* dom/PointerEvent.h:
* dom/PointerID.h: Added.
* page/PointerCaptureController.cpp:
(WebCore::PointerCaptureController::setPointerCapture):
(WebCore::PointerCaptureController::releasePointerCapture):
(WebCore::PointerCaptureController::hasPointerCapture):
(WebCore::PointerCaptureController::touchEndedOrWasCancelledForIdentifier):
(WebCore::PointerCaptureController::hasCancelledPointerEventForIdentifier):
(WebCore::PointerCaptureController::cancelPointer):
* page/PointerCaptureController.h:

Source/WebKit:

* Scripts/webkit/messages.py:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::cancelPointer):
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::cancelPointer):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

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

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/PointerEvent.h
Source/WebCore/dom/PointerID.h [new file with mode: 0644]
Source/WebCore/page/PointerCaptureController.cpp
Source/WebCore/page/PointerCaptureController.h
Source/WebKit/ChangeLog
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in

index ad89714..cfb0ee9 100644 (file)
@@ -1,3 +1,22 @@
+2019-02-04  Antoine Quint  <graouts@apple.com>
+
+        Use a dedicated type instead of int32_t for pointer identifiers
+        https://bugs.webkit.org/show_bug.cgi?id=194217
+
+        Reviewed by Antti Koivisto.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/PointerEvent.h:
+        * dom/PointerID.h: Added.
+        * page/PointerCaptureController.cpp:
+        (WebCore::PointerCaptureController::setPointerCapture):
+        (WebCore::PointerCaptureController::releasePointerCapture):
+        (WebCore::PointerCaptureController::hasPointerCapture):
+        (WebCore::PointerCaptureController::touchEndedOrWasCancelledForIdentifier):
+        (WebCore::PointerCaptureController::hasCancelledPointerEventForIdentifier):
+        (WebCore::PointerCaptureController::cancelPointer):
+        * page/PointerCaptureController.h:
+
 2019-02-04  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iOS] Unable to make a selection in jsfiddle.net using arrow keys when requesting desktop site
index bf354a4..6d45374 100644 (file)
                71E2183A17359FB8006E6E4D /* PlugInsResources.h in Headers */ = {isa = PBXBuildFile; fileRef = 71E2183817359FB8006E6E4D /* PlugInsResources.h */; };
                71E2C42621C935280024F8C8 /* AnimationEffectPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 71E2C42421C9351D0024F8C8 /* AnimationEffectPhase.h */; settings = {ATTRIBUTES = (Private, ); }; };
                71E623D1151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h in Headers */ = {isa = PBXBuildFile; fileRef = 71E623CF151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h */; };
+               71EADCD822087E720065A45F /* PointerID.h in Headers */ = {isa = PBXBuildFile; fileRef = 71EADCD622087E6D0065A45F /* PointerID.h */; settings = {ATTRIBUTES = (Private, ); }; };
                71EFCEDC202B38A900D7C411 /* AnimationEffect.h in Headers */ = {isa = PBXBuildFile; fileRef = 71EFCED7202B388D00D7C411 /* AnimationEffect.h */; settings = {ATTRIBUTES = (Private, ); }; };
                71FB967B1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h in Headers */ = {isa = PBXBuildFile; fileRef = 71FB967A1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h */; };
                724ED32C1A3A7E5400F5F13C /* EXTBlendMinMax.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 724ED3291A3A7E5400F5F13C /* EXTBlendMinMax.cpp */; };
                71E2C42421C9351D0024F8C8 /* AnimationEffectPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationEffectPhase.h; sourceTree = "<group>"; };
                71E623CE151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedIntegerOptionalInteger.cpp; sourceTree = "<group>"; };
                71E623CF151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedIntegerOptionalInteger.h; sourceTree = "<group>"; };
+               71EADCD622087E6D0065A45F /* PointerID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointerID.h; sourceTree = "<group>"; };
                71EFCED6202B388C00D7C411 /* AnimationEffect.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AnimationEffect.idl; sourceTree = "<group>"; };
                71EFCED7202B388D00D7C411 /* AnimationEffect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationEffect.h; sourceTree = "<group>"; };
                71EFCEDA202B388F00D7C411 /* AnimationEffect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AnimationEffect.cpp; sourceTree = "<group>"; };
                                317D3FF1215599E20034E3B9 /* PointerEvent.cpp */,
                                317D3FF2215599E30034E3B9 /* PointerEvent.h */,
                                317D3FEF215599E10034E3B9 /* PointerEvent.idl */,
+                               71EADCD622087E6D0065A45F /* PointerID.h */,
                                5189F0DD10B46B0E00F3C739 /* PopStateEvent.cpp */,
                                5174E20810A1F44F00F95E6F /* PopStateEvent.h */,
                                5174E20B10A1F49A00F95E6F /* PopStateEvent.idl */,
                                1A85B1E70A1B240500D8C87C /* JSHTMLDirectoryElement.h in Headers */,
                                1A85B2B70A1B2AC700D8C87C /* JSHTMLDivElement.h in Headers */,
                                1A85B1E90A1B240500D8C87C /* JSHTMLDListElement.h in Headers */,
+                               71EADCD822087E720065A45F /* PointerID.h in Headers */,
                                1A494E350A12358B00FDAFC1 /* JSHTMLDocument.h in Headers */,
                                1A494BFB0A122F4400FDAFC1 /* JSHTMLElement.h in Headers */,
                                938E65F109F09840008A48EC /* JSHTMLElementWrapperFactory.h in Headers */,
index 3bcfa95..64fac5f 100644 (file)
@@ -28,6 +28,7 @@
 #if ENABLE(POINTER_EVENTS)
 
 #include "MouseEvent.h"
+#include "PointerID.h"
 #include <wtf/text/WTFString.h>
 
 #if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
@@ -39,7 +40,7 @@ namespace WebCore {
 class PointerEvent final : public MouseEvent {
 public:
     struct Init : MouseEventInit {
-        int32_t pointerId { 0 };
+        PointerID pointerId { 0 };
         double width { 1 };
         double height { 1 };
         float pressure { 0 };
@@ -56,7 +57,7 @@ public:
         return adoptRef(*new PointerEvent(type, WTFMove(initializer)));
     }
 
-    static Ref<PointerEvent> create(const AtomicString& type, int32_t pointerId, String pointerType)
+    static Ref<PointerEvent> create(const AtomicString& type, PointerID pointerId, String pointerType)
     {
         Init initializer;
         initializer.bubbles = true;
@@ -86,7 +87,7 @@ public:
 
     virtual ~PointerEvent();
 
-    int32_t pointerId() const { return m_pointerId; }
+    PointerID pointerId() const { return m_pointerId; }
     double width() const { return m_width; }
     double height() const { return m_height; }
     float pressure() const { return m_pressure; }
@@ -108,7 +109,7 @@ private:
     PointerEvent(const AtomicString& type, const PlatformTouchEvent&, IsCancelable isCancelable, unsigned touchIndex, bool isPrimary, Ref<WindowProxy>&&);
 #endif
 
-    int32_t m_pointerId { 0 };
+    PointerID m_pointerId { 0 };
     double m_width { 1 };
     double m_height { 1 };
     float m_pressure { 0 };
diff --git a/Source/WebCore/dom/PointerID.h b/Source/WebCore/dom/PointerID.h
new file mode 100644 (file)
index 0000000..20da947
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2019 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. ``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
+ * 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
+
+#if ENABLE(POINTER_EVENTS)
+
+namespace WebCore {
+
+using PointerID = int32_t;
+
+}
+
+#endif // ENABLE(POINTER_EVENTS)
index 1c95922..edcc3ff 100644 (file)
@@ -42,7 +42,7 @@ PointerCaptureController::PointerCaptureController(Page& page)
 {
 }
 
-ExceptionOr<void> PointerCaptureController::setPointerCapture(Element* capturingTarget, int32_t pointerId)
+ExceptionOr<void> PointerCaptureController::setPointerCapture(Element* capturingTarget, PointerID pointerId)
 {
     // https://w3c.github.io/pointerevents/#setting-pointer-capture
 
@@ -72,7 +72,7 @@ ExceptionOr<void> PointerCaptureController::setPointerCapture(Element* capturing
     return { };
 }
 
-ExceptionOr<void> PointerCaptureController::releasePointerCapture(Element* capturingTarget, int32_t pointerId)
+ExceptionOr<void> PointerCaptureController::releasePointerCapture(Element* capturingTarget, PointerID pointerId)
 {
     // https://w3c.github.io/pointerevents/#releasing-pointer-capture
 
@@ -95,7 +95,7 @@ ExceptionOr<void> PointerCaptureController::releasePointerCapture(Element* captu
     return { };
 }
 
-bool PointerCaptureController::hasPointerCapture(Element* capturingTarget, int32_t pointerId)
+bool PointerCaptureController::hasPointerCapture(Element* capturingTarget, PointerID pointerId)
 {
     // https://w3c.github.io/pointerevents/#dom-element-haspointercapture
 
@@ -123,12 +123,12 @@ void PointerCaptureController::pointerLockWasApplied()
     }
 }
 
-void PointerCaptureController::touchEndedOrWasCancelledForIdentifier(int32_t pointerId)
+void PointerCaptureController::touchEndedOrWasCancelledForIdentifier(PointerID pointerId)
 {
     m_activePointerIdsToCapturingData.remove(pointerId);
 }
 
-bool PointerCaptureController::hasCancelledPointerEventForIdentifier(int32_t pointerId)
+bool PointerCaptureController::hasCancelledPointerEventForIdentifier(PointerID pointerId)
 {
     auto iterator = m_activePointerIdsToCapturingData.find(pointerId);
     return iterator != m_activePointerIdsToCapturingData.end() && iterator->value.cancelled;
@@ -183,7 +183,7 @@ void PointerCaptureController::pointerEventWasDispatched(const PointerEvent& eve
     processPendingPointerCapture(event);
 }
 
-void PointerCaptureController::cancelPointer(int32_t pointerId, const IntPoint& documentPoint)
+void PointerCaptureController::cancelPointer(PointerID pointerId, const IntPoint& documentPoint)
 {
     // https://w3c.github.io/pointerevents/#the-pointercancel-event
 
index 720a577..5cfb1e9 100644 (file)
@@ -26,6 +26,7 @@
 
 #if ENABLE(POINTER_EVENTS)
 
+#include "PointerID.h"
 #include <wtf/HashMap.h>
 
 namespace WebCore {
@@ -40,17 +41,17 @@ class PointerCaptureController {
 public:
     explicit PointerCaptureController(Page&);
 
-    ExceptionOr<void> setPointerCapture(Element*, int32_t);
-    ExceptionOr<void> releasePointerCapture(Element*, int32_t);
-    bool hasPointerCapture(Element*, int32_t);
+    ExceptionOr<void> setPointerCapture(Element*, PointerID);
+    ExceptionOr<void> releasePointerCapture(Element*, PointerID);
+    bool hasPointerCapture(Element*, PointerID);
 
     void pointerLockWasApplied();
 
-    void touchEndedOrWasCancelledForIdentifier(int32_t);
-    bool hasCancelledPointerEventForIdentifier(int32_t);
+    void touchEndedOrWasCancelledForIdentifier(PointerID);
+    bool hasCancelledPointerEventForIdentifier(PointerID);
     void pointerEventWillBeDispatched(const PointerEvent&, EventTarget*);
     void pointerEventWasDispatched(const PointerEvent&);
-    WEBCORE_EXPORT void cancelPointer(int32_t, const IntPoint&);
+    WEBCORE_EXPORT void cancelPointer(PointerID, const IntPoint&);
 
 private:
     struct CapturingData {
@@ -63,7 +64,7 @@ private:
     void processPendingPointerCapture(const PointerEvent&);
 
     Page& m_page;
-    HashMap<int32_t, CapturingData> m_activePointerIdsToCapturingData;
+    HashMap<PointerID, CapturingData> m_activePointerIdsToCapturingData;
 };
 
 } // namespace WebCore
index 9f125cc..b9b0417 100644 (file)
@@ -1,3 +1,19 @@
+2019-02-04  Antoine Quint  <graouts@apple.com>
+
+        Use a dedicated type instead of int32_t for pointer identifiers
+        https://bugs.webkit.org/show_bug.cgi?id=194217
+
+        Reviewed by Antti Koivisto.
+
+        * Scripts/webkit/messages.py:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::cancelPointer):
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::cancelPointer):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2019-02-04  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Unreviewed, avoid -Wswitch warnings introduced in r240880
index 23ad225..8a5eb60 100644 (file)
@@ -199,6 +199,7 @@ def forward_declarations_and_headers(receiver):
         'String',
         'WebCore::DocumentIdentifier',
         'WebCore::FetchIdentifier',
+        'WebCore::PointerID',
         'WebCore::ServiceWorkerIdentifier',
         'WebCore::ServiceWorkerJobIdentifier',
         'WebCore::ServiceWorkerOrClientData',
index 6a15c80..369b33c 100644 (file)
@@ -2650,7 +2650,7 @@ void WebPageProxy::handleTouchEvent(const NativeWebTouchEvent& event)
 #endif // ENABLE(TOUCH_EVENTS)
 
 #if ENABLE(POINTER_EVENTS)
-void WebPageProxy::cancelPointer(int32_t pointerId, const WebCore::IntPoint& documentPoint)
+void WebPageProxy::cancelPointer(WebCore::PointerID pointerId, const WebCore::IntPoint& documentPoint)
 {
     m_process->send(Messages::WebPage::CancelPointer(pointerId, documentPoint), m_pageID);
 }
index a7f9c5d..841f2a5 100644 (file)
@@ -81,6 +81,7 @@
 #include <WebCore/MediaPlaybackTargetContext.h>
 #include <WebCore/MediaProducer.h>
 #include <WebCore/PlatformScreen.h>
+#include <WebCore/PointerID.h>
 #include <WebCore/ScrollTypes.h>
 #include <WebCore/SearchPopupMenu.h>
 #include <WebCore/TextChecking.h>
@@ -791,7 +792,7 @@ public:
 #endif
 
 #if ENABLE(POINTER_EVENTS)
-    void cancelPointer(int32_t, const WebCore::IntPoint&);
+    void cancelPointer(WebCore::PointerID, const WebCore::IntPoint&);
 #endif
 
     void scrollBy(WebCore::ScrollDirection, WebCore::ScrollGranularity);
index 512128a..e8b570e 100644 (file)
@@ -2816,7 +2816,7 @@ void WebPage::touchEvent(const WebTouchEvent& touchEvent)
 #endif
 
 #if ENABLE(POINTER_EVENTS)
-void WebPage::cancelPointer(int32_t pointerId, const WebCore::IntPoint& documentPoint)
+void WebPage::cancelPointer(WebCore::PointerID pointerId, const WebCore::IntPoint& documentPoint)
 {
     m_page->pointerCaptureController().cancelPointer(pointerId, documentPoint);
 }
index c711456..4277c9d 100644 (file)
@@ -65,6 +65,7 @@
 #include <WebCore/Page.h>
 #include <WebCore/PageOverlay.h>
 #include <WebCore/PluginData.h>
+#include <WebCore/PointerID.h>
 #include <WebCore/SecurityPolicyViolationEvent.h>
 #include <WebCore/ShareData.h>
 #include <WebCore/UserActivity.h>
@@ -1251,7 +1252,7 @@ private:
 #endif
 
 #if ENABLE(POINTER_EVENTS)
-    void cancelPointer(int32_t, const WebCore::IntPoint&);
+    void cancelPointer(WebCore::PointerID, const WebCore::IntPoint&);
 #endif
 
 #if ENABLE(CONTEXT_MENUS)
index 2fbe145..776ed75 100644 (file)
@@ -128,7 +128,7 @@ messages -> WebPage LegacyReceiver {
 #endif
 
 #if ENABLE(POINTER_EVENTS)
-    CancelPointer(int32_t pointerId, WebCore::IntPoint documentPoint)
+    CancelPointer(WebCore::PointerID pointerId, WebCore::IntPoint documentPoint)
 #endif
 
 #if ENABLE(INPUT_TYPE_COLOR)