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

[Remote Inspection] Add SPI to make it possible to inspect content under targeted elements #26328

Merged
merged 1 commit into from
Mar 22, 2024

Conversation

whsieh
Copy link
Member

@whsieh whsieh commented Mar 22, 2024

10f56d8

[Remote Inspection] Add SPI to make it possible to inspect content under targeted elements
https://bugs.webkit.org/show_bug.cgi?id=271475

Reviewed by Aditya Keerthi.

Introduce `-_adjustVisibilityForTargetedElements:completionHandler:`, and hook it up to the newly-
landed visibility adjustment infrastructure in WebCore. See below for more details.

* LayoutTests/TestExpectations:
* LayoutTests/fast/element-targeting/basic-element-targeting-expected.html: Added.
* LayoutTests/fast/element-targeting/basic-element-targeting.html: Added.
* LayoutTests/platform/ios-wk2/TestExpectations:
* LayoutTests/platform/mac-wk2/TestExpectations:

Add a test directory (and basic test) to exercise this new SPI.

* LayoutTests/resources/ui-helper.js:
(window.UIHelper.requestRenderedTextForSelector):
(window.UIHelper.adjustVisibilityForFrontmostTarget):
(window.UIHelper):

Add a testing hook that allows layout tests to exercise element targeting.

* Source/WebCore/page/ElementTargeting.cpp:
(WebCore::setNeedsVisibilityAdjustmentRecursive):
(WebCore::adjustVisibilityForTargetedElements):
* Source/WebCore/page/ElementTargeting.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _adjustVisibilityForTargetedElements:completionHandler:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::adjustVisibilityForTargetedElements):

Add plumbing through `WebPageProxy` and `WebPage`, down into WebCore.

* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::adjustVisibilityForTargetedElements):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
* Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::adjustVisibilityForFrontmostTarget):
* Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.h:
* Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm:
(WTR::UIScriptControllerCocoa::adjustVisibilityForFrontmostTarget):

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

108c944

Misc iOS, tvOS & watchOS macOS Linux Windows
❌ πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings   πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-wpe
❌ πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ›  wpe-skia
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ›  gtk
  πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2   πŸ§ͺ gtk-wk2
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-wk2-stress ❌ πŸ§ͺ api-gtk
βœ… πŸ›  πŸ§ͺ merge   πŸ›  watch
βœ… πŸ›  watch-sim

@whsieh whsieh self-assigned this Mar 22, 2024
@whsieh whsieh added the Platform Portability improvements and other general platform improvements not driven directly by site bugs. label Mar 22, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 22, 2024
@whsieh whsieh removed the merging-blocked Applied to prevent a change from being merged label Mar 22, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 22, 2024
@whsieh whsieh removed the merging-blocked Applied to prevent a change from being merged label Mar 22, 2024
Comment on lines +362 to +367
bool changed = false;
for (auto& element : elements) {
if (setNeedsVisibilityAdjustmentRecursive(element))
changed = true;
}
return changed;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return WTF::anyOf(elements, [&] (auto& element) {
    return setNeedsVisibilityAdjustmentRecursive(element);
});

Copy link
Member Author

@whsieh whsieh Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's actually not quite what I want (since I want to continue calling setNeedsVisibilityAdjustmentRecursive on the full list of elements, even if changed already becomes true). I'll leave this as-is (unless there's another more elegant way to write this?)

(Edit: to clarify, WTF::anyOf will bail early when the lambda returns true on the first element)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah got it; sounds good!

@whsieh whsieh added the merge-queue Applied to send a pull request to merge-queue label Mar 22, 2024
…der targeted elements

https://bugs.webkit.org/show_bug.cgi?id=271475

Reviewed by Aditya Keerthi.

Introduce `-_adjustVisibilityForTargetedElements:completionHandler:`, and hook it up to the newly-
landed visibility adjustment infrastructure in WebCore. See below for more details.

* LayoutTests/TestExpectations:
* LayoutTests/fast/element-targeting/basic-element-targeting-expected.html: Added.
* LayoutTests/fast/element-targeting/basic-element-targeting.html: Added.
* LayoutTests/platform/ios-wk2/TestExpectations:
* LayoutTests/platform/mac-wk2/TestExpectations:

Add a test directory (and basic test) to exercise this new SPI.

* LayoutTests/resources/ui-helper.js:
(window.UIHelper.requestRenderedTextForSelector):
(window.UIHelper.adjustVisibilityForFrontmostTarget):
(window.UIHelper):

Add a testing hook that allows layout tests to exercise element targeting.

* Source/WebCore/page/ElementTargeting.cpp:
(WebCore::setNeedsVisibilityAdjustmentRecursive):
(WebCore::adjustVisibilityForTargetedElements):
* Source/WebCore/page/ElementTargeting.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _adjustVisibilityForTargetedElements:completionHandler:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::adjustVisibilityForTargetedElements):

Add plumbing through `WebPageProxy` and `WebPage`, down into WebCore.

* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::adjustVisibilityForTargetedElements):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
* Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::adjustVisibilityForFrontmostTarget):
* Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.h:
* Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm:
(WTR::UIScriptControllerCocoa::adjustVisibilityForFrontmostTarget):

Canonical link: https://commits.webkit.org/276573@main
@webkit-commit-queue
Copy link
Collaborator

Committed 276573@main (10f56d8): https://commits.webkit.org/276573@main

Reviewed commits have been landed. Closing PR #26328 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 10f56d8 into WebKit:main Mar 22, 2024
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Mar 22, 2024
@whsieh whsieh deleted the eng/271475 branch March 22, 2024 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Portability improvements and other general platform improvements not driven directly by site bugs.
Projects
None yet
6 participants