Title: [240943] trunk/Source/WebCore
Revision
240943
Author
grao...@webkit.org
Date
2019-02-04 14:28:32 -0800 (Mon, 04 Feb 2019)

Log Message

Use constants for pointer types
https://bugs.webkit.org/show_bug.cgi?id=194232

Reviewed by Dean Jackson.

We cannot use an enum for the pointer type since a custom pointer type can be created by developers when creating a
pointer event using _javascript_, but we can at least used string constants for the ones created internally.

* dom/PointerEvent.cpp:
(WebCore::PointerEvent::mousePointerType):
(WebCore::PointerEvent::penPointerType):
(WebCore::PointerEvent::touchPointerType):
* dom/PointerEvent.h:
* dom/ios/PointerEventIOS.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (240942 => 240943)


--- trunk/Source/WebCore/ChangeLog	2019-02-04 22:19:41 UTC (rev 240942)
+++ trunk/Source/WebCore/ChangeLog	2019-02-04 22:28:32 UTC (rev 240943)
@@ -1,3 +1,20 @@
+2019-02-04  Antoine Quint  <grao...@apple.com>
+
+        Use constants for pointer types
+        https://bugs.webkit.org/show_bug.cgi?id=194232
+
+        Reviewed by Dean Jackson.
+
+        We cannot use an enum for the pointer type since a custom pointer type can be created by developers when creating a
+        pointer event using _javascript_, but we can at least used string constants for the ones created internally.
+
+        * dom/PointerEvent.cpp:
+        (WebCore::PointerEvent::mousePointerType):
+        (WebCore::PointerEvent::penPointerType):
+        (WebCore::PointerEvent::touchPointerType):
+        * dom/PointerEvent.h:
+        * dom/ios/PointerEventIOS.cpp:
+
 2019-02-04  Zalan Bujtas  <za...@apple.com>
 
         [First paint] Adjust "finishedParsingMainDocument" flag by taking deferred and async scripts into account.

Modified: trunk/Source/WebCore/dom/PointerEvent.cpp (240942 => 240943)


--- trunk/Source/WebCore/dom/PointerEvent.cpp	2019-02-04 22:19:41 UTC (rev 240942)
+++ trunk/Source/WebCore/dom/PointerEvent.cpp	2019-02-04 22:28:32 UTC (rev 240943)
@@ -30,6 +30,24 @@
 
 namespace WebCore {
 
+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;
+}
+
 PointerEvent::PointerEvent() = default;
 
 PointerEvent::PointerEvent(const AtomicString& type, Init&& initializer)

Modified: trunk/Source/WebCore/dom/PointerEvent.h (240942 => 240943)


--- trunk/Source/WebCore/dom/PointerEvent.h	2019-02-04 22:19:41 UTC (rev 240942)
+++ trunk/Source/WebCore/dom/PointerEvent.h	2019-02-04 22:28:32 UTC (rev 240943)
@@ -48,7 +48,7 @@
         long tiltX { 0 };
         long tiltY { 0 };
         long twist { 0 };
-        String pointerType { "mouse"_s };
+        String pointerType { PointerEvent::mousePointerType() };
         bool isPrimary { false };
     };
 
@@ -85,6 +85,10 @@
     static Ref<PointerEvent> create(const PlatformTouchEvent&, unsigned touchIndex, bool isPrimary, Ref<WindowProxy>&&);
 #endif
 
+    static const String& mousePointerType();
+    static const String& penPointerType();
+    static const String& touchPointerType();
+
     virtual ~PointerEvent();
 
     PointerID pointerId() const { return m_pointerId; }
@@ -117,7 +121,7 @@
     long m_tiltX { 0 };
     long m_tiltY { 0 };
     long m_twist { 0 };
-    String m_pointerType { "mouse"_s };
+    String m_pointerType { PointerEvent::mousePointerType() };
     bool m_isPrimary { false };
 };
 

Modified: trunk/Source/WebCore/dom/ios/PointerEventIOS.cpp (240942 => 240943)


--- trunk/Source/WebCore/dom/ios/PointerEventIOS.cpp	2019-02-04 22:19:41 UTC (rev 240942)
+++ trunk/Source/WebCore/dom/ios/PointerEventIOS.cpp	2019-02-04 22:28:32 UTC (rev 240943)
@@ -69,7 +69,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 ? "pen"_s : "touch"_s)
+    , m_pointerType(event.touchTypeAtIndex(index) == PlatformTouchPoint::TouchType::Stylus ? PointerEvent::penPointerType() : PointerEvent::touchPointerType())
     , m_isPrimary(isPrimary)
 {
     // See https://github.com/w3c/pointerevents/issues/274. We might expose the azimuth and altitude
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to