Skip to content

Commit 97eef7b

Browse files
committed
[css-scoping-1][css-anchor-position-1] Define 'loose' and 'strict' tree-scoped names, to distinguish anchor-name from anchor-scope behavior. #7916 #9408 #5984
1 parent f82b0de commit 97eef7b

File tree

2 files changed

+48
-23
lines changed

2 files changed

+48
-23
lines changed

css-anchor-position-1/Overview.bs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Values are defined as follows:
168168
:: If the element generates a [=principal box=],
169169
the element is an [=anchor element=],
170170
with a list of [=anchor names=] as specified.
171-
Each [=anchor name=] is a [=tree-scoped name=].
171+
Each [=anchor name=] is a [=tree-scoped name/loosely matched=] [=tree-scoped name=].
172172

173173
Otherwise, the property has no effect.
174174
</dl>
@@ -195,6 +195,11 @@ Note: While an element is in the [=skipped contents=] of another element
195195
it's not an [=acceptable anchor element=],
196196
effectively acting as if it had no names.
197197

198+
Note: Positioned elements in [=shadow trees=]
199+
can reference [=anchor names=] defined in “higher” trees.
200+
Currently, they cannot reference [=anchor names=]
201+
defined in “lower” shadow trees, though.
202+
198203
### Implicit Anchor Elements ### {#implicit}
199204

200205
Some specifications can define that,
@@ -274,7 +279,7 @@ Values have the following meanings:
274279
to [=anchor elements=] within this subtree.
275280

276281
This value only affects [=anchor names=] in the same tree scope,
277-
as if it were a [=tree-scoped name=].
282+
as if it were a [=tree-scoped name/strictly matched=] [=tree-scoped name=].
278283
(That is, ''anchor-scope: all'' acts identically
279284
to ''anchor-scope: --foo, --bar, ...'',
280285
listing all relevant [=anchor names=].)
@@ -286,11 +291,9 @@ Values have the following meanings:
286291
to be in scope only for this element's descendants;
287292
and limits descendants to only match these [=anchor names=]
288293
to [=anchor elements=] within this subtree.
289-
The <<dashed-ident>> is a [=tree-scoped name=].
290294

291-
Note: Per [[css-scoping-1]],
292-
when two [=tree-scoped names=] are compared,
293-
they only match if they're from the same tree.
295+
The <<dashed-ident>> represents a [=tree-scoped name/strictly matched=] [=tree-scoped name=],
296+
i.e. it can only match against [=anchor names=] in the same shadow tree.[[!CSS-SCOPING-1]]
294297
</dl>
295298

296299
This property has no effect on [=implicit anchor elements=].
@@ -429,8 +432,8 @@ in anchor positioning.
429432
and either
430433
* |possible anchor| is [=in a lower top layer=] than |positioned el|, or
431434
* they both exist in the same [=top layer=],
432-
but |possible anchor| is either not [=absolutely positioned=]
433-
or occurs earlier in the [=flat tree=] order than |positioned el|
435+
but |possible anchor| is either not [=absolutely positioned=]
436+
or occurs earlier in the [=flat tree=] order than |positioned el|
434437
* The element generating |possible anchor|'s [=containing block=]
435438
(if one exists)
436439
is an [=acceptable anchor element=] for |positioned el|
@@ -2142,7 +2145,7 @@ laying out later boxes cannot change this decision.
21422145
its [=containing block=] has changed,
21432146
or it no longer generates a box.
21442147
* Its computed value for any [=longhand property|longhand=] of 'position-try' has changed.
2145-
* Its computed value for any [=@position-try property=] has changed.
2148+
* Its computed value for any [=accepted @position-try property=] has changed.
21462149
* Any of the ''@position-try'' rules referenced by it
21472150
have been added, removed, or mutated.
21482151

css-scoping-1/Overview.bs

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -696,36 +696,56 @@ Name-Defining Constructs and Inheritance</h3>
696696

697697
If an at-rule or property defines a name that other CSS constructs can refer to it by,
698698
such as a ''@font-face'' '@font-face/font-family!!descriptor' name
699-
or an ''@keyframes'' name,
699+
or an 'anchor-scope' name,
700700
it must be defined as a <dfn export for=CSS>tree-scoped name</dfn>.
701-
[=Tree-scoped names=] are "global" within a particular [=node tree=];
702-
unless otherwise specified,
703-
they're associated with the [=root=] of the [=element=] hosting the stylesheet that the at-rule or property is defined in.
704-
705-
Properties or descriptors that reference a "global" name,
701+
[=Tree-scoped names=] are associated with
702+
the [=root=] of the [=element=] hosting the stylesheet
703+
that the at-rule or property is declared in.
704+
705+
Additionally, [=tree-scoped names=] can be <dfn export for="tree-scoped name">loosely matched</dfn> or <dfn export for="tree-scoped name">strictly matched</dfn>,
706+
defaulting to [=loosely matched=] unless otherwise specified.
707+
A [=loosely matched=] [=tree-scoped name=]
708+
can be matched by [=tree-scoped references=]
709+
(see below)
710+
in the same tree or descendant trees,
711+
while a [=strictly matched=] [=tree-scoped name=]
712+
can only be matched by [=tree-scoped references=]
713+
in the exact same tree.
714+
715+
Properties or descriptors that reference a [=tree-scoped name=],
706716
such as the 'font-family!!property'
707717
or 'animation-name' properties,
708718
must define their value as a <dfn export for=CSS>tree-scoped reference</dfn>.
709-
[=Tree-scoped references=] implicitly capture
719+
These references implicitly capture
710720
a [=node tree=] [=root=]
711721
along with their specified value:
712722
unless otherwise specified,
713-
the [=root=] of the [=element=] hosting the stylesheet that the property or descriptor is defined in.
723+
the [=root=] of the [=element=] hosting the stylesheet that the property or descriptor is declared in.
714724
This [=root=] reference stays with the [=tree-scoped reference=]
715725
as it is inherited.
716726

717-
Whenever a [=tree-scoped reference=] is dereferenced
718-
to find the CSS construct it is referencing,
727+
If a [=tree-scoped name=] is <dfn export for="tree-scoped name">global</dfn>
728+
(such as ''@font-face'' names),
729+
then when a [=tree-scoped reference=] is dereferenced to find it,
719730
first search only the [=tree-scoped names=] associated with the same [=root=]
720-
as the [=tree-scoped reference=] must be searched.
731+
as the [=tree-scoped reference=].
721732
If no relevant [=tree-scoped name=] is found,
722733
and the [=root=] is a [=shadow root=],
723-
then repeat this search in the [=root=]'s [=host=]'s [=node tree=].
724-
(In other words, [=tree-scoped names=] "inherit" into descendant shadow trees,
734+
then repeat this search in the [=root=]'s [=host=]'s [=node tree=] (recursively).
735+
(In other words, global [=tree-scoped names=] inherit into descendant shadow trees,
725736
so long as they don't define the same name themselves.)
726737

738+
If a [=tree-scoped name=] is <dfn export for="tree-scoped name">local</dfn> to an element
739+
(such as 'anchor-name' or 'anchor-scope' values),
740+
then whether a [=tree-scoped reference=] matches the [=tree-scoped name=] on a given element
741+
depends on whether the [=tree-scoped name=] is [=tree-scoped name/strictly matched|strictly=] or [=tree-scoped name/loosely matched|loosely=] matched.
742+
A [=tree-scoped name/strictly matched=] [=tree-scoped name=] only matches if
743+
both names are associated with the same tree.
744+
A [=tree-scoped name/loosely matched=] [=tree-scoped name=] also matches if
745+
the [=tree-scoped name=] is associated with an ancestor tree.
746+
727747
If two [=tree-scoped names=] are directly compared
728-
(for example, comparing an [=anchor name=] with an 'anchor-scope' ident),
748+
(for example, when comparing [=computed values=]),
729749
they are considered to match only if their identifiers match,
730750
<em>and</em> their [=root=]s match exactly.
731751
(If one has a [=root=] that's an ancestor of the other, for example,
@@ -736,6 +756,8 @@ Name-Defining Constructs and Inheritance</h3>
736756
and the properties that reference them,
737757
to use these concepts.
738758

759+
Global names include:
760+
739761
* ''@font-face'', referenced by 'font-family!!property'
740762
* ''@font-feature-values'', referenced by 'font-family!!property'
741763
* ''@keyframes'', referenced by 'animation-name'

0 commit comments

Comments
 (0)