<https://webkit.org/b/119893> FrameView::frame() should return a reference.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Aug 2013 15:47:09 +0000 (15:47 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Aug 2013 15:47:09 +0000 (15:47 +0000)
Reviewed by Antti Koivisto.

FrameView::m_frame was only ever null for a brief moment during CachedFrame teardown.
Leave it alone instead, and update the assertion that depended on this behavior.
This enables us to make FrameView::frame() return a Frame&, exposing a ton of
unnecessary null checks.

* history/CachedFrame.cpp:
(WebCore::CachedFrame::destroy):

    Remove call to FrameView::clearFrame() that was the only way to get a null
    FrameView::m_frame. Immediately followed by a call to CachedFrame::clear() where
    the FrameView would get destroyed anyway.

(WebCore::CachedFrame::clear):

    Update an assertion to support the case where the Document's Frame pointer has
    been cleared out and CachedFrame is still clinging to the FrameView.

* history/CachedPage.h:

    Made CachedPage::destroy() private as it was only called by ~CachedPage().

* /:

    Frame* FrameView::frame() => Frame& FrameView::frame()

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154184 268f45cc-cd09-0410-ab3c-d52691b4dbfc

42 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/AccessibilityScrollView.cpp
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/history/CachedFrame.cpp
Source/WebCore/history/CachedPage.cpp
Source/WebCore/history/CachedPage.h
Source/WebCore/history/PageCache.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/page/efl/EventHandlerEfl.cpp
Source/WebCore/page/gtk/EventHandlerGtk.cpp
Source/WebCore/page/mac/EventHandlerMac.mm
Source/WebCore/page/qt/EventHandlerQt.cpp
Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
Source/WebCore/page/win/EventHandlerWin.cpp
Source/WebCore/platform/blackberry/PlatformScreenBlackBerry.cpp
Source/WebCore/platform/efl/ScrollbarEfl.cpp
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
Source/WebCore/plugins/IFrameShimSupport.cpp
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderFrameBase.cpp
Source/WebCore/rendering/RenderIFrame.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/rendering/RenderView.cpp
Source/WebCore/rendering/RenderWidget.cpp
Source/WebKit/efl/WebCoreSupport/PopupMenuEfl.cpp
Source/WebKit/efl/ewk/ewk_paint_context.cpp
Source/WebKit/mac/WebCoreSupport/PopupMenuMac.mm
Source/WebKit/mac/WebView/WebRenderNode.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/Shared/WebRenderObject.cpp
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp

index d43b71a..8e0509b 100644 (file)
@@ -1,3 +1,34 @@
+2013-08-16  Andreas Kling  <akling@apple.com>
+
+        <https://webkit.org/b/119893> FrameView::frame() should return a reference.
+
+        Reviewed by Antti Koivisto.
+
+        FrameView::m_frame was only ever null for a brief moment during CachedFrame teardown.
+        Leave it alone instead, and update the assertion that depended on this behavior.
+        This enables us to make FrameView::frame() return a Frame&, exposing a ton of
+        unnecessary null checks.
+
+        * history/CachedFrame.cpp:
+        (WebCore::CachedFrame::destroy):
+
+            Remove call to FrameView::clearFrame() that was the only way to get a null
+            FrameView::m_frame. Immediately followed by a call to CachedFrame::clear() where
+            the FrameView would get destroyed anyway.
+
+        (WebCore::CachedFrame::clear):
+
+            Update an assertion to support the case where the Document's Frame pointer has
+            been cleared out and CachedFrame is still clinging to the FrameView.
+
+        * history/CachedPage.h:
+
+            Made CachedPage::destroy() private as it was only called by ~CachedPage().
+
+        * /:
+
+            Frame* FrameView::frame() => Frame& FrameView::frame()
+
 2013-08-16  Brady Eidson  <beidson@apple.com>
 
         (NetworkProcess)  Sync XHRs should load using async ResourceHandles, not ResourceHandle::loadResourceSynchronously
index 6fbf115..111a3e4 100644 (file)
@@ -405,7 +405,7 @@ static void appendAccessibilityObject(AccessibilityObject* object, Accessibility
         if (!widget || !widget->isFrameView())
             return;
         
-        Document* doc = toFrameView(widget)->frame()->document();
+        Document* doc = toFrameView(widget)->frame().document();
         if (!doc || !doc->renderer())
             return;
         
@@ -1159,7 +1159,7 @@ Document* AccessibilityObject::document() const
     if (!frameView)
         return 0;
     
-    return frameView->frame()->document();
+    return frameView->frame().document();
 }
     
 Page* AccessibilityObject::page() const
index 10e9e73..fc151d9 100644 (file)
@@ -2020,10 +2020,8 @@ VisiblePosition AccessibilityRenderObject::visiblePositionForPoint(const IntPoin
         Widget* widget = toRenderWidget(renderer)->widget();
         if (!widget || !widget->isFrameView())
             break;
-        Frame* frame = toFrameView(widget)->frame();
-        if (!frame)
-            break;
-        renderView = frame->document()->renderView();
+        Frame& frame = toFrameView(widget)->frame();
+        renderView = frame.document()->renderView();
         frameView = toFrameView(widget);
     }
     
@@ -2824,11 +2822,9 @@ AccessibilitySVGRoot* AccessibilityRenderObject::remoteSVGRootElement() const
     FrameView* frameView = svgImage->frameView();
     if (!frameView)
         return 0;
-    Frame* frame = frameView->frame();
-    if (!frame)
-        return 0;
+    Frame& frame = frameView->frame();
     
-    Document* doc = frame->document();
+    Document* doc = frame.document();
     if (!doc || !doc->isSVGDocument())
         return 0;
     
@@ -2839,7 +2835,7 @@ AccessibilitySVGRoot* AccessibilityRenderObject::remoteSVGRootElement() const
     if (!rendererRoot)
         return 0;
     
-    AccessibilityObject* rootSVGObject = frame->document()->axObjectCache()->getOrCreate(rendererRoot);
+    AccessibilityObject* rootSVGObject = frame.document()->axObjectCache()->getOrCreate(rendererRoot);
 
     // In order to connect the AX hierarchy from the SVG root element from the loaded resource
     // the parent must be set, because there's no other way to get back to who created the image.
index f8139b8..349eb66 100644 (file)
@@ -188,7 +188,7 @@ AccessibilityObject* AccessibilityScrollView::webAreaObject() const
     if (!m_scrollView || !m_scrollView->isFrameView())
         return 0;
     
-    Document* doc = toFrameView(m_scrollView)->frame()->document();
+    Document* doc = toFrameView(m_scrollView)->frame().document();
     if (!doc || !doc->renderer())
         return 0;
 
@@ -230,7 +230,7 @@ AccessibilityObject* AccessibilityScrollView::parentObject() const
     if (!m_scrollView || !m_scrollView->isFrameView())
         return 0;
     
-    HTMLFrameOwnerElement* owner = toFrameView(m_scrollView)->frame()->ownerElement();
+    HTMLFrameOwnerElement* owner = toFrameView(m_scrollView)->frame().ownerElement();
     if (owner && owner->renderer())
         return axObjectCache()->getOrCreate(owner);
 
@@ -242,7 +242,7 @@ AccessibilityObject* AccessibilityScrollView::parentObjectIfExists() const
     if (!m_scrollView || !m_scrollView->isFrameView())
         return 0;
     
-    HTMLFrameOwnerElement* owner = toFrameView(m_scrollView)->frame()->ownerElement();
+    HTMLFrameOwnerElement* owner = toFrameView(m_scrollView)->frame().ownerElement();
     if (owner && owner->renderer())
         return axObjectCache()->get(owner);
     
index 0340cdf..fa1af2e 100644 (file)
@@ -276,7 +276,7 @@ StyleResolver::StyleResolver(Document* document, bool matchAuthorAndUserStyles)
         m_rootDefaultStyle = styleForElement(root, 0, DisallowStyleSharing, MatchOnlyUserAgentRules);
 
     if (m_rootDefaultStyle && view)
-        m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType(), view->frame(), m_rootDefaultStyle.get()));
+        m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType(), &view->frame(), m_rootDefaultStyle.get()));
 
     m_ruleSets.resetAuthorStyle();
 
index 8b5018d..be9a643 100644 (file)
@@ -1412,7 +1412,7 @@ bool FrameSelection::recomputeCaretRect()
 bool CaretBase::shouldRepaintCaret(const RenderView* view, bool isContentEditable) const
 {
     ASSERT(view);
-    Frame* frame = view->frameView() ? view->frameView()->frame() : 0; // The frame where the selection started.
+    Frame* frame = view->frameView() ? &view->frameView()->frame() : 0; // The frame where the selection started.
     bool caretBrowsing = frame && frame->settings() && frame->settings()->caretBrowsingEnabled();
     return (caretBrowsing || isContentEditable);
 }
index ee5e0aa..fab3de3 100644 (file)
@@ -101,33 +101,33 @@ void CachedFrameBase::restore()
     if (m_isMainFrame)
         m_view->setParentVisible(true);
 
-    Frame* frame = m_view->frame();
-    m_cachedFrameScriptData->restore(frame);
+    Frame& frame = m_view->frame();
+    m_cachedFrameScriptData->restore(&frame);
 
 #if ENABLE(SVG)
     if (m_document->svgExtensions())
         m_document->accessSVGExtensions()->unpauseAnimations();
 #endif
 
-    frame->animation()->resumeAnimationsForDocument(m_document.get());
-    frame->eventHandler().setMousePressNode(m_mousePressNode.get());
+    frame.animation()->resumeAnimationsForDocument(m_document.get());
+    frame.eventHandler().setMousePressNode(m_mousePressNode.get());
     m_document->resumeActiveDOMObjects(ActiveDOMObject::DocumentWillBecomeInactive);
     m_document->resumeScriptedAnimationControllerCallbacks();
 
     // It is necessary to update any platform script objects after restoring the
     // cached page.
-    frame->script()->updatePlatformScriptObjects();
+    frame.script()->updatePlatformScriptObjects();
 
 #if USE(ACCELERATED_COMPOSITING)
     if (m_isComposited)
-        frame->view()->restoreBackingStores();
+        frame.view()->restoreBackingStores();
 #endif
 
-    frame->loader().client()->didRestoreFromPageCache();
+    frame.loader().client()->didRestoreFromPageCache();
 
     // Reconstruct the FrameTree
     for (unsigned i = 0; i < m_childFrames.size(); ++i)
-        frame->tree()->appendChild(m_childFrames[i]->view()->frame());
+        frame.tree()->appendChild(&m_childFrames[i]->view()->frame());
 
     // Open the child CachedFrames in their respective FrameLoaders.
     for (unsigned i = 0; i < m_childFrames.size(); ++i)
@@ -138,7 +138,7 @@ void CachedFrameBase::restore()
 
     m_document->enqueuePageshowEvent(PageshowEventPersisted);
     
-    HistoryItem* historyItem = frame->loader().history()->currentItem();
+    HistoryItem* historyItem = frame.loader().history()->currentItem();
     m_document->enqueuePopstateEvent(historyItem && historyItem->stateObject() ? historyItem->stateObject() : SerializedScriptValue::nullValue());
     
 #if ENABLE(TOUCH_EVENTS)
@@ -198,7 +198,7 @@ CachedFrame::CachedFrame(Frame* frame)
     // 1 - We reuse the main frame, so when it navigates to a new page load it needs to start with a blank FrameTree.
     // 2 - It's much easier to destroy a CachedFrame while it resides in the PageCache if it is disconnected from its parent.
     for (unsigned i = 0; i < m_childFrames.size(); ++i)
-        frame->tree()->removeChild(m_childFrames[i]->view()->frame());
+        frame->tree()->removeChild(&m_childFrames[i]->view()->frame());
 
     if (!m_isMainFrame)
         frame->page()->decrementSubframeCount();
@@ -217,10 +217,10 @@ CachedFrame::CachedFrame(Frame* frame)
 void CachedFrame::open()
 {
     ASSERT(m_view);
-    m_view->frame()->loader().open(*this);
+    m_view->frame().loader().open(*this);
 
     if (!m_isMainFrame)
-        m_view->frame()->page()->incrementSubframeCount();
+        m_view->frame().page()->incrementSubframeCount();
 }
 
 void CachedFrame::clear()
@@ -234,7 +234,7 @@ void CachedFrame::clear()
     // 2 - destroy()'ed because the PageCache is pruning or the WebView was closed.
     ASSERT(!m_document->inPageCache());
     ASSERT(m_view);
-    ASSERT(m_document->frame() == m_view->frame());
+    ASSERT(!m_document->frame() || m_document->frame() == &m_view->frame());
 
     for (int i = m_childFrames.size() - 1; i >= 0; --i)
         m_childFrames[i]->clear();
@@ -256,13 +256,13 @@ void CachedFrame::destroy()
     // Only CachedFrames that are still in the PageCache should be destroyed in this manner
     ASSERT(m_document->inPageCache());
     ASSERT(m_view);
-    ASSERT(m_document->frame() == m_view->frame());
+    ASSERT(m_document->frame() == &m_view->frame());
 
     m_document->domWindow()->willDestroyCachedFrame();
 
     if (!m_isMainFrame) {
-        m_view->frame()->detachFromPage();
-        m_view->frame()->loader().detachViewsAndDocumentLoader();
+        m_view->frame().detachFromPage();
+        m_view->frame().loader().detachViewsAndDocumentLoader();
     }
     
     for (int i = m_childFrames.size() - 1; i >= 0; --i)
@@ -280,7 +280,6 @@ void CachedFrame::destroy()
     m_document->setInPageCache(false);
     // FIXME: We don't call willRemove here. Why is that OK?
     m_document->detach();
-    m_view->clearFrame();
 
     clear();
 }
index d574e7c..ef2e294 100644 (file)
@@ -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() && page->mainFrame() == &m_cachedMainFrame->view()->frame());
     ASSERT(!page->subframeCount());
 
     m_cachedMainFrame->open();
index c804efc..0f08aa6 100644 (file)
@@ -42,7 +42,6 @@ public:
 
     void restore(Page*);
     void clear();
-    void destroy();
 
     Document* document() const { return m_cachedMainFrame->document(); }
     DocumentLoader* documentLoader() const { return m_cachedMainFrame->documentLoader(); }
@@ -64,6 +63,7 @@ public:
 
 private:
     CachedPage(Page*);
+    void destroy();
 
     double m_timeStamp;
     double m_expirationTime;
index c0a1edb..33a9947 100644 (file)
@@ -401,7 +401,7 @@ void PageCache::markPagesForFullStyleRecalc(Page* page)
 
     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() == mainFrame)
             cachedPage->markForFullStyleRecalc();
     }
 }
@@ -414,7 +414,7 @@ void PageCache::markPagesForDeviceScaleChanged(Page* page)
 
     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() == mainFrame)
             cachedPage->markForDeviceScaleChanged();
     }
 }
index 662a382..daf919d 100644 (file)
@@ -1190,7 +1190,7 @@ Frame* EventHandler::subframeForTargetNode(Node* node)
     if (!widget || !widget->isFrameView())
         return 0;
 
-    return toFrameView(widget)->frame();
+    return &toFrameView(widget)->frame();
 }
 
 static bool isSubmitImage(Node* node)
@@ -2691,7 +2691,7 @@ bool EventHandler::passGestureEventToWidget(const PlatformGestureEvent& gestureE
     if (!widget->isFrameView())
         return false;
 
-    return toFrameView(widget)->frame()->eventHandler().handleGestureEvent(gestureEvent);
+    return toFrameView(widget)->frame().eventHandler().handleGestureEvent(gestureEvent);
 }
 
 bool EventHandler::passGestureEventToWidgetIfPossible(const PlatformGestureEvent& gestureEvent, RenderObject* renderer)
index 71b0b7e..f9de753 100644 (file)
@@ -626,17 +626,15 @@ Frame* Frame::frameForWidget(const Widget* widget)
     // Assume all widgets are either a FrameView or owned by a RenderWidget.
     // FIXME: That assumption is not right for scroll bars!
     ASSERT_WITH_SECURITY_IMPLICATION(widget->isFrameView());
-    return toFrameView(widget)->frame();
+    return &toFrameView(widget)->frame();
 }
 
 void Frame::clearTimers(FrameView *view, Document *document)
 {
     if (view) {
         view->unscheduleRelayout();
-        if (view->frame()) {
-            view->frame()->animation()->suspendAnimationsForDocument(document);
-            view->frame()->eventHandler().stopAutoscrollTimer();
-        }
+        view->frame().animation()->suspendAnimationsForDocument(document);
+        view->frame().eventHandler().stopAutoscrollTimer();
     }
 }
 
index 485daf4..1e6e4b9 100644 (file)
@@ -248,12 +248,10 @@ FrameView::~FrameView()
     ASSERT(!m_scrollCorner);
     ASSERT(m_actionScheduler->isEmpty());
 
-    if (m_frame) {
-        ASSERT(m_frame->view() != this || !m_frame->contentRenderer());
-        RenderPart* renderer = m_frame->ownerRenderer();
-        if (renderer && renderer->widget() == this)
-            renderer->setWidget(0);
-    }
+    ASSERT(frame().view() != this || !frame().contentRenderer());
+    RenderPart* renderer = frame().ownerRenderer();
+    if (renderer && renderer->widget() == this)
+        renderer->setWidget(0);
 }
 
 void FrameView::reset()
@@ -304,11 +302,6 @@ void FrameView::removeFromAXObjectCache()
         cache->remove(this);
 }
 
-void FrameView::clearFrame()
-{
-    m_frame = 0;
-}
-
 void FrameView::resetScrollbars()
 {
     // Reset the document's scrollbars back to our defaults before we yield the floor.
@@ -338,7 +331,7 @@ void FrameView::init()
     m_size = LayoutSize();
 
     // Propagate the marginwidth/height and scrolling modes to the view.
-    Element* ownerElement = m_frame ? m_frame->ownerElement() : 0;
+    Element* ownerElement = frame().ownerElement();
     if (ownerElement && (ownerElement->hasTagName(frameTag) || ownerElement->hasTagName(iframeTag))) {
         HTMLFrameElementBase* frameElt = toHTMLFrameElementBase(ownerElement);
         if (frameElt->scrollingMode() == ScrollbarAlwaysOff)
@@ -351,7 +344,7 @@ void FrameView::init()
             setMarginHeight(marginHeight);
     }
 
-    Page* page = frame() ? frame()->page() : 0;
+    Page* page = frame().page();
     if (page && page->chrome().client()->shouldPaintEntireContents())
         setPaintsEntireContents(true);
 }
@@ -363,8 +356,8 @@ void FrameView::prepareForDetach()
     // right now, otherwise it won't be able to reach the topDocument()'s axObject cache later.
     removeFromAXObjectCache();
 
-    if (m_frame && m_frame->page()) {
-        if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scrollingCoordinator())
+    if (frame().page()) {
+        if (ScrollingCoordinator* scrollingCoordinator = frame().page()->scrollingCoordinator())
             scrollingCoordinator->willDestroyScrollableArea(this);
     }
 }
@@ -411,17 +404,15 @@ void FrameView::clear()
     
     reset();
 
-    if (m_frame) {
-        if (RenderPart* renderer = m_frame->ownerRenderer())
-            renderer->viewCleared();
-    }
+    if (RenderPart* renderer = frame().ownerRenderer())
+        renderer->viewCleared();
 
     setScrollbarsSuppressed(true);
 }
 
 bool FrameView::isMainFrameView() const
 {
-    return m_frame && m_frame->page() && m_frame->page()->mainFrame() == m_frame;
+    return frame().page() && frame().page()->mainFrame() == &frame();
 }
 
 bool FrameView::didFirstLayout() const
@@ -437,10 +428,7 @@ void FrameView::invalidateRect(const IntRect& rect)
         return;
     }
 
-    if (!m_frame)
-        return;
-
-    RenderPart* renderer = m_frame->ownerRenderer();
+    RenderPart* renderer = frame().ownerRenderer();
     if (!renderer)
         return;
 
@@ -459,10 +447,10 @@ void FrameView::setFrameRect(const IntRect& newRect)
 #if ENABLE(TEXT_AUTOSIZING)
     // Autosized font sizes depend on the width of the viewing area.
     if (newRect.width() != oldRect.width()) {
-        Page* page = m_frame ? m_frame->page() : 0;
+        Page* page = frame().page();
         if (isMainFrameView() && page->settings().textAutosizingEnabled()) {
             for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext())
-                m_frame->document()->textAutosizer()->recalculateMultipliers();
+                frame().document()->textAutosizer()->recalculateMultipliers();
         }
     }
 #endif
@@ -507,11 +495,9 @@ void FrameView::setMarginHeight(LayoutUnit h)
 
 bool FrameView::frameFlatteningEnabled() const
 {
-    Settings* settings = frame() ? frame()->settings() : 0;
-    if (!settings)
-        return false;
-
-    return settings->frameFlatteningEnabled();
+    if (Settings* settings = frame().settings())
+        return settings->frameFlatteningEnabled();
+    return false;
 }
 
 bool FrameView::isFrameFlatteningValidForThisFrame() const
@@ -519,7 +505,7 @@ bool FrameView::isFrameFlatteningValidForThisFrame() const
     if (!frameFlatteningEnabled())
         return false;
 
-    HTMLFrameOwnerElement* owner = frame() ? frame()->ownerElement() : 0;
+    HTMLFrameOwnerElement* owner = frame().ownerElement();
     if (!owner)
         return false;
 
@@ -529,7 +515,6 @@ bool FrameView::isFrameFlatteningValidForThisFrame() const
 
 bool FrameView::avoidScrollbarCreation() const
 {
-    ASSERT(m_frame);
     // with frame flattening no subframe can have scrollbars
     // but we also cannot turn scrollbars off as we determine
     // our flattening policy using that.
@@ -555,13 +540,13 @@ void FrameView::updateCanHaveScrollbars()
 
 PassRefPtr<Scrollbar> FrameView::createScrollbar(ScrollbarOrientation orientation)
 {
-    if (Settings* settings = m_frame->settings()) {
+    if (Settings* settings = frame().settings()) {
         if (!settings->allowCustomScrollbarInMainFrame() && isMainFrameView())
             return ScrollView::createScrollbar(orientation);
     }
 
     // FIXME: We need to update the scrollbar dynamically as documents change (or as doc elements and bodies get discovered that have custom styles).
-    Document* doc = m_frame->document();
+    Document* doc = frame().document();
 
     // Try the <body> element first as a scrollbar source.
     Element* body = doc ? doc->body() : 0;
@@ -574,9 +559,9 @@ PassRefPtr<Scrollbar> FrameView::createScrollbar(ScrollbarOrientation orientatio
         return RenderScrollbar::createCustomScrollbar(this, orientation, docElement);
         
     // If we have an owning iframe/frame element, then it can set the custom scrollbar also.
-    RenderPart* frameRenderer = m_frame->ownerRenderer();
+    RenderPart* frameRenderer = frame().ownerRenderer();
     if (frameRenderer && frameRenderer->style()->hasPseudoStyle(SCROLLBAR))
-        return RenderScrollbar::createCustomScrollbar(this, orientation, 0, m_frame.get());
+        return RenderScrollbar::createCustomScrollbar(this, orientation, 0, &frame());
     
     // Nobody set a custom style, so we just use a native scrollbar.
     return ScrollView::createScrollbar(orientation);
@@ -592,13 +577,13 @@ void FrameView::setContentsSize(const IntSize& size)
     ScrollView::setContentsSize(size);
     ScrollView::contentsResized();
     
-    Page* page = frame() ? frame()->page() : 0;
+    Page* page = frame().page();
     if (!page)
         return;
 
     updateScrollableAreaSet();
 
-    page->chrome().contentsSizeChanged(frame(), size); // Notify only.
+    page->chrome().contentsSizeChanged(&frame(), size); // Notify only.
 
     m_deferSetNeedsLayouts--;
     
@@ -612,11 +597,11 @@ void FrameView::adjustViewSize()
     if (!renderView)
         return;
 
-    ASSERT(m_frame->view() == this);
+    ASSERT(frame().view() == this);
 
     const IntRect rect = renderView->documentRect();
     const IntSize& size = rect.size();
-    ScrollView::setScrollOrigin(IntPoint(-rect.x(), -rect.y()), !m_frame->document()->printing(), size == contentsSize());
+    ScrollView::setScrollOrigin(IntPoint(-rect.x(), -rect.y()), !frame().document()->printing(), size == contentsSize());
     
     setContentsSize(size);
 }
@@ -632,7 +617,7 @@ void FrameView::applyOverflowToViewport(RenderObject* o, ScrollbarMode& hMode, S
     // there is a frameScaleFactor that is greater than one on the main frame. Also disregard hidden if there is a
     // header or footer.
 
-    bool overrideHidden = isMainFrameView() && ((m_frame->frameScaleFactor() > 1) || headerHeight() || footerHeight());
+    bool overrideHidden = isMainFrameView() && ((frame().frameScaleFactor() > 1) || headerHeight() || footerHeight());
 
     EOverflow overflowX = o->style()->overflowX();
     EOverflow overflowY = o->style()->overflowY();
@@ -688,7 +673,7 @@ void FrameView::applyOverflowToViewport(RenderObject* o, ScrollbarMode& hMode, S
 
 void FrameView::applyPaginationToViewport()
 {
-    Document* document = m_frame->document();
+    Document* document = frame().document();
     Node* documentElement = document->documentElement();
     RenderObject* documentRenderer = documentElement ? documentElement->renderer() : 0;
     RenderObject* documentOrBodyRenderer = documentRenderer;
@@ -718,7 +703,7 @@ void FrameView::calculateScrollbarModesForLayout(ScrollbarMode& hMode, Scrollbar
 {
     m_viewportRenderer = 0;
 
-    const HTMLFrameOwnerElement* owner = m_frame->ownerElement();
+    const HTMLFrameOwnerElement* owner = frame().ownerElement();
     if (owner && (owner->scrollingMode() == ScrollbarAlwaysOff)) {
         hMode = ScrollbarAlwaysOff;
         vMode = ScrollbarAlwaysOff;
@@ -730,7 +715,7 @@ void FrameView::calculateScrollbarModesForLayout(ScrollbarMode& hMode, Scrollbar
         // Seamless documents begin with heights of 0; we special case that here
         // to correctly render documents that don't need scrollbars.
         IntSize fullVisibleSize = visibleContentRect(IncludeScrollbars).size();
-        bool isSeamlessDocument = frame() && frame()->document() && frame()->document()->shouldDisplaySeamlesslyWithParent();
+        bool isSeamlessDocument = frame().document() && frame().document()->shouldDisplaySeamlesslyWithParent();
         vMode = (isSeamlessDocument && !fullVisibleSize.height()) ? ScrollbarAlwaysOff : ScrollbarAuto;
     } else {
         hMode = ScrollbarAlwaysOff;
@@ -738,7 +723,7 @@ void FrameView::calculateScrollbarModesForLayout(ScrollbarMode& hMode, Scrollbar
     }
     
     if (!m_layoutRoot) {
-        Document* document = m_frame->document();
+        Document* document = frame().document();
         Node* documentElement = document->documentElement();
         RenderObject* rootRenderer = documentElement ? documentElement->renderer() : 0;
         Node* body = document->body();
@@ -812,7 +797,7 @@ bool FrameView::usesCompositedScrolling() const
     RenderView* renderView = this->renderView();
     if (!renderView)
         return false;
-    if (m_frame->settings() && m_frame->settings()->compositedScrollingForFramesEnabled())
+    if (frame().settings() && frame().settings()->compositedScrollingForFramesEnabled())
         return renderView->compositor()->inForcedCompositingMode();
     return false;
 }
@@ -906,10 +891,9 @@ GraphicsLayer* FrameView::setWantsLayerForBottomOverHangArea(bool wantsLayer) co
 
 bool FrameView::scrollbarAnimationsAreSuppressed() const
 {
-    Page* page = frame() ? frame()->page() : 0;
-    if (!page)
-        return true;
-    return page->shouldSuppressScrollbarAnimations();
+    if (Page* page = frame().page())
+        return page->shouldSuppressScrollbarAnimations();
+    return true;
 }
 
 bool FrameView::flushCompositingStateForThisFrame(Frame* rootFrameForFlush)
@@ -918,7 +902,7 @@ bool FrameView::flushCompositingStateForThisFrame(Frame* rootFrameForFlush)
     if (!renderView)
         return true; // We don't want to keep trying to update layers if we have no renderer.
 
-    ASSERT(m_frame->view() == this);
+    ASSERT(frame().view() == this);
 
     // If we sync compositing layers when a layout is pending, we may cause painting of compositing
     // layer content to occur before layout has happened, which will cause paintContents() to bail.
@@ -929,15 +913,14 @@ bool FrameView::flushCompositingStateForThisFrame(Frame* rootFrameForFlush)
     // visible flash to occur. Instead, stop the deferred repaint timer and repaint immediately.
     flushDeferredRepaints();
 
-    renderView->compositor()->flushPendingLayerChanges(rootFrameForFlush == m_frame);
+    renderView->compositor()->flushPendingLayerChanges(rootFrameForFlush == &frame());
 
     return true;
 }
 
 void FrameView::setNeedsOneShotDrawingSynchronization()
 {
-    Page* page = frame() ? frame()->page() : 0;
-    if (page)
+    if (Page* page = frame().page())
         page->chrome().client()->setNeedsOneShotDrawingSynchronization();
 }
 
@@ -945,7 +928,7 @@ void FrameView::setNeedsOneShotDrawingSynchronization()
 
 void FrameView::setHeaderHeight(int headerHeight)
 {
-    if (m_frame && m_frame->page())
+    if (frame().page())
         ASSERT(isMainFrameView());
     m_headerHeight = headerHeight;
 
@@ -955,7 +938,7 @@ void FrameView::setHeaderHeight(int headerHeight)
 
 void FrameView::setFooterHeight(int footerHeight)
 {
-    if (m_frame && m_frame->page())
+    if (frame().page())
         ASSERT(isMainFrameView());
     m_footerHeight = footerHeight;
 
@@ -993,7 +976,7 @@ bool FrameView::hasCompositedContentIncludingDescendants() const
 bool FrameView::hasCompositingAncestor() const
 {
 #if USE(ACCELERATED_COMPOSITING)
-    for (Frame* frame = m_frame->tree()->parent(); frame; frame = frame->tree()->parent()) {
+    for (Frame* frame = this->frame().tree()->parent(); frame; frame = frame->tree()->parent()) {
         if (FrameView* view = frame->view()) {
             if (view->hasCompositedContent())
                 return true;
@@ -1018,7 +1001,7 @@ void FrameView::enterCompositingMode()
 bool FrameView::isEnclosedInCompositingLayer() const
 {
 #if USE(ACCELERATED_COMPOSITING)
-    RenderObject* frameOwnerRenderer = m_frame->ownerRenderer();
+    RenderObject* frameOwnerRenderer = frame().ownerRenderer();
     if (frameOwnerRenderer && frameOwnerRenderer->containerForRepaint())
         return true;
 
@@ -1031,10 +1014,10 @@ bool FrameView::isEnclosedInCompositingLayer() const
 bool FrameView::flushCompositingStateIncludingSubframes()
 {
 #if USE(ACCELERATED_COMPOSITING)
-    bool allFramesFlushed = flushCompositingStateForThisFrame(m_frame.get());
+    bool allFramesFlushed = flushCompositingStateForThisFrame(&frame());
     
-    for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->traverseNext(m_frame.get())) {
-        bool flushed = child->view()->flushCompositingStateForThisFrame(m_frame.get());
+    for (Frame* child = frame().tree()->firstChild(); child; child = child->tree()->traverseNext(&frame())) {
+        bool flushed = child->view()->flushCompositingStateForThisFrame(&frame());
         allFramesFlushed &= flushed;
     }
     return allFramesFlushed;
@@ -1077,7 +1060,7 @@ void FrameView::resumeAnimatingImages()
     // Drawing models which cache painted content while out-of-window (WebKit2's composited drawing areas, etc.)
     // require that we repaint animated images to kickstart the animation loop.
 
-    CachedImage::resumeAnimatingImagesForLoader(frame()->document()->cachedResourceLoader());
+    CachedImage::resumeAnimatingImagesForLoader(frame().document()->cachedResourceLoader());
 }
 
 RenderObject* FrameView::layoutRoot(bool onlyDuringLayout) const
@@ -1101,7 +1084,7 @@ static inline void collectFrameViewChildren(FrameView* frameView, Vector<RefPtr<
 inline void FrameView::forceLayoutParentViewIfNeeded()
 {
 #if ENABLE(SVG)
-    RenderPart* ownerRenderer = m_frame->ownerRenderer();
+    RenderPart* ownerRenderer = frame().ownerRenderer();
     if (!ownerRenderer || !ownerRenderer->frame())
         return;
 
@@ -1152,29 +1135,22 @@ void FrameView::layout(bool allowSubtree)
     m_layoutTimer.stop();
     m_delayedLayout = false;
     m_setNeedsLayoutWasDeferred = false;
-
-    if (!m_frame) {
-        // FIXME: Do we need to set m_size.width here?
-        // FIXME: Should we set m_size.height here too?
-        m_size.setWidth(layoutWidth());
-        return;
-    }
     
     // we shouldn't enter layout() while painting
     ASSERT(!isPainting());
     if (isPainting())
         return;
 
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willLayout(m_frame.get());
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willLayout(&frame());
 
     if (!allowSubtree && m_layoutRoot) {
         m_layoutRoot->markContainingBlocksForLayout(false);
         m_layoutRoot = 0;
     }
 
-    ASSERT(m_frame->view() == this);
+    ASSERT(frame().view() == this);
 
-    Document* document = m_frame->document();
+    Document* document = frame().document();
     ASSERT(!document->inPageCache());
     bool subtree;
     RenderObject* root;
@@ -1232,7 +1208,7 @@ void FrameView::layout(bool allowSubtree)
         m_nestedLayoutCount++;
 
         if (!m_layoutRoot) {
-            Document* document = m_frame->document();
+            Document* document = frame().document();
             Node* body = document->body();
             if (body && body->renderer()) {
                 if (body->hasTagName(framesetTag) && !frameFlatteningEnabled()) {
@@ -1244,7 +1220,7 @@ void FrameView::layout(bool allowSubtree)
             }
 
 #ifdef INSTRUMENT_LAYOUT_SCHEDULING
-            if (m_firstLayout && !m_frame->ownerElement())
+            if (m_firstLayout && !frame().ownerElement())
                 printf("Elapsed time before first layout: %d\n", document->elapsedTime());
 #endif        
         }
@@ -1407,11 +1383,8 @@ void FrameView::layout(bool allowSubtree)
     if (m_nestedLayoutCount)
         return;
 
-    Page* page = frame() ? frame()->page() : 0;
-    if (!page)
-        return;
-
-    page->chrome().client()->layoutUpdated(frame());
+    if (Page* page = frame().page())
+        page->chrome().client()->layoutUpdated(&frame());
 }
 
 RenderBox* FrameView::embeddedContentBox() const
@@ -1465,8 +1438,8 @@ void FrameView::setMediaType(const String& mediaType)
 String FrameView::mediaType() const
 {
     // See if we have an override type.
-    String overrideType = m_frame->loader().client()->overrideMediaType();
-    InspectorInstrumentation::applyEmulatedMedia(m_frame.get(), &overrideType);
+    String overrideType = frame().loader().client()->overrideMediaType();
+    InspectorInstrumentation::applyEmulatedMedia(&frame(), &overrideType);
     if (!overrideType.isNull())
         return overrideType;
     return m_mediaType;
@@ -1551,7 +1524,7 @@ void FrameView::addSlowRepaintObject(RenderObject* o)
     if (!hadSlowRepaintObjects) {
         updateCanBlitOnScrollRecursively();
 
-        if (Page* page = m_frame->page()) {
+        if (Page* page = frame().page()) {
             if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
                 scrollingCoordinator->frameViewHasSlowRepaintObjectsDidChange(this);
         }
@@ -1568,7 +1541,7 @@ void FrameView::removeSlowRepaintObject(RenderObject* o)
         m_slowRepaintObjects = nullptr;
         updateCanBlitOnScrollRecursively();
 
-        if (Page* page = m_frame->page()) {
+        if (Page* page = frame().page()) {
             if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
                 scrollingCoordinator->frameViewHasSlowRepaintObjectsDidChange(this);
         }
@@ -1585,7 +1558,7 @@ void FrameView::addViewportConstrainedObject(RenderObject* object)
         if (platformWidget())
             updateCanBlitOnScrollRecursively();
 
-        if (Page* page = m_frame->page()) {
+        if (Page* page = frame().page()) {
             if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
                 scrollingCoordinator->frameViewFixedObjectsDidChange(this);
         }
@@ -1596,7 +1569,7 @@ void FrameView::removeViewportConstrainedObject(RenderObject* object)
 {
     if (m_viewportConstrainedObjects && m_viewportConstrainedObjects->contains(object)) {
         m_viewportConstrainedObjects->remove(object);
-        if (Page* page = m_frame->page()) {
+        if (Page* page = frame().page()) {
             if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
                 scrollingCoordinator->frameViewFixedObjectsDidChange(this);
         }
@@ -1632,7 +1605,7 @@ IntSize FrameView::scrollOffsetForFixedPosition() const
     IntSize totalContentsSize = this->totalContentsSize();
     IntPoint scrollPosition = this->scrollPosition();
     IntPoint scrollOrigin = this->scrollOrigin();
-    float frameScaleFactor = m_frame ? m_frame->frameScaleFactor() : 1;
+    float frameScaleFactor = frame().frameScaleFactor();
     return scrollOffsetForFixedPosition(visibleContentRect, totalContentsSize, scrollPosition, scrollOrigin, frameScaleFactor, fixedElementsLayoutRelativeToFrame(), headerHeight(), footerHeight());
 }
     
@@ -1660,26 +1633,25 @@ IntPoint FrameView::maximumScrollPosition() const
 
 bool FrameView::fixedElementsLayoutRelativeToFrame() const
 {
-    ASSERT(m_frame);
-    if (!m_frame->settings())
+    if (!frame().settings())
         return false;
 
-    return m_frame->settings()->fixedElementsLayoutRelativeToFrame();
+    return frame().settings()->fixedElementsLayoutRelativeToFrame();
 }
 
 IntPoint FrameView::lastKnownMousePosition() const
 {
-    return m_frame ? m_frame->eventHandler().lastKnownMousePosition() : IntPoint();
+    return frame().eventHandler().lastKnownMousePosition();
 }
 
 bool FrameView::isHandlingWheelEvent() const
 {
-    return m_frame ? m_frame->eventHandler().isHandlingWheelEvent() : false;
+    return frame().eventHandler().isHandlingWheelEvent();
 }
 
 bool FrameView::shouldSetCursor() const
 {
-    Page* page = frame()->page();
+    Page* page = frame().page();
     return page && page->isOnscreen() && page->focusController().isActive();
 }
 
@@ -1766,7 +1738,7 @@ void FrameView::scrollContentsSlowPath(const IntRect& updateRect)
 
         // Make sure to "apply" the scale factor here since we're converting from frame view
         // coordinates to layer backing coordinates.
-        updateRect.scale(1 / m_frame->frameScaleFactor());
+        updateRect.scale(1 / frame().frameScaleFactor());
 
         ASSERT(renderView());
         renderView()->layer()->setBackingNeedsRepaintInRect(updateRect);
@@ -1774,7 +1746,7 @@ void FrameView::scrollContentsSlowPath(const IntRect& updateRect)
 
     repaintSlowRepaintObjects();
 
-    if (RenderPart* frameRenderer = m_frame->ownerRenderer()) {
+    if (RenderPart* frameRenderer = frame().ownerRenderer()) {
         if (isEnclosedInCompositingLayer()) {
             LayoutRect rect(frameRenderer->borderLeft() + frameRenderer->paddingLeft(),
                             frameRenderer->borderTop() + frameRenderer->paddingTop(),
@@ -1815,7 +1787,7 @@ void FrameView::setIsOverlapped(bool isOverlapped)
     if (hasCompositedContentIncludingDescendants()) {
         // Overlap can affect compositing tests, so if it changes, we need to trigger
         // a layer update in the parent document.
-        if (Frame* parentFrame = m_frame->tree()->parent()) {
+        if (Frame* parentFrame = frame().tree()->parent()) {
             if (RenderView* parentView = parentFrame->contentRenderer()) {
                 RenderLayerCompositor* compositor = parentView->compositor();
                 compositor->setCompositingLayersNeedRebuild();
@@ -1871,7 +1843,7 @@ bool FrameView::scrollToFragment(const KURL& url)
     // OTOH If CSS target was set previously, we want to set it to 0, recalc
     // and possibly repaint because :target pseudo class may have been
     // set (see bug 11321).
-    if (!url.hasFragmentIdentifier() && !m_frame->document()->cssTarget())
+    if (!url.hasFragmentIdentifier() && !frame().document()->cssTarget())
         return false;
 
     String fragmentIdentifier = url.fragmentIdentifier();
@@ -1879,7 +1851,7 @@ bool FrameView::scrollToFragment(const KURL& url)
         return true;
 
     // Try again after decoding the ref, based on the document's encoding.
-    if (TextResourceDecoder* decoder = m_frame->document()->decoder())
+    if (TextResourceDecoder* decoder = frame().document()->decoder())
         return scrollToAnchor(decodeURLEscapeSequences(fragmentIdentifier, decoder->encoding()));
 
     return false;
@@ -1887,23 +1859,23 @@ bool FrameView::scrollToFragment(const KURL& url)
 
 bool FrameView::scrollToAnchor(const String& name)
 {
-    ASSERT(m_frame->document());
+    ASSERT(frame().document());
 
-    if (!m_frame->document()->haveStylesheetsLoaded()) {
-        m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(true);
+    if (!frame().document()->haveStylesheetsLoaded()) {
+        frame().document()->setGotoAnchorNeededAfterStylesheetsLoad(true);
         return false;
     }
 
-    m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(false);
+    frame().document()->setGotoAnchorNeededAfterStylesheetsLoad(false);
 
-    Element* anchorElement = m_frame->document()->findAnchor(name);
+    Element* anchorElement = frame().document()->findAnchor(name);
 
     // Setting to null will clear the current target.
-    m_frame->document()->setCSSTarget(anchorElement);
+    frame().document()->setCSSTarget(anchorElement);
 
 #if ENABLE(SVG)
-    if (m_frame->document()->isSVGDocument()) {
-        if (SVGSVGElement* svg = toSVGDocument(m_frame->document())->rootElement()) {
+    if (frame().document()->isSVGDocument()) {
+        if (SVGSVGElement* svg = toSVGDocument(frame().document())->rootElement()) {
             svg->setupInitialView(name, anchorElement);
             if (!anchorElement)
                 return true;
@@ -1915,11 +1887,11 @@ bool FrameView::scrollToAnchor(const String& name)
     if (!anchorElement && !(name.isEmpty() || equalIgnoringCase(name, "top")))
         return false;
 
-    maintainScrollPositionAtAnchor(anchorElement ? static_cast<Node*>(anchorElement) : m_frame->document());
+    maintainScrollPositionAtAnchor(anchorElement ? static_cast<Node*>(anchorElement) : frame().document());
     
     // If the anchor accepts keyboard focus, move focus there to aid users relying on keyboard navigation.
     if (anchorElement && anchorElement->isFocusable())
-        m_frame->document()->setFocusedElement(anchorElement);
+        frame().document()->setFocusedElement(anchorElement);
     
     return true;
 }
@@ -1932,7 +1904,7 @@ void FrameView::maintainScrollPositionAtAnchor(Node* anchorNode)
 
     // We need to update the layout before scrolling, otherwise we could
     // really mess things up if an anchor scroll comes at a bad moment.
-    m_frame->document()->updateStyleIfNeeded();
+    frame().document()->updateStyleIfNeeded();
     // Only do a layout if changes have occurred that make it necessary.
     RenderView* renderView = this->renderView();
     if (renderView && renderView->needsLayout())
@@ -1943,7 +1915,7 @@ void FrameView::maintainScrollPositionAtAnchor(Node* anchorNode)
 
 void FrameView::scrollElementToRect(Element* element, const IntRect& rect)
 {
-    m_frame->document()->updateLayoutIgnorePendingStylesheets();
+    frame().document()->updateLayoutIgnorePendingStylesheets();
 
     LayoutRect bounds = element->boundingBox();
     int centeringOffsetX = (rect.width() - bounds.width()) / 2;
@@ -1981,7 +1953,7 @@ void FrameView::setFixedVisibleContentRect(const IntRect& visibleContentRect)
     ScrollView::setFixedVisibleContentRect(visibleContentRect);
     if (offset != scrollOffset()) {
         repaintFixedElementsAfterScrolling();
-        if (m_frame->page()->settings().acceleratedCompositingForFixedPositionEnabled())
+        if (frame().page()->settings().acceleratedCompositingForFixedPositionEnabled())
             updateFixedElementsAfterScrolling();
         scrollAnimator()->setCurrentPosition(scrollPosition());
         scrollPositionChanged();
@@ -1990,7 +1962,7 @@ void FrameView::setFixedVisibleContentRect(const IntRect& visibleContentRect)
         // Update the scroll-bars to calculate new page-step size.
         updateScrollbars(scrollOffset());
     }
-    frame()->loader().client()->didChangeScrollOffset();
+    frame().loader().client()->didChangeScrollOffset();
 }
 
 void FrameView::setViewportConstrainedObjectsNeedLayout()
@@ -2015,8 +1987,8 @@ void FrameView::scrollPositionChangedViaPlatformWidget()
 
 void FrameView::scrollPositionChanged()
 {
-    frame()->eventHandler().sendScrollEvent();
-    frame()->eventHandler().dispatchFakeMouseMoveEventSoon();
+    frame().eventHandler().sendScrollEvent();
+    frame().eventHandler().dispatchFakeMouseMoveEventSoon();
 
 #if USE(ACCELERATED_COMPOSITING)
     if (RenderView* renderView = this->renderView()) {
@@ -2042,12 +2014,12 @@ void FrameView::repaintFixedElementsAfterScrolling()
 bool FrameView::shouldUpdateFixedElementsAfterScrolling()
 {
 #if ENABLE(THREADED_SCROLLING)
-    Page* page = m_frame->page();
+    Page* page = frame().page();
     if (!page)
         return true;
 
     // If the scrolling thread is updating the fixed elements, then the FrameView should not update them as well.
-    if (page->mainFrame() != m_frame)
+    if (page->mainFrame() != &frame())
         return true;
 
     ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator();
@@ -2083,10 +2055,9 @@ void FrameView::updateFixedElementsAfterScrolling()
 
 bool FrameView::shouldRubberBandInDirection(ScrollDirection direction) const
 {
-    Page* page = frame() ? frame()->page() : 0;
-    if (!page)
-        return ScrollView::shouldRubberBandInDirection(direction);
-    return page->chrome().client()->shouldRubberBandInDirection(direction);
+    if (Page* page = frame().page())
+        return page->chrome().client()->shouldRubberBandInDirection(direction);
+    return ScrollView::shouldRubberBandInDirection(direction);
 }
 
 bool FrameView::isRubberBandInProgress() const
@@ -2096,7 +2067,7 @@ bool FrameView::isRubberBandInProgress() const
 
     // If the scrolling thread updates the scroll position for this FrameView, then we should return
     // ScrollingCoordinator::isRubberBandInProgress().
-    if (Page* page = m_frame->page()) {
+    if (Page* page = frame().page()) {
         if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator()) {
             if (!scrollingCoordinator->shouldUpdateScrollLayerPositionOnMainThread())
                 return scrollingCoordinator->isRubberBandInProgress();
@@ -2120,7 +2091,7 @@ bool FrameView::requestScrollPositionUpdate(const IntPoint& position)
         tiledBacking->prepopulateRect(visibleRect);
     }
 
-    if (Page* page = m_frame->page()) {
+    if (Page* page = frame().page()) {
         if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
             return scrollingCoordinator->requestScrollPositionUpdate(this, position);
     }
@@ -2133,17 +2104,16 @@ bool FrameView::requestScrollPositionUpdate(const IntPoint& position)
 
 HostWindow* FrameView::hostWindow() const
 {
-    Page* page = frame() ? frame()->page() : 0;
-    if (!page)
-        return 0;
-    return &page->chrome();
+    if (Page* page = frame().page())
+        return &page->chrome();
+    return 0;
 }
 
 const unsigned cRepaintRectUnionThreshold = 25;
 
 void FrameView::repaintContentRectangle(const IntRect& r, bool immediate)
 {
-    ASSERT(!m_frame->ownerElement());
+    ASSERT(!frame().ownerElement());
 
     if (m_isTrackingRepaints) {
         IntRect repaintRect = r;
@@ -2181,8 +2151,8 @@ void FrameView::repaintContentRectangle(const IntRect& r, bool immediate)
         return;
 
 #if USE(TILED_BACKING_STORE)
-    if (frame()->tiledBackingStore()) {
-        frame()->tiledBackingStore()->invalidate(r);
+    if (frame().tiledBackingStore()) {
+        frame().tiledBackingStore()->invalidate(r);
         return;
     }
 #endif
@@ -2199,7 +2169,7 @@ void FrameView::fixedLayoutSizeChanged()
 {
     // Can be triggered before the view is set, see comment in FrameView::visibleContentsResized().
     // An ASSERT is triggered when a view schedules a layout before being attached to a frame.
-    if (!frame()->view())
+    if (!frame().view())
         return;
     ScrollView::fixedLayoutSizeChanged();
 }
@@ -2210,7 +2180,7 @@ void FrameView::visibleContentsResized()
     // be triggered before the view is attached by Frame::createView(...) setting
     // various values such as setScrollBarModes(...) for example.  An ASSERT is
     // triggered when a view is layout before being attached to a frame().
-    if (!frame()->view())
+    if (!frame().view())
         return;
 
     if (!useFixedLayout() && needsLayout())
@@ -2226,8 +2196,8 @@ void FrameView::visibleContentsResized()
 
 void FrameView::beginDeferredRepaints()
 {
-    Page* page = m_frame->page();
-    if (page->mainFrame() != m_frame) {
+    Page* page = frame().page();
+    if (page->mainFrame() != &frame()) {
         page->mainFrame()->view()->beginDeferredRepaints();
         return;
     }
@@ -2237,8 +2207,8 @@ void FrameView::beginDeferredRepaints()
 
 void FrameView::endDeferredRepaints()
 {
-    Page* page = m_frame->page();
-    if (page->mainFrame() != m_frame) {
+    Page* page = frame().page();
+    if (page->mainFrame() != &frame()) {
         page->mainFrame()->view()->endDeferredRepaints();
         return;
     }
@@ -2303,8 +2273,8 @@ void FrameView::doDeferredRepaints()
     unsigned size = m_repaintRects.size();
     for (unsigned i = 0; i < size; i++) {
 #if USE(TILED_BACKING_STORE)
-        if (frame()->tiledBackingStore()) {
-            frame()->tiledBackingStore()->invalidate(pixelSnappedIntRect(m_repaintRects[i]));
+        if (frame().tiledBackingStore()) {
+            frame().tiledBackingStore()->invalidate(pixelSnappedIntRect(m_repaintRects[i]));
             continue;
         }
 #endif
@@ -2319,9 +2289,9 @@ void FrameView::doDeferredRepaints()
 bool FrameView::shouldUseLoadTimeDeferredRepaintDelay() const
 {
     // Don't defer after the initial load of the page has been completed.
-    if (m_frame->tree()->top()->loader().isComplete())
+    if (frame().tree()->top()->loader().isComplete())
         return false;
-    Document* document = m_frame->document();
+    Document* document = frame().document();
     if (!document)
         return false;
     if (document->parsing())
@@ -2383,7 +2353,7 @@ void FrameView::endDisableRepaints()
 void FrameView::updateLayerFlushThrottlingInAllFrames()
 {
 #if USE(ACCELERATED_COMPOSITING)
-    bool isMainLoadProgressing = m_frame->page()->progress()->isMainLoadProgressing();
+    bool isMainLoadProgressing = frame().page()->progress()->isMainLoadProgressing();
     for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext(m_frame.get())) {
         if (RenderView* renderView = frame->contentRenderer())
             renderView->compositor()->setLayerFlushThrottlingEnabled(isMainLoadProgressing);
@@ -2403,8 +2373,8 @@ void FrameView::adjustTiledBackingCoverage()
 void FrameView::layoutTimerFired(Timer<FrameView>*)
 {
 #ifdef INSTRUMENT_LAYOUT_SCHEDULING
-    if (!m_frame->document()->ownerElement())
-        printf("Layout timer fired at %d\n", m_frame->document()->elapsedTime());
+    if (!frame().document()->ownerElement())
+        printf("Layout timer fired at %d\n", frame().document()->elapsedTime());
 #endif
     layout();
 }
@@ -2413,7 +2383,7 @@ void FrameView::scheduleRelayout()
 {
     // FIXME: We should assert the page is not in the page cache, but that is causing
     // too many false assertions.  See <rdar://problem/7218118>.
-    ASSERT(m_frame->view() == this);
+    ASSERT(frame().view() == this);
 
     if (m_layoutRoot) {
         m_layoutRoot->markContainingBlocksForLayout(false);
@@ -2423,15 +2393,15 @@ void FrameView::scheduleRelayout()
         return;
     if (!needsLayout())
         return;
-    if (!m_frame->document()->shouldScheduleLayout())
+    if (!frame().document()->shouldScheduleLayout())
         return;
-    InspectorInstrumentation::didInvalidateLayout(m_frame.get());
+    InspectorInstrumentation::didInvalidateLayout(&frame());
     // When frame flattening is enabled, the contents of the frame could affect the layout of the parent frames.
     // Also invalidate parent frame starting from the owner element of this frame.
-    if (m_frame->ownerRenderer() && isInChildFrameWithFrameFlattening())
-        m_frame->ownerRenderer()->setNeedsLayout(true, MarkContainingBlockChain);
+    if (frame().ownerRenderer() && isInChildFrameWithFrameFlattening())
+        frame().ownerRenderer()->setNeedsLayout(true, MarkContainingBlockChain);
 
-    int delay = m_frame->document()->minimumLayoutDelay();
+    int delay = frame().document()->minimumLayoutDelay();
     if (m_layoutTimer.isActive() && m_delayedLayout && !delay)
         unscheduleRelayout();
     if (m_layoutTimer.isActive())
@@ -2440,7 +2410,7 @@ void FrameView::scheduleRelayout()
     m_delayedLayout = delay != 0;
 
 #ifdef INSTRUMENT_LAYOUT_SCHEDULING
-    if (!m_frame->document()->ownerElement())
+    if (!frame().document()->ownerElement())
         printf("Scheduling layout for %d\n", delay);
 #endif
 
@@ -2458,7 +2428,7 @@ static bool isObjectAncestorContainerOf(RenderObject* ancestor, RenderObject* de
 
 void FrameView::scheduleRelayoutOfSubtree(RenderObject* relayoutRoot)
 {
-    ASSERT(m_frame->view() == this);
+    ASSERT(frame().view() == this);
 
     RenderView* renderView = this->renderView();
     if (renderView && renderView->needsLayout()) {
@@ -2478,21 +2448,21 @@ void FrameView::scheduleRelayoutOfSubtree(RenderObject* relayoutRoot)
                 m_layoutRoot->markContainingBlocksForLayout(false, relayoutRoot);
                 m_layoutRoot = relayoutRoot;
                 ASSERT(!m_layoutRoot->container() || !m_layoutRoot->container()->needsLayout());
-                InspectorInstrumentation::didInvalidateLayout(m_frame.get());
+                InspectorInstrumentation::didInvalidateLayout(&frame());
             } else {
                 // Just do a full relayout
                 if (m_layoutRoot)
                     m_layoutRoot->markContainingBlocksForLayout(false);
                 m_layoutRoot = 0;
                 relayoutRoot->markContainingBlocksForLayout(false);
-                InspectorInstrumentation::didInvalidateLayout(m_frame.get());
+                InspectorInstrumentation::didInvalidateLayout(&frame());
             }
         }
     } else if (m_layoutSchedulingEnabled) {
-        int delay = m_frame->document()->minimumLayoutDelay();
+        int delay = frame().document()->minimumLayoutDelay();
         m_layoutRoot = relayoutRoot;
         ASSERT(!m_layoutRoot->container() || !m_layoutRoot->container()->needsLayout());
-        InspectorInstrumentation::didInvalidateLayout(m_frame.get());
+        InspectorInstrumentation::didInvalidateLayout(&frame());
         m_delayedLayout = delay != 0;
         m_layoutTimer.startOneShot(delay * 0.001);
     }
@@ -2508,9 +2478,6 @@ bool FrameView::needsLayout() const
     // This can return true in cases where the document does not have a body yet.
     // Document::shouldScheduleLayout takes care of preventing us from scheduling
     // layout in that case.
-    if (!m_frame)
-        return false;
-
     RenderView* renderView = this->renderView();
     return layoutPending()
         || (renderView && renderView->needsLayout())
@@ -2535,8 +2502,8 @@ void FrameView::unscheduleRelayout()
         return;
 
 #ifdef INSTRUMENT_LAYOUT_SCHEDULING
-    if (!m_frame->document()->ownerElement())
-        printf("Layout timer unscheduled at %d\n", m_frame->document()->elapsedTime());
+    if (!frame().document()->ownerElement())
+        printf("Layout timer unscheduled at %d\n", frame().document()->elapsedTime());
 #endif
     
     m_layoutTimer.stop();
@@ -2642,14 +2609,14 @@ void FrameView::scrollToAnchor()
         return;
 
     LayoutRect rect;
-    if (anchorNode != m_frame->document())
+    if (anchorNode != frame().document())
         rect = anchorNode->boundingBox();
 
     // Scroll nested layers and frames to reveal the anchor.
     // Align to the top and to the closest side (this matches other browsers).
     anchorNode->renderer()->scrollRectToVisible(rect, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
 
-    if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache())
+    if (AXObjectCache* cache = frame().document()->existingAXObjectCache())
         cache->handleScrolledToAnchor(anchorNode.get());
 
     // scrollRectToVisible can call into setScrollPosition(), which resets m_maintainScrollPositionAnchor.
@@ -2715,7 +2682,7 @@ bool FrameView::updateWidgets()
     Vector<RenderObject*> objects;
     objects.reserveInitialCapacity(size);
     // Protect RendereArena from getting wiped out, when Document is detached during updateWidget().
-    RefPtr<RenderArena> protectedArena = m_frame->document()->renderArena();
+    RefPtr<RenderArena> protectedArena = frame().document()->renderArena();
 
     RenderObjectSet::const_iterator end = m_widgetUpdateSet->end();
     for (RenderObjectSet::const_iterator it = m_widgetUpdateSet->begin(); it != end; ++it) {
@@ -2756,19 +2723,19 @@ void FrameView::performPostLayoutTasks()
 {
     m_postLayoutTasksTimer.stop();
 
-    m_frame->selection()->setCaretRectNeedsUpdate();
-    m_frame->selection()->updateAppearance();
+    frame().selection()->setCaretRectNeedsUpdate();
+    frame().selection()->updateAppearance();
 
     LayoutMilestones requestedMilestones = 0;
     LayoutMilestones milestonesAchieved = 0;
-    Page* page = m_frame->page();
+    Page* page = frame().page();
     if (page)
         requestedMilestones = page->requestedLayoutMilestones();
 
-    if (m_nestedLayoutCount <= 1 && m_frame->document()->documentElement()) {
+    if (m_nestedLayoutCount <= 1 && frame().document()->documentElement()) {
         if (m_firstLayoutCallbackPending) {
             m_firstLayoutCallbackPending = false;
-            m_frame->loader().didFirstLayout();
+            frame().loader().didFirstLayout();
             if (requestedMilestones & DidFirstLayout)
                 milestonesAchieved |= DidFirstLayout;
             if (isMainFrameView())
@@ -2777,23 +2744,23 @@ void FrameView::performPostLayoutTasks()
         updateIsVisuallyNonEmpty();
 
         // If the layout was done with pending sheets, we are not in fact visually non-empty yet.
-        if (m_isVisuallyNonEmpty && !m_frame->document()->didLayoutWithPendingStylesheets() && m_firstVisuallyNonEmptyLayoutCallbackPending) {
+        if (m_isVisuallyNonEmpty && !frame().document()->didLayoutWithPendingStylesheets() && m_firstVisuallyNonEmptyLayoutCallbackPending) {
             m_firstVisuallyNonEmptyLayoutCallbackPending = false;
             if (requestedMilestones & DidFirstVisuallyNonEmptyLayout)
                 milestonesAchieved |= DidFirstVisuallyNonEmptyLayout;
         }
     }
 
-    if (milestonesAchieved && page && page->mainFrame() == m_frame)
-        m_frame->loader().didLayout(milestonesAchieved);
+    if (milestonesAchieved && page && page->mainFrame() == &frame())
+        frame().loader().didLayout(milestonesAchieved);
 #if ENABLE(FONT_LOAD_EVENTS)
     if (RuntimeEnabledFeatures::fontLoadEventsEnabled())
-        m_frame->document()->fontloader()->didLayout();
+        frame().document()->fontloader()->didLayout();
 #endif
     
     // FIXME: We should consider adding DidLayout as a LayoutMilestone. That would let us merge this
     // with didLayout(LayoutMilestones).
-    m_frame->loader().client()->dispatchDidLayout();
+    frame().loader().client()->dispatchDidLayout();
 
     if (RenderView* renderView = this->renderView())
         renderView->updateWidgetPositions();
@@ -2827,8 +2794,6 @@ void FrameView::performPostLayoutTasks()
 
 void FrameView::sendResizeEventIfNeeded()
 {
-    ASSERT(m_frame);
-
     RenderView* renderView = this->renderView();
     if (!renderView || renderView->printing())
         return;
@@ -2854,15 +2819,15 @@ void FrameView::sendResizeEventIfNeeded()
     // If we resized during layout, queue up a resize event for later, otherwise fire it right away.
     RefPtr<Event> resizeEvent = Event::create(eventNames().resizeEvent, false, false);
     if (canSendResizeEventSynchronously)
-        m_frame->document()->dispatchWindowEvent(resizeEvent.release(), m_frame->document()->domWindow());
+        frame().document()->dispatchWindowEvent(resizeEvent.release(), frame().document()->domWindow());
     else
-        m_frame->document()->enqueueWindowEvent(resizeEvent.release());
+        frame().document()->enqueueWindowEvent(resizeEvent.release());
 
 #if ENABLE(INSPECTOR)
-    Page* page = m_frame->page();
+    Page* page = frame().page();
     if (InspectorInstrumentation::hasFrontends() && isMainFrame) {
         if (InspectorClient* inspectorClient = page ? page->inspectorController()->inspectorClient() : 0)
-            inspectorClient->didResizeMainFrame(m_frame.get());
+            inspectorClient->didResizeMainFrame(&frame());
     }
 #endif
 }
@@ -2894,7 +2859,7 @@ void FrameView::autoSizeIfEnabled()
 
     TemporaryChange<bool> changeInAutoSize(m_inAutoSize, true);
 
-    Document* document = frame()->document();
+    Document* document = frame().document();
     if (!document)
         return;
 
@@ -2962,7 +2927,7 @@ void FrameView::autoSizeIfEnabled()
         // While loading only allow the size to increase (to avoid twitching during intermediate smaller states)
         // unless autoresize has just been turned on or the maximum size is smaller than the current size.
         if (m_didRunAutosize && size.height() <= m_maxAutoSize.height() && size.width() <= m_maxAutoSize.width()
-            && !frame()->loader().isComplete() && (newSize.height() < size.height() || newSize.width() < size.width()))
+            && !frame().loader().isComplete() && (newSize.height() < size.height() || newSize.width() < size.width()))
             break;
 
         resize(newSize.width(), newSize.height());
@@ -3025,7 +2990,7 @@ const Pagination& FrameView::pagination() const
         return m_pagination;
 
     if (isMainFrameView())
-        return m_frame->page()->pagination();
+        return frame().page()->pagination();
 
     return m_pagination;
 }
@@ -3037,24 +3002,23 @@ void FrameView::setPagination(const Pagination& pagination)
 
     m_pagination = pagination;
 
-    if (m_frame)
-        m_frame->document()->styleResolverChanged(DeferRecalcStyle);
+    frame().document()->styleResolverChanged(DeferRecalcStyle);
 }
 
 IntRect FrameView::windowClipRect(bool clipToContents) const
 {
-    ASSERT(m_frame->view() == this);
+    ASSERT(frame().view() == this);
 
     if (paintsEntireContents())
         return IntRect(IntPoint(), totalContentsSize());
 
     // Set our clip rect to be our contents.
     IntRect clipRect = contentsToWindow(visibleContentRect(clipToContents ? ExcludeScrollbars : IncludeScrollbars));
-    if (!m_frame || !m_frame->ownerElement())
+    if (!frame().ownerElement())
         return clipRect;
 
     // Take our owner element and get its clip rect.
-    HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement();
+    HTMLFrameOwnerElement* ownerElement = frame().ownerElement();
     FrameView* parentView = ownerElement->document()->view();
     if (parentView)
         clipRect.intersect(parentView->windowClipRectForFrameOwner(ownerElement, true));
@@ -3085,7 +3049,7 @@ IntRect FrameView::windowClipRectForFrameOwner(const HTMLFrameOwnerElement* owne
 
 bool FrameView::isActive() const
 {
-    Page* page = frame()->page();
+    Page* page = frame().page();
     return page && page->focusController().isActive();
 }
 
@@ -3095,7 +3059,7 @@ void FrameView::scrollTo(const IntSize& newOffset)
     ScrollView::scrollTo(newOffset);
     if (offset != scrollOffset())
         scrollPositionChanged();
-    frame()->loader().client()->didChangeScrollOffset();
+    frame().loader().client()->didChangeScrollOffset();
 }
 
 void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
@@ -3108,23 +3072,22 @@ void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rec
 
 void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const
 {
-    tickmarks = frame()->document()->markers()->renderedRectsForMarkers(DocumentMarker::TextMatch);
+    tickmarks = frame().document()->markers()->renderedRectsForMarkers(DocumentMarker::TextMatch);
 }
 
 IntRect FrameView::windowResizerRect() const
 {
-    Page* page = frame() ? frame()->page() : 0;
-    if (!page)
-        return IntRect();
-    return page->chrome().windowResizerRect();
+    if (Page* page = frame().page())
+        return page->chrome().windowResizerRect();
+    return IntRect();
 }
 
 float FrameView::visibleContentScaleFactor() const
 {
-    if (!isMainFrameView() || !m_frame->settings()->applyPageScaleFactorInCompositor())
+    if (!isMainFrameView() || !frame().settings()->applyPageScaleFactorInCompositor())
         return 1;
 
-    return m_frame->page()->pageScaleFactor();
+    return frame().page()->pageScaleFactor();
 }
 
 void FrameView::setVisibleScrollerThumbRect(const IntRect& scrollerThumb)
@@ -3132,23 +3095,20 @@ void FrameView::setVisibleScrollerThumbRect(const IntRect& scrollerThumb)
     if (!isMainFrameView())
         return;
 
-    m_frame->page()->chrome().client()->notifyScrollerThumbIsVisibleInRect(scrollerThumb);
+    frame().page()->chrome().client()->notifyScrollerThumbIsVisibleInRect(scrollerThumb);
 }
 
 bool FrameView::scrollbarsCanBeActive() const
 {
-    if (!m_frame)
+    if (frame().view() != this)
         return false;
 
-    if (m_frame->view() != this)
-        return false;
-
-    if (Page* page = m_frame->page()) {
+    if (Page* page = frame().page()) {
         if (page->shouldSuppressScrollbarAnimations())
             return false;
     }
 
-    if (Document* document = m_frame->document())
+    if (Document* document = frame().document())
         return !document->inPageCache();
 
     return false;
@@ -3162,7 +3122,7 @@ ScrollableArea* FrameView::enclosingScrollableArea() const
 
 IntRect FrameView::scrollableAreaBoundingBox() const
 {
-    RenderPart* ownerRenderer = frame()->ownerRenderer();
+    RenderPart* ownerRenderer = frame().ownerRenderer();
     if (!ownerRenderer)
         return frameRect();
 
@@ -3184,7 +3144,7 @@ bool FrameView::isScrollable()
         return false;
 
     // Covers #2.
-    HTMLFrameOwnerElement* owner = m_frame->ownerElement();
+    HTMLFrameOwnerElement* owner = frame().ownerElement();
     if (owner && (!owner->renderer() || !owner->renderer()->visibleToHitTesting()))
         return false;
 
@@ -3215,7 +3175,7 @@ void FrameView::updateScrollableAreaSet()
 
 bool FrameView::shouldSuspendScrollAnimations() const
 {
-    return m_frame->loader().state() != FrameStateComplete;
+    return frame().loader().state() != FrameStateComplete;
 }
 
 void FrameView::scrollbarStyleChanged(int newStyle, bool forceUpdate)
@@ -3223,7 +3183,7 @@ void FrameView::scrollbarStyleChanged(int newStyle, bool forceUpdate)
     if (!isMainFrameView())
         return;
 
-    m_frame->page()->chrome().client()->recommendedScrollbarStyleDidChange(newStyle);
+    frame().page()->chrome().client()->recommendedScrollbarStyleDidChange(newStyle);
 
     if (forceUpdate)
         ScrollView::scrollbarStyleChanged(newStyle, forceUpdate);
@@ -3231,7 +3191,7 @@ void FrameView::scrollbarStyleChanged(int newStyle, bool forceUpdate)
 
 void FrameView::setAnimatorsAreActive()
 {
-    Page* page = m_frame->page();
+    Page* page = frame().page();
     if (!page)
         return;
 
@@ -3251,7 +3211,7 @@ void FrameView::setAnimatorsAreActive()
 
 void FrameView::notifyPageThatContentAreaWillPaint() const
 {
-    Page* page = m_frame->page();
+    Page* page = frame().page();
     if (!page)
         return;
 
@@ -3273,7 +3233,7 @@ void FrameView::notifyPageThatContentAreaWillPaint() const
 bool FrameView::scrollAnimatorEnabled() const
 {
 #if ENABLE(SMOOTH_SCROLLING)
-    if (Page* page = m_frame->page())
+    if (Page* page = frame().page())
         return page->settings().scrollAnimatorEnabled();
 #endif
 
@@ -3283,7 +3243,7 @@ bool FrameView::scrollAnimatorEnabled() const
 #if ENABLE(DASHBOARD_SUPPORT) || ENABLE(DRAGGABLE_REGION)
 void FrameView::updateAnnotatedRegions()
 {
-    Document* document = m_frame->document();
+    Document* document = frame().document();
     if (!document->hasAnnotatedRegions())
         return;
     Vector<AnnotatedRegionValue> newRegions;
@@ -3291,7 +3251,7 @@ void FrameView::updateAnnotatedRegions()
     if (newRegions == document->annotatedRegions())
         return;
     document->setAnnotatedRegions(newRegions);
-    Page* page = m_frame->page();
+    Page* page = frame().page();
     if (!page)
         return;
     page->chrome().client()->annotatedRegionsChanged();
@@ -3306,7 +3266,7 @@ void FrameView::updateScrollCorner()
     
     if (!cornerRect.isEmpty()) {
         // Try the <body> element first as a scroll corner source.
-        Document* doc = m_frame->document();
+        Document* doc = frame().document();
         Element* body = doc ? doc->body() : 0;
         if (body && body->renderer()) {
             renderer = body->renderer();
@@ -3324,7 +3284,7 @@ void FrameView::updateScrollCorner()
         
         if (!cornerStyle) {
             // If we have an owning iframe/frame element, then it can set the custom scrollbar also.
-            if (RenderPart* renderer = m_frame->ownerRenderer())
+            if (RenderPart* renderer = frame().ownerRenderer())
                 cornerStyle = renderer->getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), renderer->style());
         }
     }
@@ -3377,11 +3337,11 @@ Color FrameView::documentBackgroundColor() const
     // Background images are unfortunately impractical to include.
 
     // Return invalid Color objects whenever there is insufficient information.
-    if (!frame()->document())
+    if (!frame().document())
         return Color();
 
-    Element* htmlElement = frame()->document()->documentElement();
-    Element* bodyElement = frame()->document()->body();
+    Element* htmlElement = frame().document()->documentElement();
+    Element* bodyElement = frame().document()->body();
 
     // Start with invalid colors.
     Color htmlBackgroundColor;
@@ -3434,7 +3394,7 @@ FrameView* FrameView::parentFrameView() const
     if (!parent())
         return 0;
 
-    if (Frame* parentFrame = m_frame->tree()->parent())
+    if (Frame* parentFrame = frame().tree()->parent())
         return parentFrame->view();
 
     return 0;
@@ -3442,13 +3402,13 @@ FrameView* FrameView::parentFrameView() const
 
 bool FrameView::isInChildFrameWithFrameFlattening() const
 {
-    if (!parent() || !m_frame->ownerElement())
+    if (!parent() || !frame().ownerElement())
         return false;
 
     // Frame flattening applies when the owner element is either in a frameset or
     // an iframe with flattening parameters.
-    if (m_frame->ownerElement()->hasTagName(iframeTag)) {
-        RenderIFrame* iframeRenderer = toRenderIFrame(m_frame->ownerElement()->renderPart());
+    if (frame().ownerElement()->hasTagName(iframeTag)) {
+        RenderIFrame* iframeRenderer = toRenderIFrame(frame().ownerElement()->renderPart());
         if (iframeRenderer->flattenFrame() || iframeRenderer->isSeamless())
             return true;
     }
@@ -3456,7 +3416,7 @@ bool FrameView::isInChildFrameWithFrameFlattening() const
     if (!frameFlatteningEnabled())
         return false;
 
-    if (m_frame->ownerElement()->hasTagName(frameTag))
+    if (frame().ownerElement()->hasTagName(frameTag))
         return true;
 
     return false;
@@ -3483,7 +3443,7 @@ bool FrameView::doLayoutWithFrameFlattening(bool allowSubtree)
 
     parentView->layout(allowSubtree);
 
-    RenderObject* root = m_layoutRoot ? m_layoutRoot : m_frame->document()->renderer();
+    RenderObject* root = m_layoutRoot ? m_layoutRoot : frame().document()->renderer();
     ASSERT_UNUSED(root, !root->needsLayout());
 
     return true;
@@ -3497,7 +3457,7 @@ void FrameView::updateControlTints()
     // to define when controls get the tint and to call this function when that changes.
     
     // Optimize the common case where we bring a window to the front while it's still empty.
-    if (!m_frame || m_frame->document()->url().isEmpty())
+    if (frame().document()->url().isEmpty())
         return;
 
     RenderView* renderView = this->renderView();
@@ -3536,16 +3496,13 @@ void FrameView::setWasScrolledByUser(bool wasScrolledByUser)
 
 void FrameView::paintContents(GraphicsContext* p, const IntRect& rect)
 {
-    if (!frame())
-        return;
-
-    Document* document = m_frame->document();
+    Document* document = frame().document();
 
 #ifndef NDEBUG
     bool fillWithRed;
     if (document->printing())
         fillWithRed = false; // Printing, don't fill with red (can't remember why).
-    else if (m_frame->ownerElement())
+    else if (frame().ownerElement())
         fillWithRed = false; // Subframe, don't fill with red.
     else if (isTransparent())
         fillWithRed = false; // Transparent, don't fill with red.
@@ -3581,7 +3538,7 @@ void FrameView::paintContents(GraphicsContext* p, const IntRect& rect)
 
 #if USE(ACCELERATED_COMPOSITING)
     if (!p->paintingDisabled() && !document->printing())
-        flushCompositingStateForThisFrame(m_frame.get());
+        flushCompositingStateForThisFrame(&frame());
 #endif
 
     PaintBehavior oldPaintBehavior = m_paintBehavior;
@@ -3598,7 +3555,7 @@ void FrameView::paintContents(GraphicsContext* p, const IntRect& rect)
         m_paintBehavior |= PaintBehaviorFlattenCompositingLayers;
 
     bool flatteningPaint = m_paintBehavior & PaintBehaviorFlattenCompositingLayers;
-    bool isRootFrame = !m_frame->ownerElement();
+    bool isRootFrame = !frame().ownerElement();
     if (flatteningPaint && isRootFrame)
         notifyWidgetsInAllFrames(WillPaintFlattened);
 
@@ -3704,10 +3661,10 @@ void FrameView::paintOverhangAreas(GraphicsContext* context, const IntRect& hori
     if (context->paintingDisabled())
         return;
 
-    if (m_frame->document()->printing())
+    if (frame().document()->printing())
         return;
 
-    if (isMainFrameView() && m_frame->page()->chrome().client()->paintCustomOverhangArea(context, horizontalOverhangArea, verticalOverhangArea, dirtyRect))
+    if (isMainFrameView() && frame().page()->chrome().client()->paintCustomOverhangArea(context, horizontalOverhangArea, verticalOverhangArea, dirtyRect))
         return;
 
     ScrollView::paintOverhangAreas(context, horizontalOverhangArea, verticalOverhangArea, dirtyRect);
@@ -3724,7 +3681,7 @@ void FrameView::updateLayoutAndStyleIfNeededRecursive()
     // region but then become included later by the second frame adding rects to the dirty region
     // when it lays out.
 
-    m_frame->document()->updateStyleIfNeeded();
+    frame().document()->updateStyleIfNeeded();
 
     if (needsLayout())
         layout();
@@ -3752,12 +3709,12 @@ void FrameView::updateLayoutAndStyleIfNeededRecursive()
 bool FrameView::qualifiesAsVisuallyNonEmpty() const
 {
     // No content yet.
-    Element* documentElement = m_frame->document()->documentElement();
+    Element* documentElement = frame().document()->documentElement();
     if (!documentElement || !documentElement->renderer())
         return false;
 
     // Ensure that we always get marked visually non-empty eventually.
-    if (!m_frame->document()->parsing() && m_frame->loader().stateMachine()->committedFirstRealDocumentLoad())
+    if (!frame().document()->parsing() && frame().loader().stateMachine()->committedFirstRealDocumentLoad())
         return true;
 
     // Require the document to grow a bit.
@@ -3816,7 +3773,7 @@ void FrameView::forceLayout(bool allowSubtree)
 
 void FrameView::forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor, AdjustViewSizeOrNot shouldAdjustViewSize)
 {
-    // Dumping externalRepresentation(m_frame->renderer()).ascii() is a good trick to see
+    // Dumping externalRepresentation(frame().renderer()).ascii() is a good trick to see
     // the state of things before and after the layout
     if (RenderView* renderView = this->renderView()) {
         float pageLogicalWidth = renderView->style()->isHorizontalWritingMode() ? pageSize.width() : pageSize.height();
@@ -3839,7 +3796,7 @@ void FrameView::forceLayoutForPagination(const FloatSize& pageSize, const FloatS
         if (docLogicalWidth > pageLogicalWidth) {
             int expectedPageWidth = std::min<float>(documentRect.width(), pageSize.width() * maximumShrinkFactor);
             int expectedPageHeight = std::min<float>(documentRect.height(), pageSize.height() * maximumShrinkFactor);
-            FloatSize maxPageSize = m_frame->resizePageRectsKeepingRatio(FloatSize(originalPageSize.width(), originalPageSize.height()), FloatSize(expectedPageWidth, expectedPageHeight));
+            FloatSize maxPageSize = frame().resizePageRectsKeepingRatio(FloatSize(originalPageSize.width(), originalPageSize.height()), FloatSize(expectedPageWidth, expectedPageHeight));
             pageLogicalWidth = horizontalWritingMode ? maxPageSize.width() : maxPageSize.height();
             pageLogicalHeight = horizontalWritingMode ? maxPageSize.height() : maxPageSize.width();
 
@@ -3942,7 +3899,7 @@ IntRect FrameView::convertToContainingView(const IntRect& localRect) const
         if (parentScrollView->isFrameView()) {
             const FrameView* parentView = toFrameView(parentScrollView);
             // Get our renderer in the parent view
-            RenderPart* renderer = m_frame->ownerRenderer();
+            RenderPart* renderer = frame().ownerRenderer();
             if (!renderer)
                 return localRect;
                 
@@ -3966,7 +3923,7 @@ IntRect FrameView::convertFromContainingView(const IntRect& parentRect) const
             const FrameView* parentView = toFrameView(parentScrollView);
 
             // Get our renderer in the parent view
-            RenderPart* renderer = m_frame->ownerRenderer();
+            RenderPart* renderer = frame().ownerRenderer();
             if (!renderer)
                 return parentRect;
 
@@ -3990,7 +3947,7 @@ IntPoint FrameView::convertToContainingView(const IntPoint& localPoint) const
             const FrameView* parentView = toFrameView(parentScrollView);
 
             // Get our renderer in the parent view
-            RenderPart* renderer = m_frame->ownerRenderer();
+            RenderPart* renderer = frame().ownerRenderer();
             if (!renderer)
                 return localPoint;
                 
@@ -4015,7 +3972,7 @@ IntPoint FrameView::convertFromContainingView(const IntPoint& parentPoint) const
             const FrameView* parentView = toFrameView(parentScrollView);
 
             // Get our renderer in the parent view
-            RenderPart* renderer = m_frame->ownerRenderer();
+            RenderPart* renderer = frame().ownerRenderer();
             if (!renderer)
                 return parentPoint;
 
@@ -4063,8 +4020,8 @@ void FrameView::setTracksRepaints(bool trackRepaints)
 
     // Force layout to flush out any pending repaints.
     if (trackRepaints) {
-        if (frame() && frame()->document())
-            frame()->document()->updateLayout();
+        if (frame().document())
+            frame().document()->updateLayout();
     }
 
 #if USE(ACCELERATED_COMPOSITING)
@@ -4089,8 +4046,8 @@ void FrameView::resetTrackedRepaints()
 
 String FrameView::trackedRepaintRectsAsText() const
 {
-    if (frame() && frame()->document())
-        frame()->document()->updateLayout();
+    if (frame().document())
+        frame().document()->updateLayout();
 
     TextStream ts;
     if (!m_trackedRepaintRects.isEmpty()) {
@@ -4152,7 +4109,7 @@ bool FrameView::wheelEvent(const PlatformWheelEvent& wheelEvent)
         if (offset != newOffset) {
             ScrollView::scrollTo(newOffset);
             scrollPositionChanged();
-            frame()->loader().client()->didChangeScrollOffset();
+            frame().loader().client()->didChangeScrollOffset();
         }
         return true;
     }
@@ -4165,7 +4122,7 @@ bool FrameView::wheelEvent(const PlatformWheelEvent& wheelEvent)
         return false;
 
 #if ENABLE(THREADED_SCROLLING)
-    if (Page* page = m_frame->page()) {
+    if (Page* page = frame().page()) {
         if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator()) {
             if (scrollingCoordinator->coordinatesScrollingForFrameView(this))
                 return scrollingCoordinator->handleWheelEvent(this, wheelEvent);
@@ -4205,8 +4162,8 @@ void FrameView::notifyWidgetsInAllFrames(WidgetNotification notification)
     
 AXObjectCache* FrameView::axObjectCache() const
 {
-    if (frame() && frame()->document())
-        return frame()->document()->existingAXObjectCache();
+    if (frame().document())
+        return frame().document()->existingAXObjectCache();
     return 0;
 }
     
@@ -4243,7 +4200,7 @@ void FrameView::addPaintPendingMilestones(LayoutMilestones milestones)
 
 void FrameView::firePaintRelatedMilestones()
 {
-    Page* page = m_frame->page();
+    Page* page = frame().page();
     if (!page)
         return;
 
@@ -4275,14 +4232,14 @@ void FrameView::setVisualUpdatesAllowedByClient(bool visualUpdatesAllowed)
 
     m_visualUpdatesAllowedByClient = visualUpdatesAllowed;
 
-    m_frame->document()->setVisualUpdatesAllowedByClient(visualUpdatesAllowed);
+    frame().document()->setVisualUpdatesAllowedByClient(visualUpdatesAllowed);
 }
     
 void FrameView::setScrollPinningBehavior(ScrollPinningBehavior pinning)
 {
     m_scrollPinningBehavior = pinning;
     
-    if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scrollingCoordinator())
+    if (ScrollingCoordinator* scrollingCoordinator = frame().page()->scrollingCoordinator())
         scrollingCoordinator->setScrollPinningBehavior(pinning);
     
     updateScrollbars(scrollOffset());
index 65ff07d..f230207 100644 (file)
@@ -76,10 +76,9 @@ public:
     virtual bool scheduleAnimation();
 #endif
 
-    Frame* frame() const { return m_frame.get(); }
-    void clearFrame();
+    Frame& frame() const { return *m_frame; }
 
-    RenderView* renderView() const { return m_frame ? m_frame->contentRenderer() : 0; }
+    RenderView* renderView() const { return frame().contentRenderer(); }
 
     int mapFromLayoutToCSSUnits(LayoutUnit);
     LayoutUnit mapFromCSSToLayoutUnits(int);
@@ -554,7 +553,7 @@ private:
     
     typedef HashSet<RenderObject*> RenderObjectSet;
     OwnPtr<RenderObjectSet> m_widgetUpdateSet;
-    RefPtr<Frame> m_frame;
+    const RefPtr<Frame> m_frame;
 
     OwnPtr<RenderObjectSet> m_slowRepaintObjects;
 
@@ -700,12 +699,12 @@ inline void FrameView::incrementVisuallyNonEmptyPixelCount(const IntSize& size)
 
 inline int FrameView::mapFromLayoutToCSSUnits(LayoutUnit value)
 {
-    return value / (m_frame->pageZoomFactor() * m_frame->frameScaleFactor());
+    return value / (frame().pageZoomFactor() * frame().frameScaleFactor());
 }
 
 inline LayoutUnit FrameView::mapFromCSSToLayoutUnits(int value)
 {
-    return value * m_frame->pageZoomFactor() * m_frame->frameScaleFactor();
+    return value * frame().pageZoomFactor() * frame().frameScaleFactor();
 }
 
 inline FrameView* toFrameView(Widget* widget)
index 34fb5ff..d63f09a 100644 (file)
@@ -93,7 +93,7 @@ bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& event, Widge
     if (!widget->isFrameView())
         return false;
 
-    return toFrameView(widget)->frame()->eventHandler().handleWheelEvent(event);
+    return toFrameView(widget)->frame().eventHandler().handleWheelEvent(event);
 }
 
 #if ENABLE(DRAG_SUPPORT)
index a831dd3..79674ed 100644 (file)
@@ -91,7 +91,7 @@ bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& event, Widge
     if (!widget->isFrameView())
         return false;
 
-    return toFrameView(widget)->frame()->eventHandler().handleWheelEvent(event);
+    return toFrameView(widget)->frame().eventHandler().handleWheelEvent(event);
 }
 
 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
index ec93a7e..dbb8d52 100644 (file)
@@ -431,7 +431,7 @@ bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& wheelEvent,
         if (!widget->isFrameView())
             return false;
 
-        return toFrameView(widget)->frame()->eventHandler().handleWheelEvent(wheelEvent);
+        return toFrameView(widget)->frame().eventHandler().handleWheelEvent(wheelEvent);
     }
 
     if ([currentNSEvent() type] != NSScrollWheel || m_sendingEventToSubview) 
index f0e15d8..ead70be 100644 (file)
@@ -91,7 +91,7 @@ bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& event, Widge
     if (!widget->isFrameView())
         return false;
 
-    return toFrameView(widget)->frame()->eventHandler().handleWheelEvent(event);
+    return toFrameView(widget)->frame().eventHandler().handleWheelEvent(event);
 }
 
 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
index 4d4723a..93fc1f7 100644 (file)
@@ -102,7 +102,7 @@ bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView
     ASSERT(m_page);
 
     // We currently only handle the main frame.
-    if (frameView->frame() != m_page->mainFrame())
+    if (&frameView->frame() != m_page->mainFrame())
         return false;
 
     // We currently only support composited mode.
@@ -293,14 +293,9 @@ GraphicsLayer* ScrollingCoordinator::verticalScrollbarLayerForScrollableArea(Scr
 GraphicsLayer* ScrollingCoordinator::scrollLayerForFrameView(FrameView* frameView)
 {
 #if USE(ACCELERATED_COMPOSITING)
-    Frame* frame = frameView->frame();
-    if (!frame)
-        return 0;
-
-    RenderView* renderView = frame->contentRenderer();
-    if (!renderView)
-        return 0;
-    return renderView->compositor()->scrollLayer();
+    if (RenderView* renderView = frameView->frame().contentRenderer())
+        return renderView->compositor()->scrollLayer();
+    return 0;
 #else
     UNUSED_PARAM(frameView);
     return 0;
@@ -310,15 +305,9 @@ GraphicsLayer* ScrollingCoordinator::scrollLayerForFrameView(FrameView* frameVie
 GraphicsLayer* ScrollingCoordinator::headerLayerForFrameView(FrameView* frameView)
 {
 #if USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
-    Frame* frame = frameView->frame();
-    if (!frame)
-        return 0;
-
-    RenderView* renderView = frame->contentRenderer();
-    if (!renderView)
-        return 0;
-
-    return renderView->compositor()->headerLayer();
+    if (RenderView* renderView = frameView->frame().contentRenderer())
+        renderView->compositor()->headerLayer();
+    return 0;
 #else
     UNUSED_PARAM(frameView);
     return 0;
@@ -328,14 +317,9 @@ GraphicsLayer* ScrollingCoordinator::headerLayerForFrameView(FrameView* frameVie
 GraphicsLayer* ScrollingCoordinator::footerLayerForFrameView(FrameView* frameView)
 {
 #if USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
-    Frame* frame = frameView->frame();
-    if (!frame)
-        return 0;
-
-    RenderView* renderView = frame->contentRenderer();
-    if (!renderView)
-        return 0;
-    return renderView->compositor()->footerLayer();
+    if (RenderView* renderView = frameView->frame().contentRenderer())
+        return renderView->compositor()->footerLayer();
+    return 0;
 #else
     UNUSED_PARAM(frameView);
     return 0;
@@ -345,14 +329,9 @@ GraphicsLayer* ScrollingCoordinator::footerLayerForFrameView(FrameView* frameVie
 GraphicsLayer* ScrollingCoordinator::counterScrollingLayerForFrameView(FrameView* frameView)
 {
 #if USE(ACCELERATED_COMPOSITING)
-    Frame* frame = frameView->frame();
-    if (!frame)
-        return 0;
-
-    RenderView* renderView = frame->contentRenderer();
-    if (!renderView)
-        return 0;
-    return renderView->compositor()->fixedRootBackgroundLayer();
+    if (RenderView* renderView = frameView->frame().contentRenderer())
+        return renderView->compositor()->fixedRootBackgroundLayer();
+    return 0;
 #else
     UNUSED_PARAM(frameView);
     return 0;
index 869bba9..4a10056 100644 (file)
@@ -163,7 +163,7 @@ void ScrollingCoordinatorMac::frameViewLayoutUpdated(FrameView* frameView)
     scrollParameters.scrollOrigin = frameView->scrollOrigin();
     scrollParameters.viewportRect = IntRect(IntPoint(), frameView->visibleContentRect().size());
     scrollParameters.totalContentsSize = frameView->totalContentsSize();
-    scrollParameters.frameScaleFactor = frameView->frame()->frameScaleFactor();
+    scrollParameters.frameScaleFactor = frameView->frame().frameScaleFactor();
     scrollParameters.headerHeight = frameView->headerHeight();
     scrollParameters.footerHeight = frameView->footerHeight();
 
@@ -218,12 +218,12 @@ bool ScrollingCoordinatorMac::requestScrollPositionUpdate(FrameView* frameView,
     if (!coordinatesScrollingForFrameView(frameView))
         return false;
 
-    if (frameView->inProgrammaticScroll() || frameView->frame()->document()->inPageCache())
+    if (frameView->inProgrammaticScroll() || frameView->frame().document()->inPageCache())
         updateMainFrameScrollPosition(scrollPosition, frameView->inProgrammaticScroll(), SetScrollingLayerPosition);
 
     // If this frame view's document is being put into the page cache, we don't want to update our
     // main frame scroll position. Just let the FrameView think that we did.
-    if (frameView->frame()->document()->inPageCache())
+    if (frameView->frame().document()->inPageCache())
         return true;
 
     ScrollingStateScrollingNode* stateNode = toScrollingStateScrollingNode(m_scrollingStateTree->stateNodeForID(frameView->scrollLayerID()));
index 6aeb412..a34dfab 100644 (file)
@@ -78,7 +78,7 @@ bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& wheelEvent,
     if (!widget->isFrameView())
         return false;
 
-    return toFrameView(widget)->frame()->eventHandler().handleWheelEvent(wheelEvent);
+    return toFrameView(widget)->frame().eventHandler().handleWheelEvent(wheelEvent);
 }
 
 bool EventHandler::tabsToAllFormControls(KeyboardEvent*) const
index e6ca650..334de39 100644 (file)
@@ -51,7 +51,7 @@ int screenDepth(Widget*)
 static FloatRect toUserSpace(FloatRect rect, Widget* widget)
 {
     if (widget->isFrameView()) {
-        Page* page = toFrameView(widget)->frame()->page();
+        Page* page = toFrameView(widget)->frame().page();
         if (page && !page->settings().applyDeviceScaleFactorInCompositor()) {
             rect.scale(1 / page->deviceScaleFactor());
             rect.setSize(expandedIntSize(rect.size()));
index b5a41e9..5715e83 100644 (file)
@@ -109,11 +109,11 @@ void ScrollbarEfl::setParent(ScrollView* view)
     if (!view || !view->evasObject())
         return;
 
-    Frame* frame = toFrameView(view)->frame();
-    if (!frame || !frame->page())
+    Frame& frame = toFrameView(view)->frame();
+    if (!frame.page())
         return;
 
-    String theme = static_cast<RenderThemeEfl*>(frame->page()->theme())->themePath();
+    String theme = static_cast<RenderThemeEfl*>(frame.page()->theme())->themePath();
 
     const char* group = (orientation() == HorizontalScrollbar) ? "scrollbar.horizontal" : "scrollbar.vertical";
     if (theme.isEmpty()) {
index 3b0d63f..ddf3736 100644 (file)
@@ -579,9 +579,9 @@ bool MediaPlayer::hasAudio() const
 
 bool MediaPlayer::inMediaDocument()
 {
-    Frame* frame = m_frameView ? m_frameView->frame() : 0;
-    Document* document = frame ? frame->document() : 0;
-
+    if (!m_frameView)
+        return false;
+    Document* document = m_frameView->frame().document();
     return document && document->isMediaDocument();
 }
 
index 9998af9..d73860c 100644 (file)
@@ -1387,7 +1387,7 @@ void MediaPlayerPrivateQTKit::paint(GraphicsContext* context, const IntRect& r)
 #if DRAW_FRAME_RATE
     // Draw the frame rate only after having played more than 10 frames.
     if (m_frameCountWhilePlaying > 10) {
-        Frame* frame = m_player->frameView() ? m_player->frameView()->frame() : NULL;
+        Frame* frame = m_player->frameView() ? &m_player->frameView()->frame() : NULL;
         Document* document = frame ? frame->document() : NULL;
         RenderObject* renderer = document ? document->renderer() : NULL;
         RenderStyle* styleToUse = renderer ? renderer->style() : NULL;
index 991677f..ee69114 100644 (file)
@@ -144,11 +144,10 @@ void getPluginOcclusions(Element* element, Widget* parentWidget, const IntRect&
         const FrameView* frameView = toFrameView((*it).get());
         // Check to make sure we can get both the element and the RenderObject
         // for this FrameView, if we can't just move on to the next object.
-        if (!frameView->frame() || !frameView->frame()->ownerElement()
-            || !frameView->frame()->ownerElement()->renderer())
+        if (!frameView->frame().ownerElement() || !frameView->frame().ownerElement()->renderer())
             continue;
 
-        HTMLElement* element = frameView->frame()->ownerElement();
+        HTMLElement* element = frameView->frame().ownerElement();
         RenderObject* iframeRenderer = element->renderer();
 
         if (element->hasTagName(HTMLNames::iframeTag)
index 65cf94f..cc4e1f0 100644 (file)
@@ -621,10 +621,7 @@ LayoutSize RenderBoxModelObject::stickyPositionOffset() const
         constrainingRect.setLocation(scrollOffset);
     } else {
         LayoutRect viewportRect = view()->frameView()->viewportConstrainedVisibleContentRect();
-        float scale = 1;
-        if (Frame* frame = view()->frameView()->frame())
-            scale = frame->frameScaleFactor();
-        
+        float scale = view()->frameView()->frame().frameScaleFactor();
         viewportRect.scale(1 / scale);
         constrainingRect = viewportRect;
     }
index 94c0900..b2786f3 100644 (file)
@@ -55,7 +55,7 @@ inline bool shouldExpandFrame(LayoutUnit width, LayoutUnit height, bool hasFixed
 void RenderFrameBase::layoutWithFlattening(bool hasFixedWidth, bool hasFixedHeight)
 {
     FrameView* childFrameView = toFrameView(widget());
-    RenderView* childRoot = childFrameView ? childFrameView->frame()->contentRenderer() : 0;
+    RenderView* childRoot = childFrameView ? childFrameView->frame().contentRenderer() : 0;
 
     if (!childRoot || !shouldExpandFrame(width(), height(), hasFixedWidth, hasFixedHeight)) {
         updateWidgetPosition();
index 2262a3f..cff375b 100644 (file)
@@ -94,7 +94,7 @@ RenderView* RenderIFrame::contentRootRenderer() const
     // FIXME: Is this always a valid cast? What about plugins?
     ASSERT(!widget() || widget()->isFrameView());
     FrameView* childFrameView = toFrameView(widget());
-    return childFrameView ? childFrameView->frame()->contentRenderer() : 0;
+    return childFrameView ? childFrameView->frame().contentRenderer() : 0;
 }
 
 bool RenderIFrame::flattenFrame() const
@@ -146,7 +146,7 @@ void RenderIFrame::layoutSeamlessly()
     updateWidgetPosition(); // Notify the Widget of our final height.
 
     // Assert that the child document did a complete layout.
-    RenderView* childRoot = childFrameView ? childFrameView->frame()->contentRenderer() : 0;
+    RenderView* childRoot = childFrameView ? childFrameView->frame().contentRenderer() : 0;
     ASSERT(!childFrameView || !childFrameView->layoutPending());
     ASSERT_UNUSED(childRoot, !childRoot || !childRoot->needsLayout());
 }
index 800c76c..c39c4dc 100644 (file)
@@ -2276,7 +2276,7 @@ static inline bool frameElementAndViewPermitScroll(HTMLFrameElementBase* frameEl
 
     // Forbid autoscrolls when scrollbars are off, but permits other programmatic scrolls,
     // like navigation to an anchor.
-    return !frameView->frame()->eventHandler().autoscrollInProgress();
+    return !frameView->frame().eventHandler().autoscrollInProgress();
 }
 
 void RenderLayer::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignment& alignX, const ScrollAlignment& alignY)
@@ -2360,10 +2360,8 @@ void RenderLayer::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignm
                 // This only has an effect on the Mac platform in applications
                 // that put web views into scrolling containers, such as Mac OS X Mail.
                 // The canAutoscroll function in EventHandler also knows about this.
-                if (Frame* frame = frameView->frame()) {
-                    if (Page* page = frame->page())
-                        page->chrome().scrollRectIntoView(pixelSnappedIntRect(rect));
-                }
+                if (Page* page = frameView->frame().page())
+                    page->chrome().scrollRectIntoView(pixelSnappedIntRect(rect));
             }
         }
     }
index 6fa4635..250a2a4 100644 (file)
@@ -121,9 +121,9 @@ RenderLayerBacking::RenderLayerBacking(RenderLayer* layer)
     , m_didSwitchToFullTileCoverageDuringLoading(false)
 {
     if (layer->isRootLayer()) {
-        Frame* frame = toRenderView(renderer())->frameView()->frame();
-        Page* page = frame ? frame->page() : 0;
-        if (page && frame && page->mainFrame() == frame) {
+        Frame& frame = toRenderView(renderer())->frameView()->frame();
+        Page* page = frame.page();
+        if (page && page->mainFrame() == &frame) {
             m_isMainFrameRenderViewLayer = true;
 
 #if PLATFORM(MAC)
index d89fd24..83edbf9 100644 (file)
@@ -383,7 +383,7 @@ void RenderLayerCompositor::flushPendingLayerChanges(bool isFlushRoot)
         return;
     }
 
-    AnimationUpdateBlock animationUpdateBlock(m_renderView->frameView()->frame()->animation());
+    AnimationUpdateBlock animationUpdateBlock(m_renderView->frameView()->frame().animation());
 
     ASSERT(!m_flushingLayers);
     m_flushingLayers = true;
@@ -479,7 +479,7 @@ RenderLayerCompositor* RenderLayerCompositor::enclosingCompositorFlushingLayers(
     if (!m_renderView->frameView())
         return 0;
 
-    for (Frame* frame = m_renderView->frameView()->frame(); frame; frame = frame->tree()->parent()) {
+    for (Frame* frame = &m_renderView->frameView()->frame(); frame; frame = frame->tree()->parent()) {
         RenderLayerCompositor* compositor = frame->contentRenderer() ? frame->contentRenderer()->compositor() : 0;
         if (compositor->isFlushingLayers())
             return compositor;
@@ -522,7 +522,7 @@ void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update
     if (!m_reevaluateCompositingAfterLayout && !m_compositing)
         return;
 
-    AnimationUpdateBlock animationUpdateBlock(m_renderView->frameView()->frame()->animation());
+    AnimationUpdateBlock animationUpdateBlock(m_renderView->frameView()->frame().animation());
 
     TemporaryChange<bool> postLayoutChange(m_inPostLayoutUpdate, true);
     
@@ -586,9 +586,9 @@ void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update
         m_obligatoryBackingStoreBytes = 0;
         m_secondaryBackingStoreBytes = 0;
 
-        Frame* frame = m_renderView->frameView()->frame();
+        Frame& frame = m_renderView->frameView()->frame();
         bool isMainFrame = !m_renderView->document()->ownerElement();
-        LOG(Compositing, "\nUpdate %d of %s.\n", m_rootLayerUpdateCount, isMainFrame ? "main frame" : frame->tree()->uniqueName().string().utf8().data());
+        LOG(Compositing, "\nUpdate %d of %s.\n", m_rootLayerUpdateCount, isMainFrame ? "main frame" : frame.tree()->uniqueName().string().utf8().data());
     }
 #endif
 
@@ -2928,12 +2928,12 @@ void RenderLayerCompositor::attachRootLayer(RootLayerAttachment attachment)
             ASSERT_NOT_REACHED();
             break;
         case RootLayerAttachedViaChromeClient: {
-            Frame* frame = m_renderView->frameView()->frame();
-            Page* page = frame ? frame->page() : 0;
+            Frame& frame = m_renderView->frameView()->frame();
+            Page* page = frame.page();
             if (!page)
                 return;
 
-            page->chrome().client()->attachRootGraphicsLayer(frame, rootGraphicsLayer());
+            page->chrome().client()->attachRootGraphicsLayer(&frame, rootGraphicsLayer());
             break;
         }
         case RootLayerAttachedViaEnclosingFrame: {
@@ -2972,12 +2972,12 @@ void RenderLayerCompositor::detachRootLayer()
         break;
     }
     case RootLayerAttachedViaChromeClient: {
-        Frame* frame = m_renderView->frameView()->frame();
-        Page* page = frame ? frame->page() : 0;
+        Frame& frame = m_renderView->frameView()->frame();
+        Page* page = frame.page();
         if (!page)
             return;
 
-        page->chrome().client()->attachRootGraphicsLayer(frame, 0);
+        page->chrome().client()->attachRootGraphicsLayer(&frame, 0);
     }
     break;
     case RootLayerUnattached:
@@ -3007,7 +3007,7 @@ void RenderLayerCompositor::rootLayerAttachmentChanged()
 // to use a synthetic style change to get the iframes into RenderLayers in order to allow them to composite.
 void RenderLayerCompositor::notifyIFramesOfCompositingChange()
 {
-    Frame* frame = m_renderView->frameView() ? m_renderView->frameView()->frame() : 0;
+    Frame* frame = m_renderView->frameView() ? &m_renderView->frameView()->frame() : 0;
     if (!frame)
         return;
 
@@ -3247,10 +3247,7 @@ GraphicsLayerFactory* RenderLayerCompositor::graphicsLayerFactory() const
 
 Page* RenderLayerCompositor::page() const
 {
-    if (Frame* frame = m_renderView->frameView()->frame())
-        return frame->page();
-    
-    return 0;
+    return m_renderView->frameView()->frame().page();
 }
 
 void RenderLayerCompositor::setLayerFlushThrottlingEnabled(bool enabled)
@@ -3304,8 +3301,8 @@ void RenderLayerCompositor::paintRelatedMilestonesTimerFired(Timer<RenderLayerCo
     if (!frameView)
         return;
 
-    Frame* frame = frameView->frame();
-    Page* page = frame ? frame->page() : 0;
+    Frame& frame = frameView->frame();
+    Page* page = frame.page();
     if (!page)
         return;
 
index 444c125..0f353ec 100644 (file)
@@ -588,8 +588,7 @@ void write(TextStream& ts, const RenderObject& o, int indent, RenderAsTextBehavi
         Widget* widget = toRenderWidget(&o)->widget();
         if (widget && widget->isFrameView()) {
             FrameView* view = toFrameView(widget);
-            RenderView* root = view->frame()->contentRenderer();
-            if (root) {
+            if (RenderView* root = view->frame().contentRenderer()) {
                 view->layout();
                 RenderLayer* l = root->layer();
                 if (l)
index 82e1ff6..0ac0ece 100644 (file)
@@ -930,8 +930,7 @@ bool RenderView::shouldUsePrintingLayout() const
 {
     if (!printing() || !m_frameView)
         return false;
-    Frame* frame = m_frameView->frame();
-    return frame && frame->shouldUsePrintingLayout();
+    return m_frameView->frame().shouldUsePrintingLayout();
 }
 
 size_t RenderView::getRetainedWidgets(Vector<RenderWidget*>& renderWidgets)
@@ -1073,8 +1072,7 @@ int RenderView::viewLogicalHeight() const
 
 float RenderView::zoomFactor() const
 {
-    Frame* frame = m_frameView->frame();
-    return frame ? frame->pageZoomFactor() : 1;
+    return m_frameView->frame().pageZoomFactor();
 }
 
 void RenderView::pushLayoutState(RenderObject* root)
index 271b8cf..b793272 100644 (file)
@@ -352,7 +352,7 @@ void RenderWidget::updateWidgetPosition()
     if (m_widget && m_widget->isFrameView()) {
         FrameView* frameView = toFrameView(m_widget.get());
         // Check the frame's page to make sure that the frame isn't in the process of being destroyed.
-        if ((boundsChanged || frameView->needsLayout()) && frameView->frame()->page())
+        if ((boundsChanged || frameView->needsLayout()) && frameView->frame().page())
             frameView->layout();
     }
 }
index f703457..4fd9e00 100644 (file)
@@ -51,7 +51,7 @@ PopupMenuEfl::~PopupMenuEfl()
 void PopupMenuEfl::show(const IntRect& rect, FrameView* view, int index)
 {
     ASSERT(m_popupClient);
-    ChromeClientEfl* chromeClient = static_cast<ChromeClientEfl*>(view->frame()->page()->chrome().client());
+    ChromeClientEfl* chromeClient = static_cast<ChromeClientEfl*>(view->frame().page()->chrome().client());
     ASSERT(chromeClient);
 
     m_view = view;
@@ -61,7 +61,7 @@ void PopupMenuEfl::show(const IntRect& rect, FrameView* view, int index)
 void PopupMenuEfl::hide()
 {
     ASSERT(m_view);
-    ChromeClientEfl* chromeClient = static_cast<ChromeClientEfl*>(m_view->frame()->page()->chrome().client());
+    ChromeClientEfl* chromeClient = static_cast<ChromeClientEfl*>(m_view->frame().page()->chrome().client());
     ASSERT(chromeClient);
 
     chromeClient->destroySelectPopup();
index c19d138..7eeb051 100644 (file)
@@ -160,7 +160,7 @@ void ewk_paint_context_paint(Ewk_Paint_Context* context, WebCore::FrameView* vie
     WebCore::IntRect paintArea(*area);
 
 #if USE(TILED_BACKING_STORE)
-    if (view->frame()->tiledBackingStore()) {
+    if (view->frame().tiledBackingStore()) {
         int scrollX = view->scrollX();
         int scrollY = view->scrollY();
 
@@ -168,7 +168,7 @@ void ewk_paint_context_paint(Ewk_Paint_Context* context, WebCore::FrameView* vie
 
         paintArea.move(scrollX, scrollY);
 
-        view->frame()->tiledBackingStore()->paint(context->graphicContext.get(), paintArea);
+        view->frame().tiledBackingStore()->paint(context->graphicContext.get(), paintArea);
         return;
     }
 #endif
@@ -191,7 +191,7 @@ void ewk_paint_context_paint_contents(Ewk_Paint_Context* context, WebCore::Frame
     view->paintContents(context->graphicContext.get(), paintArea);
 
 #if ENABLE(INSPECTOR)
-    WebCore::Page* page = view->frame()->page();
+    WebCore::Page* page = view->frame().page();
     if (page) {
         WebCore::InspectorController* controller = page->inspectorController();
         if (controller->highlightedNode())
index c448854..6882015 100644 (file)
@@ -172,7 +172,7 @@ void PopupMenuMac::show(const IntRect& r, FrameView* v, int index)
 
     // Save the current event that triggered the popup, so we can clean up our event
     // state after the NSMenu goes away.
-    RefPtr<Frame> frame = v->frame();
+    RefPtr<Frame> frame = &v->frame();
     RetainPtr<NSEvent> event = frame->eventHandler().currentNSEvent();
     
     RefPtr<PopupMenuMac> protector(this);
index 3275845..12636ef 100644 (file)
@@ -97,7 +97,7 @@ static WebRenderNode *copyRenderNode(RenderObject* node)
     RenderWidget* renderWidget = node->isWidget() ? toRenderWidget(node) : 0;
     Widget* widget = renderWidget ? renderWidget->widget() : 0;
     FrameView* frameView = widget && widget->isFrameView() ? toFrameView(widget) : 0;
-    Frame* frame = frameView ? frameView->frame() : 0;
+    Frame* frame = frameView ? &frameView->frame() : 0;
 
     // FIXME: broken with transforms
     FloatPoint absPos = node->localToAbsolute();
index 1403e51..ad71456 100644 (file)
@@ -2077,7 +2077,7 @@ static inline IMP getMethod(id o, SEL s)
 
 - (void)_addScrollerDashboardRegionsForFrameView:(FrameView*)frameView dashboardRegions:(NSMutableDictionary *)regions
 {    
-    NSView *documentView = [[kit(frameView->frame()) frameView] documentView];
+    NSView *documentView = [[kit(&frameView->frame()) frameView] documentView];
 
     const HashSet<RefPtr<Widget> >* children = frameView->children();
     HashSet<RefPtr<Widget> >::const_iterator end = children->end();
index 878351e..6cd2a35 100644 (file)
@@ -103,7 +103,7 @@ WebRenderObject::WebRenderObject(RenderObject* renderer, bool shouldIncludeDesce
         return;
 
     FrameView* frameView = toFrameView(widget);
-    if (RenderView* coreContentRenderer = frameView->frame()->contentRenderer()) {
+    if (RenderView* coreContentRenderer = frameView->frame().contentRenderer()) {
         RefPtr<WebRenderObject> contentRenderer = adoptRef(new WebRenderObject(coreContentRenderer, shouldIncludeDescendants));
         m_children->append(contentRenderer.get());
     }
index 06048ec..41b4c0e 100644 (file)
@@ -127,7 +127,7 @@ IntRect InjectedBundleNodeHandle::renderRect(bool* isReplaced) const
 static PassRefPtr<WebImage> imageForRect(FrameView* frameView, const IntRect& rect, SnapshotOptions options)
 {
     IntSize bitmapSize = rect.size();
-    float scaleFactor = frameView->frame()->page()->deviceScaleFactor();
+    float scaleFactor = frameView->frame().page()->deviceScaleFactor();
     bitmapSize.scale(scaleFactor);
 
     RefPtr<WebImage> snapshot = WebImage::create(bitmapSize, snapshotOptionsToImageOptions(options));