Supports all ':has' relative argument cases #29356
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Currently the relative selector is not supported yet, so this CL
provides the relative argument cases as follows.
This CL provides a wpt test for the above usage.
While matching those argument selectors on the :has argument subtree
of an element, we can get the candidate scope elements. By marking
those elements as matched, we can reduce the duplicated ':has'
argument matching operation.
HasArgumentSubtreeIterator provides the way to traverse the ':has'
argument subtree (downward subtree of the :has scope element). The
iterator provides right-to-left post-order traversal to prevent
incorrect 'NotMatched' status. And it also provides a way to limit
traversal depth or adjacent distance to prevent unnecessary tree
traversal for direct relations (child/direct sibling).
About the issue of incorrect 'NotMatched' status, the previous caching
logic has a bug of incorrectly using the cached status to skip one
argument selector matching operation for one descendant of an element.
The cached status should be used to skip the argument matching
operations for all the descendants of an element because it is the
status of :has scope element.
To store the 'NotMatched' status correctly during the ':has' subtree
traversal for argument selector matching , the traversal order should
be right-to-left reversed post-order to guarantee that, the downward
subtree(descendants/next siblings/descendants of next siblings) of
an element was checked with the argument selector before checking the
element and the previous check didn't mark the element as 'Matched'.
The ':has(.descendant)' test case in the 'has-basic.html' missed to
have an expected return value related with this bug, so the test
result is fixed with this CL.
And to check the added/fixed logic, following test are added.
Change-Id: I71f8752ad90d32c6f9ee6bf87949b838e3843eba
Bug: 669058
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2914967
Commit-Queue: Byungwoo Lee <blee@igalia.com>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#894067}