Closed Bug 1739391 Opened 4 years ago Closed 4 years ago

[wpt-sync] Sync PR 31504 - Support style invalidation of ':has()' in rightmost compound

Categories

(Core :: CSS Parsing and Computation, task, P4)

task

Tracking

()

RESOLVED FIXED
96 Branch
Tracking Status
firefox96 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 31504 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/31504
Details from upstream follow.

Byungwoo Lee <blee@igalia.com> wrote:

Support style invalidation of ':has()' in rightmost compound

This is the initial CL of supporting style invalidation with ':has()'.

To minimize complexity, we will focus on the following limited usage.

  • Supports ':has()' in a rightmost, top-level compound
  • Supports ':has()' argument starts with child or descendant combinator
  • Only allow attribute or elemental selectors in argument

So the following will be ignored for now.

  • Ignore ':has()' in a non-rightmost compound
  • Ignore ':has()' in a logical combinations
  • Ignore ':has()' argument starts with '~' or '+'
  • Ignore all pseudos in ':has()' argument

To support this case, for a change on an element, we need to invalidate
ancestors.

Invalidate every ancestors for every mutations on every element is very
bad for performance.

So we need a way to skip these.

  • irrelevant element
  • irrelevant ancestor
  • irrelevant mutation

To skip the 'irrelevant element' and 'irrelevant ancestor', this CL
introduces two flags in the ComputedStyle.

  • AffectingHas : Indicate that a mutation on the element can affect
    ':has()' state.
  • AffectedByHas : Indicate that the element can be affected by ':has()'
    state change

During style recalculation, 'AffectedByHas' flag will be set when
SelectorChecker tries to match any ':has()' selector on an element.
For every descendants of the element, the 'AffectedByHas' flag will
be changed to 'AffectingHas' flag and stored.

\<style> .a:has(.b) { color: red }\</style>
\<div>
\<div class="a"> \<!-- AffectedByHas -->
\<div> \<!-- AffectingHas -->
\<div> \<!-- AffectingHas -->
\</div>
\</div>
\</div>
\<div>
\<div>
\</div>
\</div>
\</div>

Only for a mutation on the element with 'AffectingHas', style engine
will walk up ancestors. And it invalidate style only when an ancestor
has 'AffectedByHas'

Still we have invalidation for irrelevant mutation and invalidation on
irrelevant ancestors. We will handle those by separate CLs.

Bug: 669058
Change-Id: Ia7e607e01f9a070c0d69d89679b99efa0a104797
Reviewed-on: https://chromium-review.googlesource.com/3260677
WPT-Export-Revision: e86db0a1e7cb2bec18776d2cbb123cdc2253af88

Component: web-platform-tests → CSS Parsing and Computation
Product: Testing → Core
Whiteboard: [wptsync downstream] → [wptsync downstream error]
Whiteboard: [wptsync downstream error] → [wptsync downstream]

CI Results

Ran 11 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 1 tests and 19 subtests

Status Summary

Firefox

OK : 1
PASS: 12
FAIL: 7

Chrome

OK : 1
PASS: 12
FAIL: 7

Safari

OK : 1
PASS: 12
FAIL: 7

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

/css/selectors/invalidation/attribute-or-elemental-selectors-in-has.html
add .child to #div_child: div#div_subject.color: FAIL (Chrome: FAIL, Safari: FAIL)
add .descendant to #div_child: div#div_subject.color: FAIL (Chrome: FAIL, Safari: FAIL)
add .descendant to #div_grandchild: div#div_subject.color: FAIL (Chrome: FAIL, Safari: FAIL)
set descendant to #div_grandchild[attrname]: div#div_subject.color: FAIL (Chrome: FAIL, Safari: FAIL)
change #div_grandchild to #div_descendant: div#div_subject.color: FAIL (Chrome: FAIL, Safari: FAIL)
add descendant to #div_subject: div#div_subject.color: FAIL (Chrome: FAIL, Safari: FAIL)
add "div > descendant" to #div_subject: div#div_subject.color: FAIL (Chrome: FAIL, Safari: FAIL)

Pushed by wptsync@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/20439ad7dd9d [wpt PR 31504] - Support style invalidation of ':has()' in rightmost compound, a=testonly https://hg.mozilla.org/integration/autoland/rev/532ddd3c5b9c [wpt PR 31504] - Update wpt metadata, a=testonly
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 96 Branch
You need to log in before you can comment on or make changes to this bug.