-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
Showing
15 changed files
with
185 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.