Commit d4cf8bcd authored by pdr@chromium.org's avatar pdr@chromium.org

[FastTextAutosizer] Do not inflate blocks with no children

This patch fixes a crash on empty documents where a cluster would not
get created and we would crash during inflation. I've changed
beginLayout to only call inflate when a block has children, and
refactored endLayout similarly.

BUG=348458
NOTRY=true

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

git-svn-id: svn://svn.chromium.org/blink/trunk@168352 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 5084a6ab
Test for crbug.com/348458: this test passes if it does not crash. PASS
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=800">
<style>
body {
width: 800px;
margin: 0;
overflow-y: hidden;
}
</style>
<script src="resources/autosizingTest.js"></script>
</head>
<body>
Test for crbug.com/348458: this test passes if it does not crash.
<script>
// Create an iframe with no content (html, body) except for the document.
// Note: splitting the end script tag is requried to prevent closing the script we are in.
document.body.innerHTML += "<iframe src='data:text/html,<body><script>document.removeChild(document.body.parentElement)</s" + "cript>'></body></iframe>";
var forceLayout = document.getElementsByTagName('iframe')[0].offsetWidth;
document.write("PASS");
if (testRunner)
testRunner.dumpAsText();
</script>
</body>
</html>
......@@ -136,7 +136,7 @@ void FastTextAutosizer::beginLayout(RenderBlock* block)
inflateTable(toRenderTable(block));
}
if (block->childrenInline())
if (block->childrenInline() && block->firstChild())
inflate(block);
}
......@@ -198,9 +198,6 @@ void FastTextAutosizer::endLayout(RenderBlock* block)
{
ASSERT(enabled());
if (currentCluster()->m_root == block)
m_clusterStack.removeLast();
if (block == m_firstBlock) {
m_firstBlock = 0;
m_clusterStack.clear();
......@@ -208,6 +205,8 @@ void FastTextAutosizer::endLayout(RenderBlock* block)
#ifndef NDEBUG
m_blocksThatHaveBegunLayout.clear();
#endif
} else if (currentCluster()->m_root == block) {
m_clusterStack.removeLast();
}
}
......
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