From d2c79abfa3f876c76de4ebc9d097218fde43c9a5 Mon Sep 17 00:00:00 2001 From: Gary Kacmarcik Date: Thu, 7 Oct 2021 18:15:52 -0700 Subject: [PATCH] Update click, dblclick, contextmenu to use PointerEvent --- event-algo.bs | 101 ++- event-algo.html | 1643 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 1223 insertions(+), 521 deletions(-) diff --git a/event-algo.bs b/event-algo.bs index 737766f..253d272 100644 --- a/event-algo.bs +++ b/event-algo.bs @@ -192,6 +192,9 @@ virtual keyboard. * handle native copy * handle native paste +TODO: Include native pointer events and resolve with native mouse events. How do these two +event types interact on the common platforms? +
@@ -567,24 +568,53 @@ A {{MouseEvent}} has the following: Note: The platform should call this immediately after handle native mouse up for mouseups that generate clicks. - 1. Let |mbutton| be an ID from |native| that identifies which mouse button was pressed - 1. Let |target| = hit test with viewport-relative coordinates from |native| + 1. Send click event with |native| and |target|. + +
+ +
+

send click event

+ + : Input + :: |native|, the native mousedown + :: |target|, the {{EventTarget}} of the event + + : Output + :: None + + 1. Let |mbutton| = 1 (primary mouse button by default) + 1. If |native| is valid, then + 1. Let |mbutton| be an ID from |native| that identifies which mouse button was pressed + 1. Let |eventType| = "auxclick" 1. If |mbutton| is the primary mouse button, then 1. Set |eventType| = "click" - 1. Let |event| = create a MouseEvent with |eventType| and |target| - 1. Set MouseEvent attributes from native with |native| + 1. Let |event| = create a PointerEvent with |eventType| and |target| + + 1. If |native| is valid, then + 1. Set MouseEvent attributes from native with |event|, |native| + 1. If |event|.{{screenX}} is not an integer value, then round it. + 1. If |event|.{{screenY}} is not an integer value, then round it. 1. dispatch |event| at |target| + Note: See pointerevents/100 + for info about browsers using PointerEvents and rounded coordinates. + Note: Any "default action" is handled during dispatch by triggering the activation behavior algorithm for the target. So there is no need for handle that here. However, need to verify that the existing spec handles disabled/css-pointer-events/inert/... + Note: To handle `HTMLelement.click()`, call this algorithm with |native| = null and + |target| = `HTMLelement`. + + Note: To handle keyboard-initiated clicks, call this algorithm with |native| = null and + |target| = currently focused element. +
@@ -605,8 +635,10 @@ A {{MouseEvent}} has the following: 1. Let |target| = hit test with viewport-relative coordinates from |native| - 1. Let |event| = create a MouseEvent with "dblclick" and |target| - 1. Set MouseEvent attributes from native with |native| + 1. Let |event| = create a PointerEvent with "dblclick" and |target| + 1. Set MouseEvent attributes from native with |event|, |native| + 1. If |event|.{{screenX}} is not an integer value, then round it. + 1. If |event|.{{screenY}} is not an integer value, then round it. 1. dispatch |event| at |target| @@ -719,6 +751,26 @@ A {{MouseEvent}} has the following:
+
+ + + : Input + :: |native|, the native mousedown or pointer event + :: |target|, the {{EventTarget}} of the event + + : Output + :: None + + 1. Let |menuevent| = create a PointerEvent with "contextmenu", |target| + 1. If |native| is valid, then + 1. Set MouseEvent attributes from native with |native| + + 1. Let |result| = dispatch |menuevent| at |target| + 1. If |result| is true, then show the UA context menu + + Note: To handle a context menu triggered by the keyboard, call this algorithm with + |native| = null and |target| = currently focused element. + +
+

create a PointerEvent

+ + : Input + :: |eventType|, a DOMString containing the event type + :: |eventTarget|, the {{EventTarget}} of the event + + : Output + :: None + + 1. Let |event| = the result of + creating a new event + 1. Initialize a PointerEvent with |event|, |eventType| and |eventTarget| + 1. Return |event| + +
+

create PointerEvent from MouseEvent

@@ -1553,7 +1622,7 @@ Issue: The contents of this section should eventually be moved into the PointerE :: None 1. Let |event| = the result of - creating a new PointerEvent + creating a new event 1. Let |target| = |mouseevent|.{{target}} @@ -1808,7 +1877,7 @@ A {{MouseEvent}} has the following: Issue: KeyboardLock is not yet an accepted standard and is included here as a placeholder to explore how it might be integrated. -Issue: The contents of this section should eventually be moved into the [[WICG Keyboard Lock]] spec +Issue: The contents of this section should eventually be moved into the [[WICG-Keyboard-Lock]] spec

Global State for Keyboard Lock

diff --git a/event-algo.html b/event-algo.html index 245479d..6e3451c 100644 --- a/event-algo.html +++ b/event-algo.html @@ -12,7 +12,7 @@ * - .toc for the Table of Contents (
    ) * + for the section numbers * - #toc for the Table of Contents (