Commit 4787b0a9 authored by andersca@apple.com's avatar andersca@apple.com

WKBrowsingContextController should not be an API wrapper around WebPageProxy

https://bugs.webkit.org/show_bug.cgi?id=127454

Reviewed by Dan Bernstein.

* Shared/Cocoa/APIObject.mm:
(API::Object::newObject):
* Shared/mac/ObjCObjectGraphCoders.mm:
(WebKit::WebContextObjCObjectGraphDecoderImpl::decode):
* UIProcess/API/Cocoa/WKBrowsingContextController.mm:
(-[WKBrowsingContextController _initWithPageRef:]):
(+[WKBrowsingContextController _browsingContextControllerForPageRef:]):
* UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h:
* UIProcess/API/Cocoa/WKProcessGroup.mm:
(didNavigateWithNavigationData):
(didPerformClientRedirect):
(didPerformServerRedirect):
(didUpdateHistoryTitle):
* UIProcess/API/ios/WKContentView.mm:
(-[WKContentView browsingContextController]):
* UIProcess/API/mac/WKView.mm:
(-[WKView browsingContextController]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::platformInitialize):
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::platformInitialize):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 607bf6e3
2014-01-22 Anders Carlsson <andersca@apple.com>
WKBrowsingContextController should not be an API wrapper around WebPageProxy
https://bugs.webkit.org/show_bug.cgi?id=127454
Reviewed by Dan Bernstein.
* Shared/Cocoa/APIObject.mm:
(API::Object::newObject):
* Shared/mac/ObjCObjectGraphCoders.mm:
(WebKit::WebContextObjCObjectGraphDecoderImpl::decode):
* UIProcess/API/Cocoa/WKBrowsingContextController.mm:
(-[WKBrowsingContextController _initWithPageRef:]):
(+[WKBrowsingContextController _browsingContextControllerForPageRef:]):
* UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h:
* UIProcess/API/Cocoa/WKProcessGroup.mm:
(didNavigateWithNavigationData):
(didPerformClientRedirect):
(didPerformServerRedirect):
(didUpdateHistoryTitle):
* UIProcess/API/ios/WKContentView.mm:
(-[WKContentView browsingContextController]):
* UIProcess/API/mac/WKView.mm:
(-[WKView browsingContextController]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::platformInitialize):
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::platformInitialize):
2014-01-22 Myles C. Maxfield <mmaxfield@apple.com>
Remove CSS3_TEXT_DECORATION define
......
......@@ -120,10 +120,6 @@ void* Object::newObject(size_t size, Type type)
wrapper = [WKNavigationData alloc];
break;
case Type::Page:
wrapper = [WKBrowsingContextController alloc];
break;
case Type::PageGroup:
wrapper = [WKBrowsingContextGroup alloc];
break;
......
......@@ -351,7 +351,7 @@ public:
if (!webPage)
coder.m_root = [NSNull null];
else
coder.m_root = wrapper(*webPage);
coder.m_root = [WKBrowsingContextController _browsingContextControllerForPageRef:toAPI(webPage)];
break;
}
case WKTypeRefWrapperType: {
......
......@@ -139,7 +139,7 @@ static NSString * const frameErrorKey = @"WKBrowsingContextFrameErrorKey";
@end
@implementation WKBrowsingContextController {
API::ObjectStorage<WebPageProxy> _page;
RefPtr<WebPageProxy> _page;
std::unique_ptr<PageLoadStateObserver> _pageLoadStateObserver;
WeakObjCPtr<id <WKBrowsingContextLoadDelegate>> _loadDelegate;
......@@ -158,12 +158,6 @@ static NSString * const frameErrorKey = @"WKBrowsingContextFrameErrorKey";
[super dealloc];
}
- (void)_finishInitialization
{
_pageLoadStateObserver = std::make_unique<PageLoadStateObserver>(self);
_page->pageLoadState().addObserver(*_pageLoadStateObserver);
}
#pragma mark Loading
+ (void)registerSchemeForCustomProtocol:(NSString *)scheme
......@@ -797,6 +791,24 @@ static void setUpPagePolicyClient(WKBrowsingContextController *browsingContext,
return *reinterpret_cast<API::Object*>(&_page);
}
- (instancetype)_initWithPageRef:(WKPageRef)pageRef
{
if (!(self = [super init]))
return nil;
_page = toImpl(pageRef);
_pageLoadStateObserver = std::make_unique<PageLoadStateObserver>(self);
_page->pageLoadState().addObserver(*_pageLoadStateObserver);
return self;
}
+ (WKBrowsingContextController *)_browsingContextControllerForPageRef:(WKPageRef)pageRef
{
return (WKBrowsingContextController *)WebKit::toImpl(pageRef)->loaderClient().client().base.clientInfo;
}
@end
@implementation WKBrowsingContextController (Private)
......
......@@ -31,23 +31,15 @@
#import "WeakObjCPtr.h"
#import "WebPageProxy.h"
namespace WebKit {
inline WKBrowsingContextController *wrapper(WebPageProxy& page)
{
ASSERT([page.wrapper() isKindOfClass:[WKBrowsingContextController class]]);
return (WKBrowsingContextController *)page.wrapper();
}
}
@interface WKBrowsingContextController () <WKObject> {
@package
WebKit::WeakObjCPtr<id <WKBrowsingContextHistoryDelegate>> _historyDelegate;
}
- (void)_finishInitialization;
+ (NSMutableSet *)customSchemes;
+ (WKBrowsingContextController *)_browsingContextControllerForPageRef:(WKPageRef)pageRef;
- (instancetype)_initWithPageRef:(WKPageRef)pageRef;
@end
......
......@@ -115,7 +115,7 @@ static void didNavigateWithNavigationData(WKContextRef, WKPageRef pageRef, WKNav
if (!toImpl(frameRef)->isMainFrame())
return;
WKBrowsingContextController *controller = wrapper(*toImpl(pageRef));
WKBrowsingContextController *controller = [WKBrowsingContextController _browsingContextControllerForPageRef:pageRef];
auto historyDelegate = controller->_historyDelegate.get();
if ([historyDelegate respondsToSelector:@selector(browsingContextController:didNavigateWithNavigationData:)])
......@@ -127,7 +127,7 @@ static void didPerformClientRedirect(WKContextRef, WKPageRef pageRef, WKURLRef s
if (!toImpl(frameRef)->isMainFrame())
return;
WKBrowsingContextController *controller = wrapper(*toImpl(pageRef));
WKBrowsingContextController *controller = [WKBrowsingContextController _browsingContextControllerForPageRef:pageRef];
auto historyDelegate = controller->_historyDelegate.get();
if ([historyDelegate respondsToSelector:@selector(browsingContextController:didPerformClientRedirectFromURL:toURL:)])
......@@ -139,7 +139,7 @@ static void didPerformServerRedirect(WKContextRef, WKPageRef pageRef, WKURLRef s
if (!toImpl(frameRef)->isMainFrame())
return;
WKBrowsingContextController *controller = wrapper(*toImpl(pageRef));
WKBrowsingContextController *controller = [WKBrowsingContextController _browsingContextControllerForPageRef:pageRef];
auto historyDelegate = controller->_historyDelegate.get();
if ([historyDelegate respondsToSelector:@selector(browsingContextController:didPerformServerRedirectFromURL:toURL:)])
......@@ -151,7 +151,7 @@ static void didUpdateHistoryTitle(WKContextRef, WKPageRef pageRef, WKStringRef t
if (!toImpl(frameRef)->isMainFrame())
return;
WKBrowsingContextController *controller = wrapper(*toImpl(pageRef));
WKBrowsingContextController *controller = [WKBrowsingContextController _browsingContextControllerForPageRef:pageRef];
auto historyDelegate = controller->_historyDelegate.get();
if ([historyDelegate respondsToSelector:@selector(browsingContextController:didUpdateHistoryTitle:forURL:)])
......
......@@ -49,6 +49,7 @@ using namespace WebKit;
@implementation WKContentView {
std::unique_ptr<PageClientImpl> _pageClient;
RefPtr<WebPageProxy> _page;
RetainPtr<WKBrowsingContextController> _browsingContextController;
RetainPtr<UIView> _rootContentView;
RetainPtr<WKInteractionView> _interactionView;
......@@ -116,7 +117,10 @@ using namespace WebKit;
- (WKBrowsingContextController *)browsingContextController
{
return wrapper(*_page);
if (!_browsingContextController)
_browsingContextController = [[WKBrowsingContextController alloc] _initWithPageRef:toAPI(_page.get())];
return _browsingContextController.get();
}
- (WKContentType)contentType
......
......@@ -145,6 +145,10 @@ struct WKViewInterpretKeyEventsParameters {
std::unique_ptr<PageClientImpl> _pageClient;
RefPtr<WebPageProxy> _page;
#if WK_API_ENABLED
RetainPtr<WKBrowsingContextController> _browsingContextController;
#endif
// For ToolTips.
NSToolTipTag _lastToolTipTag;
id _trackingRectOwner;
......@@ -284,7 +288,10 @@ struct WKViewInterpretKeyEventsParameters {
- (WKBrowsingContextController *)browsingContextController
{
return wrapper(*_data->_page);
if (!_data->_browsingContextController)
_data->_browsingContextController = [[WKBrowsingContextController alloc] _initWithPageRef:toAPI(_data->_page.get())];
return _data->_browsingContextController.get();
}
#endif // WK_API_ENABLED
......
......@@ -42,9 +42,6 @@ namespace WebKit {
void WebPageProxy::platformInitialize()
{
#if WK_API_ENABLED
[WebKit::wrapper(*this) _finishInitialization];
#endif
}
static String userVisibleWebKitVersionString()
......
......@@ -69,10 +69,6 @@ static bool shouldUseLegacyImplicitRubberBandControl()
void WebPageProxy::platformInitialize()
{
m_useLegacyImplicitRubberBandControl = shouldUseLegacyImplicitRubberBandControl();
#if WK_API_ENABLED
[WebKit::wrapper(*this) _finishInitialization];
#endif
}
static String userVisibleWebKitVersionString()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment