[webkit-changes] [WebKit/WebKit] e002db: `-renderedText` should not be empty for targeted e...

Wenson Hsieh noreply at github.com
Tue Aug 13 06:58:30 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e002db6b59bb5a5e7861a47de7e752d8604a18a1
      https://github.com/WebKit/WebKit/commit/e002db6b59bb5a5e7861a47de7e752d8604a18a1
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2024-08-13 (Tue, 13 Aug 2024)

  Changed paths:
    M Source/WebCore/page/ElementTargetingController.cpp
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm

  Log Message:
  -----------
  `-renderedText` should not be empty for targeted elements resolved using compound selectors
https://bugs.webkit.org/show_bug.cgi?id=277968
rdar://133705519

Reviewed by Tim Horton.

Make a couple of adjustments to the element targeting heuristic:

1.  Walk the ancestor chain and check `m_adjustedElements` to determine whether an element is in a
    visibility adjustment subtree. We do this instead of checking against the element's ancestors'
    `visibilityAdjustment()` states, because we may have temporarily reverted visibility adjustments
    when handling a targeting request.

2.  Allow selector-based targeting to find elements that have already been hidden by visibility
    adjustment.

* Source/WebCore/page/ElementTargetingController.cpp:
(WebCore::selectorForElementRecursive):
(WebCore::siblingRelativeSelectorRecursive):
(WebCore::parentRelativeSelectorRecursive):
(WebCore::selectorsForTarget):
(WebCore::ElementTargetingController::targetedElementInfo):
(WebCore::shouldIgnoreExistingVisibilityAdjustments):
(WebCore::ElementTargetingController::extractTargets):

Ensure that `isInVisibilityAdjustmentSubtree` is correctly computed in the case where we're
resolving a target inside of a visibility adjustment subtree using either selector- or search-text-
based targeting.

(WebCore::targetedElementInfo): Deleted.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm:
(TestWebKitAPI::TEST(ElementTargeting, RequestElementsFromSelectors)):

Augment an existing test to exercise this change, by verifying that `-renderedText` is equal to
"Bottom Right" for the bottom right hidden container.

Canonical link: https://commits.webkit.org/282163@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list