Commit 67818d55 authored by robhogan's avatar robhogan Committed by Commit bot

Collapse away nested anonymous blocks

https://crrev.com/59d3539fc7ce60355ccf52c00733d33dde5e118a stopped collapsing:

       LayoutBlockFlow (anonymous) at (0,0)
          LayoutBlockFlow (anonymous) at (0,0)
            LayoutInline {SPAN} at (0,0)

to

       LayoutBlockFlow (anonymous) at (0,0)
         LayoutInline {SPAN} at (0,0)

Reinstate that behaviour!

BUG=627149

Review-Url: https://codereview.chromium.org/2176043002
Cr-Commit-Position: refs/heads/master@{#407551}
parent 8b895f66
<!DOCTYPE html>
<style>
#container {
text-indent: -300px;
width: 300px;
}
</style>
<p>crbug.com/627149: Collapse away nested anonymous blocks. There should be no text below.</p>
<button id="container">
<span id="span">Text.</span>
</button>
<!DOCTYPE html>
<style>
#container {
text-indent: -300px;
width: 300px;
}
</style>
<p>crbug.com/627149: Collapse away nested anonymous blocks. There should be no text below.</p>
<button id="container">
<span id="span">Text.</span>
</button>
<script>
var container = document.getElementById('container');
var div = document.createElement('div');
container.insertBefore(div, document.getElementById('span'));
document.body.offsetTop;
container.removeChild(div);
</script>
......@@ -2403,6 +2403,11 @@ void LayoutBlockFlow::addChild(LayoutObject* newChild, LayoutObject* beforeChild
}
}
static bool isMergeableAnonymousBlock(const LayoutBlockFlow* block)
{
return block->isAnonymousBlock() && !block->continuation() && !block->beingDestroyed() && !block->isRubyRun() && !block->isRubyBase();
}
void LayoutBlockFlow::removeChild(LayoutObject* oldChild)
{
// No need to waste time in merging or removing empty anonymous blocks.
......@@ -2428,11 +2433,12 @@ void LayoutBlockFlow::removeChild(LayoutObject* oldChild)
LayoutBlock::removeChild(oldChild);
LayoutObject* child = prev ? prev : next;
if (mergedAnonymousBlocks && child && !child->previousSibling() && !child->nextSibling()) {
// The removal has knocked us down to containing only a single anonymous
// box. We can go ahead and pull the content right back up into our
if (child && child->isLayoutBlockFlow() && !child->previousSibling() && !child->nextSibling()) {
// If the removal has knocked us down to containing only a single anonymous
// box we can go ahead and pull the content right back up into our
// box.
collapseAnonymousBlockChild(toLayoutBlockFlow(child));
if (mergedAnonymousBlocks || isMergeableAnonymousBlock(toLayoutBlockFlow(child)))
collapseAnonymousBlockChild(toLayoutBlockFlow(child));
}
if (!firstChild()) {
......@@ -2554,11 +2560,6 @@ void LayoutBlockFlow::collapseAnonymousBlockChild(LayoutBlockFlow* child)
child->destroy();
}
static bool isMergeableAnonymousBlock(const LayoutBlockFlow* block)
{
return block->isAnonymousBlock() && !block->continuation() && !block->beingDestroyed() && !block->isRubyRun() && !block->isRubyBase();
}
bool LayoutBlockFlow::mergeSiblingContiguousAnonymousBlock(LayoutBlockFlow* siblingThatMayBeDeleted)
{
// Note: |this| and |siblingThatMayBeDeleted| may not be adjacent siblings at this point. There
......
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