From f25e304cbd0afe85cf2073a03d09e1f80a0cb691 Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Fri, 24 Nov 2023 01:02:48 +0100 Subject: [PATCH 01/13] Specify the textInput event Fixes #353 --- sections/legacy-event-types.txt | 113 ++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/sections/legacy-event-types.txt b/sections/legacy-event-types.txt index fcacea4..1a615c4 100644 --- a/sections/legacy-event-types.txt +++ b/sections/legacy-event-types.txt @@ -51,6 +51,7 @@ completeness. +| keypress | Sync | Yes | Element | KeyboardEvent | Yes | Yes | Varies: launch text composition system; | | | | | | | | | EVENT{blur} and EVENT{focus} events; | | | | | | | | | EVENT{DOMActivate} event; other event | ++| textInput | Sync | Yes | Element | TextEvent | Yes | Yes | EVENT{input} event | ++-----------------------------+--------+----------+------------------------------------------+------------------+------------+------------+------------------------------------------------+ @@ -517,6 +518,118 @@ completeness. ++---+-------------+------------------------+---------------------+--------------------------------+ +

Legacy {{TextEvent}} events

+ +

Interface TextEvent

+ + +
+	[Exposed=Window]
+	interface TextEvent : Event {
+		readonly attribute DOMString data;
+		void initTextEvent(DOMString type,
+			optional boolean bubbles = false,
+			optional boolean cancelable = false,
+			optional Window? view = null,
+			optional DOMString data = "undefined");
+	};
+	
+ +
+
data
+
+ data holds the value of the characters generated by + an input method. This MAY be a single Unicode character or a + non-empty sequence of Unicode characters [[Unicode]]. Characters + SHOULD be normalized as defined by the Unicode normalization + form NFC, defined in [[UAX15]]. This + attribute MAY be the empty string. + + The un-initialized value of this attribute MUST be + "" (the empty string). +
+ +
initTextEvent(typeArg)
+
+ Initializes attributes of a TextEvent object. + This method has the same behavior as {{Event/initEvent()}}. + +
+
DOMString typeArg
+
+ Refer to the {{Event/initEvent()}} method for a description of this parameter. +
+ +
boolean bubblesArg
+
+ Refer to the {{Event/initEvent()}} method for a description of this parameter. +
+ +
boolean cancelableArg
+
+ Refer to the {{Event/initEvent()}} method for a description of this parameter. +
+ +
Window? view
+
+ Specifies {{UIEvent/view}}. This value MAY be null. +
+
+
+
+ +

Legacy {{TextEvent}} event types

+ +
textInput
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypetextInput
Interface{{TextEvent}}
Sync / AsyncSync
BubblesYes
Trusted TargetsElement
CancelableYes
ComposedYes
Default action + EVENT{input} event
Context
(trusted events)
+
    +
  • Issue: TODO
  • +
+
+ + If supported by a user agent, this event MUST be dispatched + as the default action of a EVENT{beforeinput} event. + +

Legacy {{MutationEvent}} events

The mutation and mutation name event modules are designed to allow From c8951aa2bc80f8121b3ec6bfe153a130431c0193 Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Fri, 24 Nov 2023 01:09:22 +0100 Subject: [PATCH 02/13] void -> undefined in IDL --- sections/legacy-event-types.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/legacy-event-types.txt b/sections/legacy-event-types.txt index 1a615c4..5dfe51b 100644 --- a/sections/legacy-event-types.txt +++ b/sections/legacy-event-types.txt @@ -527,7 +527,7 @@ completeness. [Exposed=Window] interface TextEvent : Event { readonly attribute DOMString data; - void initTextEvent(DOMString type, + undefined initTextEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional Window? view = null, From 5c0523f1854c106bab5fd5c4f62d6e3bb7419bfd Mon Sep 17 00:00:00 2001 From: zcorpan Date: Thu, 11 Jan 2024 23:38:56 +0100 Subject: [PATCH 03/13] Move textInput spec into event-algo.bs --- event-algo.bs | 118 +- event-algo.html | 3439 +++++++++++++++---------------- sections/legacy-event-types.txt | 109 +- 3 files changed, 1808 insertions(+), 1858 deletions(-) diff --git a/event-algo.bs b/event-algo.bs index 4e24dcd..f00c3cc 100644 --- a/event-algo.bs +++ b/event-algo.bs @@ -876,7 +876,7 @@ Issue: TODO 1. If suppress key input events flag is set, then 1. Exit (since the keydown was canceled) - Issue: Handle historical keypress event here + Issue: Handle historical keypress event here. Return if cancelled. 1. Let |inputType| = null 1. Let |data| = null @@ -896,12 +896,17 @@ Issue: TODO Can be enabled by changing the "dom.input_events.beforeinput_enabled" pref in "about:config" 1. Let |result| = fire an InputEvent with "beforeinput", |inputType| and |data| - 1. If |result| is true + 1. If |result| is false, then return. + 1. Set |result| = fire a TextEvent with "textInput", and |data| - Note: Perform DOM update here. Insert key into |target| element + Note: The "textInput" event is obsolete. - Note: Compat: - For insertFromPaste, Chrome has data = null, Firefox has data = same as beforeinput. + 1. If |result| is false, then return. + + Note: Perform DOM update here. Insert key into |target| element + + Note: Compat: + For insertFromPaste, Chrome has data = null, Firefox has data = same as beforeinput. 1. Fire an InputEvent with "input", |inputType| and |data| @@ -935,6 +940,109 @@ Issue: TODO + + +
+

Text Event

+ +Note: {{TextEvent}} is obsolete. + +

TextEvent Interface

+ +
+[Exposed=Window]
+interface TextEvent : UIEvent {
+    readonly attribute DOMString data;
+    undefined initTextEvent(DOMString type,
+        optional boolean bubbles = false,
+        optional boolean cancelable = false,
+        optional Window? view = null,
+        optional DOMString data = "undefined");
+};
+
+ +The data attribute must return the value it was initialized to. + +
+

The +initTextEvent(type, bubbles, cancelable, view, data) +method steps are: + +

    +
  1. If this's dispatch flag is set, then return. + +

  2. Initialize a UIEvent with this, |type| and |eventTarget| + +

  3. Set this.{{bubbles}} = |bubbles| + +

  4. Set this.{{cancelable}} = |cancelable| + +

  5. +

    Set this.{{view}} = |view| + +

    The bubbles/cancelable/view should be parameters to "Initialize a UIEvent" instead of being set twice. + +

  6. Set this.{{TextEvent/data}} = |data| +

+
+ +
+

initialize a TextEvent

+ + : Input + :: |e|, the {{Event}} to initialize + :: |eventType|, a DOMString containing the event type + :: |eventTarget|, the {{EventTarget}} of the event + + : Output + :: None + + 1. Initialize a TextEvent with |e|, |eventType| and |eventTarget| + + 1. Initialize the following public attributes + + 1. Set event.data = null + +
+ +
+

create a TextEvent

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

fire a TextEvent

+ + : Input + :: |eventType|, a DOMString containing the event type + :: |data|, a DOMString containing event data + + : Output + :: None + + 1. Let target = + currently focused area of a top-level browsing context + 1. Let |event| = result of create a TextEvent with |eventType|, |target| + 1. Set |event|.{{TextEvent/data}} = |data| + 1. Return the result of dispatch |event| at |target| + +
+ +
+ diff --git a/event-algo.html b/event-algo.html index 5155279..d99db20 100644 --- a/event-algo.html +++ b/event-algo.html @@ -1488,7 +1488,8 @@ } } - + + - + - + -

UI Events Algorithms

-

A Collection of Interesting Ideas,

+

A Collection of Interesting Ideas,

Issue Tracking: +
GitHub
Inline In Spec
Editor:
(Google) @@ -2162,7 +2209,7 @@

@@ -2171,12 +2218,11 @@

Abstract

This document attempts to describe, in an algorithmic manner, how UIEvents - - should be handled by User Agents. Because this functionality has been shipping - in UAs for many years, the primary goal is to document the existing behaviors - and identify areas where implementations disagree. The intent is to fold this - information into the main UIEvents spec (and other specs) once there is - consensus that this process described here is adequate.

+should be handled by User Agents. Because this functionality has been shipping +in UAs for many years, the primary goal is to document the existing behaviors +and identify areas where implementations disagree. The intent is to fold this +information into the main UIEvents spec (and other specs) once there is +consensus that this process described here is adequate.