From 5ea9aa07134853628df928331e3b0cdc7dacae23 Mon Sep 17 00:00:00 2001 From: Tab Atkins-Bittner Date: Mon, 11 Mar 2024 13:47:34 -0700 Subject: [PATCH] [css-anchor-position] Add 'anchor-scope'. #9045 --- css-anchor-position-1/Overview.bs | 263 ++++++++++++++++++++---------- 1 file changed, 180 insertions(+), 83 deletions(-) diff --git a/css-anchor-position-1/Overview.bs b/css-anchor-position-1/Overview.bs index 33604c441a0d..72c1dc1b97e1 100644 --- a/css-anchor-position-1/Overview.bs +++ b/css-anchor-position-1/Overview.bs @@ -103,13 +103,13 @@ Determining the Anchor {#determining} Creating an Anchor: the 'anchor-name' property {#name} @@ -177,6 +177,98 @@ unless otherwise specified. Note: Without this, these [=pseudo-elements=], which are often inaccessible by other specifications, cannot be positioned with [=implicit anchor elements=]. + + +

+Scoping Anchor Names: the 'anchor-scope' property

+ +
+Name: anchor-scope
+Value: none | all | <>#
+Initial: none
+Applies to: all elements
+Inherited: no
+Animation type: discrete
+Computed value: as specified
+
+ +This property scopes the specified [=anchor names=], +and lookups for these [=anchor names=], +to this element's subtree. +See [[#determining]]. + +Values have the following meanings: + +
+
none +
+ No changes in [=anchor name=] scope. + +
all +
+ Specifies that all [=anchor names=] defined by this element or its descendants-- + whose scope is not already limited by a descendant using 'anchor-scope'-- + to be in scope only for this element's descendants; + and limits descendants to only match [=anchor names=] + to [=anchor elements=] within this subtree. + +
<> +
+ Specifies that a matching [=anchor name=] defined by this element or its descendants-- + whose scope is not already limited by a descendant using 'anchor-scope'-- + to be in scope only for this element's descendants; + and limits descendants to only match these [=anchor names=] + to [=anchor elements=] within this subtree. +
+ +This property has no effect on [=implicit anchors=]. + +
+ When a design pattern is re-used, + 'anchor-scope' can prevent naming clashes across identical components. + For example, if a list contains positioned elements in each list item, + which want to position themselves relative to the list item they're in, + + +
+		li {
+			anchor-name: --list-item;
+			anchor-scope: --list-item;
+		}
+		li .positioned {
+			position: absolute;
+			anchor-default: --list-item;
+			inset-area: inline-start;
+		}
+	
+ + Without 'anchor-scope', + all of the <{li}> elements would be visible + to all of the positioned elements, + and so they'd all positioned themselves relative to the final <{li}>, + stacking up on top of each other. +
+ + + Finding an Anchor {#target} ----------------- @@ -226,6 +318,11 @@ or nothing (a missing specifier). If no element satisfies these conditions, return nothing. + Note: 'anchor-scope' can restrict the visibility + of certain [=anchor names=], + which can affect what elements can be [=anchor elements=] + for a given lookup. + Note: The general rule captured by these conditions is that |el| must be fully laid out before |query el| is laid out. @@ -277,13 +374,13 @@ or nothing (a missing specifier).

@@ -350,13 +447,13 @@ to explicitly refer to edges of an [=anchor element=]. The 'inset-area' Property {#inset-area} @@ -553,11 +650,11 @@ some of the [=inset-area grid's=] rows or columns can be zero-sized. @@ -575,9 +672,9 @@ The ''anchor()'' function resolves to a <>. <anchor()> = anchor( <>? <>, <>? ) <> = <> | implicit <> = inside | outside - | top | left | right | bottom - | start | end | self-start | self-end - | <> | center + | top | left | right | bottom + | start | end | self-start | self-end + | <> | center The ''anchor()'' function has three arguments: @@ -738,13 +835,13 @@ as if by an additional ''translate()'' transform. Centering on the Anchor: the ''anchor-center'' value {#anchor-center} @@ -788,12 +885,12 @@ and has no additional effect on how [=inset properties=] resolve. @@ -882,13 +979,13 @@ it resolves to ''0px''. Anchor-Based Sizing {#sizing} @@ -960,13 +1057,13 @@ it resolves to ''0px''. Overflow Management {#fallback} @@ -1104,13 +1201,13 @@ Values have the following meanings: Determining Fallback Order: the 'position-try-order' property {#position-try-order-property} @@ -1266,13 +1363,13 @@ it's set to the property's initial value. The ''@position-try'' Rule {#fallback-rule} @@ -1343,13 +1440,13 @@ without using ''@position-try'' at all. Applying Position Fallback {#fallback-apply} @@ -1478,7 +1575,7 @@ This limit must be at least five.