Skip to content

Commit

Permalink
DL: Ensure SimplifiedLayout handles DL elements without processing ch…
Browse files Browse the repository at this point in the history
…ildren

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.

[email protected], [email protected], [email protected]

Bug: 978166
Change-Id: I4c79c49c0dd470e06b4cbd5091b5d8125d1cf4a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1675228
Reviewed-by: Ian Kilpatrick <[email protected]>
Commit-Queue: vmpstr <[email protected]>
Cr-Commit-Position: refs/heads/master@{#672568}
  • Loading branch information
vmpstr authored and Commit Bot committed Jun 26, 2019
1 parent 7c9c341 commit 135733c
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 1 deletion.
3 changes: 2 additions & 1 deletion third_party/blink/renderer/core/layout/ng/ng_block_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ scoped_refptr<const NGLayoutResult> NGBlockNode::SimplifiedLayout() {
if (!box_->NeedsLayout())
return previous_result;

DCHECK(box_->NeedsSimplifiedLayoutOnly());
DCHECK(box_->NeedsSimplifiedLayoutOnly() ||
box_->LayoutBlockedByDisplayLock(DisplayLockContext::kChildren));

// Perform layout on ourselves using the previous constraint space.
const NGConstraintSpace space(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ NGSimplifiedLayoutAlgorithm::NGSimplifiedLayoutAlgorithm(
}

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 =
To<NGPhysicalBoxFragment>(previous_result_.PhysicalFragment()).Children();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!doctype HTML>
<html>
<meta charset="utf8">
<title>Display Locking: flex layout with child lock (reference)</title>
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
<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>

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!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:[email protected]">
<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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype HTML>
<html>
<meta charset="utf8">
<title>Display Locking: flex layout with descendant lock (reference)</title>
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
<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>

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!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:[email protected]">
<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>

0 comments on commit 135733c

Please sign in to comment.