Commit 135733c8 authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

DL: Ensure SimplifiedLayout handles DL elements without processing children

This patch ensures that when we're doing a simplified layout, we
consider that children might be dirty due to being blocked by a display
lock. We skip layout out the children, and also loosen a DCHECK to allow
for display locked elements to enter the simplified layout code path.

R=cbiesinger@chromium.org, chrishtr@chromium.org, ikilpatrick@chromium.org

Bug: 978166
Change-Id: I4c79c49c0dd470e06b4cbd5091b5d8125d1cf4a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1675228Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672568}
parent 7c9c3414
...@@ -322,7 +322,8 @@ scoped_refptr<const NGLayoutResult> NGBlockNode::SimplifiedLayout() { ...@@ -322,7 +322,8 @@ scoped_refptr<const NGLayoutResult> NGBlockNode::SimplifiedLayout() {
if (!box_->NeedsLayout()) if (!box_->NeedsLayout())
return previous_result; return previous_result;
DCHECK(box_->NeedsSimplifiedLayoutOnly()); DCHECK(box_->NeedsSimplifiedLayoutOnly() ||
box_->LayoutBlockedByDisplayLock(DisplayLockContext::kChildren));
// Perform layout on ourselves using the previous constraint space. // Perform layout on ourselves using the previous constraint space.
const NGConstraintSpace space( const NGConstraintSpace space(
......
...@@ -84,6 +84,11 @@ NGSimplifiedLayoutAlgorithm::NGSimplifiedLayoutAlgorithm( ...@@ -84,6 +84,11 @@ NGSimplifiedLayoutAlgorithm::NGSimplifiedLayoutAlgorithm(
} }
scoped_refptr<const NGLayoutResult> NGSimplifiedLayoutAlgorithm::Layout() { scoped_refptr<const NGLayoutResult> NGSimplifiedLayoutAlgorithm::Layout() {
// Since simplified layout's |Layout()| function deals with laying out
// children, we can early out if we are display-locked.
if (Node().LayoutBlockedByDisplayLock(DisplayLockContext::kChildren))
return container_builder_.ToBoxFragment();
const auto previous_child_fragments = const auto previous_child_fragments =
To<NGPhysicalBoxFragment>(previous_result_.PhysicalFragment()).Children(); To<NGPhysicalBoxFragment>(previous_result_.PhysicalFragment()).Children();
......
<!doctype HTML>
<html>
<meta charset="utf8">
<title>Display Locking: flex layout with child lock (reference)</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<link rel="help" href="https://github.com/WICG/display-locking">
<style>
#flexer {
display: flex;
width: 200px;
height: 300px;
background: lightgreen;
}
#container {
background: lightblue;
}
#sizer {
width: 123px;
height: 234px;
}
</style>
<div id="flexer">
<div id="container">
<div id="sizer"></div>
</div>
</div>
<!doctype HTML>
<html class="reftest-wait">
<meta charset="utf8">
<title>Display Locking: flex layout with child lock</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<link rel="help" href="https://github.com/WICG/display-locking">
<link rel="match" href="flex-with-child-lock-ref.html">
<script src="/common/reftest-wait.js"></script>
<style>
#flexer {
display: flex;
width: 200px;
height: 300px;
background: lightgreen;
}
#container {
contain: style layout;
background: lightblue;
}
</style>
<div id="flexer">
<div id="container">
<div></div>
</div>
</div>
<script>
async function runTest() {
const container = document.getElementById("container");
await container.displayLock.acquire({ timeout: Infinity, size: [123, 234] });
takeScreenshot();
}
window.onload = runTest;
</script>
</html>
<!doctype HTML>
<html>
<meta charset="utf8">
<title>Display Locking: flex layout with descendant lock (reference)</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<link rel="help" href="https://github.com/WICG/display-locking">
<style>
#flexer {
display: flex;
width: 200px;
height: 300px;
background: lightgreen;
}
#container {
background: lightblue;
}
#sizer {
width: 123px;
height: 234px;
}
</style>
<div id="flexer">
<div>
<div id="container">
<div id="sizer"></div>
</div>
</div>
</div>
<!doctype HTML>
<html class="reftest-wait">
<meta charset="utf8">
<title>Display Locking: flex layout with descendant lock</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<link rel="help" href="https://github.com/WICG/display-locking">
<link rel="match" href="flex-with-descendant-lock-ref.html">
<script src="/common/reftest-wait.js"></script>
<style>
#flexer {
display: flex;
width: 200px;
height: 300px;
background: lightgreen;
}
#container {
contain: style layout;
background: lightblue;
}
</style>
<div id="flexer">
<div>
<div id="container">
<div></div>
</div>
</div>
</div>
<script>
async function runTest() {
const container = document.getElementById("container");
await container.displayLock.acquire({ timeout: Infinity, size: [123, 234] });
takeScreenshot();
}
window.onload = runTest;
</script>
</html>
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