Commit 095b544b authored by akling@apple.com's avatar akling@apple.com

Page::mainFrame() should return a reference.

<http://webkit.org/b/119677>

Reviewed by Antti Koivisto.

Page always creates the main Frame by itself now, so it will never be null during the Page's lifetime.

Let Page::mainFrame() return Frame& and remove a sea of null checks.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154658 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8e5f637b
2013-08-26 Andreas Kling <akling@apple.com>
Page::mainFrame() should return a reference.
<http://webkit.org/b/119677>
Reviewed by Antti Koivisto.
Page always creates the main Frame by itself now, so it will never be null during the Page's lifetime.
Let Page::mainFrame() return Frame& and remove a sea of null checks.
2013-08-26 Sam Weinig <sam@webkit.org>
Remove two unnecessary .get()s.
......@@ -3009,7 +3009,7 @@ static NSString* roleValueToNSString(AccessibilityRole value)
}
}
page->contextMenuController().showContextMenuAt(page->mainFrame(), rect.center());
page->contextMenuController().showContextMenuAt(&page->mainFrame(), rect.center());
}
- (void)accessibilityScrollToVisible
......
......@@ -189,7 +189,7 @@ void PageScriptDebugServer::setJavaScriptPaused(Page* page, bool paused)
page->setDefersLoading(paused);
for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverseNext())
for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext())
setJavaScriptPaused(frame, paused);
}
......
......@@ -64,7 +64,7 @@ void ScriptProfiler::start(ScriptState* state, const String& title)
void ScriptProfiler::startForPage(Page* inspectedPage, const String& title)
{
JSC::ExecState* scriptState = toJSDOMWindow(inspectedPage->mainFrame(), debuggerWorld())->globalExec();
JSC::ExecState* scriptState = toJSDOMWindow(&inspectedPage->mainFrame(), debuggerWorld())->globalExec();
start(scriptState, title);
}
......@@ -83,7 +83,7 @@ PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String&
PassRefPtr<ScriptProfile> ScriptProfiler::stopForPage(Page* inspectedPage, const String& title)
{
JSC::ExecState* scriptState = toJSDOMWindow(inspectedPage->mainFrame(), debuggerWorld())->globalExec();
JSC::ExecState* scriptState = toJSDOMWindow(&inspectedPage->mainFrame(), debuggerWorld())->globalExec();
return stop(scriptState, title);
}
......
......@@ -89,7 +89,7 @@ ScriptState* scriptStateFromNode(DOMWrapperWorld* world, Node* node)
ScriptState* scriptStateFromPage(DOMWrapperWorld* world, Page* page)
{
return page->mainFrame()->script().globalObject(world)->globalExec();
return page->mainFrame().script().globalObject(world)->globalExec();
}
#if ENABLE(WORKERS)
......
......@@ -200,7 +200,7 @@ static bool numberValue(CSSValue* value, float& result)
static bool colorMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)
{
int bitsPerComponent = screenDepthPerComponent(frame->page()->mainFrame()->view());
int bitsPerComponent = screenDepthPerComponent(frame->page()->mainFrame().view());
float number;
if (value)
return numberValue(value, number) && compareValue(bitsPerComponent, static_cast<int>(number), op);
......@@ -221,7 +221,7 @@ static bool color_indexMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, M
static bool monochromeMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
{
if (!screenIsMonochrome(frame->page()->mainFrame()->view())) {
if (!screenIsMonochrome(frame->page()->mainFrame().view())) {
if (value) {
float number;
return numberValue(value, number) && compareValue(0, static_cast<int>(number), op);
......@@ -268,7 +268,7 @@ static bool aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* f
static bool device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)
{
if (value) {
FloatRect sg = screenRect(frame->page()->mainFrame()->view());
FloatRect sg = screenRect(frame->page()->mainFrame().view());
return compareAspectRatioValue(value, static_cast<int>(sg.width()), static_cast<int>(sg.height()), op);
}
......@@ -359,7 +359,7 @@ static bool computeLength(CSSValue* value, bool strict, RenderStyle* style, Rend
static bool device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
{
if (value) {
FloatRect sg = screenRect(frame->page()->mainFrame()->view());
FloatRect sg = screenRect(frame->page()->mainFrame().view());
RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
int length;
long height = sg.height();
......@@ -374,7 +374,7 @@ static bool device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, F
static bool device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
{
if (value) {
FloatRect sg = screenRect(frame->page()->mainFrame()->view());
FloatRect sg = screenRect(frame->page()->mainFrame().view());
RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
int length;
long width = sg.width();
......
......@@ -1270,7 +1270,7 @@ void Document::setVisualUpdatesAllowed(bool visualUpdatesAllowed)
updateLayout();
if (Page* page = this->page()) {
if (frame() == page->mainFrame()) {
if (frame() == &page->mainFrame()) {
frameView->addPaintPendingMilestones(DidFirstPaintAfterSuppressedIncrementalRendering);
if (page->requestedLayoutMilestones() & DidFirstLayoutAfterSuppressedIncrementalRendering)
frame()->loader().didLayout(DidFirstLayoutAfterSuppressedIncrementalRendering);
......@@ -1988,7 +1988,7 @@ void Document::createRenderTree()
static void pageWheelEventHandlerCountChanged(Page& page)
{
unsigned count = 0;
for (const Frame* frame = page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
for (const Frame* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (Document* document = frame->document())
count += document->wheelEventHandlerCount();
}
......@@ -2014,13 +2014,13 @@ void Document::didBecomeCurrentDocumentInFrame()
// FIXME: Doing this every time is a waste. If the current document and its
// subframes' documents have no wheel event handlers, then the count did not change,
// unless the documents they are replacing had wheel event handlers.
if (page() && page()->mainFrame() == m_frame)
if (page() && &page()->mainFrame() == m_frame)
pageWheelEventHandlerCountChanged(*page());
#if ENABLE(TOUCH_EVENTS)
// FIXME: Doing this only for the main frame is insufficient.
// A subframe could have touch event handlers.
if (hasTouchEventHandlers() && page() && page()->mainFrame() == m_frame)
if (hasTouchEventHandlers() && page() && &page()->mainFrame() == m_frame)
page()->chrome().client().needTouchEvents(true);
#endif
......@@ -2942,7 +2942,7 @@ void Document::processViewport(const String& features, ViewportArguments::Type o
void Document::updateViewportArguments()
{
if (page() && page()->mainFrame() == frame()) {
if (page() && &page()->mainFrame() == frame()) {
#ifndef NDEBUG
m_didDispatchViewportPropertiesChanged = true;
#endif
......@@ -3996,7 +3996,7 @@ void Document::setInPageCache(bool flag)
// function. It would be nice if there was more symmetry here.
// https://bugs.webkit.org/show_bug.cgi?id=98698
v->cacheCurrentScrollPosition();
if (page && page->mainFrame() == m_frame) {
if (page && &page->mainFrame() == m_frame) {
v->resetScrollbarsAndClearContentsSize();
if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
scrollingCoordinator->clearStateTree();
......@@ -5613,7 +5613,7 @@ void Document::didRemoveTouchEventHandler(Node* handler)
#endif
if (m_touchEventTargets->size())
return;
for (const Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
for (const Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (frame->document() && frame->document()->hasTouchEventHandlers())
return;
}
......@@ -5997,7 +5997,7 @@ void Document::ensurePlugInsInjectedScript(DOMWrapperWorld* world)
if (!jsString)
jsString = plugInsJavaScript;
page()->mainFrame()->script().evaluateInWorld(ScriptSourceCode(jsString), world);
page()->mainFrame().script().evaluateInWorld(ScriptSourceCode(jsString), world);
m_hasInjectedPlugInsScript = true;
}
......
......@@ -160,7 +160,7 @@ CachedFrame::CachedFrame(Frame* frame)
ASSERT(m_view);
if (frame->page()->focusController().focusedFrame() == frame)
frame->page()->focusController().setFocusedFrame(frame->page()->mainFrame());
frame->page()->focusController().setFocusedFrame(&frame->page()->mainFrame());
// Custom scrollbar renderers will get reattached when the document comes out of the page cache
m_view->detachCustomScrollbars();
......
......@@ -53,7 +53,7 @@ PassRefPtr<CachedPage> CachedPage::create(Page* page)
CachedPage::CachedPage(Page* page)
: m_timeStamp(currentTime())
, m_expirationTime(m_timeStamp + page->settings().backForwardCacheExpirationInterval())
, m_cachedMainFrame(CachedFrame::create(page->mainFrame()))
, m_cachedMainFrame(CachedFrame::create(&page->mainFrame()))
, m_needStyleRecalcForVisitedLinks(false)
, m_needsFullStyleRecalc(false)
, m_needsCaptionPreferencesChanged(false)
......@@ -77,7 +77,7 @@ CachedPage::~CachedPage()
void CachedPage::restore(Page* page)
{
ASSERT(m_cachedMainFrame);
ASSERT(page && page->mainFrame() && page->mainFrame() == &m_cachedMainFrame->view()->frame());
ASSERT(page && &page->mainFrame() == &m_cachedMainFrame->view()->frame());
ASSERT(!page->subframeCount());
m_cachedMainFrame->open();
......@@ -89,14 +89,13 @@ void CachedPage::restore(Page* page)
element->updateFocusAppearance(true);
if (m_needStyleRecalcForVisitedLinks) {
for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverseNext())
for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext())
frame->document()->visitedLinkState().invalidateStyleForAllLinks();
}
#if USE(ACCELERATED_COMPOSITING)
if (m_needsDeviceScaleChanged) {
if (Frame* frame = page->mainFrame())
frame->deviceOrPageScaleFactorChanged();
page->mainFrame().deviceOrPageScaleFactorChanged();
}
#endif
......
......@@ -202,9 +202,9 @@ COMPILE_ASSERT(NumberOfReasonsPagesCannotBeInPageCache <= sizeof(unsigned)*8, Re
static void logCanCachePageDecision(Page* page)
{
// Only bother logging for main frames that have actually loaded and have content.
if (page->mainFrame()->loader().stateMachine()->creatingInitialEmptyDocument())
if (page->mainFrame().loader().stateMachine()->creatingInitialEmptyDocument())
return;
KURL currentURL = page->mainFrame()->loader().documentLoader() ? page->mainFrame()->loader().documentLoader()->url() : KURL();
KURL currentURL = page->mainFrame().loader().documentLoader() ? page->mainFrame().loader().documentLoader()->url() : KURL();
if (currentURL.isEmpty())
return;
......@@ -212,7 +212,7 @@ static void logCanCachePageDecision(Page* page)
PCLOG("--------\n Determining if page can be cached:");
unsigned rejectReasons = 0;
unsigned frameRejectReasons = logCanCacheFrameDecision(page->mainFrame(), indentLevel+1);
unsigned frameRejectReasons = logCanCacheFrameDecision(&page->mainFrame(), indentLevel+1);
if (frameRejectReasons)
rejectReasons |= 1 << FrameCannotBeInPageCache;
......@@ -240,7 +240,7 @@ static void logCanCachePageDecision(Page* page)
rejectReasons |= 1 << UsesDeviceMotion;
}
#endif
FrameLoadType loadType = page->mainFrame()->loader().loadType();
FrameLoadType loadType = page->mainFrame().loader().loadType();
if (loadType == FrameLoadTypeReload) {
PCLOG(" -Load type is: Reload");
rejectReasons |= 1 << IsReload;
......@@ -350,10 +350,10 @@ bool PageCache::canCache(Page* page) const
// store the final page we end up on.
// No point writing to the cache on a reload or loadSame, since we will just write
// over it again when we leave that page.
FrameLoadType loadType = page->mainFrame()->loader().loadType();
FrameLoadType loadType = page->mainFrame().loader().loadType();
return m_capacity > 0
&& canCachePageContainingThisFrame(page->mainFrame())
&& canCachePageContainingThisFrame(&page->mainFrame())
&& page->backForward()->isActive()
&& page->settings().usesPageCache()
#if ENABLE(DEVICE_ORIENTATION)
......@@ -397,11 +397,9 @@ void PageCache::markPagesForVistedLinkStyleRecalc()
void PageCache::markPagesForFullStyleRecalc(Page* page)
{
Frame* mainFrame = page->mainFrame();
for (HistoryItem* current = m_head; current; current = current->m_next) {
CachedPage* cachedPage = current->m_cachedPage.get();
if (&cachedPage->cachedMainFrame()->view()->frame() == mainFrame)
if (&cachedPage->cachedMainFrame()->view()->frame() == &page->mainFrame())
cachedPage->markForFullStyleRecalc();
}
}
......@@ -410,11 +408,9 @@ void PageCache::markPagesForFullStyleRecalc(Page* page)
#if USE(ACCELERATED_COMPOSITING)
void PageCache::markPagesForDeviceScaleChanged(Page* page)
{
Frame* mainFrame = page->mainFrame();
for (HistoryItem* current = m_head; current; current = current->m_next) {
CachedPage* cachedPage = current->m_cachedPage.get();
if (&cachedPage->cachedMainFrame()->view()->frame() == mainFrame)
if (&cachedPage->cachedMainFrame()->view()->frame() == &page->mainFrame())
cachedPage->markForDeviceScaleChanged();
}
}
......
......@@ -370,7 +370,7 @@ void HTMLPlugInImageElement::didAddUserAgentShadowRoot(ShadowRoot* root)
static DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::create(JSDOMWindow::commonVM()).leakRef();
document()->ensurePlugInsInjectedScript(isolatedWorld);
ScriptController& scriptController = page->mainFrame()->script();
ScriptController& scriptController = page->mainFrame().script();
JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(isolatedWorld));
JSC::ExecState* exec = globalObject->globalExec();
......@@ -451,7 +451,7 @@ void HTMLPlugInImageElement::restartSimilarPlugIns()
if (!document()->page())
return;
for (Frame* frame = document()->page()->mainFrame(); frame; frame = frame->tree().traverseNext()) {
for (Frame* frame = &document()->page()->mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (!frame->loader().subframeLoader()->containsPlugins())
continue;
......@@ -483,8 +483,8 @@ void HTMLPlugInImageElement::userDidClickSnapshot(PassRefPtr<MouseEvent> event,
m_pendingClickEventFromSnapshot = event;
String plugInOrigin = m_loadedUrl.host();
if (document()->page() && !SchemeRegistry::shouldTreatURLSchemeAsLocal(document()->page()->mainFrame()->document()->baseURL().protocol()) && document()->page()->settings().autostartOriginPlugInSnapshottingEnabled())
document()->page()->plugInClient()->didStartFromOrigin(document()->page()->mainFrame()->document()->baseURL().host(), plugInOrigin, loadedMimeType());
if (document()->page() && !SchemeRegistry::shouldTreatURLSchemeAsLocal(document()->page()->mainFrame().document()->baseURL().protocol()) && document()->page()->settings().autostartOriginPlugInSnapshottingEnabled())
document()->page()->plugInClient()->didStartFromOrigin(document()->page()->mainFrame().document()->baseURL().host(), plugInOrigin, loadedMimeType());
LOG(Plugins, "%p User clicked on snapshotted plug-in. Restart.", this);
restartSnapshottedPlugIn();
......@@ -540,8 +540,8 @@ static bool documentHadRecentUserGesture(Document* document)
{
double lastKnownUserGestureTimestamp = document->lastHandledUserGestureTimestamp();
if (document->frame() != document->page()->mainFrame() && document->page()->mainFrame() && document->page()->mainFrame()->document())
lastKnownUserGestureTimestamp = std::max(lastKnownUserGestureTimestamp, document->page()->mainFrame()->document()->lastHandledUserGestureTimestamp());
if (document->frame() != &document->page()->mainFrame() && document->page()->mainFrame().document())
lastKnownUserGestureTimestamp = std::max(lastKnownUserGestureTimestamp, document->page()->mainFrame().document()->lastHandledUserGestureTimestamp());
if (monotonicallyIncreasingTime() - lastKnownUserGestureTimestamp < autostartSoonAfterUserGestureThreshold)
return true;
......@@ -603,7 +603,7 @@ void HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn(const KURL& url)
return;
}
bool inMainFrame = document()->frame() == document()->page()->mainFrame();
bool inMainFrame = document()->frame() == &document()->page()->mainFrame();
if (document()->isPluginDocument() && inMainFrame) {
LOG(Plugins, "%p Plug-in document in main frame", this);
......@@ -636,8 +636,8 @@ void HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn(const KURL& url)
return;
}
if (document()->page()->settings().autostartOriginPlugInSnapshottingEnabled() && document()->page()->plugInClient() && document()->page()->plugInClient()->shouldAutoStartFromOrigin(document()->page()->mainFrame()->document()->baseURL().host(), url.host(), loadedMimeType())) {
LOG(Plugins, "%p Plug-in from (%s, %s) is marked to auto-start, set to play", this, document()->page()->mainFrame()->document()->baseURL().host().utf8().data(), url.host().utf8().data());
if (document()->page()->settings().autostartOriginPlugInSnapshottingEnabled() && document()->page()->plugInClient() && document()->page()->plugInClient()->shouldAutoStartFromOrigin(document()->page()->mainFrame().document()->baseURL().host(), url.host(), loadedMimeType())) {
LOG(Plugins, "%p Plug-in from (%s, %s) is marked to auto-start, set to play", this, document()->page()->mainFrame().document()->baseURL().host().utf8().data(), url.host().utf8().data());
m_snapshotDecision = NeverSnapshot;
return;
}
......@@ -648,7 +648,7 @@ void HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn(const KURL& url)
return;
}
if (!SchemeRegistry::shouldTreatURLSchemeAsLocal(m_loadedUrl.protocol()) && !m_loadedUrl.host().isEmpty() && m_loadedUrl.host() == document()->page()->mainFrame()->document()->baseURL().host()) {
if (!SchemeRegistry::shouldTreatURLSchemeAsLocal(m_loadedUrl.protocol()) && !m_loadedUrl.host().isEmpty() && m_loadedUrl.host() == document()->page()->mainFrame().document()->baseURL().host()) {
LOG(Plugins, "%p Plug-in is served from page's domain, set to play", this);
m_snapshotDecision = NeverSnapshot;
return;
......@@ -686,7 +686,7 @@ void HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn(const KURL& url)
return;
}
LOG(Plugins, "%p Plug-in from (%s, %s) is not auto-start, sized at %dx%d, set to wait for snapshot", this, document()->page()->mainFrame()->document()->baseURL().host().utf8().data(), url.host().utf8().data(), contentWidth, contentHeight);
LOG(Plugins, "%p Plug-in from (%s, %s) is not auto-start, sized at %dx%d, set to wait for snapshot", this, document()->page()->mainFrame().document()->baseURL().host().utf8().data(), url.host().utf8().data(), contentWidth, contentHeight);
m_snapshotDecision = Snapshotted;
setDisplayState(WaitingForSnapshot);
}
......
......@@ -373,7 +373,7 @@ CachedImage* ImageDocument::cachedImage()
bool ImageDocument::shouldShrinkToFit() const
{
return frame()->page()->settings().shrinksStandaloneImagesToFit() && frame()->page()->mainFrame() == frame();
return frame()->page()->settings().shrinksStandaloneImagesToFit() && &frame()->page()->mainFrame() == frame();
}
void ImageEventListener::handleEvent(ScriptExecutionContext*, Event* event)
......
......@@ -141,7 +141,7 @@ void InspectorAgent::domContentLoadedEventFired()
bool InspectorAgent::isMainResourceLoader(DocumentLoader* loader, const KURL& requestUrl)
{
return loader->frame() == m_inspectedPage->mainFrame() && requestUrl == loader->requestURL();
return loader->frame() == &m_inspectedPage->mainFrame() && requestUrl == loader->requestURL();
}
void InspectorAgent::evaluateForTestInFrontend(long callId, const String& script)
......@@ -171,7 +171,7 @@ void InspectorAgent::inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObject> obje
KURL InspectorAgent::inspectedURL() const
{
return m_inspectedPage->mainFrame()->document()->url();
return m_inspectedPage->mainFrame().document()->url();
}
KURL InspectorAgent::inspectedURLWithoutFragment() const
......
......@@ -266,7 +266,7 @@ void InspectorCanvasAgent::findFramesWithUninstrumentedCanvases()
{
m_framesWithUninstrumentedCanvases.clear();
for (Frame* frame = m_pageAgent->page()->mainFrame(); frame; frame = frame->tree().traverseNext()) {
for (Frame* frame = &m_pageAgent->page()->mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (!frame->document())
continue;
......
......@@ -47,14 +47,10 @@ bool InspectorClient::doDispatchMessageOnFrontendPage(Page* frontendPage, const
if (!frontendPage)
return false;
Frame* frame = frontendPage->mainFrame();
if (!frame)
return false;
String dispatchToFrontend = "InspectorFrontendAPI.dispatchMessageAsync(" + message + ");";
// FIXME: This should execute the script in the appropriate world.
frame->script().evaluate(ScriptSourceCode(dispatchToFrontend));
frontendPage->mainFrame().script().evaluate(ScriptSourceCode(dispatchToFrontend));
return true;
}
......
......@@ -222,7 +222,7 @@ void InspectorController::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWo
// If the page is supposed to serve as InspectorFrontend notify inspector frontend
// client that it's cleared so that the client can expose inspector bindings.
if (m_inspectorFrontendClient && frame == m_page->mainFrame())
if (m_inspectorFrontendClient && frame == &m_page->mainFrame())
m_inspectorFrontendClient->windowObjectCleared();
}
......
......@@ -1750,7 +1750,7 @@ void InspectorDOMAgent::frameDocumentUpdated(Frame* frame)
Page* page = frame->page();
ASSERT(page);
if (frame != page->mainFrame())
if (frame != &page->mainFrame())
return;
// Only update the main frame document, nested frame document updates are not required
......
......@@ -180,8 +180,8 @@ bool InspectorFrontendClientLocal::canAttachWindow()
return true;
// Don't allow the attach if the window would be too small to accommodate the minimum inspector size.
unsigned inspectedPageHeight = m_inspectorController->inspectedPage()->mainFrame()->view()->visibleHeight();
unsigned inspectedPageWidth = m_inspectorController->inspectedPage()->mainFrame()->view()->visibleWidth();
unsigned inspectedPageHeight = m_inspectorController->inspectedPage()->mainFrame().view()->visibleHeight();
unsigned inspectedPageWidth = m_inspectorController->inspectedPage()->mainFrame().view()->visibleWidth();
unsigned maximumAttachedHeight = inspectedPageHeight * maximumAttachedHeightRatio;
return minimumAttachedHeight <= maximumAttachedHeight && minimumAttachedWidth <= inspectedPageWidth;
}
......@@ -193,7 +193,7 @@ void InspectorFrontendClientLocal::setDockingUnavailable(bool unavailable)
void InspectorFrontendClientLocal::changeAttachedWindowHeight(unsigned height)
{
unsigned totalHeight = m_frontendPage->mainFrame()->view()->visibleHeight() + m_inspectorController->inspectedPage()->mainFrame()->view()->visibleHeight();
unsigned totalHeight = m_frontendPage->mainFrame().view()->visibleHeight() + m_inspectorController->inspectedPage()->mainFrame().view()->visibleHeight();
unsigned attachedHeight = constrainedAttachedWindowHeight(height, totalHeight);
m_settings->setProperty(inspectorAttachedHeightSetting, String::number(attachedHeight));
setAttachedWindowHeight(attachedHeight);
......@@ -201,7 +201,7 @@ void InspectorFrontendClientLocal::changeAttachedWindowHeight(unsigned height)
void InspectorFrontendClientLocal::changeAttachedWindowWidth(unsigned width)
{
unsigned totalWidth = m_frontendPage->mainFrame()->view()->visibleWidth() + m_inspectorController->inspectedPage()->mainFrame()->view()->visibleWidth();
unsigned totalWidth = m_frontendPage->mainFrame().view()->visibleWidth() + m_inspectorController->inspectedPage()->mainFrame().view()->visibleWidth();
unsigned attachedWidth = constrainedAttachedWindowWidth(width, totalWidth);
setAttachedWindowWidth(attachedWidth);
}
......@@ -210,20 +210,20 @@ void InspectorFrontendClientLocal::openInNewTab(const String& url)
{
UserGestureIndicator indicator(DefinitelyProcessingUserGesture);
Page* page = m_inspectorController->inspectedPage();
Frame* mainFrame = page->mainFrame();
FrameLoadRequest request(mainFrame->document()->securityOrigin(), ResourceRequest(), "_blank");
Frame& mainFrame = page->mainFrame();
FrameLoadRequest request(mainFrame.document()->securityOrigin(), ResourceRequest(), "_blank");
bool created;
WindowFeatures windowFeatures;
RefPtr<Frame> frame = WebCore::createWindow(mainFrame, mainFrame, request, windowFeatures, created);
RefPtr<Frame> frame = WebCore::createWindow(&mainFrame, &mainFrame, request, windowFeatures, created);
if (!frame)
return;
frame->loader().setOpener(mainFrame);
frame->loader().setOpener(&mainFrame);
frame->page()->setOpenedByDOM();
// FIXME: Why does one use mainFrame and the other frame?
frame->loader().changeLocation(mainFrame->document()->securityOrigin(), frame->document()->completeURL(url), "", false, false);
frame->loader().changeLocation(mainFrame.document()->securityOrigin(), frame->document()->completeURL(url), "", false, false);
}
void InspectorFrontendClientLocal::moveWindowBy(float x, float y)
......@@ -255,7 +255,7 @@ void InspectorFrontendClientLocal::setAttachedWindow(DockSide dockSide)
void InspectorFrontendClientLocal::restoreAttachedWindowHeight()
{
unsigned inspectedPageHeight = m_inspectorController->inspectedPage()->mainFrame()->view()->visibleHeight();
unsigned inspectedPageHeight = m_inspectorController->inspectedPage()->mainFrame().view()->visibleHeight();
String value = m_settings->getProperty(inspectorAttachedHeightSetting);
unsigned preferredHeight = value.isEmpty() ? defaultAttachedHeight : value.toUInt();
......@@ -344,16 +344,14 @@ bool InspectorFrontendClientLocal::isUnderTest()
bool InspectorFrontendClientLocal::evaluateAsBoolean(const String& expression)
{
if (!m_frontendPage->mainFrame())
return false;
ScriptValue value = m_frontendPage->mainFrame()->script().executeScript(expression);
return value.toString(mainWorldScriptState(m_frontendPage->mainFrame())) == "true";
ScriptValue value = m_frontendPage->mainFrame().script().executeScript(expression);
return value.toString(mainWorldScriptState(&m_frontendPage->mainFrame())) == "true";
}
void InspectorFrontendClientLocal::evaluateOnLoad(const String& expression)
{
if (m_frontendLoaded)
m_frontendPage->mainFrame()->script().executeScript("InspectorFrontendAPI.dispatch(" + expression + ")");
m_frontendPage->mainFrame().script().executeScript("InspectorFrontendAPI.dispatch(" + expression + ")");
else
m_evaluateOnLoad.append(expression);
}
......
......@@ -178,7 +178,7 @@ void InspectorFrontendHost::bringToFront()
void InspectorFrontendHost::setZoomFactor(float zoom)
{
m_frontendPage->mainFrame()->setPageAndTextZoomFactors(zoom, 1);
m_frontendPage->mainFrame().setPageAndTextZoomFactors(zoom, 1);
}
void InspectorFrontendHost::inspectedURLChanged(const String& newURL)
......@@ -289,7 +289,7 @@ String InspectorFrontendHost::loadResourceSynchronously(const String& url)
Vector<char> data;
ResourceError error;
ResourceResponse response;
m_frontendPage->mainFrame()->loader().loadResourceSynchronously(request, DoNotAllowStoredCredentials, DoNotAskClientForCrossOriginCredentials, error, response, data);
m_frontendPage->mainFrame().loader().loadResourceSynchronously(request, DoNotAllowStoredCredentials, DoNotAskClientForCrossOriginCredentials, error, response, data);
return String::fromUTF8(data.data(), data.size());
}
......@@ -321,7 +321,7 @@ void InspectorFrontendHost::removeFileSystem(const String& fileSystemPath)
#if ENABLE(FILE_SYSTEM)
PassRefPtr<DOMFileSystem> InspectorFrontendHost::isolatedFileSystem(const String& fileSystemName, const String& rootURL)
{
ScriptExecutionContext* context = m_frontendPage->mainFrame()->document();
ScriptExecutionContext* context = m_frontendPage->mainFrame().document();
return DOMFileSystem::create(context, fileSystemName, FileSystemTypeIsolated, KURL(ParsedURLString, rootURL), AsyncFileSystem::create());
}
#endif
......
......@@ -90,7 +90,7 @@ void InspectorInputAgent::dispatchKeyEvent(ErrorString* error, const String& typ
isSystemKey ? *isSystemKey : false,
static_cast<PlatformEvent::Modifiers>(modifiers ? *modifiers : 0),
timestamp ? *timestamp : currentTime());
m_page->mainFrame()->eventHandler().keyEvent(event);
m_page->mainFrame().eventHandler().keyEvent(event);
}
void InspectorInputAgent::dispatchMouseEvent(ErrorString* error, const String& type, int x, int y, const int* modifiers, const double* timestamp, const String* button, const int* clickCount)
......@@ -125,7 +125,7 @@ void InspectorInputAgent::dispatchMouseEvent(ErrorString* error, const String& t
// Some platforms may have flipped coordinate systems, but the given coordinates
// assume the origin is in the top-left of the window. Convert.
IntPoint convertedPoint = m_page->mainFrame()->view()->convertToContainingWindow(IntPoint(x, y));
IntPoint convertedPoint = m_page->mainFrame().view()->convertToContainingWindow(IntPoint(x, y));
IntPoint globalPoint = m_page->chrome().rootViewToScreen(IntRect(IntPoint(x, y), IntSize(0, 0))).location();
PlatformMouseEvent event(
......@@ -140,7 +140,7 @@ void InspectorInputAgent::dispatchMouseEvent(ErrorString* error, const String& t
convertedModifiers & PlatformEvent::MetaKey,
timestamp ? *timestamp : currentTime());
EventHandler& eventHandler = m_page->mainFrame()->eventHandler();
EventHandler& eventHandler = m_page->mainFrame().eventHandler();
switch (convertedType) {
case PlatformEvent::MousePressed:
eventHandler.handleMousePressEvent(event);
......
......@@ -860,7 +860,7 @@ void InspectorInstrumentation::domContentLoadedEventFiredImpl(InstrumentingAgent
if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
timelineAgent->didMarkDOMContentEvent(frame);
if (frame->page()->mainFrame() != frame)
if (&frame->page()->mainFrame() != frame)
return;
if (InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent())
......@@ -881,7 +881,7 @@ void InspectorInstrumentation::loadEventFiredImpl(InstrumentingAgents* instrumen
if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
timelineAgent->didMarkLoadEvent(frame);
if (frame->page()->mainFrame() != frame)
if (&frame->page()->mainFrame() != frame)
return;
if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
......@@ -902,8 +902,7 @@ void InspectorInstrumentation::didCommitLoadImpl(InstrumentingAgents* instrument
if (!inspectorAgent || !inspectorAgent->developerExtrasEnabled())
return;