Commit 7b0f78da authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

blink: make LayoutBlock::RemovePositionedObject remove other objects

This changes RemovePositionedObjects to remove any fixed-pos descendants.
This ensures that if the removed object is added back, it doesn't end up
after any descendants, which would cause out of order layout.

BUG=1092887
TEST=webkit-box-fixed-position-child.html

Change-Id: I41f01bad74048cf4983f0dda5fe0f073b3eb38f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2248136Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779840}
parent fdd2122d
......@@ -1000,6 +1000,23 @@ void LayoutBlock::RemovePositionedObject(LayoutBox* o) {
DCHECK(positioned_descendants);
DCHECK(positioned_descendants->Contains(o));
positioned_descendants->erase(o);
// To ensure |positioned_descendants| remains in tree order, remove any fixed
// positioned descendants. This ensures if |o| is added back, it doesn't end
// up after any descendants. This is to ensure layout of fixed position
// elements happens in tree-order.
for (auto it = positioned_descendants->begin();
it != positioned_descendants->end();) {
LayoutBox* box = *it;
auto current_it = it;
++it;
if (box->IsFixedPositioned() && box->IsDescendantOf(o)) {
g_positioned_container_map->Take(box);
positioned_descendants->erase(current_it);
box->SetNeedsLayout(layout_invalidation_reason::kAncestorMoved);
} else {
break;
}
}
if (positioned_descendants->IsEmpty()) {
g_positioned_descendants_map->erase(container);
container->has_positioned_objects_ = false;
......
<!doctype html>
<title>Verifies changing 'display' with a fixed position webkit-box that
has a fixed position child</title>
<body>
<div id="outer" style="position:fixed;">
<div style="display:-webkit-box; float:left; padding-left:100%;">
<div style="position:fixed; width:100px; height:100px;"></div>
</div>
<div style="display:inline-block; width:100px; height:20px;"></div>
</div>
<div id="elm"></div>
A
</body>
<script>
document.body.offsetTop;
elm.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