From 2d2ea050ff9e1589537bd391dcb215f4cc76b343 Mon Sep 17 00:00:00 2001 From: Byungwoo Lee Date: Wed, 2 Oct 2024 01:00:39 -0700 Subject: [PATCH] Support `:host:has()` Support `:host:has()` case to check whether a shadow host element has a relationship between its shadow root node and shadow tree element: - https://github.com/w3c/csswg-drafts/issues/10693 Normally, `:has()` checks relationship between its anchor element and the other elements in the same tree. But in `:host:has()` case, `:has()` checks relationship in the shadow tree of the anchor element. For example, `:host(.a):has(> div)` matches a shadow host element if the host has `a` class value and the shadow root of the host has a child div element. To cross tree boundary for testing selector and invalidating styles, this CL adds 'HasArgumentMatchInShadowTree' flag to the CSSSelector and sets the flag while parsing selectors. SelectorChecker and CheckPseudoHasArgumentTraversalIterator cross tree boundary for `:has()` argument test traversal if the flag is set. RuleInvalidationDataVisitor sets 'TreeBoundaryCrossing` invalidation-set flag for non-subject `:has()` if the flag is set. If StyleEngine reaches to a shadow host element while performing `:has()` invalidation, it invalidates the host element if the host is affected by `:has()` state change. Bug: 359758910 Change-Id: I69f0813deca4caefcff1f0b5ff8181ba67967a40 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5839398 Commit-Queue: Byungwoo Lee Reviewed-by: Rune Lillesveen Cr-Commit-Position: refs/heads/main@{#1362877} --- ...w-tree-element-at-nonsubject-position.html | 147 ++++++++++++++++++ ...adow-tree-element-at-subject-position.html | 143 +++++++++++++++++ 2 files changed, 290 insertions(+) create mode 100644 css/selectors/invalidation/host-has-shadow-tree-element-at-nonsubject-position.html create mode 100644 css/selectors/invalidation/host-has-shadow-tree-element-at-subject-position.html diff --git a/css/selectors/invalidation/host-has-shadow-tree-element-at-nonsubject-position.html b/css/selectors/invalidation/host-has-shadow-tree-element-at-nonsubject-position.html new file mode 100644 index 00000000000000..54f8c7b02ef675 --- /dev/null +++ b/css/selectors/invalidation/host-has-shadow-tree-element-at-nonsubject-position.html @@ -0,0 +1,147 @@ + + +:host:has(...) to check whether a shadow host has a shadow tree element (nonsubject position) + + + + +
+
+ +
+
+
+
+
+
+ + \ No newline at end of file diff --git a/css/selectors/invalidation/host-has-shadow-tree-element-at-subject-position.html b/css/selectors/invalidation/host-has-shadow-tree-element-at-subject-position.html new file mode 100644 index 00000000000000..f7c694bc36274b --- /dev/null +++ b/css/selectors/invalidation/host-has-shadow-tree-element-at-subject-position.html @@ -0,0 +1,143 @@ + + +:host:has(...) to check whether a shadow host has a shadow tree element (subject position) + + + + +
+
+ +
+
+
+
+
+
+ + \ No newline at end of file