[webkit-changes] [WebKit/WebKit] eb2cf5: [Screen Time Refactoring] Don't spin up Screen Tim...
Jessica Cheung
noreply at github.com
Wed Mar 19 21:56:22 PDT 2025
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: eb2cf5ec637d91ca194ee664da7ccc1127cc6167
https://github.com/WebKit/WebKit/commit/eb2cf5ec637d91ca194ee664da7ccc1127cc6167
Author: Jessica Cheung <jcheung23 at apple.com>
Date: 2025-03-19 (Wed, 19 Mar 2025)
Changed paths:
M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
M Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
M Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/ScreenTime.mm
Log Message:
-----------
[Screen Time Refactoring] Don't spin up Screen Time in offscreen web views
https://bugs.webkit.org/show_bug.cgi?id=289784
rdar://146809373
Reviewed by Aditya Keerthi.
Check and do not create the ScreenTimeWebpageController if the web view
is never in window. Also, add an API test for this case.
Change the API test (DoNotDonateURLsInOccludedWebView) which used to
remove the webview from window, then add the webview back to window.
Now, instead of removing the webview from the window, we add a new window
to cover the webview, effectively occluding the webview. Then check for
donations again after making the covering window have zero width and height.
Add an API test (CreateControllerAfterOffscreenWebViewBecomesInWindow) for
the case of an offscreen webview that becomes an onscreen webview.
Add an API test (ScreenTimeControllerSetsURLWhenOffscreenWebViewBecomesInWindow)
to check if we set URLs in the case of an offscreen webview that becomes
an onscreen webview.
Update the API test (ScreenTimeControllerInstalledAfterRestoreFromSessionState)
to not be added to test window upon creation and added after verifying the
controller does not exist yet.
Rename function from _updateScreenTimeShieldVisibilityForWindow
to _updateScreenTimeBasedOnWindowVisibility since we are generally setting
Screen Time information based on the window's visibility. Additionally,
install the controller if the webview is now in window and we have not
installed the controller previously. Also, set the URL on the controller
if we are installing the controller from _updateScreenTimeBasedOnWindowVisibility.
Rename function from _installScreenTimeWebpageController to
_installScreenTimeWebpageControllerIfNeeded since this is
conditional on whether we need to install the controller or not.
Note: The uninstallation of the controller for
the case of a onscreen webview, then offscreen webview will be
in a separate PR to keep things concise and organized.
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _installScreenTimeWebpageControllerIfNeeded]):
(-[WKWebView _updateScreenTimeBasedOnWindowVisibility]):
(-[WKWebView _installScreenTimeWebpageController]): Deleted.
(-[WKWebView _updateScreenTimeShieldVisibilityForWindow]): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:
* Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm:
(WebKit::PageClientImplCocoa::updateScreenTimeWebpageControllerURL):
(WebKit::PageClientImplCocoa::viewIsBecomingVisible):
(WebKit::PageClientImplCocoa::viewIsBecomingInvisible):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ScreenTime.mm:
(TEST(ScreenTime, DoNotDonateURLsInOccludedWebView)):
(TEST(ScreenTime, CreateControllerAfterOffscreenWebViewBecomesInWindow)):
(TEST(ScreenTime, ScreenTimeControllerSetsURLWhenOffscreenWebViewBecomesInWindow)):
(TEST(ScreenTime, ScreenTimeControllerInstalledAfterRestoreFromSessionState)):
(TEST(ScreenTime, DoNotDonateURLsInOffscreenWebView)): Deleted.
Canonical link: https://commits.webkit.org/292400@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