|
7 | 7 | #include "third_party/blink/renderer/core/paint/paint_layer.h"
|
8 | 8 | #include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
|
9 | 9 | #include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
|
| 10 | +#include "third_party/blink/renderer/platform/graphics/graphics_layer.h" |
10 | 11 |
|
11 | 12 | namespace blink {
|
12 | 13 |
|
@@ -129,4 +130,50 @@ TEST_F(CompositingRequirementsUpdaterTest,
|
129 | 130 | target->GetCompositingReasons());
|
130 | 131 | }
|
131 | 132 |
|
| 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 | + |
132 | 179 | } // namespace blink
|
0 commit comments