Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Side by Side Diff: third_party/WebKit/Source/core/paint/BoxPaintInvalidatorTest.cpp

Issue 2498823002: Paint invalidation of local attachment backgrounds (Closed)
Patch Set: Update test expectations Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/HTMLNames.h" 5 #include "core/HTMLNames.h"
6 #include "core/frame/FrameView.h" 6 #include "core/frame/FrameView.h"
7 #include "core/layout/LayoutTestHelper.h" 7 #include "core/layout/LayoutTestHelper.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/paint/PaintLayer.h" 9 #include "core/paint/PaintLayer.h"
10 #include "platform/graphics/GraphicsLayer.h" 10 #include "platform/graphics/GraphicsLayer.h"
11 #include "platform/graphics/paint/RasterInvalidationTracking.h" 11 #include "platform/graphics/paint/RasterInvalidationTracking.h"
12 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 12 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class BoxPaintInvalidatorTest : public RenderingTest { 16 class BoxPaintInvalidatorTest : public ::testing::WithParamInterface<bool>,
17 private ScopedRootLayerScrollingForTest,
18 public RenderingTest {
19 public:
20 BoxPaintInvalidatorTest()
21 : ScopedRootLayerScrollingForTest(GetParam()),
22 RenderingTest(SingleChildFrameLoaderClient::create()) {}
23
17 protected: 24 protected:
18 const RasterInvalidationTracking* getRasterInvalidationTracking() const { 25 const RasterInvalidationTracking* getRasterInvalidationTracking() const {
19 // TODO(wangxianzhu): Test SPv2. 26 // TODO(wangxianzhu): Test SPv2.
20 return layoutView() 27 return layoutView()
21 .layer() 28 .layer()
22 ->graphicsLayerBacking() 29 ->graphicsLayerBackingForScrolling()
23 ->getRasterInvalidationTracking(); 30 ->getRasterInvalidationTracking();
24 } 31 }
25 32
26 private: 33 private:
27 void SetUp() override { 34 void SetUp() override {
28 RenderingTest::SetUp(); 35 RenderingTest::SetUp();
29 enableCompositing(); 36 enableCompositing();
30 setBodyInnerHTML( 37 setBodyInnerHTML(
31 "<style>" 38 "<style>"
32 " body { margin: 0 }" 39 " body { margin: 0 }"
40 " ::-webkit-scrollbar { display: none }"
33 " #target {" 41 " #target {"
34 " width: 50px;" 42 " width: 50px;"
35 " height: 100px;" 43 " height: 100px;"
36 " border-width: 20px 10px;" 44 " border-width: 20px 10px;"
37 " border-style: solid;" 45 " border-style: solid;"
38 " border-color: red;" 46 " border-color: red;"
39 " transform-origin: 0 0" 47 " transform-origin: 0 0;"
48 " }"
49 " #target.local-background {"
50 " background-attachment: local;"
51 " overflow: scroll;"
52 " }"
53 " #target.gradient {"
54 " background-image: linear-gradient(blue, yellow)"
40 " }" 55 " }"
41 "</style>" 56 "</style>"
42 "<div id='target'></div>"); 57 "<div id='target'></div>");
43 } 58 }
44 }; 59 };
45 60
46 TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationExpand) { 61 INSTANTIATE_TEST_CASE_P(All, BoxPaintInvalidatorTest, ::testing::Bool());
62
63 TEST_P(BoxPaintInvalidatorTest, IncrementalInvalidationExpand) {
47 document().view()->setTracksPaintInvalidations(true); 64 document().view()->setTracksPaintInvalidations(true);
48 Element* target = document().getElementById("target"); 65 Element* target = document().getElementById("target");
49 target->setAttribute(HTMLNames::styleAttr, "width: 100px; height: 200px"); 66 target->setAttribute(HTMLNames::styleAttr, "width: 100px; height: 200px");
50 document().view()->updateAllLifecyclePhases(); 67 document().view()->updateAllLifecyclePhases();
51 const auto& rasterInvalidations = 68 const auto& rasterInvalidations =
52 getRasterInvalidationTracking()->trackedRasterInvalidations; 69 getRasterInvalidationTracking()->trackedRasterInvalidations;
53 EXPECT_EQ(2u, rasterInvalidations.size()); 70 ASSERT_EQ(2u, rasterInvalidations.size());
54 EXPECT_EQ(IntRect(60, 0, 60, 240), rasterInvalidations[0].rect); 71 EXPECT_EQ(IntRect(60, 0, 60, 240), rasterInvalidations[0].rect);
55 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); 72 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason);
56 EXPECT_EQ(IntRect(0, 120, 120, 120), rasterInvalidations[1].rect); 73 EXPECT_EQ(IntRect(0, 120, 120, 120), rasterInvalidations[1].rect);
57 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[1].reason); 74 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[1].reason);
58 document().view()->setTracksPaintInvalidations(false); 75 document().view()->setTracksPaintInvalidations(false);
59 } 76 }
60 77
61 TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationShrink) { 78 TEST_P(BoxPaintInvalidatorTest, IncrementalInvalidationShrink) {
62 document().view()->setTracksPaintInvalidations(true); 79 document().view()->setTracksPaintInvalidations(true);
63 Element* target = document().getElementById("target"); 80 Element* target = document().getElementById("target");
64 target->setAttribute(HTMLNames::styleAttr, "width: 20px; height: 80px"); 81 target->setAttribute(HTMLNames::styleAttr, "width: 20px; height: 80px");
65 document().view()->updateAllLifecyclePhases(); 82 document().view()->updateAllLifecyclePhases();
66 const auto& rasterInvalidations = 83 const auto& rasterInvalidations =
67 getRasterInvalidationTracking()->trackedRasterInvalidations; 84 getRasterInvalidationTracking()->trackedRasterInvalidations;
68 EXPECT_EQ(2u, rasterInvalidations.size()); 85 ASSERT_EQ(2u, rasterInvalidations.size());
69 EXPECT_EQ(IntRect(30, 0, 40, 140), rasterInvalidations[0].rect); 86 EXPECT_EQ(IntRect(30, 0, 40, 140), rasterInvalidations[0].rect);
70 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); 87 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason);
71 EXPECT_EQ(IntRect(0, 100, 70, 40), rasterInvalidations[1].rect); 88 EXPECT_EQ(IntRect(0, 100, 70, 40), rasterInvalidations[1].rect);
72 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[1].reason); 89 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[1].reason);
73 document().view()->setTracksPaintInvalidations(false); 90 document().view()->setTracksPaintInvalidations(false);
74 } 91 }
75 92
76 TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationMixed) { 93 TEST_P(BoxPaintInvalidatorTest, IncrementalInvalidationMixed) {
77 document().view()->setTracksPaintInvalidations(true); 94 document().view()->setTracksPaintInvalidations(true);
78 Element* target = document().getElementById("target"); 95 Element* target = document().getElementById("target");
79 target->setAttribute(HTMLNames::styleAttr, "width: 100px; height: 80px"); 96 target->setAttribute(HTMLNames::styleAttr, "width: 100px; height: 80px");
80 document().view()->updateAllLifecyclePhases(); 97 document().view()->updateAllLifecyclePhases();
81 const auto& rasterInvalidations = 98 const auto& rasterInvalidations =
82 getRasterInvalidationTracking()->trackedRasterInvalidations; 99 getRasterInvalidationTracking()->trackedRasterInvalidations;
83 EXPECT_EQ(2u, rasterInvalidations.size()); 100 ASSERT_EQ(2u, rasterInvalidations.size());
84 EXPECT_EQ(IntRect(60, 0, 60, 120), rasterInvalidations[0].rect); 101 EXPECT_EQ(IntRect(60, 0, 60, 120), rasterInvalidations[0].rect);
85 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); 102 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason);
86 EXPECT_EQ(IntRect(0, 100, 70, 40), rasterInvalidations[1].rect); 103 EXPECT_EQ(IntRect(0, 100, 70, 40), rasterInvalidations[1].rect);
87 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[1].reason); 104 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[1].reason);
88 document().view()->setTracksPaintInvalidations(false); 105 document().view()->setTracksPaintInvalidations(false);
89 } 106 }
90 107
91 TEST_F(BoxPaintInvalidatorTest, SubpixelVisualRectChagne) { 108 TEST_P(BoxPaintInvalidatorTest, SubpixelVisualRectChagne) {
92 ScopedSlimmingPaintInvalidationForTest scopedSlimmingPaintInvalidation(true); 109 ScopedSlimmingPaintInvalidationForTest scopedSlimmingPaintInvalidation(true);
93 110
94 Element* target = document().getElementById("target"); 111 Element* target = document().getElementById("target");
95 112
96 // Should do full invalidation if new geometry has subpixels. 113 // Should do full invalidation if new geometry has subpixels.
97 document().view()->setTracksPaintInvalidations(true); 114 document().view()->setTracksPaintInvalidations(true);
98 target->setAttribute(HTMLNames::styleAttr, "width: 100.6px; height: 70.3px"); 115 target->setAttribute(HTMLNames::styleAttr, "width: 100.6px; height: 70.3px");
99 document().view()->updateAllLifecyclePhases(); 116 document().view()->updateAllLifecyclePhases();
100 const auto* rasterInvalidations = 117 const auto* rasterInvalidations =
101 &getRasterInvalidationTracking()->trackedRasterInvalidations; 118 &getRasterInvalidationTracking()->trackedRasterInvalidations;
102 EXPECT_EQ(2u, rasterInvalidations->size()); 119 ASSERT_EQ(2u, rasterInvalidations->size());
103 EXPECT_EQ(IntRect(0, 0, 70, 140), (*rasterInvalidations)[0].rect); 120 EXPECT_EQ(IntRect(0, 0, 70, 140), (*rasterInvalidations)[0].rect);
104 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason); 121 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason);
105 EXPECT_EQ(IntRect(0, 0, 121, 111), (*rasterInvalidations)[1].rect); 122 EXPECT_EQ(IntRect(0, 0, 121, 111), (*rasterInvalidations)[1].rect);
106 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[1].reason); 123 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[1].reason);
107 document().view()->setTracksPaintInvalidations(false); 124 document().view()->setTracksPaintInvalidations(false);
108 125
109 // Should do full invalidation if old geometry has subpixels. 126 // Should do full invalidation if old geometry has subpixels.
110 document().view()->setTracksPaintInvalidations(true); 127 document().view()->setTracksPaintInvalidations(true);
111 target->setAttribute(HTMLNames::styleAttr, "width: 50px; height: 100px"); 128 target->setAttribute(HTMLNames::styleAttr, "width: 50px; height: 100px");
112 document().view()->updateAllLifecyclePhases(); 129 document().view()->updateAllLifecyclePhases();
113 rasterInvalidations = 130 rasterInvalidations =
114 &getRasterInvalidationTracking()->trackedRasterInvalidations; 131 &getRasterInvalidationTracking()->trackedRasterInvalidations;
115 EXPECT_EQ(2u, rasterInvalidations->size()); 132 ASSERT_EQ(2u, rasterInvalidations->size());
116 EXPECT_EQ(IntRect(0, 0, 121, 111), (*rasterInvalidations)[0].rect); 133 EXPECT_EQ(IntRect(0, 0, 121, 111), (*rasterInvalidations)[0].rect);
117 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason); 134 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason);
118 EXPECT_EQ(IntRect(0, 0, 70, 140), (*rasterInvalidations)[1].rect); 135 EXPECT_EQ(IntRect(0, 0, 70, 140), (*rasterInvalidations)[1].rect);
119 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[1].reason); 136 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[1].reason);
120 document().view()->setTracksPaintInvalidations(false); 137 document().view()->setTracksPaintInvalidations(false);
121 } 138 }
122 139
123 TEST_F(BoxPaintInvalidatorTest, SubpixelChangeWithoutVisualRectChange) { 140 TEST_P(BoxPaintInvalidatorTest, SubpixelChangeWithoutVisualRectChange) {
124 ScopedSlimmingPaintInvalidationForTest scopedSlimmingPaintInvalidation(true); 141 ScopedSlimmingPaintInvalidationForTest scopedSlimmingPaintInvalidation(true);
125 142
126 Element* target = document().getElementById("target"); 143 Element* target = document().getElementById("target");
127 LayoutObject* targetObject = target->layoutObject(); 144 LayoutObject* targetObject = target->layoutObject();
128 EXPECT_EQ(LayoutRect(0, 0, 70, 140), targetObject->previousVisualRect()); 145 EXPECT_EQ(LayoutRect(0, 0, 70, 140), targetObject->previousVisualRect());
129 146
130 // Should do full invalidation if new geometry has subpixels even if the paint 147 // Should do full invalidation if new geometry has subpixels even if the paint
131 // invalidation rect doesn't change. 148 // invalidation rect doesn't change.
132 document().view()->setTracksPaintInvalidations(true); 149 document().view()->setTracksPaintInvalidations(true);
133 target->setAttribute(HTMLNames::styleAttr, 150 target->setAttribute(HTMLNames::styleAttr,
134 "margin-top: 0.6px; width: 50px; height: 99.3px"); 151 "margin-top: 0.6px; width: 50px; height: 99.3px");
135 document().view()->updateAllLifecyclePhases(); 152 document().view()->updateAllLifecyclePhases();
136 EXPECT_EQ(LayoutRect(0, 0, 70, 140), targetObject->previousVisualRect()); 153 EXPECT_EQ(LayoutRect(0, 0, 70, 140), targetObject->previousVisualRect());
137 const auto* rasterInvalidations = 154 const auto* rasterInvalidations =
138 &getRasterInvalidationTracking()->trackedRasterInvalidations; 155 &getRasterInvalidationTracking()->trackedRasterInvalidations;
139 EXPECT_EQ(1u, rasterInvalidations->size()); 156 ASSERT_EQ(1u, rasterInvalidations->size());
140 EXPECT_EQ(IntRect(0, 0, 70, 140), (*rasterInvalidations)[0].rect); 157 EXPECT_EQ(IntRect(0, 0, 70, 140), (*rasterInvalidations)[0].rect);
141 EXPECT_EQ(PaintInvalidationLocationChange, (*rasterInvalidations)[0].reason); 158 EXPECT_EQ(PaintInvalidationLocationChange, (*rasterInvalidations)[0].reason);
142 document().view()->setTracksPaintInvalidations(false); 159 document().view()->setTracksPaintInvalidations(false);
143 160
144 document().view()->setTracksPaintInvalidations(true); 161 document().view()->setTracksPaintInvalidations(true);
145 target->setAttribute(HTMLNames::styleAttr, 162 target->setAttribute(HTMLNames::styleAttr,
146 "margin-top: 0.6px; width: 49.3px; height: 98.5px"); 163 "margin-top: 0.6px; width: 49.3px; height: 98.5px");
147 document().view()->updateAllLifecyclePhases(); 164 document().view()->updateAllLifecyclePhases();
148 EXPECT_EQ(LayoutRect(0, 0, 70, 140), targetObject->previousVisualRect()); 165 EXPECT_EQ(LayoutRect(0, 0, 70, 140), targetObject->previousVisualRect());
149 rasterInvalidations = 166 rasterInvalidations =
150 &getRasterInvalidationTracking()->trackedRasterInvalidations; 167 &getRasterInvalidationTracking()->trackedRasterInvalidations;
151 EXPECT_EQ(1u, rasterInvalidations->size()); 168 ASSERT_EQ(1u, rasterInvalidations->size());
152 EXPECT_EQ(IntRect(0, 0, 70, 140), (*rasterInvalidations)[0].rect); 169 EXPECT_EQ(IntRect(0, 0, 70, 140), (*rasterInvalidations)[0].rect);
153 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason); 170 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason);
154 document().view()->setTracksPaintInvalidations(false); 171 document().view()->setTracksPaintInvalidations(false);
155 } 172 }
156 173
157 TEST_F(BoxPaintInvalidatorTest, ResizeRotated) { 174 TEST_P(BoxPaintInvalidatorTest, ResizeRotated) {
158 ScopedSlimmingPaintInvalidationForTest scopedSlimmingPaintInvalidation(true); 175 ScopedSlimmingPaintInvalidationForTest scopedSlimmingPaintInvalidation(true);
159 176
160 Element* target = document().getElementById("target"); 177 Element* target = document().getElementById("target");
161 target->setAttribute(HTMLNames::styleAttr, "transform: rotate(45deg)"); 178 target->setAttribute(HTMLNames::styleAttr, "transform: rotate(45deg)");
162 document().view()->updateAllLifecyclePhases(); 179 document().view()->updateAllLifecyclePhases();
163 180
164 // Should do full invalidation a rotated object is resized. 181 // Should do full invalidation a rotated object is resized.
165 document().view()->setTracksPaintInvalidations(true); 182 document().view()->setTracksPaintInvalidations(true);
166 target->setAttribute(HTMLNames::styleAttr, 183 target->setAttribute(HTMLNames::styleAttr,
167 "transform: rotate(45deg); width: 200px"); 184 "transform: rotate(45deg); width: 200px");
168 document().view()->updateAllLifecyclePhases(); 185 document().view()->updateAllLifecyclePhases();
169 const auto* rasterInvalidations = 186 const auto* rasterInvalidations =
170 &getRasterInvalidationTracking()->trackedRasterInvalidations; 187 &getRasterInvalidationTracking()->trackedRasterInvalidations;
171 EXPECT_EQ(1u, rasterInvalidations->size()); 188 ASSERT_EQ(1u, rasterInvalidations->size());
172 EXPECT_EQ(IntRect(-99, 0, 255, 255), (*rasterInvalidations)[0].rect); 189 EXPECT_EQ(IntRect(-99, 0, 255, 255), (*rasterInvalidations)[0].rect);
173 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason); 190 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason);
174 document().view()->setTracksPaintInvalidations(false); 191 document().view()->setTracksPaintInvalidations(false);
175 } 192 }
176 193
177 TEST_F(BoxPaintInvalidatorTest, ResizeRotatedChild) { 194 TEST_P(BoxPaintInvalidatorTest, ResizeRotatedChild) {
178 ScopedSlimmingPaintInvalidationForTest scopedSlimmingPaintInvalidation(true); 195 ScopedSlimmingPaintInvalidationForTest scopedSlimmingPaintInvalidation(true);
179 196
180 Element* target = document().getElementById("target"); 197 Element* target = document().getElementById("target");
181 target->setAttribute(HTMLNames::styleAttr, 198 target->setAttribute(HTMLNames::styleAttr,
182 "transform: rotate(45deg); width: 200px"); 199 "transform: rotate(45deg); width: 200px");
183 target->setInnerHTML( 200 target->setInnerHTML(
184 "<div id=child style='width: 50px; height: 50px; background: red'></div>", 201 "<div id=child style='width: 50px; height: 50px; background: red'></div>",
185 ASSERT_NO_EXCEPTION); 202 ASSERT_NO_EXCEPTION);
186 document().view()->updateAllLifecyclePhases(); 203 document().view()->updateAllLifecyclePhases();
187 Element* child = document().getElementById("child"); 204 Element* child = document().getElementById("child");
188 205
189 // Should do full invalidation a rotated object is resized. 206 // Should do full invalidation a rotated object is resized.
190 document().view()->setTracksPaintInvalidations(true); 207 document().view()->setTracksPaintInvalidations(true);
191 child->setAttribute(HTMLNames::styleAttr, 208 child->setAttribute(HTMLNames::styleAttr,
192 "width: 100px; height: 50px; background: red"); 209 "width: 100px; height: 50px; background: red");
193 document().view()->updateAllLifecyclePhases(); 210 document().view()->updateAllLifecyclePhases();
194 const auto* rasterInvalidations = 211 const auto* rasterInvalidations =
195 &getRasterInvalidationTracking()->trackedRasterInvalidations; 212 &getRasterInvalidationTracking()->trackedRasterInvalidations;
196 EXPECT_EQ(1u, rasterInvalidations->size()); 213 ASSERT_EQ(1u, rasterInvalidations->size());
197 EXPECT_EQ(IntRect(-43, 21, 107, 107), (*rasterInvalidations)[0].rect); 214 EXPECT_EQ(IntRect(-43, 21, 107, 107), (*rasterInvalidations)[0].rect);
198 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason); 215 EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason);
199 document().view()->setTracksPaintInvalidations(false); 216 document().view()->setTracksPaintInvalidations(false);
200 } 217 }
201 218
219 TEST_P(BoxPaintInvalidatorTest, CompositedLayoutViewResize) {
220 enableCompositing();
221 Element* target = document().getElementById("target");
222 target->setAttribute(HTMLNames::styleAttr, "height: 2000px");
223 document().view()->updateAllLifecyclePhases();
224
225 // Resize the content.
226 document().view()->setTracksPaintInvalidations(true);
227 target->setAttribute(HTMLNames::styleAttr, "height: 3000px");
228 document().view()->updateAllLifecyclePhases();
229 const auto& rasterInvalidations =
230 getRasterInvalidationTracking()->trackedRasterInvalidations;
231 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
232 // TODO(skobes): Treat LayoutView in the same way as normal objects having
233 // background-attachment: local. crbug.com/568847.
234 EXPECT_EQ(1u, rasterInvalidations.size());
235 EXPECT_EQ(IntRect(0, 2020, 70, 1020), rasterInvalidations[0].rect);
236 EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()),
237 rasterInvalidations[0].client);
238 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason);
239 } else {
240 EXPECT_EQ(2u, rasterInvalidations.size());
241 EXPECT_EQ(IntRect(0, 2040, 800, 1000), rasterInvalidations[0].rect);
242 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()),
243 rasterInvalidations[0].client);
244 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason);
245 EXPECT_EQ(IntRect(0, 2020, 70, 1020), rasterInvalidations[1].rect);
246 EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()),
247 rasterInvalidations[1].client);
248 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[1].reason);
249 }
250 document().view()->setTracksPaintInvalidations(false);
251
252 // Resize the viewport. No paint invalidation.
253 document().view()->setTracksPaintInvalidations(true);
254 document().view()->resize(800, 1000);
255 document().view()->updateAllLifecyclePhases();
256 EXPECT_FALSE(getRasterInvalidationTracking());
257 document().view()->setTracksPaintInvalidations(false);
258 }
259
260 TEST_P(BoxPaintInvalidatorTest, NonCompositedLayoutViewResize) {
261 setBodyInnerHTML(
262 "<style>"
263 " body { margin: 0 }"
264 " iframe { display: block; width: 100px; height: 100px; border: none; }"
265 "</style>"
266 "<iframe id='iframe'></iframe>");
267 Document& frameDocument = setupChildIframe(
268 "iframe",
269 "<style>"
270 " ::-webkit-scrollbar { display: none }"
271 " body { margin: 0; background: green; height: 0 }"
272 "</style>"
273 "<div id='content' style='width: 200px; height: 200px'></div>");
274 document().view()->updateAllLifecyclePhases();
275 Element* iframe = document().getElementById("iframe");
276 Element* content = frameDocument.getElementById("content");
277 EXPECT_EQ(layoutView(),
278 content->layoutObject()->containerForPaintInvalidation());
279
280 // Resize the content.
281 document().view()->setTracksPaintInvalidations(true);
282 content->setAttribute(HTMLNames::styleAttr, "height: 500px");
283 document().view()->updateAllLifecyclePhases();
284 // No invalidation because the changed part of layout overflow is clipped.
285 EXPECT_FALSE(getRasterInvalidationTracking());
286 document().view()->setTracksPaintInvalidations(false);
287
288 // Resize the iframe.
289 document().view()->setTracksPaintInvalidations(true);
290 iframe->setAttribute(HTMLNames::styleAttr, "height: 200px");
291 document().view()->updateAllLifecyclePhases();
292 const auto& rasterInvalidations =
293 getRasterInvalidationTracking()->trackedRasterInvalidations;
294 ASSERT_EQ(2u, rasterInvalidations.size());
295 EXPECT_EQ(IntRect(0, 100, 100, 100), rasterInvalidations[0].rect);
296 EXPECT_EQ(static_cast<const DisplayItemClient*>(iframe->layoutObject()),
297 rasterInvalidations[0].client);
298 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason);
299 EXPECT_EQ(
300 static_cast<const DisplayItemClient*>(content->layoutObject()->view()),
301 rasterInvalidations[1].client);
302 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
303 // TODO(skobes): Treat LayoutView in the same way as normal objects having
304 // background-attachment: local. crbug.com/568847.
305 EXPECT_EQ(IntRect(0, 0, 100, 200), rasterInvalidations[1].rect);
306 EXPECT_EQ(PaintInvalidationFull, rasterInvalidations[1].reason);
307 } else {
308 EXPECT_EQ(IntRect(0, 100, 100, 100), rasterInvalidations[1].rect);
309 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[1].reason);
310 }
311 document().view()->setTracksPaintInvalidations(false);
312 }
313
314 TEST_P(BoxPaintInvalidatorTest, CompositedBackgroundAttachmentLocalResize) {
315 enableCompositing();
316
317 Element* target = document().getElementById("target");
318 target->setAttribute(HTMLNames::classAttr, "local-background");
319 target->setAttribute(HTMLNames::styleAttr, "will-change: transform");
320 target->setInnerHTML(
321 "<div id=child style='width: 500px; height: 500px'></div>",
322 ASSERT_NO_EXCEPTION);
323 Element* child = document().getElementById("child");
324 document().view()->updateAllLifecyclePhases();
325
326 // Resize the content.
327 document().view()->setTracksPaintInvalidations(true);
328 child->setAttribute(HTMLNames::styleAttr, "width: 500px; height: 1000px");
329 document().view()->updateAllLifecyclePhases();
330 GraphicsLayer* containerLayer = toLayoutBoxModelObject(target->layoutObject())
331 ->layer()
332 ->graphicsLayerBacking();
333 GraphicsLayer* contentsLayer = toLayoutBoxModelObject(target->layoutObject())
334 ->layer()
335 ->graphicsLayerBackingForScrolling();
336 // No invalidation on the container layer.
337 EXPECT_FALSE(containerLayer->getRasterInvalidationTracking());
338 // Incremental invalidation of background on contents layer.
339 const auto& contentsRasterInvalidations =
340 contentsLayer->getRasterInvalidationTracking()
341 ->trackedRasterInvalidations;
342 ASSERT_EQ(1u, contentsRasterInvalidations.size());
343 EXPECT_EQ(IntRect(0, 500, 500, 500), contentsRasterInvalidations[0].rect);
344 EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()),
345 contentsRasterInvalidations[0].client);
346 EXPECT_EQ(PaintInvalidationBackgroundOnScrollingContentsLayer,
347 contentsRasterInvalidations[0].reason);
348 document().view()->setTracksPaintInvalidations(false);
349
350 // Resize the container.
351 document().view()->setTracksPaintInvalidations(true);
352 target->setAttribute(HTMLNames::styleAttr,
353 "will-change: transform; height: 200px");
354 document().view()->updateAllLifecyclePhases();
355 // No invalidation on the contents layer.
356 EXPECT_FALSE(contentsLayer->getRasterInvalidationTracking());
357 // Incremental invalidation on the container layer.
358 const auto& containerRasterInvalidations =
359 containerLayer->getRasterInvalidationTracking()
360 ->trackedRasterInvalidations;
361 ASSERT_EQ(1u, containerRasterInvalidations.size());
362 EXPECT_EQ(IntRect(0, 120, 70, 120), containerRasterInvalidations[0].rect);
363 EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()),
364 containerRasterInvalidations[0].client);
365 EXPECT_EQ(PaintInvalidationIncremental,
366 containerRasterInvalidations[0].reason);
367 document().view()->setTracksPaintInvalidations(false);
368 }
369
370 TEST_P(BoxPaintInvalidatorTest,
371 CompositedBackgroundAttachmentLocalGradientResize) {
372 enableCompositing();
373
374 Element* target = document().getElementById("target");
375 target->setAttribute(HTMLNames::classAttr, "local-background gradient");
376 target->setAttribute(HTMLNames::styleAttr, "will-change: transform");
377 target->setInnerHTML(
378 "<div id='child' style='width: 500px; height: 500px'></div>",
379 ASSERT_NO_EXCEPTION);
380 Element* child = document().getElementById("child");
381 document().view()->updateAllLifecyclePhases();
382
383 // Resize the content.
384 document().view()->setTracksPaintInvalidations(true);
385 child->setAttribute(HTMLNames::styleAttr, "width: 500px; height: 1000px");
386 document().view()->updateAllLifecyclePhases();
387 GraphicsLayer* containerLayer = toLayoutBoxModelObject(target->layoutObject())
388 ->layer()
389 ->graphicsLayerBacking();
390 GraphicsLayer* contentsLayer = toLayoutBoxModelObject(target->layoutObject())
391 ->layer()
392 ->graphicsLayerBackingForScrolling();
393 // No invalidation on the container layer.
394 EXPECT_FALSE(containerLayer->getRasterInvalidationTracking());
395 // Full invalidation of background on contents layer because the gradient
396 // background is resized.
397 const auto& contentsRasterInvalidations =
398 contentsLayer->getRasterInvalidationTracking()
399 ->trackedRasterInvalidations;
400 ASSERT_EQ(1u, contentsRasterInvalidations.size());
401 EXPECT_EQ(IntRect(0, 0, 500, 1000), contentsRasterInvalidations[0].rect);
402 EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()),
403 contentsRasterInvalidations[0].client);
404 EXPECT_EQ(PaintInvalidationBackgroundOnScrollingContentsLayer,
405 contentsRasterInvalidations[0].reason);
406 document().view()->setTracksPaintInvalidations(false);
407
408 // Resize the container.
409 document().view()->setTracksPaintInvalidations(true);
410 target->setAttribute(HTMLNames::styleAttr,
411 "will-change: transform; height: 200px");
412 document().view()->updateAllLifecyclePhases();
413 EXPECT_FALSE(contentsLayer->getRasterInvalidationTracking());
414 // Full invalidation on the container layer.
415 const auto& containerRasterInvalidations =
416 containerLayer->getRasterInvalidationTracking()
417 ->trackedRasterInvalidations;
418 ASSERT_EQ(1u, containerRasterInvalidations.size());
419 EXPECT_EQ(IntRect(0, 0, 70, 240), containerRasterInvalidations[0].rect);
420 EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()),
421 containerRasterInvalidations[0].client);
422 EXPECT_EQ(PaintInvalidationBorderBoxChange,
423 containerRasterInvalidations[0].reason);
424 document().view()->setTracksPaintInvalidations(false);
425 }
426
427 TEST_P(BoxPaintInvalidatorTest, NonCompositedBackgroundAttachmentLocalResize) {
428 Element* target = document().getElementById("target");
429 target->setAttribute(HTMLNames::classAttr, "local-background");
430 target->setInnerHTML(
431 "<div id=child style='width: 500px; height: 500px'></div>",
432 ASSERT_NO_EXCEPTION);
433 Element* child = document().getElementById("child");
434 document().view()->updateAllLifecyclePhases();
435 EXPECT_EQ(&layoutView(),
436 &target->layoutObject()->containerForPaintInvalidation());
437
438 // Resize the content.
439 document().view()->setTracksPaintInvalidations(true);
440 child->setAttribute(HTMLNames::styleAttr, "width: 500px; height: 1000px");
441 document().view()->updateAllLifecyclePhases();
442 // No invalidation because the changed part is invisible.
443 EXPECT_FALSE(getRasterInvalidationTracking());
444
445 // Resize the container.
446 document().view()->setTracksPaintInvalidations(true);
447 target->setAttribute(HTMLNames::styleAttr, "height: 200px");
448 document().view()->updateAllLifecyclePhases();
449 const auto& rasterInvalidations =
450 getRasterInvalidationTracking()->trackedRasterInvalidations;
451 ASSERT_EQ(1u, rasterInvalidations.size());
452 EXPECT_EQ(IntRect(0, 120, 70, 120), rasterInvalidations[0].rect);
453 EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()),
454 rasterInvalidations[0].client);
455 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason);
456 document().view()->setTracksPaintInvalidations(false);
457 }
458
202 } // namespace blink 459 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698