Commit 7f27f699 authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

DL: Optimize PositionAndLayoutOnceIfNeeded() for display locking.

In display locking, we don't process subtrees of locked elements. In
PositionAndLayoutOnceIfNeeded, we can use this information to skip
recursing into layout code, which would abort child layout anyway.

This takes the referenced bug case from 250ms per unlock to 110ms per
unlock.

R=mstensho@chromium.org, ikilpatrick@chromium.org

Bug: 958804
Change-Id: Ied76301cb006894f3160f8243c58f9a753ed8fd2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1596837
Commit-Queue: vmpstr <vmpstr@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657251}
parent 1a86aea2
......@@ -807,7 +807,14 @@ bool LayoutBlockFlow::PositionAndLayoutOnceIfNeeded(
SetLogicalTopForChild(child, new_logical_top);
SubtreeLayoutScope layout_scope(child);
if (!child.NeedsLayout()) {
auto child_needs_layout = [&child] {
if (!child.NeedsLayout())
return false;
return child.SelfNeedsLayout() ||
!child.LayoutBlockedByDisplayLock(DisplayLockContext::kChildren);
};
if (!child_needs_layout()) {
// Like in MarkDescendantsWithFloatsForLayoutIfNeeded, we only need
// to mark this object for layout if it actually is affected by a float
if (new_logical_top != old_logical_top && child.ShrinkToAvoidFloats() &&
......@@ -821,7 +828,7 @@ bool LayoutBlockFlow::PositionAndLayoutOnceIfNeeded(
}
}
bool needed_layout = child.NeedsLayout();
bool needed_layout = child_needs_layout();
if (needed_layout)
child.UpdateLayout();
if (View()->GetLayoutState()->IsPaginated())
......
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