Title: [225765] trunk/Source/WebKit
Revision
225765
Author
[email protected]
Date
2017-12-11 16:53:30 -0800 (Mon, 11 Dec 2017)

Log Message

Add a WKPageGroupRef setter in WKWebViewConfiguration
https://bugs.webkit.org/show_bug.cgi?id=180674
<rdar://problem/35920392>

Reviewed by Brady Eidson.

There is a Mac app trying to transition to WKWebView, and it uses WKPageGroupRef extensively.
To help it transition, we are temporarily giving it an ObjC way to use this organization for
its UserContentControllers to be united per PageGroup before it transitions away from SPIs like
WKBundleAddUserScript.  Make it Mac-only to indicate that this should be transitioned away from,
rather than adopted on iOS.
        
No change in behavior for apps not using the new WKWebViewConfiguration._pageGroup SPI.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration copyWithZone:]):
(-[WKWebViewConfiguration _pageGroup]):
(-[WKWebViewConfiguration _setPageGroup:]):
* UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (225764 => 225765)


--- trunk/Source/WebKit/ChangeLog	2017-12-12 00:41:54 UTC (rev 225764)
+++ trunk/Source/WebKit/ChangeLog	2017-12-12 00:53:30 UTC (rev 225765)
@@ -1,3 +1,27 @@
+2017-12-11  Alex Christensen  <[email protected]>
+
+        Add a WKPageGroupRef setter in WKWebViewConfiguration
+        https://bugs.webkit.org/show_bug.cgi?id=180674
+        <rdar://problem/35920392>
+
+        Reviewed by Brady Eidson.
+
+        There is a Mac app trying to transition to WKWebView, and it uses WKPageGroupRef extensively.
+        To help it transition, we are temporarily giving it an ObjC way to use this organization for
+        its UserContentControllers to be united per PageGroup before it transitions away from SPIs like
+        WKBundleAddUserScript.  Make it Mac-only to indicate that this should be transitioned away from,
+        rather than adopted on iOS.
+        
+        No change in behavior for apps not using the new WKWebViewConfiguration._pageGroup SPI.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _initializeWithConfiguration:]):
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration copyWithZone:]):
+        (-[WKWebViewConfiguration _pageGroup]):
+        (-[WKWebViewConfiguration _setPageGroup:]):
+        * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+
 2017-12-11  Brent Fulgham  <[email protected]>
 
         [iOS] Remove unused services from WebContent Process sandbox

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (225764 => 225765)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2017-12-12 00:41:54 UTC (rev 225764)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2017-12-12 00:53:30 UTC (rev 225765)
@@ -517,11 +517,16 @@
     if (NSString *overrideContentSecurityPolicy = configuration._overrideContentSecurityPolicy)
         pageConfiguration->setOverrideContentSecurityPolicy(overrideContentSecurityPolicy);
 
-    RefPtr<WebKit::WebPageGroup> pageGroup;
-    NSString *groupIdentifier = configuration._groupIdentifier;
-    if (groupIdentifier.length) {
-        pageGroup = WebKit::WebPageGroup::create(configuration._groupIdentifier);
-        pageConfiguration->setPageGroup(pageGroup.get());
+#if PLATFORM(MAC)
+    if (auto pageGroup = WebKit::toImpl([configuration _pageGroup])) {
+        pageConfiguration->setPageGroup(pageGroup);
+        pageConfiguration->setUserContentController(&pageGroup->userContentController());
+    } else
+#endif
+    {
+        NSString *groupIdentifier = configuration._groupIdentifier;
+        if (groupIdentifier.length)
+            pageConfiguration->setPageGroup(WebKit::WebPageGroup::create(configuration._groupIdentifier).ptr());
     }
 
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::suppressesIncrementalRenderingKey(), WebKit::WebPreferencesStore::Value(!![_configuration suppressesIncrementalRendering]));

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (225764 => 225765)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2017-12-12 00:41:54 UTC (rev 225764)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2017-12-12 00:53:30 UTC (rev 225765)
@@ -32,6 +32,7 @@
 #import "VersionChecks.h"
 #import "WKPreferences.h"
 #import "WKProcessPool.h"
+#import "WKRetainPtr.h"
 #import "WKUserContentController.h"
 #import "WKWebView.h"
 #import "WKWebViewContentProviderRegistry.h"
@@ -136,6 +137,7 @@
     BOOL _mainContentUserGestureOverrideEnabled;
 
 #if PLATFORM(MAC)
+    WKRetainPtr<WKPageGroupRef> _pageGroup;
     double _cpuLimit;
     BOOL _showsURLsInToolTips;
     BOOL _serviceControlsEnabled;
@@ -347,6 +349,7 @@
     configuration->_serviceControlsEnabled = self->_serviceControlsEnabled;
     configuration->_imageControlsEnabled = self->_imageControlsEnabled;
     configuration->_requiresUserActionForEditingControlsManager = self->_requiresUserActionForEditingControlsManager;
+    configuration->_pageGroup = self._pageGroup;
 #endif
 #if ENABLE(DATA_DETECTION) && PLATFORM(IOS)
     configuration->_dataDetectorTypes = self->_dataDetectorTypes;
@@ -810,6 +813,16 @@
     _requiresUserActionForEditingControlsManager = requiresUserAction;
 }
 
+- (WKPageGroupRef)_pageGroup
+{
+    return _pageGroup.get();
+}
+
+- (void)_setPageGroup:(WKPageGroupRef)pageGroup
+{
+    _pageGroup = pageGroup;
+}
+
 - (void)_setCPULimit:(double)cpuLimit
 {
     _cpuLimit = cpuLimit;

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (225764 => 225765)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2017-12-12 00:41:54 UTC (rev 225764)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2017-12-12 00:53:30 UTC (rev 225765)
@@ -27,6 +27,8 @@
 
 #if WK_API_ENABLED
 
+#import <WebKit/WKBase.h>
+
 #if TARGET_OS_IPHONE
 typedef NS_ENUM(NSUInteger, _WKDragLiftDelay) {
     _WKDragLiftDelayShort = 0,
@@ -80,6 +82,7 @@
 @property (nonatomic, setter=_setImageControlsEnabled:) BOOL _imageControlsEnabled WK_API_AVAILABLE(macosx(10.12));
 @property (nonatomic, readwrite, setter=_setRequiresUserActionForEditingControlsManager:) BOOL _requiresUserActionForEditingControlsManager WK_API_AVAILABLE(macosx(10.12));
 @property (nonatomic, readwrite, setter=_setCPULimit:) double _cpuLimit WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+@property (nonatomic, readwrite, setter=_setPageGroup:) WKPageGroupRef _pageGroup WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 #endif
 
 @property (nonatomic, strong, setter=_setWebsiteDataStore:) _WKWebsiteDataStore *_websiteDataStore WK_API_DEPRECATED_WITH_REPLACEMENT("websiteDataStore", macosx(10.10, 10.11), ios(8.0, 9.0));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to