[webkit-changes] [WebKit/WebKit] df5bab: [Remote Inspection] Refactor some element selectio...
Wenson Hsieh
noreply at github.com
Thu May 9 07:14:32 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: df5bab1b42ace04ea660b238da931ea0d75723c5
https://github.com/WebKit/WebKit/commit/df5bab1b42ace04ea660b238da931ea0d75723c5
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2024-05-09 (Thu, 09 May 2024)
Changed paths:
M Source/WebCore/loader/DocumentLoader.h
M Source/WebCore/page/ElementTargetingController.cpp
M Source/WebCore/page/ElementTargetingController.h
M Source/WebCore/page/ElementTargetingTypes.h
M Source/WebKit/Scripts/webkit/messages.py
M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
M Source/WebKit/Shared/WebsitePoliciesData.h
M Source/WebKit/Shared/WebsitePoliciesData.serialization.in
M Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm
M Source/WebKit/UIProcess/WebPageProxy.cpp
M Source/WebKit/WebProcess/WebPage/WebPage.cpp
M Source/WebKit/WebProcess/WebPage/WebPage.h
M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
M Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/element-targeting-7.html
Log Message:
-----------
[Remote Inspection] Refactor some element selection heuristics
https://bugs.webkit.org/show_bug.cgi?id=273914
rdar://127633767
Reviewed by Aditya Keerthi.
Refactor some logic for finding elements in Web Inspector using Develop > Start Element Selection,
and when right clicking on an element in the tree view and selecting `Toggle Visibility`.
* Source/WebCore/loader/DocumentLoader.h:
(WebCore::DocumentLoader::visibilityAdjustmentSelectors const):
(WebCore::DocumentLoader::setVisibilityAdjustmentSelectors):
* Source/WebCore/page/ElementTargetingController.cpp:
(WebCore::ElementTargetingController::extractTargets):
Adjust this to avoid surfacing nearby elements that are already children of a targeted element,
since they're redundant.
(WebCore::ElementTargetingController::adjustVisibility):
Make this take a list of `TargetedElementAdjustment` structs, each of which contains a pair of IDs
that represents the targeted element, as well as selectors corresponding to that element.
(WebCore::ElementTargetingController::adjustVisibilityInRepeatedlyTargetedRegions):
Hoist code to initialize `m_visibilityAdjustmentSelectors` into the call site here, and also add
logic to schedule a timer to periodically check the list of selectors ~once per second, 10 seconds
after page load.
(WebCore::ElementTargetingController::applyVisibilityAdjustmentFromSelectors):
Rename `m_remainingVisibilityAdjustmentSelectors` to just `m_visibilityAdjustmentSelectors`, and
change how it works. Instead of removing matched elements from this set and clearing the whole set
after a 30 seconds, keep the members of this set intact over the course of page load. Accumulate
more entries in this list when toggling element visibility using `adjustVisibility` below.
(WebCore::ElementTargetingController::reset):
(WebCore::ElementTargetingController::resetVisibilityAdjustments):
(WebCore::ElementTargetingController::selectorBasedVisibilityAdjustmentTimerFired):
* Source/WebCore/page/ElementTargetingController.h:
* Source/WebCore/page/ElementTargetingTypes.h:
Add and deploy some type aliases to make these nested templated types easier to read.
* Source/WebKit/Scripts/webkit/messages.py:
(headers_for_type):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/Shared/WebsitePoliciesData.h:
* Source/WebKit/Shared/WebsitePoliciesData.serialization.in:
* Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm:
(-[WKWebpagePreferences _setVisibilityAdjustmentSelectorsIncludingShadowHosts:]):
Deploy the type aliases above in more places.
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetVisibilityAdjustmentsForTargetedElements):
(WebKit::WebPageProxy::adjustVisibilityForTargetedElements):
(WebKit::extractIdentifiers): Deleted.
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::adjustVisibilityForTargetedElements):
(WebKit::WebPage::resetVisibilityAdjustmentsForTargetedElements):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm:
(TestWebKitAPI::TEST(ElementTargeting, AdjustVisibilityAfterRecreatingElement)):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/element-targeting-7.html:
Add an API test to exercise the change.
Canonical link: https://commits.webkit.org/278562@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