Title: [159877] trunk/Source/WebKit2
Revision
159877
Author
[email protected]
Date
2013-11-29 16:27:38 -0800 (Fri, 29 Nov 2013)

Log Message

[Cocoa] Make WKBrowsingContextController work with WKObject wrapping
https://bugs.webkit.org/show_bug.cgi?id=125022

Reviewed by Dan Bernstein.

* Shared/Cocoa/APIObject.mm:
(API::Object::newObject):
        
* Shared/mac/ObjCObjectGraphCoders.mm:
Add support for WKProcessGroup.

(WebKit::WebContextObjCObjectGraphDecoderImpl::decode):
Replace call to _browsingContextControllerForPageRef: with wrapper.

* UIProcess/API/Cocoa/WKBrowsingContextController.mm:
Convert from wrapping the C-SPI type to storing the bits of the wrapped object inline.

(-[WKBrowsingContextController dealloc]):
Add explicit destructor call.

(-[WKBrowsingContextController setLoadDelegate:]):
(-[WKBrowsingContextController setPolicyDelegate:]):
Lazily set up the load and policy clients only once a delegate has been set to allow
continued use of the C-SPI clients for WebKitTestRunner.

(-[WKBrowsingContextController _finishInitialization]):
Move remaining work that was done in the initialize (setting up the observer) here,
and have the WebPageProxy call it.

* UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h:
(WebKit::wrapper):
Add wrapper() helper and declare conformance to the WKObject protocol. Remove no longer used
_initWithPageRef: and _browsingContextControllerForPageRef: helpers.

* UIProcess/API/Cocoa/WKProcessGroup.mm:
(didNavigateWithNavigationData):
(didPerformClientRedirect):
(didPerformServerRedirect):
(didUpdateHistoryTitle):
Switch to using wrapper().

* UIProcess/API/ios/WKContentView.mm:
* UIProcess/API/mac/WKView.mm:
Stop caching the WKBrowsingContextController, as it no long makes sense since it is the same object
as the WebPageProxy.

* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::platformInitialize):
Inform the wrapper that it is safe to finish initialization.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (159876 => 159877)


--- trunk/Source/WebKit2/ChangeLog	2013-11-29 23:21:08 UTC (rev 159876)
+++ trunk/Source/WebKit2/ChangeLog	2013-11-30 00:27:38 UTC (rev 159877)
@@ -1,3 +1,55 @@
+2013-11-29  Sam Weinig  <[email protected]>
+
+        [Cocoa] Make WKBrowsingContextController work with WKObject wrapping
+        https://bugs.webkit.org/show_bug.cgi?id=125022
+
+        Reviewed by Dan Bernstein.
+
+        * Shared/Cocoa/APIObject.mm:
+        (API::Object::newObject):
+        
+        * Shared/mac/ObjCObjectGraphCoders.mm:
+        Add support for WKProcessGroup.
+
+        (WebKit::WebContextObjCObjectGraphDecoderImpl::decode):
+        Replace call to _browsingContextControllerForPageRef: with wrapper.
+
+        * UIProcess/API/Cocoa/WKBrowsingContextController.mm:
+        Convert from wrapping the C-SPI type to storing the bits of the wrapped object inline.
+
+        (-[WKBrowsingContextController dealloc]):
+        Add explicit destructor call.
+
+        (-[WKBrowsingContextController setLoadDelegate:]):
+        (-[WKBrowsingContextController setPolicyDelegate:]):
+        Lazily set up the load and policy clients only once a delegate has been set to allow
+        continued use of the C-SPI clients for WebKitTestRunner.
+
+        (-[WKBrowsingContextController _finishInitialization]):
+        Move remaining work that was done in the initialize (setting up the observer) here,
+        and have the WebPageProxy call it.
+
+        * UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h:
+        (WebKit::wrapper):
+        Add wrapper() helper and declare conformance to the WKObject protocol. Remove no longer used
+        _initWithPageRef: and _browsingContextControllerForPageRef: helpers.
+
+        * UIProcess/API/Cocoa/WKProcessGroup.mm:
+        (didNavigateWithNavigationData):
+        (didPerformClientRedirect):
+        (didPerformServerRedirect):
+        (didUpdateHistoryTitle):
+        Switch to using wrapper().
+
+        * UIProcess/API/ios/WKContentView.mm:
+        * UIProcess/API/mac/WKView.mm:
+        Stop caching the WKBrowsingContextController, as it no long makes sense since it is the same object
+        as the WebPageProxy.
+
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::platformInitialize):
+        Inform the wrapper that it is safe to finish initialization.
+
 2013-11-29  Dan Bernstein  <[email protected]>
 
         [Cocoa] Add a way to recover from load errors

Modified: trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm (159876 => 159877)


--- trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm	2013-11-29 23:21:08 UTC (rev 159876)
+++ trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm	2013-11-30 00:27:38 UTC (rev 159877)
@@ -30,14 +30,15 @@
 
 #import "WKBackForwardListInternal.h"
 #import "WKBackForwardListItemInternal.h"
+#import "WKBrowsingContextControllerInternal.h"
 #import "WKBrowsingContextGroupInternal.h"
-#import "WKProcessGroupInternal.h"
 #import "WKNSArray.h"
 #import "WKNSDictionary.h"
 #import "WKNSError.h"
 #import "WKNSString.h"
 #import "WKNSURL.h"
 #import "WKNavigationDataInternal.h"
+#import "WKProcessGroupInternal.h"
 
 namespace API {
 
@@ -88,6 +89,10 @@
         wrapper = [WKNavigationData alloc];
         break;
 
+    case Type::Page:
+        wrapper = [WKBrowsingContextController alloc];
+        break;
+
     case Type::PageGroup:
         wrapper = [WKBrowsingContextGroup alloc];
         break;

Modified: trunk/Source/WebKit2/Shared/mac/ObjCObjectGraphCoders.mm (159876 => 159877)


--- trunk/Source/WebKit2/Shared/mac/ObjCObjectGraphCoders.mm	2013-11-29 23:21:08 UTC (rev 159876)
+++ trunk/Source/WebKit2/Shared/mac/ObjCObjectGraphCoders.mm	2013-11-30 00:27:38 UTC (rev 159877)
@@ -32,7 +32,6 @@
 // For UIProcess side encoding/decoding
 #import "WKAPICast.h"
 #import "WKBrowsingContextControllerInternal.h"
-#import "WKBrowsingContextControllerPrivate.h"
 #import "WebContextUserMessageCoders.h"
 #import "WebPageProxy.h"
 #import "WebProcessProxy.h"
@@ -343,7 +342,7 @@
             if (!webPage)
                 coder.m_root = [NSNull null];
             else 
-                coder.m_root = [WKBrowsingContextController _browsingContextControllerForPageRef:toAPI(webPage)];
+                coder.m_root = wrapper(*webPage);
             break;
         }
         case WKTypeRefWrapperType: {

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm (159876 => 159877)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm	2013-11-29 23:21:08 UTC (rev 159876)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm	2013-11-30 00:27:38 UTC (rev 159877)
@@ -109,24 +109,29 @@
 @end
 
 @implementation WKBrowsingContextController {
-    // Underlying WKPageRef.
-    WKRetainPtr<WKPageRef> _pageRef;
-
+    std::aligned_storage<sizeof(WebPageProxy), std::alignment_of<WebPageProxy>::value>::type _page;
     std::unique_ptr<PageLoadStateObserver> _pageLoadStateObserver;
 }
 
+@synthesize loadDelegate = _loadDelegate;
+@synthesize policyDelegate = _policyDelegate;
+
 - (void)dealloc
 {
-    toImpl(_pageRef.get())->pageLoadState().removeObserver(*_pageLoadStateObserver);
-    WKPageSetPageLoaderClient(_pageRef.get(), nullptr);
-    WKPageSetPagePolicyClient(_pageRef.get(), nullptr);
+    reinterpret_cast<WebPageProxy*>(&_page)->~WebPageProxy();
 
     [super dealloc];
 }
 
+- (void)_finishInitialization
+{
+    _pageLoadStateObserver = std::make_unique<PageLoadStateObserver>(self);
+    reinterpret_cast<WebPageProxy*>(&_page)->pageLoadState().addObserver(*_pageLoadStateObserver);
+}
+
 - (WKProcessGroup *)processGroup
 {
-    WebContext* context = toImpl(_pageRef.get())->process()->context();
+    WebContext* context = reinterpret_cast<WebPageProxy*>(&_page)->process()->context();
     if (!context)
         return nil;
     return wrapper(*context);
@@ -134,7 +139,7 @@
 
 - (WKBrowsingContextGroup *)browsingContextGroup
 {
-    WebPageGroup* pageGroup = toImpl(_pageRef.get())->pageGroup();
+    WebPageGroup* pageGroup = reinterpret_cast<WebPageProxy*>(&_page)->pageGroup();
     if (!pageGroup)
         return nil;
     return wrapper(*pageGroup);
@@ -142,7 +147,7 @@
 
 - (WKPageRef)_pageRef
 {
-    return _pageRef.get();
+    return toAPI(reinterpret_cast<WebPageProxy*>(&_page));
 }
 
 #pragma mark Loading
@@ -180,7 +185,7 @@
     if (userData)
         wkUserData = ObjCObjectGraph::create(userData);
 
-    WKPageLoadURLRequestWithUserData(_pageRef.get(), wkRequest.get(), (WKTypeRef)wkUserData.get());
+    WKPageLoadURLRequestWithUserData(toAPI(reinterpret_cast<WebPageProxy*>(&_page)), wkRequest.get(), (WKTypeRef)wkUserData.get());
 }
 
 - (void)loadFileURL:(NSURL *)URL restrictToFilesWithin:(NSURL *)allowedDirectory
@@ -200,7 +205,7 @@
     if (userData)
         wkUserData = ObjCObjectGraph::create(userData);
 
-    WKPageLoadFileWithUserData(_pageRef.get(), wkURL.get(), wkAllowedDirectory.get(), (WKTypeRef)wkUserData.get());
+    WKPageLoadFileWithUserData(toAPI(reinterpret_cast<WebPageProxy*>(&_page)), wkURL.get(), wkAllowedDirectory.get(), (WKTypeRef)wkUserData.get());
 }
 
 - (void)loadHTMLString:(NSString *)HTMLString baseURL:(NSURL *)baseURL
@@ -222,7 +227,7 @@
     if (userData)
         wkUserData = ObjCObjectGraph::create(userData);
 
-    WKPageLoadHTMLStringWithUserData(_pageRef.get(), wkHTMLString.get(), wkBaseURL.get(), (WKTypeRef)wkUserData.get());
+    WKPageLoadHTMLStringWithUserData(toAPI(reinterpret_cast<WebPageProxy*>(&_page)), wkHTMLString.get(), wkBaseURL.get(), (WKTypeRef)wkUserData.get());
 }
 
 - (void)loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL
@@ -233,7 +238,7 @@
     CString unreachableURLString;
     getURLBytes((CFURLRef)unreachableURL, unreachableURLString);
 
-    toImpl(_pageRef.get())->loadAlternateHTMLString(string, String::fromUTF8(baseURLString), String::fromUTF8(unreachableURLString));
+    reinterpret_cast<WebPageProxy*>(&_page)->loadAlternateHTMLString(string, String::fromUTF8(baseURLString), String::fromUTF8(unreachableURLString));
 }
 
 - (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)baseURL
@@ -270,54 +275,54 @@
     if (userData)
         wkUserData = ObjCObjectGraph::create(userData);
 
-    WKPageLoadDataWithUserData(_pageRef.get(), toAPI(wkData.get()), wkMIMEType.get(), wkEncodingName.get(), wkBaseURL.get(), (WKTypeRef)wkUserData.get());
+    WKPageLoadDataWithUserData(toAPI(reinterpret_cast<WebPageProxy*>(&_page)), toAPI(wkData.get()), wkMIMEType.get(), wkEncodingName.get(), wkBaseURL.get(), (WKTypeRef)wkUserData.get());
 }
 
 - (void)stopLoading
 {
-    WKPageStopLoading(_pageRef.get());
+    WKPageStopLoading(toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
 }
 
 - (void)reload
 {
-    WKPageReload(_pageRef.get());
+    WKPageReload(toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
 }
 
 - (void)reloadFromOrigin
 {
-    WKPageReloadFromOrigin(_pageRef.get());
+    WKPageReloadFromOrigin(toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
 }
 
 #pragma mark Back/Forward
 
 - (void)goForward
 {
-    WKPageGoForward(_pageRef.get());
+    WKPageGoForward(toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
 }
 
 - (BOOL)canGoForward
 {
-    return WKPageCanGoForward(_pageRef.get());
+    return WKPageCanGoForward(toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
 }
 
 - (void)goBack
 {
-    WKPageGoBack(_pageRef.get());
+    WKPageGoBack(toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
 }
 
 - (BOOL)canGoBack
 {
-    return WKPageCanGoBack(_pageRef.get());
+    return WKPageCanGoBack(toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
 }
 
 - (void)goToBackForwardListItem:(WKBackForwardListItem *)item
 {
-    toImpl(_pageRef.get())->goToBackForwardItem(&item._item);
+    reinterpret_cast<WebPageProxy*>(&_page)->goToBackForwardItem(&item._item);
 }
 
 - (WKBackForwardList *)backForwardList
 {
-    WebBackForwardList* list = toImpl(_pageRef.get())->backForwardList();
+    WebBackForwardList* list = reinterpret_cast<WebPageProxy*>(&_page)->backForwardList();
     if (!list)
         return nil;
 
@@ -328,56 +333,56 @@
 
 - (NSURL *)activeURL
 {
-    return autoreleased(WKPageCopyActiveURL(_pageRef.get()));
+    return autoreleased(WKPageCopyActiveURL(toAPI(reinterpret_cast<WebPageProxy*>(&_page))));
 }
 
 - (NSURL *)provisionalURL
 {
-    return autoreleased(WKPageCopyProvisionalURL(_pageRef.get()));
+    return autoreleased(WKPageCopyProvisionalURL(toAPI(reinterpret_cast<WebPageProxy*>(&_page))));
 }
 
 - (NSURL *)committedURL
 {
-    return autoreleased(WKPageCopyCommittedURL(_pageRef.get()));
+    return autoreleased(WKPageCopyCommittedURL(toAPI(reinterpret_cast<WebPageProxy*>(&_page))));
 }
 
 - (NSURL *)unreachableURL
 {
-    return [NSURL _web_URLWithWTFString:toImpl(_pageRef.get())->pageLoadState().unreachableURL() relativeToURL:nil];
+    return [NSURL _web_URLWithWTFString:reinterpret_cast<WebPageProxy*>(&_page)->pageLoadState().unreachableURL() relativeToURL:nil];
 }
 
 - (double)estimatedProgress
 {
-    return toImpl(_pageRef.get())->estimatedProgress();
+    return reinterpret_cast<WebPageProxy*>(&_page)->estimatedProgress();
 }
 
 #pragma mark Active Document Introspection
 
 - (NSString *)title
 {
-    return autoreleased(WKPageCopyTitle(_pageRef.get()));
+    return autoreleased(WKPageCopyTitle(toAPI(reinterpret_cast<WebPageProxy*>(&_page))));
 }
 
 #pragma mark Zoom
 
 - (CGFloat)textZoom
 {
-    return WKPageGetTextZoomFactor(_pageRef.get());
+    return WKPageGetTextZoomFactor(toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
 }
 
 - (void)setTextZoom:(CGFloat)textZoom
 {
-    return WKPageSetTextZoomFactor(_pageRef.get(), textZoom);
+    return WKPageSetTextZoomFactor(toAPI(reinterpret_cast<WebPageProxy*>(&_page)), textZoom);
 }
 
 - (CGFloat)pageZoom
 {
-    return WKPageGetPageZoomFactor(_pageRef.get());
+    return WKPageGetPageZoomFactor(toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
 }
 
 - (void)setPageZoom:(CGFloat)pageZoom
 {
-    return WKPageSetPageZoomFactor(_pageRef.get(), pageZoom);
+    return WKPageSetPageZoomFactor(toAPI(reinterpret_cast<WebPageProxy*>(&_page)), pageZoom);
 }
 
 static NSError *createErrorWithRecoveryAttempter(WKErrorRef wkError, WKFrameRef frame, WKBrowsingContextController *browsingContext)
@@ -602,28 +607,22 @@
     WKPageSetPagePolicyClient(pageRef, &policyClient);
 }
 
-/* This should only be called from associate view. */
-
-- (id)_initWithPageRef:(WKPageRef)pageRef
+- (void)setLoadDelegate:(id<WKBrowsingContextLoadDelegate>)loadDelegate
 {
-    self = [super init];
-    if (!self)
-        return nil;
-
-    _pageRef = pageRef;
-
-    _pageLoadStateObserver = std::make_unique<PageLoadStateObserver>(self);
-    toImpl(_pageRef.get())->pageLoadState().addObserver(*_pageLoadStateObserver);
-
-    setUpPageLoaderClient(self, pageRef);
-    setUpPagePolicyClient(self, pageRef);
-
-    return self;
+    _loadDelegate = loadDelegate;
+    if (_loadDelegate)
+        setUpPageLoaderClient(self, toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
+    else
+        WKPageSetPageLoaderClient(toAPI(reinterpret_cast<WebPageProxy*>(&_page)), nullptr);;
 }
 
-+ (WKBrowsingContextController *)_browsingContextControllerForPageRef:(WKPageRef)pageRef
+-(void)setPolicyDelegate:(id<WKBrowsingContextPolicyDelegate>)policyDelegate
 {
-    return (WKBrowsingContextController *)WebKit::toImpl(pageRef)->loaderClient().client().clientInfo;
+    _policyDelegate = policyDelegate;
+    if (_policyDelegate)
+        setUpPagePolicyClient(self, toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
+    else
+        WKPageSetPagePolicyClient(toAPI(reinterpret_cast<WebPageProxy*>(&_page)), nullptr);;
 }
 
 + (NSMutableSet *)customSchemes
@@ -655,6 +654,13 @@
     return YES;
 }
 
+#pragma mark WKObject protocol implementation
+
+- (API::Object&)_apiObject
+{
+    return *reinterpret_cast<API::Object*>(&_page);
+}
+
 @end
 
 @implementation WKBrowsingContextController (Private)
@@ -682,12 +688,12 @@
         return;
     }
 
-    WKPageSetPaginationMode(_pageRef.get(), mode);
+    WKPageSetPaginationMode(toAPI(reinterpret_cast<WebPageProxy*>(&_page)), mode);
 }
 
 - (WKBrowsingContextPaginationMode)paginationMode
 {
-    switch (WKPageGetPaginationMode(_pageRef.get())) {
+    switch (WKPageGetPaginationMode(toAPI(reinterpret_cast<WebPageProxy*>(&_page)))) {
     case kWKPaginationModeUnpaginated:
         return WKPaginationModeUnpaginated;
     case kWKPaginationModeLeftToRight:
@@ -706,42 +712,42 @@
 
 - (void)setPaginationBehavesLikeColumns:(BOOL)behavesLikeColumns
 {
-    WKPageSetPaginationBehavesLikeColumns(_pageRef.get(), behavesLikeColumns);
+    WKPageSetPaginationBehavesLikeColumns(toAPI(reinterpret_cast<WebPageProxy*>(&_page)), behavesLikeColumns);
 }
 
 - (BOOL)paginationBehavesLikeColumns
 {
-    return WKPageGetPaginationBehavesLikeColumns(_pageRef.get());
+    return WKPageGetPaginationBehavesLikeColumns(toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
 }
 
 - (void)setPageLength:(CGFloat)pageLength
 {
-    WKPageSetPageLength(_pageRef.get(), pageLength);
+    WKPageSetPageLength(toAPI(reinterpret_cast<WebPageProxy*>(&_page)), pageLength);
 }
 
 - (CGFloat)pageLength
 {
-    return WKPageGetPageLength(_pageRef.get());
+    return WKPageGetPageLength(toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
 }
 
 - (void)setGapBetweenPages:(CGFloat)gapBetweenPages
 {
-    WKPageSetGapBetweenPages(_pageRef.get(), gapBetweenPages);
+    WKPageSetGapBetweenPages(toAPI(reinterpret_cast<WebPageProxy*>(&_page)), gapBetweenPages);
 }
 
 - (CGFloat)gapBetweenPages
 {
-    return WKPageGetGapBetweenPages(_pageRef.get());
+    return WKPageGetGapBetweenPages(toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
 }
 
 - (NSUInteger)pageCount
 {
-    return WKPageGetPageCount(_pageRef.get());
+    return WKPageGetPageCount(toAPI(reinterpret_cast<WebPageProxy*>(&_page)));
 }
 
 - (WKBrowsingContextHandle *)handle
 {
-    return [[[WKBrowsingContextHandle alloc] _initWithPageID:toImpl(_pageRef.get())->pageID()] autorelease];
+    return [[[WKBrowsingContextHandle alloc] _initWithPageID:reinterpret_cast<WebPageProxy*>(&_page)->pageID()] autorelease];
 }
 
 @end

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h (159876 => 159877)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h	2013-11-29 23:21:08 UTC (rev 159876)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h	2013-11-30 00:27:38 UTC (rev 159877)
@@ -27,14 +27,22 @@
 
 #if WK_API_ENABLED
 
-@interface WKBrowsingContextController ()
+#import "WKObject.h"
+#import "WebPageProxy.h"
 
-/* This should only be called from associate view. */
-- (id)_initWithPageRef:(WKPageRef)pageRef;
+namespace WebKit {
 
-/* Returns a WKBrowsingContextController associated with the WKPageRef. */
-+ (WKBrowsingContextController *)_browsingContextControllerForPageRef:(WKPageRef)pageRef;
+inline WKBrowsingContextController *wrapper(WebPageProxy& page)
+{
+    ASSERT([page.wrapper() isKindOfClass:[WKBrowsingContextController class]]);
+    return (WKBrowsingContextController *)page.wrapper();
+}
 
+}
+
+@interface WKBrowsingContextController () <WKObject>
+
+- (void)_finishInitialization;
 + (NSMutableSet *)customSchemes;
 
 @end

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessGroup.mm (159876 => 159877)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessGroup.mm	2013-11-29 23:21:08 UTC (rev 159876)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessGroup.mm	2013-11-30 00:27:38 UTC (rev 159877)
@@ -109,7 +109,7 @@
     if (!toImpl(frameRef)->isMainFrame())
         return;
 
-    WKBrowsingContextController *controller = [WKBrowsingContextController _browsingContextControllerForPageRef:pageRef];
+    WKBrowsingContextController *controller = wrapper(*toImpl(pageRef));
     if ([controller.historyDelegate respondsToSelector:@selector(browsingContextController:didNavigateWithNavigationData:)])
         [controller.historyDelegate browsingContextController:controller didNavigateWithNavigationData:wrapper(*toImpl(navigationDataRef))];
 }
@@ -119,7 +119,7 @@
     if (!toImpl(frameRef)->isMainFrame())
         return;
 
-    WKBrowsingContextController *controller = [WKBrowsingContextController _browsingContextControllerForPageRef:pageRef];
+    WKBrowsingContextController *controller = wrapper(*toImpl(pageRef));
     if ([controller.historyDelegate respondsToSelector:@selector(browsingContextController:didPerformClientRedirectFromURL:toURL:)])
         [controller.historyDelegate browsingContextController:controller didPerformClientRedirectFromURL:wrapper(*toImpl(sourceURLRef)) toURL:wrapper(*toImpl(destinationURLRef))];
 }
@@ -129,7 +129,7 @@
     if (!toImpl(frameRef)->isMainFrame())
         return;
 
-    WKBrowsingContextController *controller = [WKBrowsingContextController _browsingContextControllerForPageRef:pageRef];
+    WKBrowsingContextController *controller = wrapper(*toImpl(pageRef));
     if ([controller.historyDelegate respondsToSelector:@selector(browsingContextController:didPerformServerRedirectFromURL:toURL:)])
         [controller.historyDelegate browsingContextController:controller didPerformServerRedirectFromURL:wrapper(*toImpl(sourceURLRef)) toURL:wrapper(*toImpl(destinationURLRef))];
 }
@@ -139,7 +139,7 @@
     if (!toImpl(frameRef)->isMainFrame())
         return;
 
-    WKBrowsingContextController *controller = [WKBrowsingContextController _browsingContextControllerForPageRef:pageRef];
+    WKBrowsingContextController *controller = wrapper(*toImpl(pageRef));
     if ([controller.historyDelegate respondsToSelector:@selector(browsingContextController:didUpdateHistoryTitle:forURL:)])
         [controller.historyDelegate browsingContextController:controller didUpdateHistoryTitle:wrapper(*toImpl(titleRef)) forURL:wrapper(*toImpl(urlRef))];
 }

Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm (159876 => 159877)


--- trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm	2013-11-29 23:21:08 UTC (rev 159876)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm	2013-11-30 00:27:38 UTC (rev 159877)
@@ -52,8 +52,6 @@
     std::unique_ptr<PageClientImpl> _pageClient;
     RefPtr<WebPageProxy> _page;
 
-    RetainPtr<WKBrowsingContextController> _browsingContextController;
-
     RetainPtr<UIView> _rootContentView;
     RetainPtr<WKInteractionView> _interactionView;
 }
@@ -104,9 +102,7 @@
 
 - (WKBrowsingContextController *)browsingContextController
 {
-    if (!_browsingContextController)
-        _browsingContextController = adoptNS([[WKBrowsingContextController alloc] _initWithPageRef:toAPI(_page.get())]);
-    return _browsingContextController.get();
+    return wrapper(*_page);
 }
 
 - (WKContentType)contentType

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (159876 => 159877)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2013-11-29 23:21:08 UTC (rev 159876)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2013-11-30 00:27:38 UTC (rev 159877)
@@ -153,9 +153,6 @@
 @public
     std::unique_ptr<PageClientImpl> _pageClient;
     RefPtr<WebPageProxy> _page;
-    
-    // Cache of the associated WKBrowsingContextController.
-    RetainPtr<WKBrowsingContextController> _browsingContextController;
 
     // For ToolTips.
     NSToolTipTag _lastToolTipTag;
@@ -300,9 +297,7 @@
 
 - (WKBrowsingContextController *)browsingContextController
 {
-    if (!_data->_browsingContextController)
-        _data->_browsingContextController = adoptNS([[WKBrowsingContextController alloc] _initWithPageRef:[self pageRef]]);
-    return _data->_browsingContextController.get();
+    return wrapper(*_data->_page);
 }
 
 #endif // WK_API_ENABLED

Modified: trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm (159876 => 159877)


--- trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm	2013-11-29 23:21:08 UTC (rev 159876)
+++ trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm	2013-11-30 00:27:38 UTC (rev 159877)
@@ -32,11 +32,12 @@
 #import "DictionaryPopupInfo.h"
 #import "EditorState.h"
 #import "NativeWebKeyboardEvent.h"
-#import "PluginComplexTextInputState.h"
 #import "PageClient.h"
 #import "PageClientImpl.h"
+#import "PluginComplexTextInputState.h"
 #import "StringUtilities.h"
 #import "TextChecker.h"
+#import "WKBrowsingContextControllerInternal.h"
 #import "WebPageMessages.h"
 #import "WebProcessProxy.h"
 #import <WebCore/DictationAlternative.h>
@@ -45,8 +46,8 @@
 #import <WebCore/SystemVersionMac.h>
 #import <WebCore/TextAlternativeWithRange.h>
 #import <WebKitSystemInterface.h>
+#import <mach-o/dyld.h>
 #import <wtf/text/StringConcatenate.h>
-#import <mach-o/dyld.h>
 
 @interface NSApplication (Details)
 - (void)speakString:(NSString *)string;
@@ -67,6 +68,10 @@
 void WebPageProxy::platformInitialize()
 {
     m_useLegacyImplicitRubberBandControl = shouldUseLegacyImplicitRubberBandControl();
+
+#if WK_API_ENABLED
+    [WebKit::wrapper(*this) _finishInitialization];
+#endif
 }
 
 #if defined(__ppc__) || defined(__ppc64__)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to