Commit 141c10c8 authored by yigu's avatar yigu Committed by Commit bot

Fix CSS clips cannot be correctly handled by composited scroller

BUG=645957
TEST=PaintLayerScrollableAreaTest.OnlyAutoClippedScrollingContentsLayerPromoted
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2595593002
Cr-Commit-Position: refs/heads/master@{#440925}
parent 32af9a84
......@@ -1762,7 +1762,8 @@ bool PaintLayerScrollableArea::computeNeedsCompositedScrolling(
// with the results.
return !(layer->size().isEmpty() || layer->hasDescendantWithClipPath() ||
layer->hasAncestorWithClipPath() ||
layer->layoutObject()->style()->hasBorderRadius());
layer->layoutObject()->style()->hasBorderRadius() ||
layer->layoutObject()->hasClip());
}
void PaintLayerScrollableArea::addStyleRelatedMainThreadScrollingReasons(
......
......@@ -462,4 +462,40 @@ TEST_F(PaintLayerScrollableAreaTest, OverlayScrollbarColorThemeUpdated) {
ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeLight,
blackLayer->getScrollableArea()->getScrollbarOverlayColorTheme());
}
// Test that css clip applied to the scroller will cause the
// scrolling contents layer to not be promoted.
TEST_F(PaintLayerScrollableAreaTest,
OnlyAutoClippedScrollingContentsLayerPromoted) {
setBodyInnerHTML(
"<style>"
".clip { clip: rect(0px,60px,50px,0px); }"
"#scroller { position: absolute; overflow: auto;"
"height: 100px; width: 100px; background: grey;"
"will-change:transform; }"
"#scrolled { height: 300px; }"
"</style>"
"<div id=\"scroller\"><div id=\"scrolled\"></div></div>");
document().view()->updateAllLifecyclePhases();
Element* scroller = document().getElementById("scroller");
PaintLayer* paintLayer =
toLayoutBoxModelObject(scroller->layoutObject())->layer();
ASSERT_TRUE(paintLayer);
EXPECT_TRUE(paintLayer->needsCompositedScrolling());
// Add clip to scroller.
scroller->setAttribute("class", "clip", ASSERT_NO_EXCEPTION);
document().view()->updateAllLifecyclePhases();
paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
ASSERT_TRUE(paintLayer);
EXPECT_FALSE(paintLayer->needsCompositedScrolling());
// Change the scroller to be auto clipped again.
scroller->removeAttribute("class");
document().view()->updateAllLifecyclePhases();
paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
ASSERT_TRUE(paintLayer);
EXPECT_TRUE(paintLayer->needsCompositedScrolling());
}
}
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