Skip to content

Commit 9cef400

Browse files
committed
[css-anchor-position-1] Give pile of algorithms some subheadings w3c#12818
1 parent 59804be commit 9cef400

1 file changed

Lines changed: 57 additions & 48 deletions

File tree

css-anchor-position-1/Overview.bs

Lines changed: 57 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Shortname: css-anchor-position
44
Level: 1
55
Status: ED
66
Group: csswg
7-
Work Status: exploring
7+
Work Status: refining
88
ED: https://drafts.csswg.org/css-anchor-position-1/
99
TR: https://www.w3.org/TR/css-anchor-position-1/
1010
Editor: Tab Atkins-Bittner, Google, http://xanthir.com/contact/, w3cid 42199
@@ -1556,7 +1556,7 @@ Values have the following meanings:
15561556
: <dfn><<try-tactic>></dfn>
15571557
::
15581558
Automatically creates a [=position option=]
1559-
by [=applying a try-tactic|applying the specified try tactic=]
1559+
by [=executing a try-tactic|executing the specified try tactic=]
15601560
to the box's [=base styles=],
15611561
then adding the constructed [=position option=]
15621562
to the box's [=position options list=].
@@ -1961,38 +1961,49 @@ This limit must be <em>at least</em> five.
19611961
all the [=remembered scroll offsets=] stay the same.
19621962
</div>
19631963

1964-
<div algorithm>
1965-
To <dfn>apply a position option</dfn> to a box's element |el|,
1966-
given a [=position option=] |new styles|:
1967-
1968-
1. With |new styles| inserted into the cascade
1969-
in the [=position fallback origin=],
1970-
resolve the cascade,
1971-
and perform enough layout to determine |el|'s [=used value|used styles=].
1964+
During a full layout pass,
1965+
once a box has determined its fallback styles
1966+
(or determined it's not using any),
1967+
laying out later boxes cannot change this decision.
19721968

1973-
For the purpose of calculating these styles,
1974-
a <em>hypothetical</em> [=anchor recalculation point=] is calculated,
1975-
and the resulting hypothetical [=remembered scroll offsets=] are used to determine |el|'s styles.
1969+
<div class=example>
1970+
For example, say you have two positioned boxes,
1971+
A and B,
1972+
with A laid out before B.
1973+
If B overflows and causes A's containing block to gain scrollbars,
1974+
this <em>does not</em> cause A
1975+
to go back and re-determine its fallback styles
1976+
in an attempt to avoid overflowing.
1977+
(At best, this can result in exponential layout costs;
1978+
at worst, it's cyclic and will never settle.)
19761979

1977-
2. Return |el|'s [=used value|used styles=].
1980+
Layout does not "go backward", in other words.
19781981
</div>
19791982

1980-
<div algorithm="remember or forget the last successful position option">
1983+
<h4 id="statefulness">
1984+
Maintaining and Clearing Fallback Choices</h4>
1985+
1986+
Some changes to a box have a particularly direct effect on [=determining position fallback styles=]
1987+
and thus trigger special behavior. These <dfn>fallback-sensitive changes</dfn> include:
1988+
* Its computed 'position' value has changed,
1989+
its [=containing block=] association has changed,
1990+
or it no longer generates a box.
1991+
* Its computed value for any [=longhand property|longhand=] of 'position-try' has changed.
1992+
* Its computed value for any [=accepted @position-try property=] has changed.
1993+
* Any of the ''@position-try'' rules referenced by it
1994+
have been added, removed, or mutated.
1995+
1996+
In order to maintain layout stability as much as possible,
1997+
[=determining position fallback styles=] prioritizes the [=last successful position option=],
1998+
which is determined as follows:
1999+
2000+
<div algorithm="record the last successful position option">
19812001
At the time that {{ResizeObserver}} events are determined and delivered,
1982-
the box can <dfn export>remember or forget the last successful position option</dfn>:
2002+
the box must <dfn export>record the last successful position option</dfn> as follows:
19832003

19842004
* If |el| has a [=last successful position option=]
19852005
remove its [=last successful position option=]
1986-
if any of the following are true:
1987-
1988-
* Its computed 'position' value has changed,
1989-
its [=containing block=] association has changed,
1990-
or it no longer generates a box.
1991-
* Its computed value for any [=longhand property|longhand=] of 'position-try' has changed.
1992-
* Its computed value for any [=accepted @position-try property=] has changed.
1993-
* Any of the ''@position-try'' rules referenced by it
1994-
have been added, removed, or mutated.
1995-
2006+
if any [=fallback-sensitive changes=] have occurred.
19962007
Then, [=determine position fallback styles=] for |el|
19972008
and set its [=last successful position option=]
19982009
to the set of [=accepted @position-try properties=] (and values)
@@ -2007,8 +2018,27 @@ This limit must be <em>at least</em> five.
20072018
is intentionally identical to the treatment of [=last remembered sizes=].
20082019
</div>
20092020

2021+
<h4 id="applying-options">
2022+
Applying Position Options</h4>
2023+
2024+
<div algorithm>
2025+
To <dfn>apply a position option</dfn> to a box's element |el|,
2026+
given a [=position option=] |new styles|:
2027+
2028+
1. With |new styles| inserted into the cascade
2029+
in the [=position fallback origin=],
2030+
resolve the cascade,
2031+
and perform enough layout to determine |el|'s [=used value|used styles=].
2032+
2033+
For the purpose of calculating these styles,
2034+
a <em>hypothetical</em> [=anchor recalculation point=] is calculated,
2035+
and the resulting hypothetical [=remembered scroll offsets=] are used to determine |el|'s styles.
2036+
2037+
2. Return |el|'s [=used value|used styles=].
2038+
</div>
2039+
20102040
<div algorithm>
2011-
To <dfn>apply a try-tactic</dfn>
2041+
To <dfn>execute a try-tactic</dfn>
20122042
to a set of |styles|
20132043
of a box's element |el|,
20142044
between two directions |directions|,
@@ -2124,27 +2154,6 @@ This limit must be <em>at least</em> five.
21242154
5. Return |styles|.
21252155
</div>
21262156

2127-
During a full layout pass,
2128-
once a box has determined its fallback styles
2129-
(or determined it's not using any),
2130-
laying out later boxes cannot change this decision.
2131-
2132-
<div class=example>
2133-
For example, say you have two positioned boxes,
2134-
A and B,
2135-
with A laid out before B.
2136-
If B overflows and causes A's containing block to gain scrollbars,
2137-
this <em>does not</em> cause A
2138-
to go back and re-determine its fallback styles
2139-
in an attempt to avoid overflowing.
2140-
(At best, this can result in exponential layout costs;
2141-
at worst, it's cyclic and will never settle.)
2142-
2143-
Layout does not "go backward", in other words.
2144-
</div>
2145-
2146-
2147-
21482157
<!-- Big Text: visibility
21492158

21502159
█▌ █▌ ████ ███▌ ████ ████▌ ████ █▌ ████ █████▌ █ ▐▌

0 commit comments

Comments
 (0)