From 88acd4d4af38934ec6f035cb214c51aeb5b346d5 Mon Sep 17 00:00:00 2001 From: Anders Hartvoll Ruud Date: Mon, 16 Jan 2023 04:07:43 -0800 Subject: [PATCH] [@scope] Support implicit scoping roots This CL makes it possible to specify a @scope rule without any prelude, scoping the rules implicitly to the parent of the owner node. This is implemented by storing a StyleSheetContents in each StyleScope, and treating each owner-parent-node of the StyleSheetContents as a scoping root. The following likely doesn't work, and is postponed for future CLs: - Constructed stylesheets - An owner node whose parent node is a ShadowRoot https://github.com/w3c/csswg-drafts/issues/7349 Bug: 1379844 Change-Id: Icbfae88636662e9a16dd11f9c7a371c997447f60 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4161741 Reviewed-by: Rune Lillesveen Commit-Queue: Anders Hartvoll Ruud Cr-Commit-Position: refs/heads/main@{#1093015} --- css/css-cascade/resources/scope.css | 4 + css/css-cascade/scope-implicit-external.html | 30 +++++++ css/css-cascade/scope-implicit.html | 91 ++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 css/css-cascade/resources/scope.css create mode 100644 css/css-cascade/scope-implicit-external.html create mode 100644 css/css-cascade/scope-implicit.html diff --git a/css/css-cascade/resources/scope.css b/css/css-cascade/resources/scope.css new file mode 100644 index 00000000000000..780e90fb67b996 --- /dev/null +++ b/css/css-cascade/resources/scope.css @@ -0,0 +1,4 @@ +@scope { + :scope { z-index:1; } + .a { z-index:2; } +} diff --git a/css/css-cascade/scope-implicit-external.html b/css/css-cascade/scope-implicit-external.html new file mode 100644 index 00000000000000..d1ac738b778da3 --- /dev/null +++ b/css/css-cascade/scope-implicit-external.html @@ -0,0 +1,30 @@ + + + + @scope - implicit scope root (external sheet) + + + + + +
+
+ +
+
+
+ + + + diff --git a/css/css-cascade/scope-implicit.html b/css/css-cascade/scope-implicit.html new file mode 100644 index 00000000000000..805a91eba36754 --- /dev/null +++ b/css/css-cascade/scope-implicit.html @@ -0,0 +1,91 @@ + +@scope - implicit scope root + + + +
+ + + + + + + + +