[WK2][iOS] Add radiusX / radiusY / rotationAngle to WebPlatformTouchPoint
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Sep 2016 19:19:44 +0000 (19:19 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Sep 2016 19:19:44 +0000 (19:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162787
<rdar://problem/28554292>

Reviewed by Benjamin Poulain.

Source/WebKit2:

Add radiusX / radiusY / rotationAngle to WebPlatformTouchPoint.

* Platform/spi/ios/UIKitSPI.h:
* Shared/WebEvent.h:
(WebKit::WebPlatformTouchPoint::setRadiusX):
(WebKit::WebPlatformTouchPoint::radiusX):
(WebKit::WebPlatformTouchPoint::setRadiusY):
(WebKit::WebPlatformTouchPoint::radiusY):
(WebKit::WebPlatformTouchPoint::setRotationAngle):
(WebKit::WebPlatformTouchPoint::rotationAngle):
* Shared/WebEventConversion.cpp:
(WebKit::WebKit2PlatformTouchPoint::WebKit2PlatformTouchPoint):
* Shared/ios/NativeWebTouchEventIOS.mm:
(WebKit::NativeWebTouchEvent::extractWebTouchPoint):
* Shared/ios/WebPlatformTouchPointIOS.cpp:
(WebKit::WebPlatformTouchPoint::encode):
(WebKit::WebPlatformTouchPoint::decode):

LayoutTests:

Extend Touch constructor test coverage to cover radiusX / radiusY / rotationAngle
attributes.

* fast/events/touch/touch-constructor.html:

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

LayoutTests/ChangeLog
LayoutTests/fast/events/touch/touch-constructor.html
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/spi/ios/UIKitSPI.h
Source/WebKit2/Shared/WebEvent.h
Source/WebKit2/Shared/WebEventConversion.cpp
Source/WebKit2/Shared/ios/NativeWebTouchEventIOS.mm
Source/WebKit2/Shared/ios/WebPlatformTouchPointIOS.cpp

index 8cab438..dc5bc75 100644 (file)
@@ -1,3 +1,16 @@
+2016-09-30  Chris Dumez  <cdumez@apple.com>
+
+        [WK2][iOS] Add radiusX / radiusY / rotationAngle to WebPlatformTouchPoint
+        https://bugs.webkit.org/show_bug.cgi?id=162787
+        <rdar://problem/28554292>
+
+        Reviewed by Benjamin Poulain.
+
+        Extend Touch constructor test coverage to cover radiusX / radiusY / rotationAngle
+        attributes.
+
+        * fast/events/touch/touch-constructor.html:
+
 2016-09-30  Saam Barati  <sbarati@apple.com>
 
         Arrow functions should not allow duplicate parameter names
index 81e1f38..735467e 100644 (file)
@@ -25,14 +25,6 @@ function validateTouch(touch, dictionary)
         shouldBe("createdTouch.screenX", "init.screenX");
     else
         shouldBe("createdTouch.screenX", "0");
-    if (init.hasOwnProperty("screenX"))
-        shouldBe("createdTouch.screenX", "init.screenX");
-    else
-        shouldBe("createdTouch.screenX", "0");
-    if (init.hasOwnProperty("screenX"))
-        shouldBe("createdTouch.screenX", "init.screenX");
-    else
-        shouldBe("createdTouch.screenX", "0");
     if (init.hasOwnProperty("screenY"))
         shouldBe("createdTouch.screenY", "init.screenY");
     else
@@ -53,6 +45,18 @@ function validateTouch(touch, dictionary)
         shouldBe("createdTouch.clientY", "init.clientY");
     else
         shouldBe("createdTouch.clientY", "0");
+    if (init.hasOwnProperty("radiusX"))
+        shouldBe("createdTouch.radiusX", "init.radiusX");
+    else
+        shouldBe("createdTouch.radiusX", "0");
+    if (init.hasOwnProperty("radiusY"))
+        shouldBe("createdTouch.radiusY", "init.radiusY");
+    else
+        shouldBe("createdTouch.radiusY", "0");
+    if (init.hasOwnProperty("rotationAngle"))
+        shouldBe("createdTouch.rotationAngle", "init.rotationAngle");
+    else
+        shouldBe("createdTouch.rotationAngle", "0");
     if (init.hasOwnProperty("force"))
         shouldBe("createdTouch.force", "init.force");
     else
@@ -64,12 +68,12 @@ shouldNotThrow("touch = new Touch({ identifier: 1, target: document.body })");
 validateTouch(touch, { identifier: 1, target: document.body });
 
 debug("");
-shouldNotThrow("touch = new Touch({ identifier: 1, target: document.body, clientX: 1, clientY: 2, screenX: 3, screenY: 4, pageX: 5, pageY: 6, force: 7 })");
-validateTouch(touch, { identifier: 1, target: document.body, clientX: 1, clientY: 2, screenX: 3, screenY: 4, pageX: 5, pageY: 6, force: 7 });
+shouldNotThrow("touch = new Touch({ identifier: 1, target: document.body, clientX: 1, clientY: 2, screenX: 3, screenY: 4, pageX: 5, pageY: 6, force: 7, radiusX: 8, radiusY: 9, rotationAngle: 10 })");
+validateTouch(touch, { identifier: 1, target: document.body, clientX: 1, clientY: 2, screenX: 3, screenY: 4, pageX: 5, pageY: 6, force: 7, radiusX: 8, radiusY: 9, rotationAngle: 10 });
 
 debug("");
-shouldNotThrow("touch = new Touch({ identifier: 1, target: document.body, clientX: 1.5, clientY: 2.5, screenX: 3.5, screenY: 4.5, pageX: 5.5, pageY: 6.5, force: 7.5, clientX: 8.5, clientY: 9.5 })");
-validateTouch(touch, { identifier: 1, target: document.body, clientX: 1.5, clientY: 2.5, screenX: 3.5, screenY: 4.5, pageX: 5.5, pageY: 6.5, force: 7.5, clientX: 8.5, clientY: 9.5 });
+shouldNotThrow("touch = new Touch({ identifier: 1, target: document.body, clientX: 1.5, clientY: 2.5, screenX: 3.5, screenY: 4.5, pageX: 5.5, pageY: 6.5, force: 7.5, radiusX: 8.5, radiusY: 9.5, rotationAngle: 10.5 })");
+validateTouch(touch, { identifier: 1, target: document.body, clientX: 1.5, clientY: 2.5, screenX: 3.5, screenY: 4.5, pageX: 5.5, pageY: 6.5, force: 7.5, radiusX: 8.5, radiusY: 9.5, rotationAngle: 10.5 });
 </script>
 <script src="../../../resources/js-test-post.js"></script>
 </body>
index 5ed9d01..a80b428 100644 (file)
@@ -1,3 +1,29 @@
+2016-09-30  Chris Dumez  <cdumez@apple.com>
+
+        [WK2][iOS] Add radiusX / radiusY / rotationAngle to WebPlatformTouchPoint
+        https://bugs.webkit.org/show_bug.cgi?id=162787
+        <rdar://problem/28554292>
+
+        Reviewed by Benjamin Poulain.
+
+        Add radiusX / radiusY / rotationAngle to WebPlatformTouchPoint.
+
+        * Platform/spi/ios/UIKitSPI.h:
+        * Shared/WebEvent.h:
+        (WebKit::WebPlatformTouchPoint::setRadiusX):
+        (WebKit::WebPlatformTouchPoint::radiusX):
+        (WebKit::WebPlatformTouchPoint::setRadiusY):
+        (WebKit::WebPlatformTouchPoint::radiusY):
+        (WebKit::WebPlatformTouchPoint::setRotationAngle):
+        (WebKit::WebPlatformTouchPoint::rotationAngle):
+        * Shared/WebEventConversion.cpp:
+        (WebKit::WebKit2PlatformTouchPoint::WebKit2PlatformTouchPoint):
+        * Shared/ios/NativeWebTouchEventIOS.mm:
+        (WebKit::NativeWebTouchEvent::extractWebTouchPoint):
+        * Shared/ios/WebPlatformTouchPointIOS.cpp:
+        (WebKit::WebPlatformTouchPoint::encode):
+        (WebKit::WebPlatformTouchPoint::decode):
+
 2016-09-30  Megan Gardner  <megan_gardner@apple.com>
 
         Make it possible to test web-related user-interface features
index dc85961..4a96601 100644 (file)
@@ -654,6 +654,8 @@ struct _UIWebTouchPoint {
     unsigned identifier;
     UITouchPhase phase;
 #if __IPHONE_OS_VERSION_MIN_REQUIRED > 100000
+    // FIXME: Uncomment this once UIKit is updated (rdar://problem/28555313).
+    // CGFloat majorRadiusInScreenCoordinates;
     CGFloat force;
     CGFloat altitudeAngle;
     CGFloat azimuthAngle;
index 0da9b15..b004b50 100644 (file)
@@ -325,6 +325,12 @@ public:
     TouchPointState state() const { return phase(); }
 
 #if ENABLE(IOS_TOUCH_EVENTS)
+    void setRadiusX(double radiusX) { m_radiusX = radiusX; }
+    double radiusX() const { return m_radiusX; }
+    void setRadiusY(double radiusY) { m_radiusY = radiusY; }
+    double radiusY() const { return m_radiusY; }
+    void setRotationAngle(double rotationAngle) { m_rotationAngle = rotationAngle; }
+    double rotationAngle() const { return m_rotationAngle; }
     void setForce(double force) { m_force = force; }
     double force() const { return m_force; }
     void setAltitudeAngle(double altitudeAngle) { m_altitudeAngle = altitudeAngle; }
@@ -343,6 +349,9 @@ private:
     WebCore::IntPoint m_location;
     uint32_t m_phase;
 #if ENABLE(IOS_TOUCH_EVENTS)
+    double m_radiusX { 0 };
+    double m_radiusY { 0 };
+    double m_rotationAngle { 0 };
     double m_force { 0 };
     double m_altitudeAngle { 0 };
     double m_azimuthAngle { 0 };
index deb8faf..5d3fc00 100644 (file)
@@ -243,7 +243,7 @@ public:
 WebKit2PlatformTouchPoint(const WebPlatformTouchPoint& webTouchPoint)
     : PlatformTouchPoint(webTouchPoint.identifier(), webTouchPoint.location(), touchEventType(webTouchPoint)
 #if ENABLE(IOS_TOUCH_EVENTS)
-        , webTouchPoint.force(), webTouchPoint.altitudeAngle(), webTouchPoint.azimuthAngle(), webPlatformTouchTypeToPlatform(webTouchPoint.touchType())
+        , webTouchPoint.radiusX(), webTouchPoint.radiusY(), webTouchPoint.rotationAngle(), webTouchPoint.force(), webTouchPoint.altitudeAngle(), webTouchPoint.azimuthAngle(), webPlatformTouchTypeToPlatform(webTouchPoint.touchType())
 #endif
     )
 {
index 2e2efe2..19dc104 100644 (file)
@@ -103,6 +103,10 @@ Vector<WebPlatformTouchPoint> NativeWebTouchEvent::extractWebTouchPoint(const _U
         WebPlatformTouchPoint::TouchPointState phase = convertTouchPhase(touchPoint.phase);
         WebPlatformTouchPoint platformTouchPoint = WebPlatformTouchPoint(identifier, location, phase);
 #if ENABLE(IOS_TOUCH_EVENTS)
+        // FIXME: We should use touchPoint.majorRadiusInScreenCoordinates for radiusX / radiusY once it is available (rdar://problem/28555313).
+        platformTouchPoint.setRadiusX(0);
+        platformTouchPoint.setRadiusY(0);
+        platformTouchPoint.setRotationAngle(0); // Not available in _UIWebTouchEvent yet.
         platformTouchPoint.setForce(touchPoint.force);
 #if defined UI_WEB_TOUCH_EVENT_HAS_STYLUS_DATA && UI_WEB_TOUCH_EVENT_HAS_STYLUS_DATA
         platformTouchPoint.setAltitudeAngle(touchPoint.altitudeAngle);
index 0c3f1a6..2c0493c 100644 (file)
@@ -40,6 +40,9 @@ void WebPlatformTouchPoint::encode(IPC::Encoder& encoder) const
     encoder << m_location;
     encoder << m_phase;
 #if ENABLE(IOS_TOUCH_EVENTS)
+    encoder << m_radiusX;
+    encoder << m_radiusY;
+    encoder << m_rotationAngle;
     encoder << m_force;
     encoder << m_altitudeAngle;
     encoder << m_azimuthAngle;
@@ -56,6 +59,12 @@ bool WebPlatformTouchPoint::decode(IPC::Decoder& decoder, WebPlatformTouchPoint&
     if (!decoder.decode(result.m_phase))
         return false;
 #if ENABLE(IOS_TOUCH_EVENTS)
+    if (!decoder.decode(result.m_radiusX))
+        return false;
+    if (!decoder.decode(result.m_radiusY))
+        return false;
+    if (!decoder.decode(result.m_rotationAngle))
+        return false;
     if (!decoder.decode(result.m_force))
         return false;
     if (!decoder.decode(result.m_altitudeAngle))