From 58f8e52168540a048a9e3fccad5f85dc0c5f133c Mon Sep 17 00:00:00 2001
From: Raphael Kubo da Costa
Date: Fri, 8 Mar 2024 19:00:35 +0100
Subject: [PATCH] Modernize algorithms in "Algorithm" section
The original main goal was to give a name to the existing algorithm that
used to run in the "next animation frame task" so that it could be
referenced in the upcoming WebDriver section, but "animation frame task" as
a concept did not exist, and one thing led to another and the final change
includes a better version of the original algorithms, but without any
user-visible changes.
This change borrows a lot of ideas from the Screen Orientation spec as of
its 2023-08-09 Editor's Draft.
Most important changes:
- The "update the device posture information" algorithm was renamed to
"calculate the device posture information" so that it returns a value
instead of updating `[[CurrentPosture]]` directly -- that is done as task
queued in the user interaction task source (more on this below).
- Call the main algorithm "device posture change steps".
- Merge the separate page visibility-related algorithm into the main one,
and add the proper checks to it to ensure that documents whose visibility
state is "hidden" are not updated and that calls to "update the device
posture information" that result in the same value being stored do not
fire any "change" events.
- The "change" event is now queued to be fired in the user interaction task
source so that the moment it is actually fired is more predictable (the
"device posture change steps" are not running at any specific point of the
HTML event loop).
While here: the definition of the `onchange` attribute was updated to
mention the current terms defined in the HTML spec, along with a proper
`` for the event handler event type.
The language and the references used in the text have also been updated: we
no longer deal with browsing contexts, but with navigables; the
PAGE-VISIBILITY spec is no longer treated as a separate specification, as it
was merged into HTML a few years ago.
Related to #104. Fixes #95.
---
index.html | 144 +++++++++++++++++++++++------------------------------
1 file changed, 61 insertions(+), 83 deletions(-)
diff --git a/index.html b/index.html
index 22e72b0..9b6ba6a 100644
--- a/index.html
+++ b/index.html
@@ -250,9 +250,10 @@
- Updating the device posture information
+ Calculating the device posture information
- The steps to update the device posture information of a
- document are as follows:
+ The steps to calculate the device posture information of a
+ {{Document}} |document:Document| are as follows:
Return a {{DevicePostureType}} value determined in an
+ [=implementation-defined=] way based on the current hinge angle
+ value, [=current screen orientation=], as well as potential
+ implementation-specific signals, according to the [=posture values
+ table=].
@@ -464,74 +466,70 @@
Device Posture change
- Whenever the screen(s) fold angle, screen orientation or device
- specific signals change, the user agent MUST run the following
- steps as part of the next animation frame task:
+ When the user agent determines that the screen(s)' fold angle,
+ orientation or device-specific signals have changed for a [=top-level
+ traversable=], it MUST run the [=device posture change steps=] with
+ the [=top-level traversable=]'s [=navigable/active document=].
+
+
+ The device posture change steps for a {{Document}}
+ |document:Document| and an optional boolean |disallowRecursion|
+ (default false) are as follows:
[=Fire an event=] named "{{DevicePosture/change}}" at the
+ {{DevicePosture}} object associated with |document|'s [=relevant
+ global object=]'s associated {{Navigator}}.
-
- Fire an event named `change` at |document|'s
- {{Window.navigator.devicePosture}} object.
+
+
+
If |disallowRecursion| is true, abort these steps.
+
Run the [=device posture change steps=] with
+ |descendantNavigable|'s [=navigable/active document=] and true.
- Whenever a document becomes visible per [[PAGE-VISIBILITY]],
- in other words after the now visible algorithm is run, the
- user agent MUST run the following substeps as part of the next
- animation frame task:
+ This specification defines the following [=page visibility change
+ steps=] given |visibility state| and |document:Document|: