Changeset 225765 in webkit


Ignore:
Timestamp:
Dec 11, 2017 4:53:30 PM (6 years ago)
Author:
achristensen@apple.com
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:
Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r225763 r225765  
     12017-12-11  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add a WKPageGroupRef setter in WKWebViewConfiguration
     4        https://bugs.webkit.org/show_bug.cgi?id=180674
     5        <rdar://problem/35920392>
     6
     7        Reviewed by Brady Eidson.
     8
     9        There is a Mac app trying to transition to WKWebView, and it uses WKPageGroupRef extensively.
     10        To help it transition, we are temporarily giving it an ObjC way to use this organization for
     11        its UserContentControllers to be united per PageGroup before it transitions away from SPIs like
     12        WKBundleAddUserScript.  Make it Mac-only to indicate that this should be transitioned away from,
     13        rather than adopted on iOS.
     14       
     15        No change in behavior for apps not using the new WKWebViewConfiguration._pageGroup SPI.
     16
     17        * UIProcess/API/Cocoa/WKWebView.mm:
     18        (-[WKWebView _initializeWithConfiguration:]):
     19        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
     20        (-[WKWebViewConfiguration copyWithZone:]):
     21        (-[WKWebViewConfiguration _pageGroup]):
     22        (-[WKWebViewConfiguration _setPageGroup:]):
     23        * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
     24
    1252017-12-11  Brent Fulgham  <bfulgham@apple.com>
    226
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r225714 r225765  
    518518        pageConfiguration->setOverrideContentSecurityPolicy(overrideContentSecurityPolicy);
    519519
    520     RefPtr<WebKit::WebPageGroup> pageGroup;
    521     NSString *groupIdentifier = configuration._groupIdentifier;
    522     if (groupIdentifier.length) {
    523         pageGroup = WebKit::WebPageGroup::create(configuration._groupIdentifier);
    524         pageConfiguration->setPageGroup(pageGroup.get());
     520#if PLATFORM(MAC)
     521    if (auto pageGroup = WebKit::toImpl([configuration _pageGroup])) {
     522        pageConfiguration->setPageGroup(pageGroup);
     523        pageConfiguration->setUserContentController(&pageGroup->userContentController());
     524    } else
     525#endif
     526    {
     527        NSString *groupIdentifier = configuration._groupIdentifier;
     528        if (groupIdentifier.length)
     529            pageConfiguration->setPageGroup(WebKit::WebPageGroup::create(configuration._groupIdentifier).ptr());
    525530    }
    526531
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm

    r225615 r225765  
    3333#import "WKPreferences.h"
    3434#import "WKProcessPool.h"
     35#import "WKRetainPtr.h"
    3536#import "WKUserContentController.h"
    3637#import "WKWebView.h"
     
    137138
    138139#if PLATFORM(MAC)
     140    WKRetainPtr<WKPageGroupRef> _pageGroup;
    139141    double _cpuLimit;
    140142    BOOL _showsURLsInToolTips;
     
    348350    configuration->_imageControlsEnabled = self->_imageControlsEnabled;
    349351    configuration->_requiresUserActionForEditingControlsManager = self->_requiresUserActionForEditingControlsManager;
     352    configuration->_pageGroup = self._pageGroup;
    350353#endif
    351354#if ENABLE(DATA_DETECTION) && PLATFORM(IOS)
     
    811814}
    812815
     816- (WKPageGroupRef)_pageGroup
     817{
     818    return _pageGroup.get();
     819}
     820
     821- (void)_setPageGroup:(WKPageGroupRef)pageGroup
     822{
     823    _pageGroup = pageGroup;
     824}
     825
    813826- (void)_setCPULimit:(double)cpuLimit
    814827{
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h

    r225615 r225765  
    2727
    2828#if WK_API_ENABLED
     29
     30#import <WebKit/WKBase.h>
    2931
    3032#if TARGET_OS_IPHONE
     
    8183@property (nonatomic, readwrite, setter=_setRequiresUserActionForEditingControlsManager:) BOOL _requiresUserActionForEditingControlsManager WK_API_AVAILABLE(macosx(10.12));
    8284@property (nonatomic, readwrite, setter=_setCPULimit:) double _cpuLimit WK_API_AVAILABLE(macosx(WK_MAC_TBA));
     85@property (nonatomic, readwrite, setter=_setPageGroup:) WKPageGroupRef _pageGroup WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    8386#endif
    8487
Note: See TracChangeset for help on using the changeset viewer.