Commit 09aad079 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

blink: makes positioned objects appear at end

This helps ensure positioned objects are laid out in tree order.

BUG=1098840

Change-Id: I33b4290101e1c6e684a29330268e3f2f052fb7a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2264951Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783009}
parent 7016aebf
......@@ -975,6 +975,7 @@ void LayoutBlock::InsertPositionedObject(LayoutBox* o) {
if (container_map_it->value == this) {
DCHECK(HasPositionedObjects());
DCHECK(PositionedObjects()->Contains(o));
PositionedObjects()->AppendOrMoveToLast(o);
return;
}
RemovePositionedObject(o);
......@@ -1010,23 +1011,6 @@ 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>
<link rel="help" href="https://crbug.com/1098840">
<title>Verifies changing 'display' nested positions is not problematic</title>
<div style="position:absolute; display:table;">
<div style="position:fixed;"></div>
</div>
<span></span>
<div id="boom" style="display:none;"></div>
<script>
document.body.offsetTop;
boom.style.display = "block";
</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