Commit 47afbe8e authored by Tien-Ren Chen's avatar Tien-Ren Chen Committed by Commit Bot

[Blink] Fix under-invalidation for sticky descendants of non-composited scoller

Sticky descendants need to re-compute paint offset upon scrolled. Beside
fixing the under-invalidation, this CL also reduced the strength of the
invalidation so instead of full paint invalidation it only needs a paint
offset check.

BUG=874675

Cq-Include-Trybots: luci.chromium.try:linux-blink-gen-property-trees;luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I0e4ab3b667a6f06bfe3c584285dc2e31fa4ea7c2
Reviewed-on: https://chromium-review.googlesource.com/1182668Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Tien-Ren Chen <trchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585370}
parent ab53b635
...@@ -245,9 +245,6 @@ Bug(none) fast/borders/border-radius-mask-video.html [ Failure ] ...@@ -245,9 +245,6 @@ Bug(none) fast/borders/border-radius-mask-video.html [ Failure ]
Bug(none) fast/clip/overflow-border-radius-composited-parent.html [ Failure ] Bug(none) fast/clip/overflow-border-radius-composited-parent.html [ Failure ]
Bug(none) fast/clip/overflow-border-radius-composited.html [ Failure ] Bug(none) fast/clip/overflow-border-radius-composited.html [ Failure ]
crbug.com/874675 compositing/overflow/mixed-composited-nested-sticky-overflow-scroller.html [ Failure ]
crbug.com/874675 fast/css/sticky/sticky-clip-rel-child.html [ Failure ]
# Something wrong with vertical-rl scrollbars # Something wrong with vertical-rl scrollbars
crbug.com/853945 fast/block/positioning/vertical-rl/002.html [ Failure ] crbug.com/853945 fast/block/positioning/vertical-rl/002.html [ Failure ]
crbug.com/853945 fast/block/positioning/vertical-rl/fixed-positioning.html [ Failure ] crbug.com/853945 fast/block/positioning/vertical-rl/fixed-positioning.html [ Failure ]
......
...@@ -887,6 +887,34 @@ TEST_P(PaintAndRasterInvalidationTest, ResizeContainerOfFixedSizeSVG) { ...@@ -887,6 +887,34 @@ TEST_P(PaintAndRasterInvalidationTest, ResizeContainerOfFixedSizeSVG) {
GetDocument().View()->SetTracksPaintInvalidations(false); GetDocument().View()->SetTracksPaintInvalidations(false);
} }
TEST_P(PaintAndRasterInvalidationTest, ScrollingInvalidatesStickyOffset) {
SetBodyInnerHTML(R"HTML(
<div id="scroller" style="width:300px; height:200px; overflow:scroll">
<div id="sticky" style="position:sticky; top:50px;
width:50px; height:100px; background:red;">
<div id="inner" style="width:100px; height:50px; background:red;">
</div>
</div>
<div style="height:1000px;"></div>
</div>
)HTML");
Element* scroller = GetDocument().getElementById("scroller");
scroller->setScrollTop(100);
const auto* sticky = GetLayoutObjectByElementId("sticky");
EXPECT_TRUE(sticky->ShouldCheckForPaintInvalidation());
EXPECT_EQ(LayoutPoint(0, 50), sticky->FirstFragment().PaintOffset());
const auto* inner = GetLayoutObjectByElementId("inner");
EXPECT_EQ(LayoutPoint(0, 50), inner->FirstFragment().PaintOffset());
GetDocument().View()->UpdateAllLifecyclePhases();
EXPECT_FALSE(sticky->ShouldCheckForPaintInvalidation());
EXPECT_EQ(LayoutPoint(0, 150), sticky->FirstFragment().PaintOffset());
EXPECT_EQ(LayoutPoint(0, 150), inner->FirstFragment().PaintOffset());
}
class PaintInvalidatorTestClient : public EmptyChromeClient { class PaintInvalidatorTestClient : public EmptyChromeClient {
public: public:
void InvalidateRect(const IntRect&) override { void InvalidateRect(const IntRect&) override {
......
...@@ -509,6 +509,8 @@ void PaintLayerScrollableArea::UpdateScrollOffset( ...@@ -509,6 +509,8 @@ void PaintLayerScrollableArea::UpdateScrollOffset(
void PaintLayerScrollableArea::InvalidatePaintForScrollOffsetChange( void PaintLayerScrollableArea::InvalidatePaintForScrollOffsetChange(
bool offset_was_zero) { bool offset_was_zero) {
InvalidatePaintForStickyDescendants();
bool requires_paint_invalidation = false; bool requires_paint_invalidation = false;
// "background-attachment: local" causes the background of this element to // "background-attachment: local" causes the background of this element to
...@@ -554,13 +556,9 @@ void PaintLayerScrollableArea::InvalidatePaintForScrollOffsetChange( ...@@ -554,13 +556,9 @@ void PaintLayerScrollableArea::InvalidatePaintForScrollOffsetChange(
bool is_root_layer = Layer()->IsRootLayer(); bool is_root_layer = Layer()->IsRootLayer();
frame_view->InvalidateBackgroundAttachmentFixedDescendants(*GetLayoutBox()); frame_view->InvalidateBackgroundAttachmentFixedDescendants(*GetLayoutBox());
if (is_root_layer) { if (is_root_layer && frame_view->HasViewportConstrainedObjects() &&
// Some special invalidations for the root layer. !frame_view->InvalidateViewportConstrainedObjects()) {
if (frame_view->HasViewportConstrainedObjects()) { requires_paint_invalidation = true;
if (!frame_view->InvalidateViewportConstrainedObjects())
requires_paint_invalidation = true;
}
InvalidatePaintForStickyDescendants();
} }
if (requires_paint_invalidation) { if (requires_paint_invalidation) {
...@@ -1893,7 +1891,7 @@ bool PaintLayerScrollableArea::HasNonCompositedStickyDescendants() const { ...@@ -1893,7 +1891,7 @@ bool PaintLayerScrollableArea::HasNonCompositedStickyDescendants() const {
void PaintLayerScrollableArea::InvalidatePaintForStickyDescendants() { void PaintLayerScrollableArea::InvalidatePaintForStickyDescendants() {
if (PaintLayerScrollableAreaRareData* d = RareData()) { if (PaintLayerScrollableAreaRareData* d = RareData()) {
for (PaintLayer* sticky_layer : d->sticky_constraints_map_.Keys()) for (PaintLayer* sticky_layer : d->sticky_constraints_map_.Keys())
sticky_layer->GetLayoutObject().SetSubtreeShouldDoFullPaintInvalidation(); sticky_layer->GetLayoutObject().SetShouldCheckForPaintInvalidation();
} }
} }
......
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