Skip to content

Commit

Permalink
Correct output clip of scrollbar effect nodes
Browse files Browse the repository at this point in the history
The output clip should be the parent of the current clip (the overflow
clip). Scrollbars are not clipped by the overflow clip. This didn't
cause any visible problem because we ignore the clip when we see the
PaintChunk of the scrollbar escapes the current effect's output clip,
but that caused annoying DLOG(ERROR) in PaintChunksToCcLayer for
in abnormal situation.

The incorrect output clip was added in crrev.com/1164980.

Bug: 1422877
Change-Id: I3927fa34ef8120ae9725bda57d72ddb839cf897e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4939807
Reviewed-by: Philip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1210369}
  • Loading branch information
wangxianzhu authored and Chromium LUCI CQ committed Oct 16, 2023
1 parent 901f513 commit 2623815
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2568,7 +2568,14 @@ void FragmentPaintPropertyTreeBuilder::UpdateScrollAndScrollTranslation() {
if (needs_effect_node) {
EffectPaintPropertyNode::State effect_state;
effect_state.local_transform_space = context_.current.transform;
effect_state.output_clip = context_.current.clip;
if (properties_->OverflowClip()) {
// Scrollbars are not clipped by OverflowClip, so the output
// clip should be the parent of the overflow clip.
DCHECK_EQ(context_.current.clip, properties_->OverflowClip());
effect_state.output_clip = context_.current.clip->Parent();
} else {
effect_state.output_clip = context_.current.clip;
}
effect_state.compositor_element_id =
scrollable_area->GetScrollbarElementId(orientation);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7286,4 +7286,21 @@ TEST_P(PaintPropertyTreeBuilderTest, BackgroundClipFragmented) {
gfx::RectF(200, 0, 100, 200));
}

TEST_P(PaintPropertyTreeBuilderTest, OverlayScrollbarEffects) {
SetBodyInnerHTML(R"HTML(
<div id="target" style="width: 100px; height: 100px; overflow: scroll">
<div style="height: 300px"></div>
</div>
)HTML");
CHECK(GetDocument().GetPage()->GetScrollbarTheme().UsesOverlayScrollbars());

auto* properties = PaintPropertiesForElement("target");
ASSERT_TRUE(properties);
ASSERT_TRUE(properties->OverflowClip());
EXPECT_FALSE(properties->HorizontalScrollbarEffect());
ASSERT_TRUE(properties->VerticalScrollbarEffect());
EXPECT_EQ(properties->OverflowClip()->Parent(),
properties->VerticalScrollbarEffect()->OutputClip());
}

} // namespace blink

0 comments on commit 2623815

Please sign in to comment.