From fd4ce389c137432c7e7c007298af106c10ee733a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 21 Apr 2025 13:33:23 +0200 Subject: [PATCH 1/4] [css-contain-2] Stop monkey-patching the HTML spec. --- css-contain-2/Overview.bs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/css-contain-2/Overview.bs b/css-contain-2/Overview.bs index 614339e5a8a..837e3375be9 100644 --- a/css-contain-2/Overview.bs +++ b/css-contain-2/Overview.bs @@ -1994,6 +1994,18 @@ Suppressing An Element's Contents Entirely: the 'content-visibility' property {# When the element becomes disconnected, the element's [=proximity to the viewport=] becomes [=not determined=]. +
+ All elements have a currently relevant to the user flag, initially false. +
+ +
+ To update content relevancy for a document doc: + + 1. For each element [=connected=] to doc with ''auto'' used value of ''content-visibility'' + 1. If element is [=relevant to the user=], then set element's [=currently relevant to the user=] flag to true. + 1. Otherwise, set element's [=currently relevant to the user=] flag to false. +
+
An element is relevant to the user if any of the following conditions are true: @@ -2308,14 +2320,7 @@ Restrictions and Clarifications {#cv-notes} 3. If an element starts or stops [=skipped contents|skipping its contents=], - this change happens - after the requestAnimationFrame callbacks - of the frame that renders the effects of the change - have run. - Specifically, such changes will take effect between steps 13 and 14 - of [=update the rendering=] step of the Processing Model - (between “run the animation frame callbacks” - and “run the update intersection observations steps”). + this change happens when [=update content relevancy for a document=] runs.
Determining the viewport intersection of the element From 7ce5782a1e1e86c554b116cd732de637fa89f5ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 21 Apr 2025 13:54:22 +0200 Subject: [PATCH 2/4] [css-contain-2] More refined approach, I think. --- css-contain-2/Overview.bs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/css-contain-2/Overview.bs b/css-contain-2/Overview.bs index 837e3375be9..69849fe5b4c 100644 --- a/css-contain-2/Overview.bs +++ b/css-contain-2/Overview.bs @@ -1999,11 +1999,30 @@ Suppressing An Element's Contents Entirely: the 'content-visibility' property {#
- To update content relevancy for a document doc: + To update content relevancy for a document given a document doc, and a boolean isFirstIteration: + 1. Let changed be false. 1. For each element [=connected=] to doc with ''auto'' used value of ''content-visibility'' - 1. If element is [=relevant to the user=], then set element's [=currently relevant to the user=] flag to true. - 1. Otherwise, set element's [=currently relevant to the user=] flag to false. + 1. Determine proximity to the viewport for element. + 1. If element is not [=currently relevant to the user=] and element is [=relevant to the user=], then: + 2. Set changed to true. + 2. Set element's [=currently relevant to the user=] flag to true. + 1. If isFirstIteration is false, then [=continue=]. + 1. If element is [=relevant to the user=], then: + 1. If element's [=currently relevant to the user=] flag is false, set changed to true. + 1. Set element's [=currently relevant to the user=] flag to true. + 1. Otherwise: + 1. If element's [=currently relevant to the user=] flag is true, set changed to true. + 1. Set element's [=currently relevant to the user=] flag to false. + 1. return changed. + +
+ The intent of the changed variable is for the initial viewport + proximity determination, which takes effect immediately, to be reflected in + the style and layout calculation which is carried out in a previous step of + this loop. Proximity determinations other than the initial one take effect + at the next rendering opportunity. +
From ec07976a021a618e84ca97ed74fa946d3c342239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 10 May 2025 13:05:23 +0200 Subject: [PATCH 3/4] [css-contain-2] Try to fix the prose for initial determination to happen sync, effectively. --- css-contain-2/Overview.bs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/css-contain-2/Overview.bs b/css-contain-2/Overview.bs index 69849fe5b4c..2ba4eee4aee 100644 --- a/css-contain-2/Overview.bs +++ b/css-contain-2/Overview.bs @@ -1999,15 +1999,13 @@ Suppressing An Element's Contents Entirely: the 'content-visibility' property {#
- To update content relevancy for a document given a document doc, and a boolean isFirstIteration: + To update content relevancy for a document given a document doc, and a boolean updateNonInitial: 1. Let changed be false. 1. For each element [=connected=] to doc with ''auto'' used value of ''content-visibility'' - 1. Determine proximity to the viewport for element. - 1. If element is not [=currently relevant to the user=] and element is [=relevant to the user=], then: - 2. Set changed to true. - 2. Set element's [=currently relevant to the user=] flag to true. - 1. If isFirstIteration is false, then [=continue=]. + 1. Let isInitialDetermination be true if element's [=proximity to the viewport=] is [=not determined=], otherwise false. + 1. Determine [=proximity to the viewport=] for element. + 1. If updateNonInitial is false and isInitialDetermination is false, then [=continue=]. 1. If element is [=relevant to the user=], then: 1. If element's [=currently relevant to the user=] flag is false, set changed to true. 1. Set element's [=currently relevant to the user=] flag to true. @@ -2017,10 +2015,12 @@ Suppressing An Element's Contents Entirely: the 'content-visibility' property {# 1. return changed.
- The intent of the changed variable is for the initial viewport - proximity determination, which takes effect immediately, to be reflected in - the style and layout calculation which is carried out in a previous step of - this loop. Proximity determinations other than the initial one take effect + The intent of the changed and updateNonInitial + variables is for the initial viewport proximity determination, which takes + effect immediately, to be reflected in the style and layout calculation + this frame. + + Proximity determinations other than the initial one take effect at the next rendering opportunity.
From 4248490afa1fbd774f5d385fb952afd4f4ba00d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 10 May 2025 13:34:57 +0200 Subject: [PATCH 4/4] [css-contain-2] Keep non-initial viewport determination happen one frame later. --- css-contain-2/Overview.bs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/css-contain-2/Overview.bs b/css-contain-2/Overview.bs index 2ba4eee4aee..6d134c124f4 100644 --- a/css-contain-2/Overview.bs +++ b/css-contain-2/Overview.bs @@ -1998,20 +1998,28 @@ Suppressing An Element's Contents Entirely: the 'content-visibility' property {# All elements have a currently relevant to the user flag, initially false.
+
+ To update currently relevant to the user given an element element: + + 1. Let currentlyRelevant be true if element is [=relevant to the user=], otherwise false. + 1. If element's [=currently relevant to the user=] flag is equal to currentlyRelevant, then return false. + 1. Set element's [=currently relevant to the user=] flag to currentlyRelevant. + 1. return true. +
+
To update content relevancy for a document given a document doc, and a boolean updateNonInitial: 1. Let changed be false. - 1. For each element [=connected=] to doc with ''auto'' used value of ''content-visibility'' + 1. For each element [=connected=] to doc with ''auto'' used value of ''content-visibility'': + 1. If updateNonInitial is true: + 1. If [=update currently relevant to the user=] for element returns true. + 1. Set changed to true. 1. Let isInitialDetermination be true if element's [=proximity to the viewport=] is [=not determined=], otherwise false. 1. Determine [=proximity to the viewport=] for element. - 1. If updateNonInitial is false and isInitialDetermination is false, then [=continue=]. - 1. If element is [=relevant to the user=], then: - 1. If element's [=currently relevant to the user=] flag is false, set changed to true. - 1. Set element's [=currently relevant to the user=] flag to true. - 1. Otherwise: - 1. If element's [=currently relevant to the user=] flag is true, set changed to true. - 1. Set element's [=currently relevant to the user=] flag to false. + 1. If isInitialDetermination is false, then [=continue=]. + 1. If [=update currently relevant to the user=] for element returns true. + 1. Set changed to true. 1. return changed.