Skip to content

Commit

Permalink
chore: cherry-pick d8d64b7cd244 from chromium (#26893)
Browse files Browse the repository at this point in the history
* chore: cherry-pick d8d64b7cd244 from chromium

* update patches

Co-authored-by: Electron Bot <electron@github.com>
  • Loading branch information
2 people authored and belenko committed Dec 14, 2020
1 parent 0e49e76 commit 6619d0d
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 0 deletions.
1 change: 1 addition & 0 deletions patches/chromium/.patches
Expand Up @@ -155,6 +155,7 @@ make_macos_os_version_numbers_consistent.patch
ignore_renderframehostimpl_detach_for_speculative_rfhs.patch
ui_check_that_unpremultiply_is_passed_a_32bpp_image.patch
cherry-pick-eec5025668f8.patch
cherry-pick-d8d64b7cd244.patch
cherry-pick-5ffbb7ed173a.patch
propagate_disable-dev-shm-usage_to_child_processes.patch
cherry-pick-bbc6ab5bb49c.patch
Expand Down
132 changes: 132 additions & 0 deletions patches/chromium/cherry-pick-d8d64b7cd244.patch
@@ -0,0 +1,132 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Xianzhu Wang <wangxianzhu@chromium.org>
Date: Mon, 16 Nov 2020 17:26:33 +0000
Subject: Ensure change type for OverflowControlsClip is returned

This at least ensures that we will update the paint properites for the
composited overflow control layers in pre-CompositeAfterPaint to avoid
stale properties on the layers.

The test doesn't actually reproduce the bug because any test simpler
than the bug case couldn't reproduce the bug as the update would be
triggered in other code paths (any style change, layout change, etc.).

Anyway this CL does fix the bug case.

TBR=wangxianzhu@chromium.org

(cherry picked from commit c20bb9897ef6d26a46391a4dc1658c5d33e0c100)

(cherry picked from commit cfb81e677a508871f56d8bec958d0b585298ae0c)

Bug: 1137603
Change-Id: I5cca970bcf8cda6085527f79a97f269c4e3e9986
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2500264
Reviewed-by: Stefan Zager <szager@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Original-Original-Commit-Position: refs/heads/master@{#820986}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536910
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Original-Commit-Position: refs/branch-heads/4240@{#1446}
Cr-Original-Branched-From: f297677702651916bbf65e59c0d4bbd4ce57d1ee-refs/heads/master@{#800218}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2540592
Reviewed-by: Victor-Gabriel Savu <vsavu@google.com>
Commit-Queue: Jana Grill <janagrill@chromium.org>
Cr-Commit-Position: refs/branch-heads/4240_112@{#26}
Cr-Branched-From: 427c00d3874b6abcf4c4c2719768835fc3ef26d6-refs/branch-heads/4240@{#1291}
Cr-Branched-From: f297677702651916bbf65e59c0d4bbd4ce57d1ee-refs/heads/master@{#800218}

diff --git a/third_party/blink/renderer/core/paint/compositing/compositing_layer_property_updater_test.cc b/third_party/blink/renderer/core/paint/compositing/compositing_layer_property_updater_test.cc
index b7946eb567463938066b54ecd54ca710f649380e..f7ff1d68e36840c8647b863943f8c9134233c8ee 100644
--- a/third_party/blink/renderer/core/paint/compositing/compositing_layer_property_updater_test.cc
+++ b/third_party/blink/renderer/core/paint/compositing/compositing_layer_property_updater_test.cc
@@ -174,4 +174,56 @@ TEST_F(CompositingLayerPropertyUpdaterTest,
}
}

+TEST_F(CompositingLayerPropertyUpdaterTest, OverflowControlsClip) {
+ SetBodyInnerHTML(R"HTML(
+ <style>
+ ::-webkit-scrollbar { width: 20px; }
+ #container {
+ width: 5px;
+ height: 100px;
+ }
+ #target {
+ overflow: scroll;
+ will-change: transform;
+ width: 100%;
+ height: 100%;
+ }
+ </style>
+ <div id="container">
+ <div id="target"></div>
+ </div>
+ )HTML");
+
+ // Initially the vertical scrollbar overflows the narrow border box.
+ auto* container = GetDocument().getElementById("container");
+ auto* target = ToLayoutBox(GetLayoutObjectByElementId("target"));
+ auto* scrollbar_layer =
+ target->GetScrollableArea()->GraphicsLayerForVerticalScrollbar();
+ auto target_state = target->FirstFragment().LocalBorderBoxProperties();
+ auto scrollbar_state = target_state;
+ auto* overflow_controls_clip =
+ target->FirstFragment().PaintProperties()->OverflowControlsClip();
+ ASSERT_TRUE(overflow_controls_clip);
+ scrollbar_state.SetClip(*overflow_controls_clip);
+ EXPECT_EQ(scrollbar_state, scrollbar_layer->GetPropertyTreeState());
+
+ // Widen target to make the vertical scrollbar contained by the border box.
+ container->setAttribute(html_names::kStyleAttr, "width: 100px");
+ UpdateAllLifecyclePhasesForTest();
+ LOG(ERROR) << target->Size();
+ EXPECT_FALSE(
+ target->FirstFragment().PaintProperties()->OverflowControlsClip());
+ EXPECT_EQ(target_state, scrollbar_layer->GetPropertyTreeState());
+
+ // Narrow down target back.
+ container->removeAttribute(html_names::kStyleAttr);
+ UpdateAllLifecyclePhasesForTest();
+ scrollbar_state = target_state;
+ overflow_controls_clip =
+ target->FirstFragment().PaintProperties()->OverflowControlsClip();
+ ASSERT_TRUE(overflow_controls_clip);
+ scrollbar_state.SetClip(*overflow_controls_clip);
+ EXPECT_EQ(scrollbar_state, scrollbar_layer->GetPropertyTreeState());
+}
+
} // namespace blink
diff --git a/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc b/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc
index 6810fb3e4f7ba1c994812c3fa983009792e00cc4..7d391839432a7d11102db78ef84b6369357eb77f 100644
--- a/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc
+++ b/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc
@@ -1525,21 +1525,21 @@ void FragmentPaintPropertyTreeBuilder::UpdateOverflowControlsClip() {

if (NeedsOverflowControlsClip()) {
// Clip overflow controls to the border box rect. Not wrapped with
- // OnUpdateClip() because this clip doesn't affect descendants.
+ // OnUpdateClip() because this clip doesn't affect descendants. Wrap with
+ // OnUpdate() to let PrePaintTreeWalk see the change. This may cause
+ // unnecessary subtree update, but is not a big deal because it is rare.
const auto& clip_rect = PhysicalRect(context_.current.paint_offset,
ToLayoutBox(object_).Size());
- properties_->UpdateOverflowControlsClip(
+ OnUpdate(properties_->UpdateOverflowControlsClip(
*context_.current.clip,
ClipPaintPropertyNode::State(context_.current.transform,
FloatRoundedRect(FloatRect(clip_rect)),
- ToSnappedClipRect(clip_rect)));
+ ToSnappedClipRect(clip_rect))));
} else {
- properties_->ClearOverflowControlsClip();
+ OnClear(properties_->ClearOverflowControlsClip());
}

- // No need to set force_subtree_update_reasons and clip_changed because
- // OverflowControlsClip applies to overflow controls only, not descendants.
- // We also don't walk into custom scrollbars in PrePaintTreeWalk and
+ // We don't walk into custom scrollbars in PrePaintTreeWalk because
// LayoutObjects under custom scrollbars don't support paint properties.
}

0 comments on commit 6619d0d

Please sign in to comment.