commit | 23853bcbfb791418abea2c0c90bdce2c5cb3ecd2 | [log] [tgz] |
---|---|---|
author | Byungwoo Lee <blee@igalia.com> | Tue Apr 26 05:54:28 2022 |
committer | Blink WPT Bot <blink-w3c-test-autoroller@chromium.org> | Tue Apr 26 06:02:07 2022 |
tree | f68948d0c0f1dc5d53be7f7a1ef1ac692f2f3258 | |
parent | 2f3f5cb555144ab1f400c4f51d6b3c8900880eb5 [diff] |
Fix :has() invalidation bug on the inserted element/subtree :has() invalidation doesn't work for any mutation on an inserted element or subtree if the element or subtree didn't trigger the :has() invalidation when it inserted. <style> .a:has(.b) { color: green } </style> <div id="subject" class="a"></div> <script> const child = document.createElement('div'); subject.appendChild(child); child.classList.add('b'); getComputedStyle(subject).color; // Must be green. But it isn't. </script> Currently, only the SelectorChecker set the SiblingsAffectedByHas and AncestorsOrAncestorSiblingsAffectedByHas flags while checking a :has() argument selector. So if an insertion didn't trigger any :has() invalidation, the inserted element or subtree doesn't have the flags set. If an element doesn't have the flag set, any mutations on the element cannot trigger the :has() invalidation. To fix this bug, StyleEngine gets the two flags from the parent or previous sibling of the inserted element (or the root of inserted subtree), and set the flags on the inserted element or subtree. - Get AncestorsOrAncestorSiblingsAffectedByHas from parent - Get SiblingsAffectedByHas from previous sibling To prevent unnecessary AncestorsOrAncestorSiblingsAffectdByHas flag set, the SiblingsAffectedByHas flag is divided into these two flags. - SiblingsAffectedByHasForSiblingRelationship The :has() argument starts with a sibling combinator, and it doesn't have any child or descendant combinator. (.e.g. '.a:has(~ .b) {}') - SiblingsAffectedByHasForSiblingDescendantRelationship The :has() argument starts with sibling combinator, and it also has a child or descendant combinator. (.e.g. '.a:has(~ .b .c) {}' Only when one or more of these two conditions are satisfied, StyleEngine sets the AncestorsOrAncestorSiblingsAffectedByHas flag on the descendants of the inserted subtree root. - If the previous sibling has the SiblingsAffectedByHasForSiblingDescendantRelationship flag set. - If the parent has the AncestorsOrAncestorSiblingsAffectedByHas flag set The :has() scope element need to have the flags set also because the inserted element can be the only element that possibly affects the :has() state of the :has() scope element. (Then the StyleEngine needs to get the flags from the :has() scope element) So, the flag setting logic in the SelectorChecker::CheckPseudoHas() was changed to set the flags on the :has() scope element before starting the :has() argument checking traversal. The logic of setting SiblingsAffectedByHas flags was relocated to be invoked before starting :has() argument checking traversal to simplify the flag setting logic. To collect flags setting related code in the same place, the AffectedByHasIterator class was moved to the selector_checker.cc file. And it was renamed as below to clarify its purpose. - AncestorsOrAncestorSiblingsAffectedByHasIterator This CL includes the fix for https://crbug.com/1315107. For every parsing finished element, if the parent or previous sibling of the element has the flags set, StyleEngine checks the finished element and its descendants for :has() invalidation. Due to the logic of flag checking, the descendant traversal will be done only for the topmost parsing finished element. Bug: 669058, 1315107 Change-Id: I20c5b7e2956514d10257e90270982ab3afd93cb6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3590254 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Byungwoo Lee <blee@igalia.com> Cr-Commit-Position: refs/heads/main@{#996014}
The web-platform-tests Project is a cross-browser test suite for the Web-platform stack. Writing tests in a way that allows them to be run in all browsers gives browser projects confidence that they are shipping software that is compatible with other implementations, and that later implementations will be compatible with their implementations. This in turn gives Web authors/developers confidence that they can actually rely on the Web platform to deliver on the promise of working across browsers and devices without needing extra layers of abstraction to paper over the gaps left by specification editors and implementors.
The most important sources of information and activity are:
wpt:matrix.org
matrix channel; includes participants located around the world, but busiest during the European working day.If you'd like clarification about anything, don't hesitate to ask in the chat room or on the mailing list.
Clone or otherwise get https://github.com/web-platform-tests/wpt.
Note: because of the frequent creation and deletion of branches in this repo, it is recommended to “prune” stale branches when fetching updates, i.e. use git pull --prune
(or git fetch -p && git merge
).
See the documentation website and in particular the system setup for running tests locally.
The wpt
command provides a frontend to a variety of tools for working with and running web-platform-tests. Some of the most useful commands are:
wpt serve
- For starting the wpt http serverwpt run
- For running tests in a browserwpt lint
- For running the lint against all testswpt manifest
- For updating or generating a MANIFEST.json
test manifestwpt install
- For installing the latest release of a browser or webdriver server on the local machine.wpt serve-wave
- For starting the wpt http server and the WAVE test runner. For more details on how to use the WAVE test runner see the documentation.On Windows wpt
commands must be prefixed with python
or the path to the python binary (if python
is not in your %PATH%
).
python wpt [command]
Alternatively, you may also use Bash on Ubuntu on Windows in the Windows 10 Anniversary Update build, then access your windows partition from there to launch wpt
commands.
Please make sure git and your text editor do not automatically convert line endings, as it will cause lint errors. For git, please set git config core.autocrlf false
in your working tree.
The master branch is automatically synced to wpt.live and w3c-test.org.
Save the Web, Write Some Tests!
Absolutely everyone is welcome to contribute to test development. No test is too small or too simple, especially if it corresponds to something for which you've noted an interoperability bug in a browser.
The way to contribute is just as usual:
git checkout -b topic
../wpt lint
as described above.If you spot an issue with a test and are not comfortable providing a pull request per above to fix it, please file a new issue. Thank you!