Diff
Modified: trunk/LayoutTests/ChangeLog (205765 => 205766)
--- trunk/LayoutTests/ChangeLog 2016-09-09 20:46:23 UTC (rev 205765)
+++ trunk/LayoutTests/ChangeLog 2016-09-09 20:57:50 UTC (rev 205766)
@@ -1,3 +1,22 @@
+2016-09-08 Dean Jackson <[email protected]>
+
+ Expose Apple Pencil data to Touch events
+ https://bugs.webkit.org/show_bug.cgi?id=161783
+ <rdar://problem/28218898>
+
+ Reviewed by Beth Dakin.
+
+ Four new tests that check data coming out of an Apple Pencil.
+
+ * fast/events/touch/ios/pencil-data-change-does-not-give-touchmove-expected.txt: Added.
+ * fast/events/touch/ios/pencil-data-change-does-not-give-touchmove.html: Added.
+ * fast/events/touch/ios/pencil-data-change-gives-touchforcechange-expected.txt: Added.
+ * fast/events/touch/ios/pencil-data-change-gives-touchforcechange.html: Added.
+ * fast/events/touch/ios/pencil-move-provides-stylus-data-expected.txt: Added.
+ * fast/events/touch/ios/pencil-move-provides-stylus-data.html: Added.
+ * fast/events/touch/ios/pencil-touch-registered-as-pencil-expected.txt: Added.
+ * fast/events/touch/ios/pencil-touch-registered-as-pencil.html: Added.
+
2016-09-09 Tim Horton <[email protected]>
Text replacement candidates don't always overwrite the entire original string
Added: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove-expected.txt (0 => 205766)
--- trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove-expected.txt 2016-09-09 20:57:50 UTC (rev 205766)
@@ -0,0 +1,18 @@
+Test that an Apple Pencil that changes pressure + angles does not generate a touchmove.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+ touchstart fired.
+PASS event.touches.length is 1
+PASS event.touches[0].touchType is 'stylus'
+PASS event.touches[0].altitudeAngle is within 0.01 of 1
+PASS event.touches[0].azimuthAngle is within 0.01 of 2
+PASS event.touches[0].force is within 0.01 of 0.5
+PASS: Did not see a touchmove.
+touchend fired.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove-expected.txt
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Revision
\ No newline at end of property
Added: svn:mime-type
+text/plain
\ No newline at end of property
Added: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove.html (0 => 205766)
--- trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove.html (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove.html 2016-09-09 20:57:50 UTC (rev 205766)
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+ <script src=""
+ <style>
+ body {
+ margin: none;
+ }
+ </style>
+ <meta name="viewport" content="initial-scale=1">
+</head>
+<body>
+ <p id="description"></p>
+ <div id="console">
+ </div>
+ <script>
+ description("Test that an Apple Pencil that changes pressure + angles does not generate a touchmove.");
+ window.jsTestIsAsync = true;
+
+ function getUIScript(x, y)
+ {
+ return `
+ (function() {
+ uiController.stylusDownAtPoint(${x}, ${y}, 2, 1, 0.5, function () {});
+ uiController.stylusMoveToPoint(${x}, ${y}, 2.1, 1.1, 0.6, function () {});
+ uiController.stylusUpAtPoint(${x}, ${y}, function () {});
+ })();`
+ }
+
+ function runTest()
+ {
+ var failed = false;
+ window.addEventListener("touchstart", (event) => {
+ debug("touchstart fired.");
+ shouldBe("event.touches.length", "1");
+ shouldBe("event.touches[0].touchType", "'stylus'");
+ shouldBeCloseTo("event.touches[0].altitudeAngle", 1, 0.01);
+ shouldBeCloseTo("event.touches[0].azimuthAngle", 2, 0.01);
+ shouldBeCloseTo("event.touches[0].force", 0.5, 0.01);
+ });
+
+ window.addEventListener("touchmove", (event) => {
+ debug("FAIL: touchmove fired.");
+ failed = true;
+ });
+
+ window.addEventListener("touchend", (event) => {
+ if (!failed)
+ debug("PASS: Did not see a touchmove.");
+ debug("touchend fired.");
+ finishJSTest();
+ });
+
+ if (window.testRunner)
+ testRunner.runUIScript(getUIScript(50, 200), function(result) { });
+ }
+
+ window.addEventListener("load", runTest, false);
+ </script>
+ <script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove.html
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Revision
\ No newline at end of property
Added: svn:mime-type
+text/html
\ No newline at end of property
Added: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange-expected.txt (0 => 205766)
--- trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange-expected.txt 2016-09-09 20:57:50 UTC (rev 205766)
@@ -0,0 +1,23 @@
+Test that an Apple Pencil produces touchforcechange events.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+ touchstart fired.
+PASS event.touches.length is 1
+PASS event.touches[0].touchType is 'stylus'
+PASS event.touches[0].altitudeAngle is within 0.01 of 1
+PASS event.touches[0].azimuthAngle is within 0.01 of 2
+PASS event.touches[0].force is within 0.01 of 0.5
+touchforcechange fired.
+PASS event.touches.length is 1
+PASS event.touches[0].touchType is 'stylus'
+PASS event.touches[0].altitudeAngle is within 0.01 of 1.1
+PASS event.touches[0].azimuthAngle is within 0.01 of 2.1
+PASS event.touches[0].force is within 0.01 of 0.6
+touchend fired.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange-expected.txt
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Revision
\ No newline at end of property
Added: svn:mime-type
+text/plain
\ No newline at end of property
Added: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange.html (0 => 205766)
--- trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange.html (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange.html 2016-09-09 20:57:50 UTC (rev 205766)
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+ <script src=""
+ <style>
+ body {
+ margin: none;
+ }
+ </style>
+ <meta name="viewport" content="initial-scale=1">
+</head>
+<body>
+ <p id="description"></p>
+ <div id="console">
+ </div>
+ <script>
+ description("Test that an Apple Pencil produces touchforcechange events.");
+ window.jsTestIsAsync = true;
+
+ function getUIScript(x, y)
+ {
+ return `
+ (function() {
+ uiController.stylusDownAtPoint(${x}, ${y}, 2, 1, 0.5, function () {});
+ uiController.stylusMoveToPoint(${x}, ${y}, 2.1, 1.1, 0.6, function () {});
+ uiController.stylusUpAtPoint(${x}, ${y}, function () {});
+ })();`
+ }
+
+ function runTest()
+ {
+ window.addEventListener("touchstart", (event) => {
+ debug("touchstart fired.");
+ shouldBe("event.touches.length", "1");
+ shouldBe("event.touches[0].touchType", "'stylus'");
+ shouldBeCloseTo("event.touches[0].altitudeAngle", 1, 0.01);
+ shouldBeCloseTo("event.touches[0].azimuthAngle", 2, 0.01);
+ shouldBeCloseTo("event.touches[0].force", 0.5, 0.01);
+ });
+
+ window.addEventListener("touchforcechange", (event) => {
+ debug("touchforcechange fired.");
+ shouldBe("event.touches.length", "1");
+ shouldBe("event.touches[0].touchType", "'stylus'");
+ shouldBeCloseTo("event.touches[0].altitudeAngle", 1.1, 0.01);
+ shouldBeCloseTo("event.touches[0].azimuthAngle", 2.1, 0.01);
+ shouldBeCloseTo("event.touches[0].force", 0.6, 0.01);
+ });
+
+ window.addEventListener("touchend", (event) => {
+ debug("touchend fired.");
+ finishJSTest();
+ });
+
+ if (window.testRunner)
+ testRunner.runUIScript(getUIScript(50, 200), function(result) { });
+ }
+
+ window.addEventListener("load", runTest, false);
+ </script>
+ <script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange.html
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Revision
\ No newline at end of property
Added: svn:mime-type
+text/html
\ No newline at end of property
Added: trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data-expected.txt (0 => 205766)
--- trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data-expected.txt 2016-09-09 20:57:50 UTC (rev 205766)
@@ -0,0 +1,23 @@
+Test that a moving Apple Pencil provides stylus information.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+ touchstart fired.
+PASS event.touches.length is 1
+PASS event.touches[0].touchType is 'stylus'
+PASS event.touches[0].altitudeAngle is within 0.01 of 1
+PASS event.touches[0].azimuthAngle is within 0.01 of 2
+PASS event.touches[0].force is within 0.01 of 0.5
+touchmove fired.
+PASS event.touches.length is 1
+PASS event.touches[0].touchType is 'stylus'
+PASS event.touches[0].altitudeAngle is within 0.01 of 1.1
+PASS event.touches[0].azimuthAngle is within 0.01 of 2.1
+PASS event.touches[0].force is within 0.01 of 0.6
+touchend fired.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data-expected.txt
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Revision
\ No newline at end of property
Added: svn:mime-type
+text/plain
\ No newline at end of property
Added: trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data.html (0 => 205766)
--- trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data.html (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data.html 2016-09-09 20:57:50 UTC (rev 205766)
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+ <script src=""
+ <style>
+ body {
+ margin: none;
+ }
+ </style>
+ <meta name="viewport" content="initial-scale=1">
+</head>
+<body>
+ <p id="description"></p>
+ <div id="console">
+ </div>
+ <script>
+ description("Test that a moving Apple Pencil provides stylus information.");
+ window.jsTestIsAsync = true;
+
+ function getUIScript(x, y)
+ {
+ return `
+ (function() {
+ uiController.stylusDownAtPoint(${x}, ${y}, 2, 1, 0.5, function () {});
+ uiController.stylusMoveToPoint(${x + 1}, ${y + 1}, 2.1, 1.1, 0.6, function () {});
+ uiController.stylusUpAtPoint(${x + 10}, ${y + 10}, function () {});
+ })();`
+ }
+
+ function runTest()
+ {
+ window.addEventListener("touchstart", (event) => {
+ debug("touchstart fired.");
+ shouldBe("event.touches.length", "1");
+ shouldBe("event.touches[0].touchType", "'stylus'");
+ shouldBeCloseTo("event.touches[0].altitudeAngle", 1, 0.01);
+ shouldBeCloseTo("event.touches[0].azimuthAngle", 2, 0.01);
+ shouldBeCloseTo("event.touches[0].force", 0.5, 0.01);
+ });
+
+ window.addEventListener("touchmove", (event) => {
+ debug("touchmove fired.");
+ shouldBe("event.touches.length", "1");
+ shouldBe("event.touches[0].touchType", "'stylus'");
+ shouldBeCloseTo("event.touches[0].altitudeAngle", 1.1, 0.01);
+ shouldBeCloseTo("event.touches[0].azimuthAngle", 2.1, 0.01);
+ shouldBeCloseTo("event.touches[0].force", 0.6, 0.01);
+ });
+
+ window.addEventListener("touchend", (event) => {
+ debug("touchend fired.");
+ finishJSTest();
+ });
+
+ if (window.testRunner)
+ testRunner.runUIScript(getUIScript(50, 200), function(result) { });
+ }
+
+ window.addEventListener("load", runTest, false);
+ </script>
+ <script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data.html
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Revision
\ No newline at end of property
Added: svn:mime-type
+text/html
\ No newline at end of property
Added: trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil-expected.txt (0 => 205766)
--- trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil-expected.txt 2016-09-09 20:57:50 UTC (rev 205766)
@@ -0,0 +1,17 @@
+Test that an Apple Pencil provides stylus information.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+ touchstart fired.
+PASS event.touches.length is 1
+PASS event.touches[0].touchType is 'stylus'
+PASS event.touches[0].altitudeAngle is within 0.01 of 1
+PASS event.touches[0].azimuthAngle is within 0.01 of 2
+PASS event.touches[0].force is within 0.01 of 0.5
+touchend fired.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil-expected.txt
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Revision
\ No newline at end of property
Added: svn:mime-type
+text/plain
\ No newline at end of property
Added: trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil.html (0 => 205766)
--- trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil.html (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil.html 2016-09-09 20:57:50 UTC (rev 205766)
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+ <script src=""
+ <style>
+ body {
+ margin: none;
+ }
+ </style>
+ <meta name="viewport" content="initial-scale=1">
+</head>
+<body>
+ <p id="description"></p>
+ <div id="console">
+ </div>
+ <script>
+ description("Test that an Apple Pencil provides stylus information.");
+ window.jsTestIsAsync = true;
+
+ function getUIScript(x, y)
+ {
+ return `
+ (function() {
+ uiController.stylusTapAtPoint(${x}, ${y}, 2, 1, 0.5, function () {});
+ })();`
+ }
+
+ function runTest()
+ {
+ window.addEventListener("touchstart", (event) => {
+ debug("touchstart fired.");
+ shouldBe("event.touches.length", "1");
+ shouldBe("event.touches[0].touchType", "'stylus'");
+ shouldBeCloseTo("event.touches[0].altitudeAngle", 1, 0.01);
+ shouldBeCloseTo("event.touches[0].azimuthAngle", 2, 0.01);
+ shouldBeCloseTo("event.touches[0].force", 0.5, 0.01);
+ });
+
+ window.addEventListener("touchend", (event) => {
+ debug("touchend fired.");
+ finishJSTest();
+ });
+
+ if (window.testRunner)
+ testRunner.runUIScript(getUIScript(50, 200), function(result) { });
+ }
+
+ window.addEventListener("load", runTest, false);
+ </script>
+ <script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil.html
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Revision
\ No newline at end of property
Added: svn:mime-type
+text/html
\ No newline at end of property
Modified: trunk/Source/WebKit2/ChangeLog (205765 => 205766)
--- trunk/Source/WebKit2/ChangeLog 2016-09-09 20:46:23 UTC (rev 205765)
+++ trunk/Source/WebKit2/ChangeLog 2016-09-09 20:57:50 UTC (rev 205766)
@@ -1,3 +1,32 @@
+2016-09-08 Dean Jackson <[email protected]>
+
+ Expose Apple Pencil data to Touch events
+ https://bugs.webkit.org/show_bug.cgi?id=161783
+ <rdar://problem/28218898>
+
+ Reviewed by Beth Dakin.
+
+ * Platform/spi/ios/UIKitSPI.h: Expose the new SPI. Since this is only used
+ on public builds, guard it against everything that is <= iOS 10.0.
+ * Shared/WebEvent.h: New properties.
+ (WebKit::WebPlatformTouchPoint::setAltitudeAngle):
+ (WebKit::WebPlatformTouchPoint::altitudeAngle):
+ (WebKit::WebPlatformTouchPoint::setAzimuthAngle):
+ (WebKit::WebPlatformTouchPoint::azimuthAngle):
+ (WebKit::WebPlatformTouchPoint::setTouchType):
+ (WebKit::WebPlatformTouchPoint::touchType):
+ (WebKit::WebPlatformTouchPoint::force): Deleted.
+ * Shared/WebEventConversion.cpp:
+ (WebKit::webPlatformTouchTypeToPlatform):
+ (WebKit::WebKit2PlatformTouchPoint::WebKit2PlatformTouchPoint): More
+ parameters sent to parent constructor.
+ * Shared/ios/NativeWebTouchEventIOS.mm:
+ (WebKit::convertTouchType):
+ (WebKit::NativeWebTouchEvent::extractWebTouchPoint):
+ * Shared/ios/WebPlatformTouchPointIOS.cpp:
+ (WebKit::WebPlatformTouchPoint::encode):
+ (WebKit::WebPlatformTouchPoint::decode):
+
2016-09-09 Tim Horton <[email protected]>
Text replacement candidates don't always overwrite the entire original string
Modified: trunk/Source/WebKit2/Platform/spi/ios/UIKitSPI.h (205765 => 205766)
--- trunk/Source/WebKit2/Platform/spi/ios/UIKitSPI.h 2016-09-09 20:46:23 UTC (rev 205765)
+++ trunk/Source/WebKit2/Platform/spi/ios/UIKitSPI.h 2016-09-09 20:57:50 UTC (rev 205766)
@@ -643,12 +643,22 @@
UIWebTouchEventTouchCancel = 3,
} UIWebTouchEventType;
+typedef enum {
+ UIWebTouchPointTypeDirect = 0,
+ UIWebTouchPointTypeStylus
+} UIWebTouchPointType;
+
struct _UIWebTouchPoint {
CGPoint locationInScreenCoordinates;
CGPoint locationInDocumentCoordinates;
unsigned identifier;
UITouchPhase phase;
- CGFloat majorRadiusInScreenCoordinates;
+#if __IPHONE_OS_VERSION_MIN_REQUIRED > 100000
+ CGFloat force;
+ CGFloat altitudeAngle;
+ CGFloat azimuthAngle;
+ UIWebTouchPointType touchType;
+#endif
};
struct _UIWebTouchEvent {
Modified: trunk/Source/WebKit2/Shared/WebEvent.h (205765 => 205766)
--- trunk/Source/WebKit2/Shared/WebEvent.h 2016-09-09 20:46:23 UTC (rev 205765)
+++ trunk/Source/WebKit2/Shared/WebEvent.h 2016-09-09 20:57:50 UTC (rev 205766)
@@ -306,6 +306,11 @@
TouchCancelled
};
+ enum class TouchType {
+ Direct,
+ Stylus
+ };
+
WebPlatformTouchPoint() { }
WebPlatformTouchPoint(unsigned identifier, WebCore::IntPoint location, TouchPointState phase)
: m_identifier(identifier)
@@ -322,6 +327,12 @@
#if ENABLE(IOS_TOUCH_EVENTS)
void setForce(double force) { m_force = force; }
double force() const { return m_force; }
+ void setAltitudeAngle(double altitudeAngle) { m_altitudeAngle = altitudeAngle; }
+ double altitudeAngle() const { return m_altitudeAngle; }
+ void setAzimuthAngle(double azimuthAngle) { m_azimuthAngle = azimuthAngle; }
+ double azimuthAngle() const { return m_azimuthAngle; }
+ void setTouchType(TouchType touchType) { m_touchType = static_cast<uint32_t>(touchType); }
+ TouchType touchType() const { return static_cast<TouchType>(m_touchType); }
#endif
void encode(IPC::Encoder&) const;
@@ -333,6 +344,9 @@
uint32_t m_phase;
#if ENABLE(IOS_TOUCH_EVENTS)
double m_force { 0 };
+ double m_altitudeAngle { 0 };
+ double m_azimuthAngle { 0 };
+ uint32_t m_touchType { static_cast<uint32_t>(TouchType::Direct) };
#endif
};
Modified: trunk/Source/WebKit2/Shared/WebEventConversion.cpp (205765 => 205766)
--- trunk/Source/WebKit2/Shared/WebEventConversion.cpp 2016-09-09 20:46:23 UTC (rev 205765)
+++ trunk/Source/WebKit2/Shared/WebEventConversion.cpp 2016-09-09 20:57:50 UTC (rev 205766)
@@ -243,12 +243,22 @@
}
}
+static WebCore::PlatformTouchPoint::TouchType webPlatformTouchTypeToPlatform(const WebPlatformTouchPoint::TouchType& webTouchType)
+{
+ switch (webTouchType) {
+ case WebPlatformTouchPoint::TouchType::Direct:
+ return WebCore::PlatformTouchPoint::TouchType::Direct;
+ case WebPlatformTouchPoint::TouchType::Stylus:
+ return WebCore::PlatformTouchPoint::TouchType::Stylus;
+ }
+}
+
class WebKit2PlatformTouchPoint : public WebCore::PlatformTouchPoint {
public:
WebKit2PlatformTouchPoint(const WebPlatformTouchPoint& webTouchPoint)
: PlatformTouchPoint(webTouchPoint.identifier(), webTouchPoint.location(), touchEventType(webTouchPoint)
#if ENABLE(IOS_TOUCH_EVENTS)
- , webTouchPoint.force()
+ , webTouchPoint.force(), webTouchPoint.altitudeAngle(), webTouchPoint.azimuthAngle(), webPlatformTouchTypeToPlatform(webTouchPoint.touchType())
#endif
)
{
Modified: trunk/Source/WebKit2/Shared/ios/NativeWebTouchEventIOS.mm (205765 => 205766)
--- trunk/Source/WebKit2/Shared/ios/NativeWebTouchEventIOS.mm 2016-09-09 20:46:23 UTC (rev 205765)
+++ trunk/Source/WebKit2/Shared/ios/NativeWebTouchEventIOS.mm 2016-09-09 20:57:50 UTC (rev 205766)
@@ -70,6 +70,21 @@
}
}
+#if defined UI_WEB_TOUCH_EVENT_HAS_STYLUS_DATA && UI_WEB_TOUCH_EVENT_HAS_STYLUS_DATA
+static WebPlatformTouchPoint::TouchType convertTouchType(UIWebTouchPointType touchType)
+{
+ switch (touchType) {
+ case UIWebTouchPointTypeDirect:
+ return WebPlatformTouchPoint::TouchType::Direct;
+ case UIWebTouchPointTypeStylus:
+ return WebPlatformTouchPoint::TouchType::Stylus;
+ default:
+ ASSERT_NOT_REACHED();
+ return WebPlatformTouchPoint::TouchType::Direct;
+ }
+}
+#endif
+
static inline WebCore::IntPoint positionForCGPoint(CGPoint position)
{
return WebCore::IntPoint(position);
@@ -89,7 +104,12 @@
WebPlatformTouchPoint platformTouchPoint = WebPlatformTouchPoint(identifier, location, phase);
#if ENABLE(IOS_TOUCH_EVENTS)
platformTouchPoint.setForce(touchPoint.force);
+#if defined UI_WEB_TOUCH_EVENT_HAS_STYLUS_DATA && UI_WEB_TOUCH_EVENT_HAS_STYLUS_DATA
+ platformTouchPoint.setAltitudeAngle(touchPoint.altitudeAngle);
+ platformTouchPoint.setAzimuthAngle(touchPoint.azimuthAngle);
+ platformTouchPoint.setTouchType(convertTouchType(touchPoint.touchType));
#endif
+#endif
touchPointList.uncheckedAppend(platformTouchPoint);
}
return touchPointList;
Modified: trunk/Source/WebKit2/Shared/ios/WebPlatformTouchPointIOS.cpp (205765 => 205766)
--- trunk/Source/WebKit2/Shared/ios/WebPlatformTouchPointIOS.cpp 2016-09-09 20:46:23 UTC (rev 205765)
+++ trunk/Source/WebKit2/Shared/ios/WebPlatformTouchPointIOS.cpp 2016-09-09 20:57:50 UTC (rev 205766)
@@ -41,6 +41,9 @@
encoder << m_phase;
#if ENABLE(IOS_TOUCH_EVENTS)
encoder << m_force;
+ encoder << m_altitudeAngle;
+ encoder << m_azimuthAngle;
+ encoder << m_touchType;
#endif
}
@@ -55,6 +58,12 @@
#if ENABLE(IOS_TOUCH_EVENTS)
if (!decoder.decode(result.m_force))
return false;
+ if (!decoder.decode(result.m_altitudeAngle))
+ return false;
+ if (!decoder.decode(result.m_azimuthAngle))
+ return false;
+ if (!decoder.decode(result.m_touchType))
+ return false;
#endif
return true;
}
Modified: trunk/Tools/ChangeLog (205765 => 205766)
--- trunk/Tools/ChangeLog 2016-09-09 20:46:23 UTC (rev 205765)
+++ trunk/Tools/ChangeLog 2016-09-09 20:57:50 UTC (rev 205766)
@@ -1,3 +1,19 @@
+2016-09-08 Dean Jackson <[email protected]>
+
+ Expose Apple Pencil data to Touch events
+ https://bugs.webkit.org/show_bug.cgi?id=161783
+ <rdar://problem/28218898>
+
+ Reviewed by Beth Dakin.
+
+ The values that IOHID expects are different from their
+ documentation, and from what UITouch interprets. Tweak
+ incoming data so it will produce the output we expect.
+
+ * WebKitTestRunner/ios/HIDEventGenerator.mm:
+ (-[HIDEventGenerator stylusDownAtPoint:azimuthAngle:altitudeAngle:pressure:]):
+ (-[HIDEventGenerator stylusMoveToPoint:azimuthAngle:altitudeAngle:pressure:]):
+
2016-09-09 JF Bastien <[email protected]>
Unreviewed. Added myself to the list of committers.
Modified: trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm (205765 => 205766)
--- trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm 2016-09-09 20:46:23 UTC (rev 205765)
+++ trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm 2016-09-09 20:57:50 UTC (rev 205766)
@@ -434,10 +434,15 @@
_activePointCount = 1;
_activePoints[0].point = location;
_activePoints[0].isStylus = YES;
- _activePoints[0].pathPressure = pressure;
- _activePoints[0].azimuthAngle = azimuthAngle;
- _activePoints[0].altitudeAngle = altitudeAngle;
+ // At the time of writing, the IOKit documentation isn't always correct. For example
+ // it says that pressure is a value [0,1], but in practice it is [0,500] for stylus
+ // data. It does not mention that the azimuth angle is offset from a full rotation.
+ // Also, UIKit and IOHID interpret the altitude as different adjacent angles.
+ _activePoints[0].pathPressure = pressure * 500;
+ _activePoints[0].azimuthAngle = M_PI * 2 - azimuthAngle;
+ _activePoints[0].altitudeAngle = M_PI_2 - altitudeAngle;
+
RetainPtr<IOHIDEventRef> eventRef = adoptCF([self _createIOHIDEventType:StylusEventTouched]);
[self _sendHIDEvent:eventRef.get()];
}
@@ -447,9 +452,10 @@
_activePointCount = 1;
_activePoints[0].point = location;
_activePoints[0].isStylus = YES;
- _activePoints[0].pathPressure = pressure;
- _activePoints[0].azimuthAngle = azimuthAngle;
- _activePoints[0].altitudeAngle = altitudeAngle;
+ // See notes above for details on these calculations.
+ _activePoints[0].pathPressure = pressure * 500;
+ _activePoints[0].azimuthAngle = M_PI * 2 - azimuthAngle;
+ _activePoints[0].altitudeAngle = M_PI_2 - altitudeAngle;
RetainPtr<IOHIDEventRef> eventRef = adoptCF([self _createIOHIDEventType:StylusEventMoved]);
[self _sendHIDEvent:eventRef.get()];