Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 048d68a2ee2a1517b2f8bc4006b5d73ebb22c159
https://github.com/WebKit/WebKit/commit/048d68a2ee2a1517b2f8bc4006b5d73ebb22c159
Author: Wenson Hsieh <[email protected]>
Date: 2024-04-25 (Thu, 25 Apr 2024)
Changed paths:
A LayoutTests/fast/element-targeting/target-container-with-link-expected.txt
A LayoutTests/fast/element-targeting/target-container-with-link.html
M Source/WebCore/page/ElementTargetingController.cpp
Log Message:
-----------
[Remote Inspection] Element targeting should try :has() before falling back
to relative selectors
https://bugs.webkit.org/show_bug.cgi?id=273265
rdar://127065936
Reviewed by Abrar Protyasha.
Currently, when finding suitable selectors for a given target element, we first
check the target's
class, ID, and other DOM attributes to see if we can find anything unique.
Failing this, we then
fall back to a recursive selector, assembled using either `nth-child` (if
relative to the parent) or
`+` (if relative to a sibling). This can lead to unstable targeting behaviors
in some cases.
Instead, implement another strategy based around using `:has(…)` on any child
element with unique
attributes, and add ancestor selectors (`… > …`) until the selector uniquely
identifies the target.
Prefer this strategy, before falling back to parent or sibling selectors.
* LayoutTests/fast/element-targeting/target-container-with-link-expected.txt:
Added.
* LayoutTests/fast/element-targeting/target-container-with-link.html: Added.
Add a layout test to exercise the change.
* Source/WebCore/page/ElementTargetingController.cpp:
(WebCore::computeTagAndAttributeSelector):
(WebCore::computeHasChildSelector):
(WebCore::selectorsForTarget):
Canonical link: https://commits.webkit.org/278020@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes