WebKit Bugzilla
Attachment 360410 Details for
Bug 193945
: Produce "pen" Pointer Events if using a stylus (e.g. Apple Pencil)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193945-20190128180041.patch (text/plain), 7.70 KB, created by
Dean Jackson
on 2019-01-28 18:00:42 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Dean Jackson
Created:
2019-01-28 18:00:42 PST
Size:
7.70 KB
patch
obsolete
>Subversion Revision: 240588 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index be0b10298aae75e3d17de54c2bfd16ed1e5e2052..546902708aadf338a2b26e0c350f1c1041045409 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,20 @@ >+2019-01-28 Dean Jackson <dino@apple.com> >+ >+ Produce "pen" Pointer Events if using a stylus (e.g. Apple Pencil) >+ https://bugs.webkit.org/show_bug.cgi?id=193945 >+ <rdar://problem/47618922> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Calculate the pressure, tiltX and tiltY values for incoming >+ Pointer Events, which have values when the PlatformTouchEvent >+ originated from a stylus. >+ >+ Test: pointerevents/ios/pointer-events-dispatch-on-stylus.html >+ >+ * dom/PointerEvent.h: Default to "mouse". >+ * dom/ios/PointerEventIOS.cpp: Calculate the values. >+ > 2019-01-28 Oriol Brufau <obrufau@igalia.com> > > [css-logical] Reject unitless length quirk in 'inset' shorthand >diff --git a/Source/WebCore/dom/PointerEvent.h b/Source/WebCore/dom/PointerEvent.h >index 3932df9b46bb5bf1014e3ab748286478052b5e6d..bdaee5eaebf2e84d77d529587659bb9c00ce066b 100644 >--- a/Source/WebCore/dom/PointerEvent.h >+++ b/Source/WebCore/dom/PointerEvent.h >@@ -47,7 +47,7 @@ public: > long tiltX { 0 }; > long tiltY { 0 }; > long twist { 0 }; >- String pointerType; >+ String pointerType { "mouse"_s }; > bool isPrimary { false }; > }; > >@@ -97,7 +97,7 @@ private: > long m_tiltX { 0 }; > long m_tiltY { 0 }; > long m_twist { 0 }; >- String m_pointerType; >+ String m_pointerType { "mouse"_s }; > bool m_isPrimary { false }; > }; > >diff --git a/Source/WebCore/dom/ios/PointerEventIOS.cpp b/Source/WebCore/dom/ios/PointerEventIOS.cpp >index 92bb83ea7f749386cd2241bef018afdd1fa24f31..2112ee84a6f8912adf4f8c66bc6083abe67cbac0 100644 >--- a/Source/WebCore/dom/ios/PointerEventIOS.cpp >+++ b/Source/WebCore/dom/ios/PointerEventIOS.cpp >@@ -68,9 +68,17 @@ PointerEvent::PointerEvent(const AtomicString& type, const PlatformTouchEvent& e > , m_pointerId(event.touchIdentifierAtIndex(index)) > , 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_isPrimary(isPrimary) > { >+ // See https://github.com/w3c/pointerevents/issues/274. We might expose the azimuth and altitude >+ // directly as well as the tilt. >+ double azimuthAngle = event.azimuthAngleAtIndex(index); >+ double altitudeAngle = event.altitudeAngleAtIndex(index); >+ >+ m_tiltX = round(sin(azimuthAngle) * cos(altitudeAngle) * 90); >+ m_tiltY = round(cos(azimuthAngle) * cos(altitudeAngle) * 90); > } > > } // namespace WebCore >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 4dc94e86f7a6b197487fef703807dfcee2eac20d..b989c3b10e9766a69504f3f92e6766bc75f78910 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,20 @@ >+2019-01-28 Dean Jackson <dino@apple.com> >+ >+ Produce "pen" Pointer Events if using a stylus (e.g. Apple Pencil) >+ https://bugs.webkit.org/show_bug.cgi?id=193945 >+ <rdar://problem/47618922> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test for stylus -> "pen" Pointer Events. >+ >+ * pointerevents/ios/pointer-events-dispatch-on-stylus-expected.txt: Added. >+ * pointerevents/ios/pointer-events-dispatch-on-stylus.html: Added. >+ * pointerevents/ios/pointer-events-dispatch-on-touch.html: Test for "touch" type. >+ * pointerevents/utils.js: Add a new helper for stylus event generation. >+ (prototype.assertMatchesEvents): >+ (const.ui.new.UIController.prototype.beginStylus): >+ > 2019-01-28 Antoine Quint <graouts@apple.com> > > Limit user-agent interactions based on the touch-action property on iOS >diff --git a/LayoutTests/pointerevents/ios/pointer-events-dispatch-on-stylus-expected.txt b/LayoutTests/pointerevents/ios/pointer-events-dispatch-on-stylus-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..b213dd9c7f9ee906feea1e22bf0f91adcd7ca9b7 >--- /dev/null >+++ b/LayoutTests/pointerevents/ios/pointer-events-dispatch-on-stylus-expected.txt >@@ -0,0 +1,3 @@ >+ >+PASS Pointer events get dispatched in response to a stylus. >+ >diff --git a/LayoutTests/pointerevents/ios/pointer-events-dispatch-on-stylus.html b/LayoutTests/pointerevents/ios/pointer-events-dispatch-on-stylus.html >new file mode 100644 >index 0000000000000000000000000000000000000000..b6015066d3295e3469e40153a026449c4ba92471 >--- /dev/null >+++ b/LayoutTests/pointerevents/ios/pointer-events-dispatch-on-stylus.html >@@ -0,0 +1,35 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<meta charset=utf-8> >+<meta name="viewport" content="width=device-width, initial-scale=1"> >+</head> >+<body> >+<script src="../../resources/testharness.js"></script> >+<script src="../../resources/testharnessreport.js"></script> >+<script src="../utils.js"></script> >+<script> >+ >+'use strict'; >+ >+const fifteenDegrees = Math.PI / 12; >+const thirtyDegrees = Math.PI / 6; >+ >+target_test((target, test) => { >+ target.addEventListener("pointerdown", event => { >+ assert_true(event instanceof PointerEvent); >+ assert_equals(event.type, "pointerdown"); >+ assert_equals(event.clientX, 50); >+ assert_equals(event.clientY, 50); >+ assert_equals(event.pointerType, "pen"); >+ assert_equals(event.pressure, 0.75); >+ assert_approx_equals(event.tiltX, 20, 1); >+ assert_approx_equals(event.tiltY, 75, 1); >+ test.done(); >+ }); >+ ui.beginStylus({ x: 50, y: 50, pressure: 0.75, azimuthAngle: fifteenDegrees, altitudeAngle: thirtyDegrees }); >+}, "Pointer events get dispatched in response to a stylus."); >+ >+</script> >+</body> >+</html> >\ No newline at end of file >diff --git a/LayoutTests/pointerevents/ios/pointer-events-dispatch-on-touch.html b/LayoutTests/pointerevents/ios/pointer-events-dispatch-on-touch.html >index e11971d62feb4c9928cbd3414568b1972bc6dff4..5d4748cfbba6915def3b856b902e70dbcdbef670 100644 >--- a/LayoutTests/pointerevents/ios/pointer-events-dispatch-on-touch.html >+++ b/LayoutTests/pointerevents/ios/pointer-events-dispatch-on-touch.html >@@ -18,6 +18,7 @@ target_test((target, test) => { > assert_equals(event.type, "pointerdown"); > assert_equals(event.clientX, 50); > assert_equals(event.clientY, 50); >+ assert_equals(event.pointerType, "touch"); > test.done(); > }); > ui.beginTouches({ x: 50, y: 50 }); >diff --git a/LayoutTests/pointerevents/utils.js b/LayoutTests/pointerevents/utils.js >index 0487af746e3547dce92707e0009488dfde2eec53..c89f0c3fcc216e43b4e68286913f09780a60b77d 100644 >--- a/LayoutTests/pointerevents/utils.js >+++ b/LayoutTests/pointerevents/utils.js >@@ -34,7 +34,6 @@ function target_test(...args) > > class EventTracker > { >- > constructor(target, eventNames) > { > this.target = target; >@@ -71,7 +70,6 @@ class EventTracker > assert_equals(expectedEvent[property], actualEvent[property], `Property ${property} matches for event at index ${i}.`); > } > } >- > } > > const ui = new (class UIController { >@@ -188,6 +186,14 @@ const ui = new (class UIController { > })); > } > >+ beginStylus(options) >+ { >+ options.azimuthAngle = options.azimuthAngle || 0; >+ options.altitudeAngle = options.altitudeAngle || 0; >+ options.pressure = options.pressure || 0; >+ return this._run(`uiController.stylusDownAtPoint(${options.x}, ${options.y}, ${options.azimuthAngle}, ${options.altitudeAngle}, ${options.pressure})`); >+ } >+ > _runEvents(events) > { > return this._run(`uiController.sendEventStream('${JSON.stringify({ events })}')`);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
graouts
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193945
: 360410