<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[205766] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/205766">205766</a></dd>
<dt>Author</dt> <dd>dino@apple.com</dd>
<dt>Date</dt> <dd>2016-09-09 13:57:50 -0700 (Fri, 09 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Expose Apple Pencil data to Touch events
https://bugs.webkit.org/show_bug.cgi?id=161783
&lt;rdar://problem/28218898&gt;

Reviewed by Beth Dakin.

Source/WebKit2:

* Platform/spi/ios/UIKitSPI.h: Expose the new SPI. Since this is only used
on public builds, guard it against everything that is &lt;= 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):

Tools:

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:]):

LayoutTests:

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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformspiiosUIKitSPIh">trunk/Source/WebKit2/Platform/spi/ios/UIKitSPI.h</a></li>
<li><a href="#trunkSourceWebKit2SharedWebEventh">trunk/Source/WebKit2/Shared/WebEvent.h</a></li>
<li><a href="#trunkSourceWebKit2SharedWebEventConversioncpp">trunk/Source/WebKit2/Shared/WebEventConversion.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharediosNativeWebTouchEventIOSmm">trunk/Source/WebKit2/Shared/ios/NativeWebTouchEventIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2SharediosWebPlatformTouchPointIOScpp">trunk/Source/WebKit2/Shared/ios/WebPlatformTouchPointIOS.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitTestRunneriosHIDEventGeneratormm">trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasteventstouchiospencildatachangedoesnotgivetouchmoveexpectedtxt">trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchiospencildatachangedoesnotgivetouchmovehtml">trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove.html</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchiospencildatachangegivestouchforcechangeexpectedtxt">trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchiospencildatachangegivestouchforcechangehtml">trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange.html</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchiospencilmoveprovidesstylusdataexpectedtxt">trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchiospencilmoveprovidesstylusdatahtml">trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data.html</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchiospenciltouchregisteredaspencilexpectedtxt">trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchiospenciltouchregisteredaspencilhtml">trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (205765 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-09-09 20:46:23 UTC (rev 205765)
+++ trunk/LayoutTests/ChangeLog        2016-09-09 20:57:50 UTC (rev 205766)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2016-09-08  Dean Jackson  &lt;dino@apple.com&gt;
+
+        Expose Apple Pencil data to Touch events
+        https://bugs.webkit.org/show_bug.cgi?id=161783
+        &lt;rdar://problem/28218898&gt;
+
+        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.
+
</ins><span class="cx"> 2016-09-09  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Text replacement candidates don't always overwrite the entire original string
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchiospencildatachangedoesnotgivetouchmoveexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove-expected.txt (0 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Test that an Apple Pencil that changes pressure + angles does not generate a touchmove.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+
+    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
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/plain
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfasteventstouchiospencildatachangedoesnotgivetouchmovehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove.html (0 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;style&gt;
+        body {
+            margin: none;
+        }
+    &lt;/style&gt;
+    &lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+    &lt;div id=&quot;console&quot;&gt;
+    &lt;/div&gt;
+    &lt;script&gt;
+        description(&quot;Test that an Apple Pencil that changes pressure + angles does not generate a touchmove.&quot;);
+        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(&quot;touchstart&quot;, (event) =&gt; {
+                debug(&quot;touchstart fired.&quot;);
+                shouldBe(&quot;event.touches.length&quot;, &quot;1&quot;);
+                shouldBe(&quot;event.touches[0].touchType&quot;, &quot;'stylus'&quot;);
+                shouldBeCloseTo(&quot;event.touches[0].altitudeAngle&quot;, 1, 0.01);
+                shouldBeCloseTo(&quot;event.touches[0].azimuthAngle&quot;, 2, 0.01);
+                shouldBeCloseTo(&quot;event.touches[0].force&quot;, 0.5, 0.01);
+            });
+
+            window.addEventListener(&quot;touchmove&quot;, (event) =&gt; {
+                debug(&quot;FAIL: touchmove fired.&quot;);
+                failed = true;
+            });
+
+            window.addEventListener(&quot;touchend&quot;, (event) =&gt; {
+                if (!failed)
+                    debug(&quot;PASS: Did not see a touchmove.&quot;);
+                debug(&quot;touchend fired.&quot;);
+                finishJSTest();
+            });
+
+            if (window.testRunner)
+                testRunner.runUIScript(getUIScript(50, 200), function(result) { });
+        }
+
+        window.addEventListener(&quot;load&quot;, runTest, false);
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-does-not-give-touchmove.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfasteventstouchiospencildatachangegivestouchforcechangeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange-expected.txt (0 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+Test that an Apple Pencil produces touchforcechange events.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+
+    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
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/plain
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfasteventstouchiospencildatachangegivestouchforcechangehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange.html (0 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;style&gt;
+        body {
+            margin: none;
+        }
+    &lt;/style&gt;
+    &lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+    &lt;div id=&quot;console&quot;&gt;
+    &lt;/div&gt;
+    &lt;script&gt;
+        description(&quot;Test that an Apple Pencil produces touchforcechange events.&quot;);
+        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(&quot;touchstart&quot;, (event) =&gt; {
+                debug(&quot;touchstart fired.&quot;);
+                shouldBe(&quot;event.touches.length&quot;, &quot;1&quot;);
+                shouldBe(&quot;event.touches[0].touchType&quot;, &quot;'stylus'&quot;);
+                shouldBeCloseTo(&quot;event.touches[0].altitudeAngle&quot;, 1, 0.01);
+                shouldBeCloseTo(&quot;event.touches[0].azimuthAngle&quot;, 2, 0.01);
+                shouldBeCloseTo(&quot;event.touches[0].force&quot;, 0.5, 0.01);
+            });
+
+            window.addEventListener(&quot;touchforcechange&quot;, (event) =&gt; {
+                debug(&quot;touchforcechange fired.&quot;);
+                shouldBe(&quot;event.touches.length&quot;, &quot;1&quot;);
+                shouldBe(&quot;event.touches[0].touchType&quot;, &quot;'stylus'&quot;);
+                shouldBeCloseTo(&quot;event.touches[0].altitudeAngle&quot;, 1.1, 0.01);
+                shouldBeCloseTo(&quot;event.touches[0].azimuthAngle&quot;, 2.1, 0.01);
+                shouldBeCloseTo(&quot;event.touches[0].force&quot;, 0.6, 0.01);
+            });
+
+            window.addEventListener(&quot;touchend&quot;, (event) =&gt; {
+                debug(&quot;touchend fired.&quot;);
+                finishJSTest();
+            });
+
+            if (window.testRunner)
+                testRunner.runUIScript(getUIScript(50, 200), function(result) { });
+        }
+
+        window.addEventListener(&quot;load&quot;, runTest, false);
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-data-change-gives-touchforcechange.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfasteventstouchiospencilmoveprovidesstylusdataexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data-expected.txt (0 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+Test that a moving Apple Pencil provides stylus information.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+
+    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
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/plain
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfasteventstouchiospencilmoveprovidesstylusdatahtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data.html (0 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;style&gt;
+        body {
+            margin: none;
+        }
+    &lt;/style&gt;
+    &lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+    &lt;div id=&quot;console&quot;&gt;
+    &lt;/div&gt;
+    &lt;script&gt;
+        description(&quot;Test that a moving Apple Pencil provides stylus information.&quot;);
+        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(&quot;touchstart&quot;, (event) =&gt; {
+                debug(&quot;touchstart fired.&quot;);
+                shouldBe(&quot;event.touches.length&quot;, &quot;1&quot;);
+                shouldBe(&quot;event.touches[0].touchType&quot;, &quot;'stylus'&quot;);
+                shouldBeCloseTo(&quot;event.touches[0].altitudeAngle&quot;, 1, 0.01);
+                shouldBeCloseTo(&quot;event.touches[0].azimuthAngle&quot;, 2, 0.01);
+                shouldBeCloseTo(&quot;event.touches[0].force&quot;, 0.5, 0.01);
+            });
+
+            window.addEventListener(&quot;touchmove&quot;, (event) =&gt; {
+                debug(&quot;touchmove fired.&quot;);
+                shouldBe(&quot;event.touches.length&quot;, &quot;1&quot;);
+                shouldBe(&quot;event.touches[0].touchType&quot;, &quot;'stylus'&quot;);
+                shouldBeCloseTo(&quot;event.touches[0].altitudeAngle&quot;, 1.1, 0.01);
+                shouldBeCloseTo(&quot;event.touches[0].azimuthAngle&quot;, 2.1, 0.01);
+                shouldBeCloseTo(&quot;event.touches[0].force&quot;, 0.6, 0.01);
+            });
+
+            window.addEventListener(&quot;touchend&quot;, (event) =&gt; {
+                debug(&quot;touchend fired.&quot;);
+                finishJSTest();
+            });
+
+            if (window.testRunner)
+                testRunner.runUIScript(getUIScript(50, 200), function(result) { });
+        }
+
+        window.addEventListener(&quot;load&quot;, runTest, false);
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-move-provides-stylus-data.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfasteventstouchiospenciltouchregisteredaspencilexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil-expected.txt (0 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+Test that an Apple Pencil provides stylus information.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+
+    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
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/plain
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfasteventstouchiospenciltouchregisteredaspencilhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil.html (0 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;style&gt;
+        body {
+            margin: none;
+        }
+    &lt;/style&gt;
+    &lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+    &lt;div id=&quot;console&quot;&gt;
+    &lt;/div&gt;
+    &lt;script&gt;
+        description(&quot;Test that an Apple Pencil provides stylus information.&quot;);
+        window.jsTestIsAsync = true;
+
+        function getUIScript(x, y)
+        {
+            return `
+            (function() {
+                uiController.stylusTapAtPoint(${x}, ${y}, 2, 1, 0.5, function () {});
+            })();`
+        }
+
+        function runTest()
+        {
+            window.addEventListener(&quot;touchstart&quot;, (event) =&gt; {
+                debug(&quot;touchstart fired.&quot;);
+                shouldBe(&quot;event.touches.length&quot;, &quot;1&quot;);
+                shouldBe(&quot;event.touches[0].touchType&quot;, &quot;'stylus'&quot;);
+                shouldBeCloseTo(&quot;event.touches[0].altitudeAngle&quot;, 1, 0.01);
+                shouldBeCloseTo(&quot;event.touches[0].azimuthAngle&quot;, 2, 0.01);
+                shouldBeCloseTo(&quot;event.touches[0].force&quot;, 0.5, 0.01);
+            });
+
+            window.addEventListener(&quot;touchend&quot;, (event) =&gt; {
+                debug(&quot;touchend fired.&quot;);
+                finishJSTest();
+            });
+
+            if (window.testRunner)
+                testRunner.runUIScript(getUIScript(50, 200), function(result) { });
+        }
+
+        window.addEventListener(&quot;load&quot;, runTest, false);
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/events/touch/ios/pencil-touch-registered-as-pencil.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (205765 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2016-09-08  Dean Jackson  &lt;dino@apple.com&gt;
+
+        Expose Apple Pencil data to Touch events
+        https://bugs.webkit.org/show_bug.cgi?id=161783
+        &lt;rdar://problem/28218898&gt;
+
+        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 &lt;= 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):
+
</ins><span class="cx"> 2016-09-09  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Text replacement candidates don't always overwrite the entire original string
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformspiiosUIKitSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/spi/ios/UIKitSPI.h (205765 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -643,12 +643,22 @@
</span><span class="cx">     UIWebTouchEventTouchCancel = 3,
</span><span class="cx"> } UIWebTouchEventType;
</span><span class="cx"> 
</span><ins>+typedef enum {
+    UIWebTouchPointTypeDirect = 0,
+    UIWebTouchPointTypeStylus
+} UIWebTouchPointType;
+
</ins><span class="cx"> struct _UIWebTouchPoint {
</span><span class="cx">     CGPoint locationInScreenCoordinates;
</span><span class="cx">     CGPoint locationInDocumentCoordinates;
</span><span class="cx">     unsigned identifier;
</span><span class="cx">     UITouchPhase phase;
</span><del>-    CGFloat majorRadiusInScreenCoordinates;
</del><ins>+#if __IPHONE_OS_VERSION_MIN_REQUIRED &gt; 100000
+    CGFloat force;
+    CGFloat altitudeAngle;
+    CGFloat azimuthAngle;
+    UIWebTouchPointType touchType;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> struct _UIWebTouchEvent {
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebEvent.h (205765 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -306,6 +306,11 @@
</span><span class="cx">         TouchCancelled
</span><span class="cx">     };
</span><span class="cx"> 
</span><ins>+    enum class TouchType {
+        Direct,
+        Stylus
+    };
+
</ins><span class="cx">     WebPlatformTouchPoint() { }
</span><span class="cx">     WebPlatformTouchPoint(unsigned identifier, WebCore::IntPoint location, TouchPointState phase)
</span><span class="cx">         : m_identifier(identifier)
</span><span class="lines">@@ -322,6 +327,12 @@
</span><span class="cx"> #if ENABLE(IOS_TOUCH_EVENTS)
</span><span class="cx">     void setForce(double force) { m_force = force; }
</span><span class="cx">     double force() const { return m_force; }
</span><ins>+    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&lt;uint32_t&gt;(touchType); }
+    TouchType touchType() const { return static_cast&lt;TouchType&gt;(m_touchType); }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     void encode(IPC::Encoder&amp;) const;
</span><span class="lines">@@ -333,6 +344,9 @@
</span><span class="cx">     uint32_t m_phase;
</span><span class="cx"> #if ENABLE(IOS_TOUCH_EVENTS)
</span><span class="cx">     double m_force { 0 };
</span><ins>+    double m_altitudeAngle { 0 };
+    double m_azimuthAngle { 0 };
+    uint32_t m_touchType { static_cast&lt;uint32_t&gt;(TouchType::Direct) };
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebEventConversioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebEventConversion.cpp (205765 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -243,12 +243,22 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static WebCore::PlatformTouchPoint::TouchType webPlatformTouchTypeToPlatform(const WebPlatformTouchPoint::TouchType&amp; webTouchType)
+{
+    switch (webTouchType) {
+    case WebPlatformTouchPoint::TouchType::Direct:
+        return WebCore::PlatformTouchPoint::TouchType::Direct;
+    case WebPlatformTouchPoint::TouchType::Stylus:
+        return WebCore::PlatformTouchPoint::TouchType::Stylus;
+    }
+}
+
</ins><span class="cx"> class WebKit2PlatformTouchPoint : public WebCore::PlatformTouchPoint {
</span><span class="cx"> public:
</span><span class="cx"> WebKit2PlatformTouchPoint(const WebPlatformTouchPoint&amp; webTouchPoint)
</span><span class="cx">     : PlatformTouchPoint(webTouchPoint.identifier(), webTouchPoint.location(), touchEventType(webTouchPoint)
</span><span class="cx"> #if ENABLE(IOS_TOUCH_EVENTS)
</span><del>-    , webTouchPoint.force()
</del><ins>+        , webTouchPoint.force(), webTouchPoint.altitudeAngle(), webTouchPoint.azimuthAngle(), webPlatformTouchTypeToPlatform(webTouchPoint.touchType())
</ins><span class="cx"> #endif
</span><span class="cx">     )
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2SharediosNativeWebTouchEventIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/ios/NativeWebTouchEventIOS.mm (205765 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -70,6 +70,21 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if defined UI_WEB_TOUCH_EVENT_HAS_STYLUS_DATA &amp;&amp; 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
+
</ins><span class="cx"> static inline WebCore::IntPoint positionForCGPoint(CGPoint position)
</span><span class="cx"> {
</span><span class="cx">     return WebCore::IntPoint(position);
</span><span class="lines">@@ -89,7 +104,12 @@
</span><span class="cx">         WebPlatformTouchPoint platformTouchPoint = WebPlatformTouchPoint(identifier, location, phase);
</span><span class="cx"> #if ENABLE(IOS_TOUCH_EVENTS)
</span><span class="cx">         platformTouchPoint.setForce(touchPoint.force);
</span><ins>+#if defined UI_WEB_TOUCH_EVENT_HAS_STYLUS_DATA &amp;&amp; UI_WEB_TOUCH_EVENT_HAS_STYLUS_DATA
+        platformTouchPoint.setAltitudeAngle(touchPoint.altitudeAngle);
+        platformTouchPoint.setAzimuthAngle(touchPoint.azimuthAngle);
+        platformTouchPoint.setTouchType(convertTouchType(touchPoint.touchType));
</ins><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx">         touchPointList.uncheckedAppend(platformTouchPoint);
</span><span class="cx">     }
</span><span class="cx">     return touchPointList;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharediosWebPlatformTouchPointIOScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/ios/WebPlatformTouchPointIOS.cpp (205765 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -41,6 +41,9 @@
</span><span class="cx">     encoder &lt;&lt; m_phase;
</span><span class="cx"> #if ENABLE(IOS_TOUCH_EVENTS)
</span><span class="cx">     encoder &lt;&lt; m_force;
</span><ins>+    encoder &lt;&lt; m_altitudeAngle;
+    encoder &lt;&lt; m_azimuthAngle;
+    encoder &lt;&lt; m_touchType;
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -55,6 +58,12 @@
</span><span class="cx"> #if ENABLE(IOS_TOUCH_EVENTS)
</span><span class="cx">     if (!decoder.decode(result.m_force))
</span><span class="cx">         return false;
</span><ins>+    if (!decoder.decode(result.m_altitudeAngle))
+        return false;
+    if (!decoder.decode(result.m_azimuthAngle))
+        return false;
+    if (!decoder.decode(result.m_touchType))
+        return false;
</ins><span class="cx"> #endif
</span><span class="cx">     return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (205765 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-09-09 20:46:23 UTC (rev 205765)
+++ trunk/Tools/ChangeLog        2016-09-09 20:57:50 UTC (rev 205766)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-09-08  Dean Jackson  &lt;dino@apple.com&gt;
+
+        Expose Apple Pencil data to Touch events
+        https://bugs.webkit.org/show_bug.cgi?id=161783
+        &lt;rdar://problem/28218898&gt;
+
+        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:]):
+
</ins><span class="cx"> 2016-09-09  JF Bastien  &lt;jfbastien@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed. Added myself to the list of committers.
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunneriosHIDEventGeneratormm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm (205765 => 205766)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -434,10 +434,15 @@
</span><span class="cx">     _activePointCount = 1;
</span><span class="cx">     _activePoints[0].point = location;
</span><span class="cx">     _activePoints[0].isStylus = YES;
</span><del>-    _activePoints[0].pathPressure = pressure;
-    _activePoints[0].azimuthAngle = azimuthAngle;
-    _activePoints[0].altitudeAngle = altitudeAngle;
</del><span class="cx"> 
</span><ins>+    // 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;
+
</ins><span class="cx">     RetainPtr&lt;IOHIDEventRef&gt; eventRef = adoptCF([self _createIOHIDEventType:StylusEventTouched]);
</span><span class="cx">     [self _sendHIDEvent:eventRef.get()];
</span><span class="cx"> }
</span><span class="lines">@@ -447,9 +452,10 @@
</span><span class="cx">     _activePointCount = 1;
</span><span class="cx">     _activePoints[0].point = location;
</span><span class="cx">     _activePoints[0].isStylus = YES;
</span><del>-    _activePoints[0].pathPressure = pressure;
-    _activePoints[0].azimuthAngle = azimuthAngle;
-    _activePoints[0].altitudeAngle = altitudeAngle;
</del><ins>+    // 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;
</ins><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;IOHIDEventRef&gt; eventRef = adoptCF([self _createIOHIDEventType:StylusEventMoved]);
</span><span class="cx">     [self _sendHIDEvent:eventRef.get()];
</span></span></pre>
</div>
</div>

</body>
</html>