WebKit Bugzilla
Attachment 345802 Details for
Bug 188030
: Begin making WKWebViewConfiguration a wrapper around an API::PageConfiguration
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188030-20180725165703.patch (text/plain), 15.66 KB, created by
Alex Christensen
on 2018-07-25 16:57:03 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alex Christensen
Created:
2018-07-25 16:57:03 PDT
Size:
15.66 KB
patch
obsolete
>Index: Source/WebKit/ChangeLog >=================================================================== >--- Source/WebKit/ChangeLog (revision 234218) >+++ Source/WebKit/ChangeLog (working copy) >@@ -1,3 +1,32 @@ >+2018-07-25 Alex Christensen <achristensen@webkit.org> >+ >+ Begin making WKWebViewConfiguration a wrapper around an API::PageConfiguration >+ https://bugs.webkit.org/show_bug.cgi?id=188030 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ I've arbitrarily chosen _treatsSHA1SignedCertificatesAsInsecure and _urlSchemeHandlers >+ as the first two properties to transition, and I've made a way to incrementally transition. >+ >+ * UIProcess/API/APIPageConfiguration.cpp: >+ (API::PageConfiguration::copy const): >+ (API::PageConfiguration::urlSchemeHandlerForURLScheme): >+ (API::PageConfiguration::setURLSchemeHandlerForURLScheme): >+ * UIProcess/API/APIPageConfiguration.h: >+ (API::PageConfiguration::urlSchemeHandlers): >+ * UIProcess/API/Cocoa/WKWebView.mm: >+ (-[WKWebView _initializeWithConfiguration:]): >+ * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: >+ (-[WKWebViewConfiguration init]): >+ (-[WKWebViewConfiguration copyWithZone:]): >+ (-[WKWebViewConfiguration setURLSchemeHandler:forURLScheme:]): >+ (-[WKWebViewConfiguration urlSchemeHandlerForURLScheme:]): >+ (-[WKWebViewConfiguration copyPageConfiguration]): >+ (-[WKWebViewConfiguration _treatsSHA1SignedCertificatesAsInsecure]): >+ (-[WKWebViewConfiguration _setTreatsSHA1SignedCertificatesAsInsecure:]): >+ (-[WKWebViewConfiguration _urlSchemeHandlers]): Deleted. >+ * UIProcess/API/Cocoa/WKWebViewConfigurationInternal.h: >+ > 2018-07-25 Jeremy Jones <jeremyj@apple.com> > > Mask AVBackgroundView to the corner radius. >Index: Source/WebKit/UIProcess/API/APIPageConfiguration.cpp >=================================================================== >--- Source/WebKit/UIProcess/API/APIPageConfiguration.cpp (revision 234209) >+++ Source/WebKit/UIProcess/API/APIPageConfiguration.cpp (working copy) >@@ -31,6 +31,7 @@ > #include "WebPageProxy.h" > #include "WebPreferences.h" > #include "WebProcessPool.h" >+#include "WebURLSchemeHandler.h" > #include "WebUserContentControllerProxy.h" > > #if ENABLE(APPLICATION_MANIFEST) >@@ -81,6 +82,7 @@ Ref<PageConfiguration> PageConfiguration > #if ENABLE(APPLICATION_MANIFEST) > copy->m_applicationManifest = this->m_applicationManifest; > #endif >+ copy->m_urlSchemeHandlers = this->m_urlSchemeHandlers; > > return copy; > } >@@ -174,6 +176,16 @@ void PageConfiguration::setSessionID(PAL > m_sessionID = sessionID; > } > >+RefPtr<WebKit::WebURLSchemeHandler> PageConfiguration::urlSchemeHandlerForURLScheme(const WTF::String& scheme) >+{ >+ return m_urlSchemeHandlers.get(scheme); >+} >+ >+void PageConfiguration::setURLSchemeHandlerForURLScheme(Ref<WebKit::WebURLSchemeHandler>&& handler, const WTF::String& scheme) >+{ >+ m_urlSchemeHandlers.set(scheme, WTFMove(handler)); >+} >+ > #if ENABLE(APPLICATION_MANIFEST) > const ApplicationManifest* PageConfiguration::applicationManifest() const > { >Index: Source/WebKit/UIProcess/API/APIPageConfiguration.h >=================================================================== >--- Source/WebKit/UIProcess/API/APIPageConfiguration.h (revision 234209) >+++ Source/WebKit/UIProcess/API/APIPageConfiguration.h (working copy) >@@ -23,8 +23,7 @@ > * THE POSSIBILITY OF SUCH DAMAGE. > */ > >-#ifndef APIPageConfiguration_h >-#define APIPageConfiguration_h >+#pragma once > > #include "APIObject.h" > #include "WebPreferencesStore.h" >@@ -38,6 +37,7 @@ class WebPageGroup; > class WebPageProxy; > class WebPreferences; > class WebProcessPool; >+class WebURLSchemeHandler; > class WebUserContentControllerProxy; > } > >@@ -115,6 +115,10 @@ public: > void setApplicationManifest(ApplicationManifest*); > #endif > >+ RefPtr<WebKit::WebURLSchemeHandler> urlSchemeHandlerForURLScheme(const WTF::String&); >+ void setURLSchemeHandlerForURLScheme(Ref<WebKit::WebURLSchemeHandler>&&, const WTF::String&); >+ const HashMap<WTF::String, RefPtr<WebKit::WebURLSchemeHandler>>& urlSchemeHandlers() { return m_urlSchemeHandlers; } >+ > private: > > RefPtr<WebKit::WebProcessPool> m_processPool; >@@ -130,14 +134,14 @@ private: > // Once we get rid of it we should get rid of this configuration parameter as well. > PAL::SessionID m_sessionID; > >- bool m_treatsSHA1SignedCertificatesAsInsecure = true; >+ bool m_treatsSHA1SignedCertificatesAsInsecure { true }; > #if PLATFORM(IOS) >- bool m_alwaysRunsAtForegroundPriority = false; >+ bool m_alwaysRunsAtForegroundPriority { false }; > #endif >- bool m_initialCapitalizationEnabled = true; >- bool m_waitsForPaintAfterViewDidMoveToWindow = true; >- bool m_drawsBackground = true; >- bool m_controlledByAutomation = false; >+ bool m_initialCapitalizationEnabled { true }; >+ bool m_waitsForPaintAfterViewDidMoveToWindow { true }; >+ bool m_drawsBackground { true }; >+ bool m_controlledByAutomation { false }; > std::optional<double> m_cpuLimit; > > WTF::String m_overrideContentSecurityPolicy; >@@ -145,9 +149,8 @@ private: > #if ENABLE(APPLICATION_MANIFEST) > RefPtr<ApplicationManifest> m_applicationManifest; > #endif >+ >+ HashMap<WTF::String, RefPtr<WebKit::WebURLSchemeHandler>> m_urlSchemeHandlers; > }; > > } // namespace API >- >- >-#endif // APIPageConfiguration_h >Index: Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (revision 234209) >+++ Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (working copy) >@@ -506,7 +506,7 @@ - (void)_initializeWithConfiguration:(WK > WebKit::WebProcessPool& processPool = *[_configuration processPool]->_processPool; > processPool.setResourceLoadStatisticsEnabled(configuration.websiteDataStore._resourceLoadStatisticsEnabled); > >- auto pageConfiguration = API::PageConfiguration::create(); >+ auto pageConfiguration = [configuration copyPageConfiguration]; > > pageConfiguration->setProcessPool(&processPool); > pageConfiguration->setPreferences([_configuration preferences]->_preferences.get()); >@@ -516,7 +516,6 @@ - (void)_initializeWithConfiguration:(WK > pageConfiguration->setUserContentController([_configuration userContentController]->_userContentControllerProxy.get()); > pageConfiguration->setVisitedLinkStore([_configuration _visitedLinkStore]->_visitedLinkStore.get()); > pageConfiguration->setWebsiteDataStore([_configuration websiteDataStore]->_websiteDataStore.get()); >- pageConfiguration->setTreatsSHA1SignedCertificatesAsInsecure([_configuration _treatsSHA1SignedCertificatesAsInsecure]); > > if (NSString *overrideContentSecurityPolicy = configuration._overrideContentSecurityPolicy) > pageConfiguration->setOverrideContentSecurityPolicy(overrideContentSecurityPolicy); >@@ -631,7 +630,7 @@ // We are in the View's initializati > static uint32_t programSDKVersion = dyld_get_program_sdk_version(); > _allowsLinkPreview = programSDKVersion >= firstSDKVersionWithLinkPreviewEnabledByDefault; > >- _contentView = adoptNS([[WKContentView alloc] initWithFrame:bounds processPool:processPool configuration:WTFMove(pageConfiguration) webView:self]); >+ _contentView = adoptNS([[WKContentView alloc] initWithFrame:bounds processPool:processPool configuration:pageConfiguration.copyRef() webView:self]); > > _page = [_contentView page]; > [self _dispatchSetDeviceOrientation:deviceOrientation()]; >@@ -678,7 +677,7 @@ // We are in the View's initializati > #endif > > #if PLATFORM(MAC) >- _impl = std::make_unique<WebKit::WebViewImpl>(self, self, processPool, WTFMove(pageConfiguration)); >+ _impl = std::make_unique<WebKit::WebViewImpl>(self, self, processPool, pageConfiguration.copyRef()); > _page = &_impl->page(); > > _impl->setAutomaticallyAdjustsContentInsets(true); >@@ -709,9 +708,8 @@ // We are in the View's initializati > [self _setUpSQLiteDatabaseTrackerClient]; > #endif > >- auto *handlers = _configuration.get()._urlSchemeHandlers; >- for (NSString *key in handlers) >- _page->setURLSchemeHandlerForScheme(WebKit::WebURLSchemeHandlerCocoa::create(handlers[key]), key); >+ for (auto& pair : pageConfiguration->urlSchemeHandlers()) >+ _page->setURLSchemeHandlerForScheme(WebKit::WebURLSchemeHandlerCocoa::create(static_cast<WebKit::WebURLSchemeHandlerCocoa*>(pair.value.get())->apiHandler()), pair.key); > > pageToViewMap().add(_page.get(), self); > >Index: Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (revision 234209) >+++ Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (working copy) >@@ -38,6 +38,7 @@ > #import "WKWebView.h" > #import "WKWebViewContentProviderRegistry.h" > #import "WebKit2Initialize.h" >+#import "WebURLSchemeHandlerCocoa.h" > #import "_WKVisitedLinkStore.h" > #import "_WKWebsiteDataStoreInternal.h" > #import <WebCore/RuntimeApplicationChecks.h> >@@ -104,6 +105,7 @@ static _WKDragLiftDelay toDragLiftDelay( > #endif > > @implementation WKWebViewConfiguration { >+ RefPtr<API::PageConfiguration> _pageConfiguration; > LazyInitialized<RetainPtr<WKProcessPool>> _processPool; > LazyInitialized<RetainPtr<WKPreferences>> _preferences; > LazyInitialized<RetainPtr<WKUserContentController>> _userContentController; >@@ -113,7 +115,6 @@ static _WKDragLiftDelay toDragLiftDelay( > WeakObjCPtr<WKWebView> _alternateWebViewForNavigationGestures; > RetainPtr<NSString> _groupIdentifier; > LazyInitialized<RetainPtr<NSString>> _applicationNameForUserAgent; >- LazyInitialized<RetainPtr<NSMutableDictionary<NSString *, id <WKURLSchemeHandler>>>> _urlSchemeHandlers; > NSTimeInterval _incrementalRenderingSuppressionTimeout; > BOOL _treatsSHA1SignedCertificatesAsInsecure; > BOOL _respectsImageOrientation; >@@ -178,6 +179,8 @@ - (instancetype)init > > WebKit::InitializeWebKit2(); > >+ _pageConfiguration = API::PageConfiguration::create(); >+ > #if PLATFORM(IOS) > #if !PLATFORM(WATCHOS) > _allowsPictureInPictureMediaPlayback = YES; >@@ -230,7 +233,6 @@ - (instancetype)init > _convertsPositionStyleOnCopy = NO; > _allowsMetaRefresh = YES; > _allowUniversalAccessFromFileURLs = NO; >- _treatsSHA1SignedCertificatesAsInsecure = YES; > _needsStorageAccessFromFileURLsQuirk = YES; > > #if PLATFORM(IOS) >@@ -339,6 +341,7 @@ - (id)copyWithZone:(NSZone *)zone > { > WKWebViewConfiguration *configuration = [(WKWebViewConfiguration *)[[self class] allocWithZone:zone] init]; > >+ configuration->_pageConfiguration = _pageConfiguration->copy(); > configuration.processPool = self.processPool; > configuration.preferences = self.preferences; > configuration.userContentController = self.userContentController; >@@ -346,7 +349,6 @@ - (id)copyWithZone:(NSZone *)zone > configuration._visitedLinkStore = self._visitedLinkStore; > configuration._relatedWebView = _relatedWebView.get().get(); > configuration._alternateWebViewForNavigationGestures = _alternateWebViewForNavigationGestures.get().get(); >- configuration->_treatsSHA1SignedCertificatesAsInsecure = _treatsSHA1SignedCertificatesAsInsecure; > #if PLATFORM(IOS) > configuration._contentProviderRegistry = self._contentProviderRegistry; > #endif >@@ -408,7 +410,6 @@ - (id)copyWithZone:(NSZone *)zone > configuration->_needsStorageAccessFromFileURLsQuirk = self->_needsStorageAccessFromFileURLsQuirk; > configuration->_overrideContentSecurityPolicy = adoptNS([self->_overrideContentSecurityPolicy copyWithZone:zone]); > >- configuration->_urlSchemeHandlers.set(adoptNS([self._urlSchemeHandlers mutableCopyWithZone:zone])); > configuration->_mediaContentTypesRequiringHardwareSupport = adoptNS([self._mediaContentTypesRequiringHardwareSupport copyWithZone:zone]); > configuration->_legacyEncryptedMediaAPIEnabled = self->_legacyEncryptedMediaAPIEnabled; > configuration->_allowMediaContentTypesRequiringHardwareSupportAsFallback = self->_allowMediaContentTypesRequiringHardwareSupportAsFallback; >@@ -493,8 +494,6 @@ - (void)_setVisitedLinkStore:(_WKVisited > > - (void)setURLSchemeHandler:(id <WKURLSchemeHandler>)urlSchemeHandler forURLScheme:(NSString *)urlScheme > { >- auto *urlSchemeHandlers = _urlSchemeHandlers.get([] { return adoptNS([[NSMutableDictionary alloc] init]); }); >- > if ([WKWebView handlesURLScheme:urlScheme]) > [NSException raise:NSInvalidArgumentException format:@"'%@' is a URL scheme that WKWebView handles natively", urlScheme]; > >@@ -502,10 +501,10 @@ - (void)setURLSchemeHandler:(id <WKURLSc > if (!canonicalScheme) > [NSException raise:NSInvalidArgumentException format:@"'%@' is not a valid URL scheme", urlScheme]; > >- if ([urlSchemeHandlers objectForKey:(NSString *)canonicalScheme.value()]) >+ if (_pageConfiguration->urlSchemeHandlerForURLScheme(*canonicalScheme)) > [NSException raise:NSInvalidArgumentException format:@"URL scheme '%@' already has a registered URL scheme handler", urlScheme]; > >- [urlSchemeHandlers setObject:urlSchemeHandler forKey:(NSString *)canonicalScheme.value()]; >+ _pageConfiguration->setURLSchemeHandlerForURLScheme(WebKit::WebURLSchemeHandlerCocoa::create(urlSchemeHandler), *canonicalScheme); > } > > - (nullable id <WKURLSchemeHandler>)urlSchemeHandlerForURLScheme:(NSString *)urlScheme >@@ -514,8 +513,8 @@ - (nullable id <WKURLSchemeHandler>)urlS > if (!canonicalScheme) > return nil; > >- auto *urlSchemeHandlers = _urlSchemeHandlers.get([] { return adoptNS([[NSMutableDictionary alloc] init]); }); >- return [urlSchemeHandlers objectForKey:(NSString *)canonicalScheme.value()]; >+ auto handler = _pageConfiguration->urlSchemeHandlerForURLScheme(*canonicalScheme); >+ return handler ? static_cast<WebKit::WebURLSchemeHandlerCocoa*>(handler.get())->apiHandler() : nil; > } > > #pragma clang diagnostic push >@@ -533,11 +532,6 @@ - (void)_setWebsiteDataStore:(_WKWebsite > > #pragma clang diagnostic pop > >-- (NSMutableDictionary<NSString *, id <WKURLSchemeHandler>> *)_urlSchemeHandlers >-{ >- return _urlSchemeHandlers.get([] { return adoptNS([[NSMutableDictionary alloc] init]); }); >-} >- > #if PLATFORM(IOS) > - (WKWebViewContentProviderRegistry *)_contentProviderRegistry > { >@@ -550,6 +544,11 @@ - (void)_setContentProviderRegistry:(WKW > } > #endif > >+- (Ref<API::PageConfiguration>)copyPageConfiguration >+{ >+ return _pageConfiguration->copy(); >+} >+ > @end > > @implementation WKWebViewConfiguration (WKPrivate) >@@ -586,12 +585,12 @@ - (void)_setGroupIdentifier:(NSString *) > > - (BOOL)_treatsSHA1SignedCertificatesAsInsecure > { >- return _treatsSHA1SignedCertificatesAsInsecure; >+ return _pageConfiguration->treatsSHA1SignedCertificatesAsInsecure(); > } > > - (void)_setTreatsSHA1SignedCertificatesAsInsecure:(BOOL)insecure > { >- _treatsSHA1SignedCertificatesAsInsecure = insecure; >+ _pageConfiguration->setTreatsSHA1SignedCertificatesAsInsecure(insecure); > } > > - (BOOL)_respectsImageOrientation >Index: Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationInternal.h >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationInternal.h (revision 234209) >+++ Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationInternal.h (working copy) >@@ -23,7 +23,9 @@ > * THE POSSIBILITY OF SUCH DAMAGE. > */ > >+#import "APIPageConfiguration.h" > #import "WKWebViewConfigurationPrivate.h" >+#import <wtf/Ref.h> > > #if WK_API_ENABLED > >@@ -32,12 +34,12 @@ > > @interface WKWebViewConfiguration () > >-@property (nonatomic, readonly) NSMutableDictionary<NSString *, id <WKURLSchemeHandler>> *_urlSchemeHandlers; >- > #if PLATFORM(IOS) > @property (nonatomic, setter=_setContentProviderRegistry:) WKWebViewContentProviderRegistry *_contentProviderRegistry; > #endif > >+- (Ref<API::PageConfiguration>)copyPageConfiguration; >+ > @end > > #endif
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188030
:
345802
|
345886