Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports all ':has' relative argument cases #29356

Merged
merged 1 commit into from Jun 19, 2021

Conversation

chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Jun 14, 2021

Currently the relative selector is not supported yet, so this CL
provides the relative argument cases as follows.

  • :has(:scope > <complex-selector>)
  • :has(:scope ~ <complex-selector>)
  • :has(:scope + <complex-selector>)

This CL provides a wpt test for the above usage.

  • has-relative-argument.html

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.

  • has-relative-argument.html

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}

Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot chromium-wpt-export-bot changed the title Supports ':has' argument starts with child or sibling relation Support all ':has' relative argument cases. Jun 15, 2021
@chromium-wpt-export-bot chromium-wpt-export-bot changed the title Support all ':has' relative argument cases. Supports all ':has' relative argument cases Jun 17, 2021
@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-2914967 branch 3 times, most recently from ae876f2 to 2d0b62f Compare Jun 19, 2021
Currently the relative selector is not supported yet, so this CL
provides the relative argument cases as follows.
 - :has(:scope > <complex-selector>)
 - :has(:scope ~ <complex-selector>)
 - :has(:scope + <complex-selector>)

This CL provides a wpt test for the above usage.
 - has-relative-argument.html

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.
 - has-relative-argument.html

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}
@chromium-wpt-export-bot chromium-wpt-export-bot merged commit eff766e into master Jun 19, 2021
22 checks passed
@chromium-wpt-export-bot chromium-wpt-export-bot deleted the chromium-export-cl-2914967 branch Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants