Commit 48919b7a authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

Remove anonymous block wrapper when inline continuation is removed.

Keeping empty anonymous blocks around is bad. The only known actual
problem is in multicol (but it may cause other issues too). Based on the
layout object tree, multicol creates anonymous LayoutMultiColumnSet and
LayoutMultiColumnSpannerPlaceholder objects, to keep track of what is
regular column content and what are spanners. Leaving a
LayoutMultiColumnSet around just for the sake of an empty anonymous
block (which may get cleaned up without notifying the multicol code)
will confuse multicol layout.

Bug: 1102137
Change-Id: Ibfb46d0dc173ecfdb2e7903efee5a49de3da3ff3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2283355
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786197}
parent 93a58ba3
...@@ -3493,9 +3493,26 @@ void LayoutObject::DestroyAndCleanupAnonymousWrappers() { ...@@ -3493,9 +3493,26 @@ void LayoutObject::DestroyAndCleanupAnonymousWrappers() {
if (destroy_root_parent->IsLayoutFlowThread()) if (destroy_root_parent->IsLayoutFlowThread())
break; break;
if (destroy_root->PreviousSibling() || destroy_root->NextSibling()) // We need to keep the anonymous parent, if it won't become empty by the
break; // Need to keep the anonymous parent, since it won't become empty // removal of this LayoutObject.
// by the removal of this LayoutObject. if (destroy_root->PreviousSibling())
break;
if (const LayoutObject* sibling = destroy_root->NextSibling()) {
if (destroy_root->GetNode()) {
// When there are inline continuations, there may be multiple layout
// objects generated from the same node, and those are special. They
// will be removed as part of destroying |this|, in
// LayoutInline::WillBeDestroyed(). So if that's all we have left, we
// need to realize now that the anonymous containing block will become
// empty. So we have to destroy it.
while (sibling && sibling->GetNode() == destroy_root->GetNode())
sibling = sibling->NextSibling();
}
if (sibling)
break;
DCHECK(destroy_root->IsLayoutInline());
DCHECK(ToLayoutInline(destroy_root)->Continuation());
}
} }
destroy_root->Destroy(); destroy_root->Destroy();
......
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1102137">
<div style="columns:3;">
<span id="inlineWithBlock"><div></div></span><div id="spanner1" style="column-span:all;"></div>
<div id="spanner2" style="display:none; column-span:all;"></div>
<div id="block1" style="display:none;"></div>
<div id="spanner3" style="display:none; column-span:all;"></div>
<div id="block2" style="display:none;"></div>
</div>
<script>
document.body.offsetTop;
inlineWithBlock.style.display = "none";
document.body.offsetTop;
spanner1.style.display = "none";
document.body.offsetTop;
spanner2.style.display = "block";
document.body.offsetTop;
block1.style.display = "block";
block2.style.display = "block";
document.body.offsetTop;
spanner3.style.display = "block";
</script>
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/css-multicol-1/#column-span">
<meta name="assert" content="Margins of two adjacent spanners will collapse with each other">
<link rel="match" href="../reference/ref-filled-green-100px-square-only.html">
<style>
#spanner1 {
column-span: all;
margin-bottom: 100px;
}
#spanner2 {
column-span: all;
margin-top: 100px;
}
</style>
<p>Test passes if there is a filled green square.</p>
<div style="columns:3; width:100px; background:green;">
<div id="spanner1"></div>
<span id="inlineWithBlock"><div></div></span><div id="spanner2"></div>
</div>
<script>
document.body.offsetTop;
inlineWithBlock.style.display = "none";
</script>
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