Commit ad1a31b9 authored by akling@apple.com's avatar 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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154686 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f343e23a
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.
......@@ -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)
......
......@@ -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
......
......@@ -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
}
......
......@@ -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);
}
......
......@@ -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)
......
......@@ -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);
}
}
......
......@@ -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));
......
......@@ -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);
}
......
......@@ -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";
......
......@@ -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)
......
......@@ -208,7 +208,7 @@ public:
bool hasRenderNamedFlowThreads() const;
bool checkTwoPassLayoutForAutoHeightRegions() const;
FlowThreadController* flowThreadController();
FlowThreadController& flowThreadController();
void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment