Skip to content

Commit de4f01b

Browse files
committed
[css-anchor-position-1] Adopt Xiaocheng's suggestion for fixing the fallback check. w3c#8059.
1 parent 95ad995 commit de4f01b

File tree

1 file changed

+50
-27
lines changed

1 file changed

+50
-27
lines changed

css-anchor-position-1/Overview.bs

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ spec:css-cascade-5; type:dfn; text:property
2424
<style>
2525
/* Put nice boxes around each algorithm. */
2626
[data-algorithm]:not(.heading) {
27-
padding: .5em;
28-
border: thin solid #ddd; border-radius: .5em;
29-
margin: .5em calc(-0.5em - 1px);
27+
padding: .5em;
28+
border: thin solid #ddd; border-radius: .5em;
29+
margin: .5em calc(-0.5em - 1px);
3030
}
3131
[data-algorithm]:not(.heading) > :first-child {
32-
margin-top: 0;
32+
margin-top: 0;
3333
}
3434
[data-algorithm]:not(.heading) > :last-child {
35-
margin-bottom: 0;
35+
margin-bottom: 0;
3636
}
3737
[data-algorithm] [data-algorithm] {
38-
margin: 1em 0;
38+
margin: 1em 0;
3939
}
4040
</style>
4141

@@ -91,12 +91,12 @@ to refer to the position of one or more [=anchor elements=].
9191
The ''anchor()'' function resolves to a <<length>>.
9292

9393
<pre class=prod>
94-
&lt;anchor()> = anchor( <<anchor-element>>? <<anchor-side>>, <<length-percentage>>? )
95-
<dfn><<anchor-element>></dfn> = <<dashed-ident>> | implicit
96-
<dfn><<anchor-side>></dfn> = auto | auto-same
97-
| top | left | right | bottom
98-
| start | end | self-start | self-end
99-
| <<percentage>> | center
94+
&lt;anchor()> = anchor( <<anchor-element>>? <<anchor-side>>, <<length-percentage>>? )
95+
<dfn><<anchor-element>></dfn> = <<dashed-ident>> | implicit
96+
<dfn><<anchor-side>></dfn> = auto | auto-same
97+
| top | left | right | bottom
98+
| start | end | self-start | self-end
99+
| <<percentage>> | center
100100
</pre>
101101

102102
The ''anchor()'' function has three arguments:
@@ -899,21 +899,44 @@ Probably should introduce a <css>smooth</css> keyword
899899
to 'position-fallback'
900900
to trigger automatic "animation" of the fallback'd properties.
901901

902-
To determine which entry is selected,
903-
[=list/iterate=] over the [=position fallback list=],
904-
applying the properties of each entry in turn
905-
according to the standard cascade rules,
906-
and additionally shifting the element's [=margin box=]
907-
according to its [=snapshotted scroll offset=]
908-
(if it has one),
909-
and determining whether or not the element's [=margin box=]
910-
overflows its [=containing block=].
911-
912-
Note: Descendants overflowing the anchored block
913-
don't affect this.
914-
915-
The properties of the first non-overflowing entry
916-
(or the last attempted entry, if none succeeded),
902+
<div algorithm>
903+
To <dfn>determine the position fallback styles</dfn> of an element |el|:
904+
905+
1. Let |base styles| be the current used styles of |el|.
906+
907+
2. [=list/For each=] |fallback styles| in the [=position fallback list=]:
908+
909+
1. Apply the styles in |fallback styles| to |el|,
910+
overriding the corresponding properties in |base styles|.
911+
912+
Perform any specified/computed/used-value time normalizations
913+
that are required to make the overridden styles into [=used values=]
914+
(such as resolving [=math functions=], etc).
915+
916+
Let |adjusted styles|
917+
be |el|'s styles after these adjustments.
918+
919+
2. If |el| has a [=snapshotted scroll offset=],
920+
then shift |el|'s margin box's position by the offsets.
921+
922+
Also, if any of |el|'s [=inset properties=] are non-auto,
923+
add the [=snapshotted scroll offset=] for the appropriate axis
924+
to their values.
925+
Recalculate |el|'s [=inset-modified containing block=]
926+
using these shifted values
927+
to obtain the |scroll-adjusted IMCB|.
928+
929+
3. If |el|'s margin box is fully contained within the |scroll-adjusted IMCB|,
930+
or |fallback styles| is the final entry in the [=position fallback list=],
931+
then use |adjusted styles| for |el|
932+
and exit this algorithm.
933+
934+
Note: Descendants overflowing |el|
935+
don't affect this calculation,
936+
only |el|'s own [=margin box=].
937+
</div>
938+
939+
The styles returned by [=determining the position fallback styles=]
917940
are taken as the final values for the specified properties.
918941

919942
Implementations may choose to impose an implementation-defined limit

0 commit comments

Comments
 (0)