From 135733c81754fb87891f681d33550d8abcc47539 Mon Sep 17 00:00:00 2001 From: Vladimir Levin Date: Wed, 26 Jun 2019 17:54:05 +0000 Subject: [PATCH] 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/+/1675228 Reviewed-by: Ian Kilpatrick Commit-Queue: vmpstr Cr-Commit-Position: refs/heads/master@{#672568} --- .../renderer/core/layout/ng/ng_block_node.cc | 3 +- .../ng/ng_simplified_layout_algorithm.cc | 5 +++ .../flex-with-child-lock-ref.html | 29 ++++++++++++++ .../flex-with-child-lock.html | 38 ++++++++++++++++++ .../flex-with-descendant-lock-ref.html | 31 ++++++++++++++ .../flex-with-descendant-lock.html | 40 +++++++++++++++++++ 6 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-child-lock-ref.html create mode 100644 third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-child-lock.html create mode 100644 third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-descendant-lock-ref.html create mode 100644 third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-descendant-lock.html diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_node.cc b/third_party/blink/renderer/core/layout/ng/ng_block_node.cc index 0c87e9b6e476ef..48a0d63f7bccbb 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_block_node.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_block_node.cc @@ -322,7 +322,8 @@ scoped_refptr 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( diff --git a/third_party/blink/renderer/core/layout/ng/ng_simplified_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/ng_simplified_layout_algorithm.cc index cb6babb6f929ff..ce4af475c3bfd2 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_simplified_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_simplified_layout_algorithm.cc @@ -84,6 +84,11 @@ NGSimplifiedLayoutAlgorithm::NGSimplifiedLayoutAlgorithm( } scoped_refptr 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(previous_result_.PhysicalFragment()).Children(); diff --git a/third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-child-lock-ref.html b/third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-child-lock-ref.html new file mode 100644 index 00000000000000..d7d651106af5f5 --- /dev/null +++ b/third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-child-lock-ref.html @@ -0,0 +1,29 @@ + + + +Display Locking: flex layout with child lock (reference) + + + + + +
+
+
+
+
+ diff --git a/third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-child-lock.html b/third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-child-lock.html new file mode 100644 index 00000000000000..0a9af371566302 --- /dev/null +++ b/third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-child-lock.html @@ -0,0 +1,38 @@ + + + +Display Locking: flex layout with child lock + + + + + + + +
+
+
+
+
+ + + diff --git a/third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-descendant-lock-ref.html b/third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-descendant-lock-ref.html new file mode 100644 index 00000000000000..48a09b84c5e7c1 --- /dev/null +++ b/third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-descendant-lock-ref.html @@ -0,0 +1,31 @@ + + + +Display Locking: flex layout with descendant lock (reference) + + + + + +
+
+
+
+
+
+
+ diff --git a/third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-descendant-lock.html b/third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-descendant-lock.html new file mode 100644 index 00000000000000..471d9dfb8c9bc4 --- /dev/null +++ b/third_party/blink/web_tests/wpt_internal/display-lock/lock-after-append/flex-with-descendant-lock.html @@ -0,0 +1,40 @@ + + + +Display Locking: flex layout with descendant lock + + + + + + + +
+
+
+
+
+
+
+ + +