Skip to content

Commit 3e92c6f

Browse files
committed
Properly invalidate backings of squashed content when it loses its squashing layer.
Previously, in such situations we failed to mark the layer as needing layer requirements update, which already has code to issue an invalidation on the new backing of the content now that it lost squashing. Bug: 865415 [email protected] (cherry picked from commit afd0623) Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel Change-Id: I807bf1426e45ce71ed42024512e9c77481f018cc Reviewed-on: https://chromium-review.googlesource.com/1145896 Commit-Queue: Chris Harrelson <[email protected]> Reviewed-by: Tien-Ren Chen <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#577404} Reviewed-on: https://chromium-review.googlesource.com/1149615 Reviewed-by: Chris Harrelson <[email protected]> Cr-Commit-Position: refs/branch-heads/3497@{#62} Cr-Branched-From: 271eaf5-refs/heads/master@{#576753}
1 parent 971df0f commit 3e92c6f

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,8 @@ void CompositingRequirementsUpdater::UpdateRecursive(
637637

638638
// Layer assignment is needed for allocating or removing composited
639639
// layers related to this PaintLayer; hence the below conditions.
640-
if (reasons_to_composite || layer->GetCompositingState() != kNotComposited)
640+
if (reasons_to_composite || layer->GetCompositingState() != kNotComposited ||
641+
layer->LostGroupedMapping())
641642
layer->SetNeedsCompositingLayerAssignment();
642643

643644
// At this point we have finished collecting all reasons to composite this

third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater_test.cc

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "third_party/blink/renderer/core/paint/paint_layer.h"
88
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
99
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
10+
#include "third_party/blink/renderer/platform/graphics/graphics_layer.h"
1011

1112
namespace blink {
1213

@@ -129,4 +130,50 @@ TEST_F(CompositingRequirementsUpdaterTest,
129130
target->GetCompositingReasons());
130131
}
131132

133+
// This test sets up a situation where a squashed PaintLayer loses its
134+
// backing, but does not change visual rect. Therefore the compositing system
135+
// must invalidate it because of change of backing.
136+
TEST_F(CompositingRequirementsUpdaterTest,
137+
NeedsLayerAssignmentAfterSquashingRemoval) {
138+
SetBodyInnerHTML(R"HTML(
139+
<style>
140+
* {
141+
margin: 0
142+
}
143+
#target {
144+
width: 100px; height: 100px; backface-visibility: hidden
145+
}
146+
div {
147+
width: 100px; height: 100px;
148+
position: absolute;
149+
background: lightblue;
150+
top: 0px;
151+
}
152+
</style>
153+
<div id=target></div>
154+
<div id=squashed></div>
155+
)HTML");
156+
157+
PaintLayer* squashed =
158+
ToLayoutBoxModelObject(GetLayoutObjectByElementId("squashed"))->Layer();
159+
EXPECT_EQ(kPaintsIntoGroupedBacking, squashed->GetCompositingState());
160+
161+
GetDocument().View()->SetTracksPaintInvalidations(true);
162+
163+
GetDocument().getElementById("target")->setAttribute(HTMLNames::styleAttr,
164+
"display: none");
165+
GetDocument().View()->UpdateAllLifecyclePhases();
166+
167+
EXPECT_EQ(kNotComposited, squashed->GetCompositingState());
168+
auto* tracking = GetDocument()
169+
.View()
170+
->GetLayoutView()
171+
->Layer()
172+
->GraphicsLayerBacking()
173+
->GetRasterInvalidationTracking();
174+
EXPECT_TRUE(tracking->HasInvalidations());
175+
176+
EXPECT_EQ(IntRect(0, 0, 100, 100), tracking->Invalidations()[0].rect);
177+
}
178+
132179
} // namespace blink

0 commit comments

Comments
 (0)