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

Move most LazyInitialized ivars from WKWebViewConfiguration to API::PageConfiguration #26177

Conversation

achristensen07
Copy link
Contributor

@achristensen07 achristensen07 commented Mar 20, 2024

9b4ec97

Move most LazyInitialized ivars from WKWebViewConfiguration to API::PageConfiguration
https://bugs.webkit.org/show_bug.cgi?id=271301
rdar://125067469

Reviewed by Chris Dumez.

This is a step towards the API::PageConfiguration being made in WebPageProxy::createNewPage
rather than UIClient::createNewPage.

This new way of storing these objects is more robust against invalid use of WKWebViewConfiguration
if nil is set as the value of non-nullable objects, so the validate step is no longer needed
and the InvalidConfiguration API test needed some changes, but this should have no impact on
legitimate use of the API.

* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/API/APIPageConfiguration.cpp:
(API::PageConfiguration::Data::createBrowsingContextGroup):
(API::PageConfiguration::Data::createWebProcessPool):
(API::PageConfiguration::Data::createWebUserContentControllerProxy):
(API::PageConfiguration::Data::createWebPreferences):
(API::PageConfiguration::Data::createVisitedLinkStore):
(API::PageConfiguration::Data::createWebsitePolicies):
(API::PageConfiguration::create):
(API::PageConfiguration::browsingContextGroup const):
(API::PageConfiguration::processPool const):
(API::PageConfiguration::userContentController const):
(API::PageConfiguration::preferences const):
(API::PageConfiguration::pageToCloneSessionStorageFrom const):
(API::PageConfiguration::setPageToCloneSessionStorageFrom):
(API::PageConfiguration::visitedLinkStore const):
(API::PageConfiguration::websiteDataStore const):
(API::PageConfiguration::websiteDataStoreIfExists const):
(API::PageConfiguration::protectedWebsiteDataStore const):
(API::PageConfiguration::setWebsiteDataStore):
(API::PageConfiguration::defaultWebsitePolicies const):
(API::PageConfiguration::urlSchemeHandlerForURLScheme):
(API::PageConfiguration::setURLSchemeHandlerForURLScheme):
(API::PageConfiguration::lockdownModeEnabled const):
(API::PageConfiguration::delaysWebProcessLaunchUntilFirstLoad const):
(API::PageConfiguration::isLockdownModeExplicitlySet const):
(API::PageConfiguration::preferencesForGPUProcess const):
(API::PageConfiguration::preferencesForNetworkProcess const):
(API::PageConfiguration::PageConfiguration): Deleted.
(API::PageConfiguration::browsingContextGroup): Deleted.
(API::PageConfiguration::processPool): Deleted.
(API::PageConfiguration::userContentController): Deleted.
(API::PageConfiguration::visitedLinkStore): Deleted.
(API::PageConfiguration::websiteDataStore): Deleted.
(API::PageConfiguration::protectedWebsiteDataStore): Deleted.
* Source/WebKit/UIProcess/API/APIPageConfiguration.h:
(API::PageConfiguration::Data::initializer):
* Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp:
(API::WebsitePolicies::WebsitePolicies):
(API::WebsitePolicies::copy const):
* Source/WebKit/UIProcess/API/APIWebsitePolicies.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
(-[WKWebView _setupPageConfiguration:]):
(validate): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration processPool]):
(-[WKWebViewConfiguration setProcessPool:]):
(-[WKWebViewConfiguration preferences]):
(-[WKWebViewConfiguration setPreferences:]):
(-[WKWebViewConfiguration userContentController]):
(-[WKWebViewConfiguration setUserContentController:]):
(-[WKWebViewConfiguration websiteDataStore]):
(-[WKWebViewConfiguration setWebsiteDataStore:]):
(-[WKWebViewConfiguration defaultWebpagePreferences]):
(-[WKWebViewConfiguration setDefaultWebpagePreferences:]):
(-[WKWebViewConfiguration _visitedLinkStore]):
(-[WKWebViewConfiguration _setVisitedLinkStore:]):
(-[WKWebViewConfiguration _websiteDataStoreIfExists]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm:
(-[WKWebpagePreferences init]):
(): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h:
* Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseCreateWebPage):
* Source/WebKit/UIProcess/API/wpe/WPEWebView.cpp:
(WKWPE::m_backend):
* Source/WebKit/UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
* Source/WebKit/UIProcess/Cocoa/WebPagePreferencesLockdownModeObserver.h: Copied from Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h.
* Source/WebKit/UIProcess/Cocoa/WebPagePreferencesLockdownModeObserver.mm: Copied from Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h.
(WebKit::WebPagePreferencesLockdownModeObserver::WebPagePreferencesLockdownModeObserver):
(WebKit::WebPagePreferencesLockdownModeObserver::~WebPagePreferencesLockdownModeObserver):
(WebKit::WebPagePreferencesLockdownModeObserver::willChangeLockdownMode):
(WebKit::WebPagePreferencesLockdownModeObserver::didChangeLockdownMode):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::m_browsingContextGroup):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
* Source/WebKit/UIProcess/WebPageProxy.cpp.orig: Copied from Source/WebKit/UIProcess/WebPageProxy.cpp.
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::createWebPage):
* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::predictedUserAgentForRequest const):
* Source/WebKit/UIProcess/win/WebView.cpp:
(WebKit::WebView::WebView):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKit/WKPageConfiguration.cpp:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewConfiguration.mm:
(TEST):

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

b9bb653

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 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  watch
βœ… πŸ›  πŸ§ͺ unsafe-merge βœ… πŸ›  watch-sim

@achristensen07 achristensen07 self-assigned this Mar 20, 2024
@achristensen07 achristensen07 added the WebKit API For issues and bugs in the Web Kit public embedding APIs label Mar 20, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 20, 2024
@achristensen07 achristensen07 removed the merging-blocked Applied to prevent a change from being merged label Mar 20, 2024
@achristensen07 achristensen07 force-pushed the eng/Move-most-LazyInitialized-ivars-from-WKWebViewConfiguration-to-APIPageConfiguration branch from d41d8ac to 94efcd5 Compare March 20, 2024 07:16
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 20, 2024
@achristensen07 achristensen07 removed the merging-blocked Applied to prevent a change from being merged label Mar 20, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 20, 2024
@achristensen07 achristensen07 force-pushed the eng/Move-most-LazyInitialized-ivars-from-WKWebViewConfiguration-to-APIPageConfiguration branch from 94efcd5 to 80ea1d6 Compare March 20, 2024 07:30
@achristensen07 achristensen07 removed the merging-blocked Applied to prevent a change from being merged label Mar 20, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 20, 2024
@achristensen07 achristensen07 removed the merging-blocked Applied to prevent a change from being merged label Mar 20, 2024
@achristensen07 achristensen07 force-pushed the eng/Move-most-LazyInitialized-ivars-from-WKWebViewConfiguration-to-APIPageConfiguration branch from 80ea1d6 to cb4cdbe Compare March 20, 2024 07:39
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 20, 2024
@achristensen07 achristensen07 removed the merging-blocked Applied to prevent a change from being merged label Mar 20, 2024
@achristensen07 achristensen07 force-pushed the eng/Move-most-LazyInitialized-ivars-from-WKWebViewConfiguration-to-APIPageConfiguration branch from cb4cdbe to 94ce76b Compare March 20, 2024 19:35
@achristensen07 achristensen07 requested review from zdobersek and a team as code owners March 20, 2024 19:35
@achristensen07 achristensen07 force-pushed the eng/Move-most-LazyInitialized-ivars-from-WKWebViewConfiguration-to-APIPageConfiguration branch from 94ce76b to 6ac194d Compare March 20, 2024 22:49
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 21, 2024
@achristensen07 achristensen07 removed the merging-blocked Applied to prevent a change from being merged label Mar 21, 2024
@achristensen07 achristensen07 force-pushed the eng/Move-most-LazyInitialized-ivars-from-WKWebViewConfiguration-to-APIPageConfiguration branch from 6ac194d to 039ddc8 Compare March 21, 2024 01:51
@achristensen07 achristensen07 force-pushed the eng/Move-most-LazyInitialized-ivars-from-WKWebViewConfiguration-to-APIPageConfiguration branch from 039ddc8 to 9d12a61 Compare March 21, 2024 03:32
Copy link
Contributor

@cdumez cdumez left a comment

Choose a reason for hiding this comment

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

r=me with changes.

static Ref<WebKit::WebPreferences> createWebPreferences();
static Ref<WebKit::VisitedLinkStore> createVisitedLinkStore();
static Ref<WebsitePolicies> createWebsitePolicies();
LazyInitializedRef<WebKit::BrowsingContextGroup, createBrowsingContextGroup> browsingContextGroup;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Please add a blank line to separate member functions from data members.

class WebPagePreferencesLockdownModeObserver final : public LockdownModeObserver {
WTF_MAKE_FAST_ALLOCATED;
public:
WebPagePreferencesLockdownModeObserver(API::WebsitePolicies&);
Copy link
Contributor

Choose a reason for hiding this comment

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

explicit?

@@ -0,0 +1,13814 @@
/*
* Copyright (C) 2010-2023 Apple Inc. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please drop this file from the PR before landing. .orig

@achristensen07 achristensen07 force-pushed the eng/Move-most-LazyInitialized-ivars-from-WKWebViewConfiguration-to-APIPageConfiguration branch from 9d12a61 to 46d363d Compare March 21, 2024 04:56
@achristensen07 achristensen07 force-pushed the eng/Move-most-LazyInitialized-ivars-from-WKWebViewConfiguration-to-APIPageConfiguration branch from 46d363d to b9bb653 Compare March 21, 2024 05:32
@achristensen07 achristensen07 added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Mar 21, 2024
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Move-most-LazyInitialized-ivars-from-WKWebViewConfiguration-to-APIPageConfiguration branch from b9bb653 to d2f84ed Compare March 21, 2024 14:54
…ageConfiguration

https://bugs.webkit.org/show_bug.cgi?id=271301
rdar://125067469

Reviewed by Chris Dumez.

This is a step towards the API::PageConfiguration being made in WebPageProxy::createNewPage
rather than UIClient::createNewPage.

This new way of storing these objects is more robust against invalid use of WKWebViewConfiguration
if nil is set as the value of non-nullable objects, so the validate step is no longer needed
and the InvalidConfiguration API test needed some changes, but this should have no impact on
legitimate use of the API.

* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/API/APIPageConfiguration.cpp:
(API::PageConfiguration::Data::createBrowsingContextGroup):
(API::PageConfiguration::Data::createWebProcessPool):
(API::PageConfiguration::Data::createWebUserContentControllerProxy):
(API::PageConfiguration::Data::createWebPreferences):
(API::PageConfiguration::Data::createVisitedLinkStore):
(API::PageConfiguration::Data::createWebsitePolicies):
(API::PageConfiguration::create):
(API::PageConfiguration::browsingContextGroup const):
(API::PageConfiguration::processPool const):
(API::PageConfiguration::userContentController const):
(API::PageConfiguration::preferences const):
(API::PageConfiguration::pageToCloneSessionStorageFrom const):
(API::PageConfiguration::setPageToCloneSessionStorageFrom):
(API::PageConfiguration::visitedLinkStore const):
(API::PageConfiguration::websiteDataStore const):
(API::PageConfiguration::websiteDataStoreIfExists const):
(API::PageConfiguration::protectedWebsiteDataStore const):
(API::PageConfiguration::setWebsiteDataStore):
(API::PageConfiguration::defaultWebsitePolicies const):
(API::PageConfiguration::urlSchemeHandlerForURLScheme):
(API::PageConfiguration::setURLSchemeHandlerForURLScheme):
(API::PageConfiguration::lockdownModeEnabled const):
(API::PageConfiguration::delaysWebProcessLaunchUntilFirstLoad const):
(API::PageConfiguration::isLockdownModeExplicitlySet const):
(API::PageConfiguration::preferencesForGPUProcess const):
(API::PageConfiguration::preferencesForNetworkProcess const):
(API::PageConfiguration::PageConfiguration): Deleted.
(API::PageConfiguration::browsingContextGroup): Deleted.
(API::PageConfiguration::processPool): Deleted.
(API::PageConfiguration::userContentController): Deleted.
(API::PageConfiguration::visitedLinkStore): Deleted.
(API::PageConfiguration::websiteDataStore): Deleted.
(API::PageConfiguration::protectedWebsiteDataStore): Deleted.
* Source/WebKit/UIProcess/API/APIPageConfiguration.h:
(API::PageConfiguration::Data::initializer):
* Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp:
(API::WebsitePolicies::WebsitePolicies):
(API::WebsitePolicies::copy const):
* Source/WebKit/UIProcess/API/APIWebsitePolicies.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
(-[WKWebView _setupPageConfiguration:]):
(validate): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration processPool]):
(-[WKWebViewConfiguration setProcessPool:]):
(-[WKWebViewConfiguration preferences]):
(-[WKWebViewConfiguration setPreferences:]):
(-[WKWebViewConfiguration userContentController]):
(-[WKWebViewConfiguration setUserContentController:]):
(-[WKWebViewConfiguration websiteDataStore]):
(-[WKWebViewConfiguration setWebsiteDataStore:]):
(-[WKWebViewConfiguration defaultWebpagePreferences]):
(-[WKWebViewConfiguration setDefaultWebpagePreferences:]):
(-[WKWebViewConfiguration _visitedLinkStore]):
(-[WKWebViewConfiguration _setVisitedLinkStore:]):
(-[WKWebViewConfiguration _websiteDataStoreIfExists]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm:
(-[WKWebpagePreferences init]):
(): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h:
* Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseCreateWebPage):
* Source/WebKit/UIProcess/API/wpe/WPEWebView.cpp:
(WKWPE::m_backend):
* Source/WebKit/UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
* Source/WebKit/UIProcess/Cocoa/WebPagePreferencesLockdownModeObserver.h: Copied from Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h.
* Source/WebKit/UIProcess/Cocoa/WebPagePreferencesLockdownModeObserver.mm: Copied from Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h.
(WebKit::WebPagePreferencesLockdownModeObserver::WebPagePreferencesLockdownModeObserver):
(WebKit::WebPagePreferencesLockdownModeObserver::~WebPagePreferencesLockdownModeObserver):
(WebKit::WebPagePreferencesLockdownModeObserver::willChangeLockdownMode):
(WebKit::WebPagePreferencesLockdownModeObserver::didChangeLockdownMode):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::m_browsingContextGroup):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
* Source/WebKit/UIProcess/WebPageProxy.cpp.orig: Copied from Source/WebKit/UIProcess/WebPageProxy.cpp.
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::createWebPage):
* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::predictedUserAgentForRequest const):
* Source/WebKit/UIProcess/win/WebView.cpp:
(WebKit::WebView::WebView):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKit/WKPageConfiguration.cpp:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewConfiguration.mm:
(TEST):

Canonical link: https://commits.webkit.org/276462@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Move-most-LazyInitialized-ivars-from-WKWebViewConfiguration-to-APIPageConfiguration branch from d2f84ed to 9b4ec97 Compare March 21, 2024 14:57
@webkit-commit-queue
Copy link
Collaborator

Committed 276462@main (9b4ec97): https://commits.webkit.org/276462@main

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

@webkit-commit-queue webkit-commit-queue merged commit 9b4ec97 into WebKit:main Mar 21, 2024
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Mar 21, 2024
@rkirsling
Copy link
Member

PlayStationWebView was not updated; fixed in #26299.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit API For issues and bugs in the Web Kit public embedding APIs
Projects
None yet
6 participants