Commit 4a9bae1e authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

DL: Use exclusive ancestors for forcing if we don't have to do self-updates.

This patch ensures that when we force the update on a display locked
element, we prefer using exclusive ancestors (ie still skip the subtree
walk), unless self layout was prevented.

If self layout is not prevented, then we shouldn't need to unlock the
element as all of the updates on it would normally happen anyway.

R=chrishtr@chromium.org, rakina@chromium.org

Bug: 954063
Change-Id: Ie41598c80fe6364c9f0b7758b59505d4af35e3c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1613369Reviewed-by: default avatarRakina Zata Amni <rakina@chromium.org>
Commit-Queue: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660079}
parent 84759f63
...@@ -67,12 +67,26 @@ DisplayLockUtilities::ScopedChainForcedUpdate::ScopedChainForcedUpdate( ...@@ -67,12 +67,26 @@ DisplayLockUtilities::ScopedChainForcedUpdate::ScopedChainForcedUpdate(
return; return;
} }
const_cast<Node*>(node)->UpdateDistributionForFlatTreeTraversal(); const_cast<Node*>(node)->UpdateDistributionForFlatTreeTraversal();
// Get the right ancestor view. Only use inclusive ancestors if the node
// itself is locked and it prevents self layout. If self layout is not
// prevented, we don't need to force the subtree layout, so use exclusive
// ancestors in that case.
auto ancestor_view = [node] {
if (node->IsElementNode()) {
auto* context = ToElement(node)->GetDisplayLockContext();
if (context && !context->ShouldLayout(DisplayLockContext::kSelf))
return FlatTreeTraversal::InclusiveAncestorsOf(*node);
}
return FlatTreeTraversal::AncestorsOf(*node);
}();
// TODO(vmpstr): This is somewhat inefficient, since we would pay the cost // TODO(vmpstr): This is somewhat inefficient, since we would pay the cost
// of traversing the ancestor chain even for nodes that are not in the // of traversing the ancestor chain even for nodes that are not in the
// locked subtree. We need to figure out if there is a supplementary // locked subtree. We need to figure out if there is a supplementary
// structure that we can use to quickly identify nodes that are in the // structure that we can use to quickly identify nodes that are in the
// locked subtree. // locked subtree.
for (Node& ancestor : FlatTreeTraversal::InclusiveAncestorsOf(*node)) { for (Node& ancestor : ancestor_view) {
if (!ancestor.IsElementNode()) if (!ancestor.IsElementNode())
continue; continue;
if (auto* context = ToElement(ancestor).GetDisplayLockContext()) if (auto* context = ToElement(ancestor).GetDisplayLockContext())
......
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