Commit 41d91b8e authored by pdr@chromium.org's avatar pdr@chromium.org

[FastTextAutosizer] Refactor FTA::inflate() to be internal to FTA

This patch moves inflate() to be a private internal detail of
FastTextAutosizer and relies on beginLayout to call inflate. This
patch also has a minor cleanup removing an untrue FIXME in inflate().

No new tests as this is just a refactoring.

BUG=302005

Review URL: https://codereview.chromium.org/138143004

git-svn-id: svn://svn.chromium.org/blink/trunk@165134 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent cb778953
......@@ -83,6 +83,18 @@ void FastTextAutosizer::beginLayout(RenderBlock* block)
if (shouldBeClusterRoot(block))
m_clusterStack.append(getOrCreateCluster(block));
if (block->childrenInline())
inflate(block);
}
void FastTextAutosizer::endLayout(RenderBlock* block)
{
if (!enabled())
return;
if (!m_clusterStack.isEmpty() && m_clusterStack.last()->m_root == block)
m_clusterStack.removeLast();
}
void FastTextAutosizer::inflate(RenderBlock* block)
......@@ -94,7 +106,6 @@ void FastTextAutosizer::inflate(RenderBlock* block)
// localMultiplier is used to prevent inflation of some containers such as a row of links.
float localMultiplier = TextAutosizer::containerShouldBeAutosized(block) ? cluster->m_multiplier : 1;
// FIXME: Add an optimization to not do this walk if it's not needed.
for (InlineWalker walker(block); !walker.atEnd(); walker.advance()) {
RenderObject* inlineObj = walker.current();
if (inlineObj->isText()) {
......@@ -104,15 +115,6 @@ void FastTextAutosizer::inflate(RenderBlock* block)
}
}
void FastTextAutosizer::endLayout(RenderBlock* block)
{
if (!enabled())
return;
if (!m_clusterStack.isEmpty() && m_clusterStack.last()->m_root == block)
m_clusterStack.removeLast();
}
bool FastTextAutosizer::enabled()
{
return m_document->settings()
......
......@@ -62,7 +62,6 @@ public:
void destroy(RenderBlock*);
void beginLayout(RenderBlock*);
void inflate(RenderBlock*);
void endLayout(RenderBlock*);
private:
......@@ -98,6 +97,7 @@ private:
explicit FastTextAutosizer(Document*);
void inflate(RenderBlock*);
bool enabled();
void prepareRenderViewInfo(RenderView*);
bool shouldBeClusterRoot(RenderBlock*);
......
......@@ -308,15 +308,16 @@ void RenderBlockFlow::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalH
LayoutUnit previousHeight = logicalHeight();
setLogicalHeight(beforeEdge);
FastTextAutosizer* textAutosizer = document().fastTextAutosizer();
if (textAutosizer)
textAutosizer->beginLayout(this);
m_repaintLogicalTop = 0;
m_repaintLogicalBottom = 0;
LayoutUnit maxFloatLogicalBottom = 0;
if (!firstChild() && !isAnonymousBlock())
setChildrenInline(true);
FastTextAutosizer* textAutosizer = document().fastTextAutosizer();
if (textAutosizer)
textAutosizer->beginLayout(this);
if (childrenInline())
layoutInlineChildren(relayoutChildren, m_repaintLogicalTop, m_repaintLogicalBottom, afterEdge);
else
......
......@@ -1550,9 +1550,6 @@ void RenderBlockFlow::repaintDirtyFloats(Vector<FloatWithRect>& floats)
void RenderBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom, LayoutUnit afterEdge)
{
if (FastTextAutosizer* textAutosizer = document().fastTextAutosizer())
textAutosizer->inflate(this);
// Lay out our hypothetical grid line as though it occurs at the top of the block.
if (view()->layoutState() && view()->layoutState()->lineGrid() == this)
layoutLineGridBox();
......
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