RenderView::flowThreadController() should return a reference.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Aug 2013 15:17:14 +0000 (15:17 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Aug 2013 15:17:14 +0000 (15:17 +0000)
<https://webkit.org/b/120363>

Reviewed by Antti Koivisto.

This function does lazy construction and always returns an object.

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

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/NodeRenderingContext.cpp
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderNamedFlowThread.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderRegion.cpp
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/rendering/RenderView.cpp
Source/WebCore/rendering/RenderView.h

index 961c03e..482dd2a 100644 (file)
@@ -1,5 +1,14 @@
 2013-08-27  Andreas Kling  <akling@apple.com>
 
+        RenderView::flowThreadController() should return a reference.
+        <https://webkit.org/b/120363>
+
+        Reviewed by Antti Koivisto.
+
+        This function does lazy construction and always returns an object.
+
+2013-08-27  Andreas Kling  <akling@apple.com>
+
         HTMLAppletElement: Use child iterator to walk <param> children.
         <https://webkit.org/b/120361>
 
index 7c60400..66cf1f7 100644 (file)
@@ -1392,7 +1392,7 @@ void Element::removedFrom(ContainerNode* insertionPoint)
 void Element::unregisterNamedFlowContentNode()
 {
     if (document()->cssRegionsEnabled() && inNamedFlow() && document()->renderView())
-        document()->renderView()->flowThreadController()->unregisterNamedFlowContentNode(this);
+        document()->renderView()->flowThreadController().unregisterNamedFlowContentNode(this);
 }
 
 void Element::lazyReattach(ShouldSetAttached shouldSetAttached)
index a5b3871..3638503 100644 (file)
@@ -977,7 +977,7 @@ bool Node::canStartSelection() const
 
 bool Node::isRegisteredWithNamedFlow() const
 {
-    return document()->renderView()->flowThreadController()->isContentNodeRegisteredWithAnyNamedFlow(this);
+    return document()->renderView()->flowThreadController().isContentNodeRegisteredWithAnyNamedFlow(this);
 }
 
 Element* Node::shadowHost() const
index 13dd4b4..3eef18a 100644 (file)
@@ -229,9 +229,9 @@ void NodeRenderingContext::moveToFlowThreadIfNeeded()
         return;
 
     ASSERT(m_node->document()->renderView());
-    FlowThreadController* flowThreadController = m_node->document()->renderView()->flowThreadController();
-    m_parentFlowRenderer = &flowThreadController->ensureRenderFlowThreadWithName(m_style->flowThread());
-    flowThreadController->registerNamedFlowContentNode(m_node, m_parentFlowRenderer);
+    FlowThreadController& flowThreadController = m_node->document()->renderView()->flowThreadController();
+    m_parentFlowRenderer = &flowThreadController.ensureRenderFlowThreadWithName(m_style->flowThread());
+    flowThreadController.registerNamedFlowContentNode(m_node, m_parentFlowRenderer);
 #endif
 }
 
index 3c1316c..18f0adf 100644 (file)
@@ -137,14 +137,14 @@ public:
         : m_view(view)
         , m_renderFlowThread(0)
     {
-        m_renderFlowThread = m_view->flowThreadController()->currentRenderFlowThread();
+        m_renderFlowThread = m_view->flowThreadController().currentRenderFlowThread();
         if (m_renderFlowThread)
-            view->flowThreadController()->setCurrentRenderFlowThread(0);
+            view->flowThreadController().setCurrentRenderFlowThread(0);
     }
     ~CurrentRenderFlowThreadDisabler()
     {
         if (m_renderFlowThread)
-            m_view->flowThreadController()->setCurrentRenderFlowThread(m_renderFlowThread);
+            m_view->flowThreadController().setCurrentRenderFlowThread(m_renderFlowThread);
     }
 private:
     RenderView* m_view;
@@ -1098,7 +1098,7 @@ bool RenderFlowThread::addForcedRegionBreak(const RenderBlock* block, LayoutUnit
 void RenderFlowThread::incrementAutoLogicalHeightRegions()
 {
     if (!m_autoLogicalHeightRegionsCount)
-        view().flowThreadController()->incrementFlowThreadsWithAutoLogicalHeightRegions();
+        view().flowThreadController().incrementFlowThreadsWithAutoLogicalHeightRegions();
     ++m_autoLogicalHeightRegionsCount;
 }
 
@@ -1107,7 +1107,7 @@ void RenderFlowThread::decrementAutoLogicalHeightRegions()
     ASSERT(m_autoLogicalHeightRegionsCount > 0);
     --m_autoLogicalHeightRegionsCount;
     if (!m_autoLogicalHeightRegionsCount)
-        view().flowThreadController()->decrementFlowThreadsWithAutoLogicalHeightRegions();
+        view().flowThreadController().decrementFlowThreadsWithAutoLogicalHeightRegions();
 }
 
 void RenderFlowThread::collectLayerFragments(LayerFragments& layerFragments, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect)
@@ -1264,19 +1264,19 @@ CurrentRenderFlowThreadMaintainer::CurrentRenderFlowThreadMaintainer(RenderFlowT
 {
     if (!m_renderFlowThread)
         return;
-    FlowThreadController* controller = m_renderFlowThread->view().flowThreadController();
-    m_previousRenderFlowThread = controller->currentRenderFlowThread();
+    FlowThreadController& controller = m_renderFlowThread->view().flowThreadController();
+    m_previousRenderFlowThread = controller.currentRenderFlowThread();
     ASSERT(!m_previousRenderFlowThread || !renderFlowThread->isRenderNamedFlowThread());
-    controller->setCurrentRenderFlowThread(m_renderFlowThread);
+    controller.setCurrentRenderFlowThread(m_renderFlowThread);
 }
 
 CurrentRenderFlowThreadMaintainer::~CurrentRenderFlowThreadMaintainer()
 {
     if (!m_renderFlowThread)
         return;
-    FlowThreadController* controller = m_renderFlowThread->view().flowThreadController();
-    ASSERT(controller->currentRenderFlowThread() == m_renderFlowThread);
-    controller->setCurrentRenderFlowThread(m_previousRenderFlowThread);
+    FlowThreadController& controller = m_renderFlowThread->view().flowThreadController();
+    ASSERT(controller.currentRenderFlowThread() == m_renderFlowThread);
+    controller.setCurrentRenderFlowThread(m_previousRenderFlowThread);
 }
 
 
index 2246a41..76f4505 100644 (file)
@@ -618,7 +618,7 @@ void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update
 void RenderLayerCompositor::updateRenderFlowThreadLayersIfNeeded()
 {
     if (m_renderView.hasRenderNamedFlowThreads())
-        m_renderView.flowThreadController()->updateRenderFlowThreadLayersIfNeeded();
+        m_renderView.flowThreadController().updateRenderFlowThreadLayersIfNeeded();
 }
 
 void RenderLayerCompositor::layerBecameNonComposited(const RenderLayer* renderLayer)
index 2f6d158..b2a6cc0 100644 (file)
@@ -412,7 +412,7 @@ void RenderNamedFlowThread::addDependencyOnFlowThread(RenderNamedFlowThread* oth
     RenderNamedFlowThreadCountedSet::AddResult result = m_layoutBeforeThreadsSet.add(otherFlowThread);
     if (result.isNewEntry) {
         // This is the first time we see this dependency. Make sure we recalculate all the dependencies.
-        view().flowThreadController()->setIsRenderNamedFlowThreadOrderDirty(true);
+        view().flowThreadController().setIsRenderNamedFlowThreadOrderDirty(true);
     }
 }
 
@@ -421,7 +421,7 @@ void RenderNamedFlowThread::removeDependencyOnFlowThread(RenderNamedFlowThread*
     bool removed = m_layoutBeforeThreadsSet.remove(otherFlowThread);
     if (removed) {
         checkInvalidRegions();
-        view().flowThreadController()->setIsRenderNamedFlowThreadOrderDirty(true);
+        view().flowThreadController().setIsRenderNamedFlowThreadOrderDirty(true);
     }
 }
 
index a6d3568..fa3522f 100644 (file)
@@ -629,7 +629,7 @@ RenderFlowThread* RenderObject::locateFlowThreadContainingBlock() const
     ASSERT(flowThreadState() != NotInsideFlowThread);
 
     // See if we have the thread cached because we're in the middle of layout.
-    RenderFlowThread* flowThread = view().flowThreadController()->currentRenderFlowThread();
+    RenderFlowThread* flowThread = view().flowThreadController().currentRenderFlowThread();
     if (flowThread)
         return flowThread;
     
@@ -2468,7 +2468,7 @@ void RenderObject::willBeDestroyed()
 #ifndef NDEBUG
     if (!documentBeingDestroyed() && view().hasRenderNamedFlowThreads()) {
         // After remove, the object and the associated information should not be in any flow thread.
-        const RenderNamedFlowThreadList* flowThreadList = view().flowThreadController()->renderNamedFlowThreadList();
+        const RenderNamedFlowThreadList* flowThreadList = view().flowThreadController().renderNamedFlowThreadList();
         for (RenderNamedFlowThreadList::const_iterator iter = flowThreadList->begin(); iter != flowThreadList->end(); ++iter) {
             const RenderNamedFlowThread* renderFlowThread = *iter;
             ASSERT(!renderFlowThread->hasChild(this));
index 4882fbc..f0f2f2a 100644 (file)
@@ -381,7 +381,7 @@ void RenderRegion::repaintFlowThreadContentRectangle(const LayoutRect& repaintRe
 
 void RenderRegion::installFlowThread()
 {
-    m_flowThread = &view().flowThreadController()->ensureRenderFlowThreadWithName(style()->regionThread());
+    m_flowThread = &view().flowThreadController().ensureRenderFlowThreadWithName(style()->regionThread());
 
     // By now the flow thread should already be added to the rendering tree,
     // so we go up the rendering parents and check that this region is not part of the same
@@ -495,7 +495,7 @@ void RenderRegion::setRegionObjectsRegionStyle()
 
     // Start from content nodes and recursively compute the style in region for the render objects below.
     // If the style in region was already computed, used that style instead of computing a new one.
-    const RenderNamedFlowThread& namedFlow = view().flowThreadController()->ensureRenderFlowThreadWithName(style()->regionThread());
+    const RenderNamedFlowThread& namedFlow = view().flowThreadController().ensureRenderFlowThreadWithName(style()->regionThread());
     const NamedFlowContentNodes& contentNodes = namedFlow.contentNodes();
 
     for (NamedFlowContentNodes::const_iterator iter = contentNodes.begin(), end = contentNodes.end(); iter != end; ++iter) {
@@ -691,7 +691,7 @@ void RenderRegion::computePreferredLogicalWidths()
 
 void RenderRegion::getRanges(Vector<RefPtr<Range> >& rangeObjects) const
 {
-    const RenderNamedFlowThread& namedFlow = view().flowThreadController()->ensureRenderFlowThreadWithName(style()->regionThread());
+    const RenderNamedFlowThread& namedFlow = view().flowThreadController().ensureRenderFlowThreadWithName(style()->regionThread());
     namedFlow.getRanges(rangeObjects, this);
 }
 
index 2454934..1569f8c 100644 (file)
@@ -696,7 +696,7 @@ static void writeRenderNamedFlowThreads(TextStream& ts, RenderView* renderView,
     if (!renderView->hasRenderNamedFlowThreads())
         return;
 
-    const RenderNamedFlowThreadList* list = renderView->flowThreadController()->renderNamedFlowThreadList();
+    const RenderNamedFlowThreadList* list = renderView->flowThreadController().renderNamedFlowThreadList();
 
     writeIndent(ts, indent);
     ts << "Flow Threads\n";
index ea3f299..2b3e61a 100644 (file)
@@ -144,7 +144,7 @@ void RenderView::layoutContent(const LayoutState& state)
 
     RenderBlock::layout();
     if (hasRenderNamedFlowThreads())
-        flowThreadController()->layoutRenderNamedFlowThreads();
+        flowThreadController().layoutRenderNamedFlowThreads();
 #ifndef NDEBUG
     checkLayoutState(state);
 #endif
@@ -212,7 +212,7 @@ bool RenderView::initializeLayoutState(LayoutState& state)
         // Set the current render flow thread to point to our ancestor. This will allow the seamless document to locate the correct
         // regions when doing a layout.
         if (seamlessAncestor->flowThreadContainingBlock()) {
-            flowThreadController()->setCurrentRenderFlowThread(seamlessAncestor->view().flowThreadController()->currentRenderFlowThread());
+            flowThreadController().setCurrentRenderFlowThread(seamlessAncestor->view().flowThreadController().currentRenderFlowThread());
             isSeamlessAncestorInFlowThread = true;
         }
     }
@@ -237,13 +237,13 @@ void RenderView::layoutContentInAutoLogicalHeightRegions(const LayoutState& stat
 {
     // We need to invalidate all the flows with auto-height regions if one such flow needs layout.
     // If none is found we do a layout a check back again afterwards.
-    if (!flowThreadController()->updateFlowThreadsNeedingLayout()) {
+    if (!flowThreadController().updateFlowThreadsNeedingLayout()) {
         // Do a first layout of the content. In some cases more layouts are not needed (e.g. only flows with non-auto-height regions have changed).
         layoutContent(state);
 
         // If we find no named flow needing a two step layout after the first layout, exit early.
         // Otherwise, initiate the two step layout algorithm and recompute all the flows.
-        if (!flowThreadController()->updateFlowThreadsNeedingTwoStepLayout())
+        if (!flowThreadController().updateFlowThreadsNeedingTwoStepLayout())
             return;
     }
 
@@ -252,7 +252,7 @@ void RenderView::layoutContentInAutoLogicalHeightRegions(const LayoutState& stat
 
     // Propagate the computed auto-height values upwards.
     // Non-auto-height regions may invalidate the flow thread because they depended on auto-height regions, but that's ok.
-    flowThreadController()->updateFlowThreadsIntoConstrainedPhase();
+    flowThreadController().updateFlowThreadsIntoConstrainedPhase();
 
     // Do one last layout that should update the auto-height regions found in the main flow
     // and solve pathological dependencies between regions (e.g. a non-auto-height region depending
@@ -269,18 +269,18 @@ void RenderView::layoutContentToComputeOverflowInRegions(const LayoutState& stat
     // First pass through the flow threads and mark the regions as needing a simple layout.
     // The regions extract the overflow from the flow thread and pass it to their containg
     // block chain.
-    flowThreadController()->updateFlowThreadsIntoOverflowPhase();
+    flowThreadController().updateFlowThreadsIntoOverflowPhase();
     if (needsLayout())
         layoutContent(state);
 
     // In case scrollbars resized the regions a new pass is necessary to update the flow threads
     // and recompute the overflow on regions. This is the final state of the flow threads.
-    flowThreadController()->updateFlowThreadsIntoFinalPhase();
+    flowThreadController().updateFlowThreadsIntoFinalPhase();
     if (needsLayout())
         layoutContent(state);
 
     // Finally reset the layout state of the flow threads.
-    flowThreadController()->updateFlowThreadsIntoMeasureContentPhase();
+    flowThreadController().updateFlowThreadsIntoMeasureContentPhase();
 }
 
 void RenderView::layout()
@@ -336,7 +336,7 @@ void RenderView::layout()
     setNeedsLayout(false);
     
     if (isSeamlessAncestorInFlowThread)
-        flowThreadController()->setCurrentRenderFlowThread(0);
+        flowThreadController().setCurrentRenderFlowThread(0);
 }
 
 LayoutUnit RenderView::pageOrViewLogicalHeight() const
@@ -1168,7 +1168,7 @@ void RenderView::styleDidChange(StyleDifference diff, const RenderStyle* oldStyl
 {
     RenderBlock::styleDidChange(diff, oldStyle);
     if (hasRenderNamedFlowThreads())
-        flowThreadController()->styleDidChange();
+        flowThreadController().styleDidChange();
 }
 
 bool RenderView::hasRenderNamedFlowThreads() const
@@ -1181,12 +1181,12 @@ bool RenderView::checkTwoPassLayoutForAutoHeightRegions() const
     return hasRenderNamedFlowThreads() && m_flowThreadController->hasFlowThreadsWithAutoLogicalHeightRegions();
 }
 
-FlowThreadController* RenderView::flowThreadController()
+FlowThreadController& RenderView::flowThreadController()
 {
     if (!m_flowThreadController)
         m_flowThreadController = FlowThreadController::create(this);
 
-    return m_flowThreadController.get();
+    return *m_flowThreadController;
 }
 
 void RenderView::pushLayoutStateForCurrentFlowThread(const RenderObject* object)
index fc246b9..f72af5d 100644 (file)
@@ -208,7 +208,7 @@ public:
     
     bool hasRenderNamedFlowThreads() const;
     bool checkTwoPassLayoutForAutoHeightRegions() const;
-    FlowThreadController* flowThreadController();
+    FlowThreadController& flowThreadController();
 
     void styleDidChange(StyleDifference, const RenderStyle* oldStyle);