Commit 3b9444bb authored by weinig@apple.com's avatar weinig@apple.com

[CTTE] The WebPageProxy's WebPageGroup is never null so it should be stored in a Ref

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

Reviewed by Dan Bernstein.

* UIProcess/API/C/WKPage.cpp:
(WKPageGetPageGroup):
* UIProcess/API/C/mac/WKPagePrivateMac.cpp:
(WKPageIsURLKnownHSTSHost):
* UIProcess/API/Cocoa/WKBrowsingContextController.mm:
(-[WKBrowsingContextController browsingContextGroup]):
* UIProcess/API/mac/WKView.mm:
(-[WKView _preferencesDidChange]):
(-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]):
* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext):
(WebKit::WebContext::createWebPage):
* UIProcess/WebContext.h:
* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorPageGroups::inspectorLevel):
(WebKit::WebInspectorPageGroups::isInspectorPageGroup):
(WebKit::WebInspectorPageGroups::inspectorPageGroupLevel):
(WebKit::WebInspectorProxy::isInspectorPage):
* UIProcess/WebInspectorProxy.h:
* UIProcess/WebPageGroup.cpp:
(WebKit::WebPageGroup::createNonNull):
* UIProcess/WebPageGroup.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::create):
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle):
(WebKit::WebPageProxy::preferencesDidChange):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::pageGroup):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::createWebPage):
* UIProcess/WebProcessProxy.h:
* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::WebInspectorProxy::createInspectorWindow):
(WebKit::WebInspectorProxy::platformCreateInspectorPage):
(WebKit::WebInspectorProxy::windowFrameDidChange):
* UIProcess/mac/WebProcessProxyMac.mm:
(WebKit::WebProcessProxy::pageIsProcessSuppressible):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159896 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 42115e1b
2013-11-30 Sam Weinig <sam@webkit.org>
[CTTE] The WebPageProxy's WebPageGroup is never null so it should be stored in a Ref
https://bugs.webkit.org/show_bug.cgi?id=125038
Reviewed by Dan Bernstein.
* UIProcess/API/C/WKPage.cpp:
(WKPageGetPageGroup):
* UIProcess/API/C/mac/WKPagePrivateMac.cpp:
(WKPageIsURLKnownHSTSHost):
* UIProcess/API/Cocoa/WKBrowsingContextController.mm:
(-[WKBrowsingContextController browsingContextGroup]):
* UIProcess/API/mac/WKView.mm:
(-[WKView _preferencesDidChange]):
(-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]):
* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext):
(WebKit::WebContext::createWebPage):
* UIProcess/WebContext.h:
* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorPageGroups::inspectorLevel):
(WebKit::WebInspectorPageGroups::isInspectorPageGroup):
(WebKit::WebInspectorPageGroups::inspectorPageGroupLevel):
(WebKit::WebInspectorProxy::isInspectorPage):
* UIProcess/WebInspectorProxy.h:
* UIProcess/WebPageGroup.cpp:
(WebKit::WebPageGroup::createNonNull):
* UIProcess/WebPageGroup.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::create):
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle):
(WebKit::WebPageProxy::preferencesDidChange):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::pageGroup):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::createWebPage):
* UIProcess/WebProcessProxy.h:
* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::WebInspectorProxy::createInspectorWindow):
(WebKit::WebInspectorProxy::platformCreateInspectorPage):
(WebKit::WebInspectorProxy::windowFrameDidChange):
* UIProcess/mac/WebProcessProxyMac.mm:
(WebKit::WebProcessProxy::pageIsProcessSuppressible):
2013-11-30 Dan Bernstein <mitz@apple.com>
Added a version of +[NSURL _web_URLWithWTFString:relativeToURL:] that doesn’t take a base URL and switched all callers to it.
......
......@@ -60,7 +60,7 @@ WKContextRef WKPageGetContext(WKPageRef pageRef)
WKPageGroupRef WKPageGetPageGroup(WKPageRef pageRef)
{
return toAPI(toImpl(pageRef)->pageGroup());
return toAPI(&toImpl(pageRef)->pageGroup());
}
void WKPageLoadURL(WKPageRef pageRef, WKURLRef URLRef)
......
......@@ -42,7 +42,7 @@ pid_t WKPageGetProcessIdentifier(WKPageRef pageRef)
bool WKPageIsURLKnownHSTSHost(WKPageRef page, WKURLRef url)
{
WebPageProxy* webPageProxy = toImpl(page);
bool privateBrowsingEnabled = webPageProxy->pageGroup()->preferences()->privateBrowsingEnabled();
bool privateBrowsingEnabled = webPageProxy->pageGroup().preferences()->privateBrowsingEnabled();
return webPageProxy->process()->context()->isURLKnownHSTSHost(toImpl(url)->string(), privateBrowsingEnabled);
}
......@@ -121,10 +121,7 @@ static NSString * const frameErrorKey = @"WKBrowsingContextFrameErrorKey";
- (WKBrowsingContextGroup *)browsingContextGroup
{
WebPageGroup* pageGroup = _page->pageGroup();
if (!pageGroup)
return nil;
return wrapper(*pageGroup);
return wrapper(_page->pageGroup());
}
#pragma mark Loading
......
......@@ -2272,7 +2272,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
- (void)_preferencesDidChange
{
BOOL needsViewFrameInWindowCoordinates = _data->_page->pageGroup()->preferences()->pluginsEnabled();
BOOL needsViewFrameInWindowCoordinates = _data->_page->pageGroup().preferences()->pluginsEnabled();
if (!!needsViewFrameInWindowCoordinates == !!_data->_needsViewFrameInWindowCoordinates)
return;
......@@ -2922,7 +2922,7 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path)
_data->_intrinsicContentSize = NSMakeSize(NSViewNoInstrinsicMetric, NSViewNoInstrinsicMetric);
_data->_needsViewFrameInWindowCoordinates = _data->_page->pageGroup()->preferences()->pluginsEnabled();
_data->_needsViewFrameInWindowCoordinates = _data->_page->pageGroup().preferences()->pluginsEnabled();
_data->_frameOrigin = NSZeroPoint;
_data->_contentAnchor = WKContentAnchorTopLeft;
......
......@@ -136,7 +136,7 @@ WebContext::WebContext(const String& injectedBundlePath)
, m_webProcessCountLimit(UINT_MAX)
, m_haveInitialEmptyProcess(false)
, m_processWithPageCache(0)
, m_defaultPageGroup(WebPageGroup::create())
, m_defaultPageGroup(WebPageGroup::createNonNull())
, m_injectedBundlePath(injectedBundlePath)
, m_visitedLinkProvider(this)
, m_plugInAutoStartProvider(this)
......@@ -756,10 +756,7 @@ PassRefPtr<WebPageProxy> WebContext::createWebPage(PageClient& pageClient, WebPa
process = createNewWebProcessRespectingProcessCountLimit();
}
if (!pageGroup)
pageGroup = m_defaultPageGroup.get();
return process->createWebPage(pageClient, this, pageGroup);
return process->createWebPage(pageClient, pageGroup ? *pageGroup : m_defaultPageGroup.get());
}
DownloadProxy* WebContext::download(WebPageProxy* initiatingPage, const ResourceRequest& request)
......
......@@ -419,7 +419,7 @@ private:
WebProcessProxy* m_processWithPageCache;
RefPtr<WebPageGroup> m_defaultPageGroup;
Ref<WebPageGroup> m_defaultPageGroup;
RefPtr<API::Object> m_injectedBundleInitializationUserData;
String m_injectedBundlePath;
......
......@@ -66,20 +66,20 @@ public:
return instance;
}
unsigned inspectorLevel(WebPageGroup* inspectedPageGroup)
unsigned inspectorLevel(WebPageGroup& inspectedPageGroup)
{
return isInspectorPageGroup(inspectedPageGroup) ? inspectorPageGroupLevel(inspectedPageGroup) + 1 : 1;
}
bool isInspectorPageGroup(WebPageGroup* group)
bool isInspectorPageGroup(WebPageGroup& group)
{
return m_pageGroupLevel.contains(group);
return m_pageGroupLevel.contains(&group);
}
unsigned inspectorPageGroupLevel(WebPageGroup* group)
unsigned inspectorPageGroupLevel(WebPageGroup& group)
{
ASSERT(isInspectorPageGroup(group));
return m_pageGroupLevel.get(group);
return m_pageGroupLevel.get(&group);
}
WebPageGroup* inspectorPageGroupForLevel(unsigned level)
......@@ -356,9 +356,9 @@ void WebInspectorProxy::togglePageProfiling()
m_isProfilingPage = !m_isProfilingPage;
}
bool WebInspectorProxy::isInspectorPage(WebPageProxy* page)
bool WebInspectorProxy::isInspectorPage(WebPageProxy& page)
{
return WebInspectorPageGroups::shared().isInspectorPageGroup(page->pageGroup());
return WebInspectorPageGroups::shared().isInspectorPageGroup(page.pageGroup());
}
static bool isMainInspectorPage(const WebInspectorProxy* webInspectorProxy, WKURLRequestRef requestRef)
......
......@@ -132,7 +132,7 @@ public:
bool isProfilingPage() const { return m_isProfilingPage; }
void togglePageProfiling();
static bool isInspectorPage(WebPageProxy*);
static bool isInspectorPage(WebPageProxy&);
// Implemented the platform WebInspectorProxy file
String inspectorPageURL() const;
......
......@@ -54,6 +54,11 @@ PassRefPtr<WebPageGroup> WebPageGroup::create(const String& identifier, bool vis
return adoptRef(new WebPageGroup(identifier, visibleToInjectedBundle, visibleToHistoryClient));
}
PassRef<WebPageGroup> WebPageGroup::createNonNull(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient)
{
return adoptRef(*new WebPageGroup(identifier, visibleToInjectedBundle, visibleToHistoryClient));
}
WebPageGroup* WebPageGroup::get(uint64_t pageGroupID)
{
return webPageGroupMap().get(pageGroupID);
......
......@@ -42,6 +42,7 @@ class WebPageGroup : public API::TypedObject<API::Object::Type::PageGroup> {
public:
WebPageGroup(const String& identifier = String(), bool visibleToInjectedBundle = true, bool visibleToHistoryClient = true);
static PassRefPtr<WebPageGroup> create(const String& identifier = String(), bool visibleToInjectedBundle = true, bool visibleToHistoryClient = true);
static PassRef<WebPageGroup> createNonNull(const String& identifier = String(), bool visibleToInjectedBundle = true, bool visibleToHistoryClient = true);
static WebPageGroup* get(uint64_t pageGroupID);
virtual ~WebPageGroup();
......
......@@ -222,16 +222,16 @@ static const char* webKeyboardEventTypeString(WebEvent::Type type)
}
#endif // !LOG_DISABLED
PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient& pageClient, PassRefPtr<WebProcessProxy> process, WebPageGroup* pageGroup, uint64_t pageID)
PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient& pageClient, PassRefPtr<WebProcessProxy> process, WebPageGroup& pageGroup, uint64_t pageID)
{
return adoptRef(new WebPageProxy(pageClient, process, pageGroup, pageID));
}
WebPageProxy::WebPageProxy(PageClient& pageClient, PassRefPtr<WebProcessProxy> process, WebPageGroup* pageGroup, uint64_t pageID)
WebPageProxy::WebPageProxy(PageClient& pageClient, PassRefPtr<WebProcessProxy> process, WebPageGroup& pageGroup, uint64_t pageID)
: m_pageClient(pageClient)
, m_process(process)
, m_pageGroup(pageGroup)
, m_mainFrame(0)
, m_mainFrame(nullptr)
, m_userAgent(standardUserAgent())
, m_geolocationPermissionRequestManager(*this)
, m_notificationPermissionRequestManager(*this)
......@@ -593,7 +593,7 @@ bool WebPageProxy::maybeInitializeSandboxExtensionHandle(const URL& url, Sandbox
#if ENABLE(INSPECTOR)
// Don't give the inspector full access to the file system.
if (WebInspectorProxy::isInspectorPage(this))
if (WebInspectorProxy::isInspectorPage(*this))
return false;
#endif
......@@ -2017,7 +2017,7 @@ void WebPageProxy::preferencesDidChange()
// even if nothing changed in UI process, so that overrides get removed.
// Preferences need to be updated during synchronous printing to make "print backgrounds" preference work when toggled from a print dialog checkbox.
m_process->send(Messages::WebPage::PreferencesDidChange(pageGroup()->preferences()->store()), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
m_process->send(Messages::WebPage::PreferencesDidChange(pageGroup().preferences()->store()), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
}
void WebPageProxy::didCreateMainFrame(uint64_t frameID)
......
......@@ -322,7 +322,7 @@ class WebPageProxy
, public CoreIPC::MessageReceiver {
public:
static PassRefPtr<WebPageProxy> create(PageClient&, PassRefPtr<WebProcessProxy>, WebPageGroup*, uint64_t pageID);
static PassRefPtr<WebPageProxy> create(PageClient&, PassRefPtr<WebProcessProxy>, WebPageGroup&, uint64_t pageID);
virtual ~WebPageProxy();
uint64_t pageID() const { return m_pageID; }
......@@ -700,7 +700,7 @@ public:
WebProcessProxy* process() const;
PlatformProcessIdentifier processIdentifier() const;
WebPageGroup* pageGroup() const { return m_pageGroup.get(); }
WebPageGroup& pageGroup() { return m_pageGroup.get(); }
bool isValid() const;
......@@ -847,7 +847,7 @@ public:
WebCore::ScrollPinningBehavior scrollPinningBehavior() { return m_scrollPinningBehavior; }
private:
WebPageProxy(PageClient&, PassRefPtr<WebProcessProxy>, WebPageGroup*, uint64_t pageID);
WebPageProxy(PageClient&, PassRefPtr<WebProcessProxy>, WebPageGroup&, uint64_t pageID);
void platformInitialize();
void initializeCreationParameters();
......@@ -1154,7 +1154,7 @@ private:
std::unique_ptr<DrawingAreaProxy> m_drawingArea;
RefPtr<WebProcessProxy> m_process;
RefPtr<WebPageGroup> m_pageGroup;
Ref<WebPageGroup> m_pageGroup;
RefPtr<WebFrameProxy> m_mainFrame;
RefPtr<WebFrameProxy> m_focusedFrame;
RefPtr<WebFrameProxy> m_frameSetLargestFrame;
......
......@@ -160,7 +160,7 @@ WebPageProxy* WebProcessProxy::webPage(uint64_t pageID)
return globalPageMap().get(pageID);
}
PassRefPtr<WebPageProxy> WebProcessProxy::createWebPage(PageClient& pageClient, WebContext*, WebPageGroup* pageGroup)
PassRefPtr<WebPageProxy> WebProcessProxy::createWebPage(PageClient& pageClient, WebPageGroup& pageGroup)
{
uint64_t pageID = generatePageID();
RefPtr<WebPageProxy> webPage = WebPageProxy::create(pageClient, this, pageGroup, pageID);
......
......@@ -77,7 +77,7 @@ public:
WebContext* context() const { return m_context.get(); }
static WebPageProxy* webPage(uint64_t pageID);
PassRefPtr<WebPageProxy> createWebPage(PageClient&, WebContext*, WebPageGroup*);
PassRefPtr<WebPageProxy> createWebPage(PageClient&, WebPageGroup&);
void addExistingWebPage(WebPageProxy*, uint64_t pageID);
void removeWebPage(uint64_t pageID);
Vector<WebPageProxy*> pages() const;
......
......@@ -285,7 +285,7 @@ void WebInspectorProxy::createInspectorWindow()
NSRect windowFrame = NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight);
// Restore the saved window frame, if there was one.
NSString *savedWindowFrameString = page()->pageGroup()->preferences()->inspectorWindowFrame();
NSString *savedWindowFrameString = page()->pageGroup().preferences()->inspectorWindowFrame();
NSRect savedWindowFrame = NSRectFromString(savedWindowFrameString);
if (!NSIsEmptyRect(savedWindowFrame))
windowFrame = savedWindowFrame;
......@@ -384,7 +384,7 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
} else {
initialRect = NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight);
NSString *windowFrameString = page()->pageGroup()->preferences()->inspectorWindowFrame();
NSString *windowFrameString = page()->pageGroup().preferences()->inspectorWindowFrame();
NSRect windowFrame = NSRectFromString(windowFrameString);
if (!NSIsEmptyRect(windowFrame))
initialRect = [NSWindow contentRectForFrameRect:windowFrame styleMask:windowStyleMask];
......@@ -607,7 +607,7 @@ void WebInspectorProxy::windowFrameDidChange()
return;
NSString *frameString = NSStringFromRect([m_inspectorWindow frame]);
page()->pageGroup()->preferences()->setInspectorWindowFrame(frameString);
page()->pageGroup().preferences()->setInspectorWindowFrame(frameString);
}
void WebInspectorProxy::inspectedViewFrameDidChange(CGFloat currentDimension)
......
......@@ -61,7 +61,7 @@ void WebProcessProxy::platformGetLaunchOptions(ProcessLauncher::LaunchOptions& l
bool WebProcessProxy::pageIsProcessSuppressible(WebPageProxy* page)
{
return !page->isViewVisible() && page->pageGroup()->preferences()->pageVisibilityBasedProcessSuppressionEnabled();
return !page->isViewVisible() && page->pageGroup().preferences()->pageVisibilityBasedProcessSuppressionEnabled();
}
bool WebProcessProxy::allPagesAreProcessSuppressible() const
......
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