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

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

Issue 2671853003: [SPInvalidation] Use GeometryMapper in PaintLayerClipper for paint. (Closed)
Patch Set: none Created 3 years, 10 months 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/paint/PaintLayerClipper.h" 5 #include "core/paint/PaintLayerClipper.h"
6 6
7 #include "core/layout/LayoutBoxModelObject.h" 7 #include "core/layout/LayoutBoxModelObject.h"
8 #include "core/layout/LayoutTestHelper.h" 8 #include "core/layout/LayoutTestHelper.h"
9 #include "core/layout/LayoutView.h" 9 #include "core/layout/LayoutView.h"
10 #include "core/paint/PaintLayer.h" 10 #include "core/paint/PaintLayer.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 Element* target = document().getElementById("target"); 51 Element* target = document().getElementById("target");
52 PaintLayer* targetPaintLayer = 52 PaintLayer* targetPaintLayer =
53 toLayoutBoxModelObject(target->layoutObject())->layer(); 53 toLayoutBoxModelObject(target->layoutObject())->layer();
54 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects); 54 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects);
55 // When RLS is enabled, the LayoutView will have a composited scrolling layer, 55 // When RLS is enabled, the LayoutView will have a composited scrolling layer,
56 // so don't apply an overflow clip. 56 // so don't apply an overflow clip.
57 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 57 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
58 context.setIgnoreOverflowClip(); 58 context.setIgnoreOverflowClip();
59 LayoutRect layerBounds; 59 LayoutRect layerBounds;
60 ClipRect backgroundRect, foregroundRect; 60 ClipRect backgroundRect, foregroundRect;
61 targetPaintLayer->clipper().calculateRects( 61 targetPaintLayer
62 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds, 62 ->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
63 backgroundRect, foregroundRect); 63 .calculateRects(context, LayoutRect(LayoutRect::infiniteIntRect()),
64 layerBounds, backgroundRect, foregroundRect);
64 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect()); 65 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect());
65 EXPECT_EQ(LayoutRect(8, 8, 200, 300), foregroundRect.rect()); 66 EXPECT_EQ(LayoutRect(8, 8, 200, 300), foregroundRect.rect());
66 EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds); 67 EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds);
67 } 68 }
68 69
69 TEST_P(PaintLayerClipperTest, ControlClip) { 70 TEST_P(PaintLayerClipperTest, ControlClip) {
70 setBodyInnerHTML( 71 setBodyInnerHTML(
71 "<!DOCTYPE html>" 72 "<!DOCTYPE html>"
72 "<input id=target style='position:absolute; width: 200px; height: 300px'" 73 "<input id=target style='position:absolute; width: 200px; height: 300px'"
73 " type=button>"); 74 " type=button>");
74 Element* target = document().getElementById("target"); 75 Element* target = document().getElementById("target");
75 PaintLayer* targetPaintLayer = 76 PaintLayer* targetPaintLayer =
76 toLayoutBoxModelObject(target->layoutObject())->layer(); 77 toLayoutBoxModelObject(target->layoutObject())->layer();
77 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects); 78 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects);
78 // When RLS is enabled, the LayoutView will have a composited scrolling layer, 79 // When RLS is enabled, the LayoutView will have a composited scrolling layer,
79 // so don't apply an overflow clip. 80 // so don't apply an overflow clip.
80 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 81 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
81 context.setIgnoreOverflowClip(); 82 context.setIgnoreOverflowClip();
82 LayoutRect layerBounds; 83 LayoutRect layerBounds;
83 ClipRect backgroundRect, foregroundRect; 84 ClipRect backgroundRect, foregroundRect;
84 targetPaintLayer->clipper().calculateRects( 85 targetPaintLayer
85 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds, 86 ->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
86 backgroundRect, foregroundRect); 87 .calculateRects(context, LayoutRect(LayoutRect::infiniteIntRect()),
88 layerBounds, backgroundRect, foregroundRect);
87 #if OS(MACOSX) 89 #if OS(MACOSX)
88 // If the PaintLayer clips overflow, the background rect is intersected with 90 // If the PaintLayer clips overflow, the background rect is intersected with
89 // the PaintLayer bounds... 91 // the PaintLayer bounds...
90 EXPECT_EQ(LayoutRect(3, 4, 210, 28), backgroundRect.rect()); 92 EXPECT_EQ(LayoutRect(3, 4, 210, 28), backgroundRect.rect());
91 // and the foreground rect is intersected with the control clip in this case. 93 // and the foreground rect is intersected with the control clip in this case.
92 EXPECT_EQ(LayoutRect(8, 8, 200, 18), foregroundRect.rect()); 94 EXPECT_EQ(LayoutRect(8, 8, 200, 18), foregroundRect.rect());
93 EXPECT_EQ(LayoutRect(8, 8, 200, 18), layerBounds); 95 EXPECT_EQ(LayoutRect(8, 8, 200, 18), layerBounds);
94 #else 96 #else
95 // If the PaintLayer clips overflow, the background rect is intersected with 97 // If the PaintLayer clips overflow, the background rect is intersected with
96 // the PaintLayer bounds... 98 // the PaintLayer bounds...
(...skipping 15 matching lines...) Expand all
112 PaintLayer* targetPaintLayer = 114 PaintLayer* targetPaintLayer =
113 toLayoutBoxModelObject(target->layoutObject())->layer(); 115 toLayoutBoxModelObject(target->layoutObject())->layer();
114 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects); 116 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects);
115 // When RLS is enabled, the LayoutView will have a composited scrolling layer, 117 // When RLS is enabled, the LayoutView will have a composited scrolling layer,
116 // so don't apply an overflow clip. 118 // so don't apply an overflow clip.
117 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 119 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
118 context.setIgnoreOverflowClip(); 120 context.setIgnoreOverflowClip();
119 121
120 LayoutRect layerBounds; 122 LayoutRect layerBounds;
121 ClipRect backgroundRect, foregroundRect; 123 ClipRect backgroundRect, foregroundRect;
122 targetPaintLayer->clipper().calculateRects( 124 targetPaintLayer
123 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds, 125 ->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
124 backgroundRect, foregroundRect); 126 .calculateRects(context, LayoutRect(LayoutRect::infiniteIntRect()),
127 layerBounds, backgroundRect, foregroundRect);
125 128
126 // Only the foreground rect gets hasRadius set for overflow clipping 129 // Only the foreground rect gets hasRadius set for overflow clipping
127 // of descendants. 130 // of descendants.
128 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect()); 131 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect());
129 EXPECT_FALSE(backgroundRect.hasRadius()); 132 EXPECT_FALSE(backgroundRect.hasRadius());
130 EXPECT_EQ(LayoutRect(8, 8, 200, 300), foregroundRect.rect()); 133 EXPECT_EQ(LayoutRect(8, 8, 200, 300), foregroundRect.rect());
131 EXPECT_TRUE(foregroundRect.hasRadius()); 134 EXPECT_TRUE(foregroundRect.hasRadius());
132 EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds); 135 EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds);
133 } 136 }
134 137
(...skipping 12 matching lines...) Expand all
147 toLayoutBoxModelObject(parent->layoutObject())->layer(); 150 toLayoutBoxModelObject(parent->layoutObject())->layer();
148 151
149 Element* child = document().getElementById("child"); 152 Element* child = document().getElementById("child");
150 PaintLayer* childPaintLayer = 153 PaintLayer* childPaintLayer =
151 toLayoutBoxModelObject(child->layoutObject())->layer(); 154 toLayoutBoxModelObject(child->layoutObject())->layer();
152 155
153 ClipRectsContext context(parentPaintLayer, UncachedClipRects); 156 ClipRectsContext context(parentPaintLayer, UncachedClipRects);
154 157
155 LayoutRect layerBounds; 158 LayoutRect layerBounds;
156 ClipRect backgroundRect, foregroundRect; 159 ClipRect backgroundRect, foregroundRect;
157 childPaintLayer->clipper().calculateRects( 160 childPaintLayer
158 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds, 161 ->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
159 backgroundRect, foregroundRect); 162 .calculateRects(context, LayoutRect(LayoutRect::infiniteIntRect()),
163 layerBounds, backgroundRect, foregroundRect);
160 164
161 EXPECT_EQ(LayoutRect(0, 0, 200, 300), backgroundRect.rect()); 165 EXPECT_EQ(LayoutRect(0, 0, 200, 300), backgroundRect.rect());
162 EXPECT_TRUE(backgroundRect.hasRadius()); 166 EXPECT_TRUE(backgroundRect.hasRadius());
163 EXPECT_EQ(LayoutRect(0, 0, 200, 300), foregroundRect.rect()); 167 EXPECT_EQ(LayoutRect(0, 0, 200, 300), foregroundRect.rect());
164 EXPECT_TRUE(foregroundRect.hasRadius()); 168 EXPECT_TRUE(foregroundRect.hasRadius());
165 EXPECT_EQ(LayoutRect(0, 0, 500, 500), layerBounds); 169 EXPECT_EQ(LayoutRect(0, 0, 500, 500), layerBounds);
166 } 170 }
167 171
168 TEST_P(PaintLayerClipperTest, ControlClipSelect) { 172 TEST_P(PaintLayerClipperTest, ControlClipSelect) {
169 setBodyInnerHTML( 173 setBodyInnerHTML(
170 "<select id='target' style='position: relative; width: 100px; " 174 "<select id='target' style='position: relative; width: 100px; "
171 " background: none; border: none; padding: 0px 15px 0px 5px;'>" 175 " background: none; border: none; padding: 0px 15px 0px 5px;'>"
172 " <option>" 176 " <option>"
173 " Test long texttttttttttttttttttttttttttttttt" 177 " Test long texttttttttttttttttttttttttttttttt"
174 " </option>" 178 " </option>"
175 "</select>"); 179 "</select>");
176 Element* target = document().getElementById("target"); 180 Element* target = document().getElementById("target");
177 PaintLayer* targetPaintLayer = 181 PaintLayer* targetPaintLayer =
178 toLayoutBoxModelObject(target->layoutObject())->layer(); 182 toLayoutBoxModelObject(target->layoutObject())->layer();
179 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects); 183 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects);
180 // When RLS is enabled, the LayoutView will have a composited scrolling layer, 184 // When RLS is enabled, the LayoutView will have a composited scrolling layer,
181 // so don't apply an overflow clip. 185 // so don't apply an overflow clip.
182 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 186 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
183 context.setIgnoreOverflowClip(); 187 context.setIgnoreOverflowClip();
184 LayoutRect layerBounds; 188 LayoutRect layerBounds;
185 ClipRect backgroundRect, foregroundRect; 189 ClipRect backgroundRect, foregroundRect;
186 targetPaintLayer->clipper().calculateRects( 190 targetPaintLayer
187 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds, 191 ->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
188 backgroundRect, foregroundRect); 192 .calculateRects(context, LayoutRect(LayoutRect::infiniteIntRect()),
193 layerBounds, backgroundRect, foregroundRect);
189 // The control clip for a select excludes the area for the down arrow. 194 // The control clip for a select excludes the area for the down arrow.
190 #if OS(MACOSX) 195 #if OS(MACOSX)
191 EXPECT_EQ(LayoutRect(16, 9, 79, 13), foregroundRect.rect()); 196 EXPECT_EQ(LayoutRect(16, 9, 79, 13), foregroundRect.rect());
192 #elif OS(WIN) 197 #elif OS(WIN)
193 EXPECT_EQ(LayoutRect(17, 9, 60, 16), foregroundRect.rect()); 198 EXPECT_EQ(LayoutRect(17, 9, 60, 16), foregroundRect.rect());
194 #else 199 #else
195 EXPECT_EQ(LayoutRect(17, 9, 60, 15), foregroundRect.rect()); 200 EXPECT_EQ(LayoutRect(17, 9, 60, 15), foregroundRect.rect());
196 #endif 201 #endif
197 } 202 }
198 203
199 TEST_P(PaintLayerClipperTest, LayoutSVGRootChild) { 204 TEST_P(PaintLayerClipperTest, LayoutSVGRootChild) {
200 setBodyInnerHTML( 205 setBodyInnerHTML(
201 "<svg width=200 height=300 style='position: relative'>" 206 "<svg width=200 height=300 style='position: relative'>"
202 " <foreignObject width=400 height=500>" 207 " <foreignObject width=400 height=500>"
203 " <div id=target xmlns='http://www.w3.org/1999/xhtml' " 208 " <div id=target xmlns='http://www.w3.org/1999/xhtml' "
204 "style='position: relative'></div>" 209 "style='position: relative'></div>"
205 " </foreignObject>" 210 " </foreignObject>"
206 "</svg>"); 211 "</svg>");
207 212
208 Element* target = document().getElementById("target"); 213 Element* target = document().getElementById("target");
209 PaintLayer* targetPaintLayer = 214 PaintLayer* targetPaintLayer =
210 toLayoutBoxModelObject(target->layoutObject())->layer(); 215 toLayoutBoxModelObject(target->layoutObject())->layer();
211 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects); 216 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects);
212 LayoutRect layerBounds; 217 LayoutRect layerBounds;
213 ClipRect backgroundRect, foregroundRect; 218 ClipRect backgroundRect, foregroundRect;
214 targetPaintLayer->clipper().calculateRects( 219 targetPaintLayer
215 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds, 220 ->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
216 backgroundRect, foregroundRect); 221 .calculateRects(context, LayoutRect(LayoutRect::infiniteIntRect()),
222 layerBounds, backgroundRect, foregroundRect);
217 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect()); 223 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect());
218 EXPECT_EQ(LayoutRect(8, 8, 200, 300), foregroundRect.rect()); 224 EXPECT_EQ(LayoutRect(8, 8, 200, 300), foregroundRect.rect());
219 EXPECT_EQ(LayoutRect(8, 8, 400, 0), layerBounds); 225 EXPECT_EQ(LayoutRect(8, 8, 400, 0), layerBounds);
220 } 226 }
221 227
222 TEST_P(PaintLayerClipperTest, ContainPaintClip) { 228 TEST_P(PaintLayerClipperTest, ContainPaintClip) {
223 setBodyInnerHTML( 229 setBodyInnerHTML(
224 "<div id='target'" 230 "<div id='target'"
225 " style='contain: paint; width: 200px; height: 200px; overflow: auto'>" 231 " style='contain: paint; width: 200px; height: 200px; overflow: auto'>"
226 " <div style='height: 400px'></div>" 232 " <div style='height: 400px'></div>"
227 "</div>"); 233 "</div>");
228 234
229 LayoutRect infiniteRect(LayoutRect::infiniteIntRect()); 235 LayoutRect infiniteRect(LayoutRect::infiniteIntRect());
230 PaintLayer* layer = 236 PaintLayer* layer =
231 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); 237 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer();
232 ClipRectsContext context(layer, PaintingClipRectsIgnoringOverflowClip); 238 ClipRectsContext context(layer, PaintingClipRectsIgnoringOverflowClip);
233 LayoutRect layerBounds; 239 LayoutRect layerBounds;
234 ClipRect backgroundRect, foregroundRect; 240 ClipRect backgroundRect, foregroundRect;
235 layer->clipper().calculateRects(context, infiniteRect, layerBounds, 241 layer->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
236 backgroundRect, foregroundRect); 242 .calculateRects(context, infiniteRect, layerBounds, backgroundRect,
243 foregroundRect);
237 EXPECT_GE(backgroundRect.rect().size().width().toInt(), 33554422); 244 EXPECT_GE(backgroundRect.rect().size().width().toInt(), 33554422);
238 EXPECT_GE(backgroundRect.rect().size().height().toInt(), 33554422); 245 EXPECT_GE(backgroundRect.rect().size().height().toInt(), 33554422);
239 EXPECT_EQ(backgroundRect.rect(), foregroundRect.rect()); 246 EXPECT_EQ(backgroundRect.rect(), foregroundRect.rect());
240 EXPECT_EQ(LayoutRect(0, 0, 200, 200), layerBounds); 247 EXPECT_EQ(LayoutRect(0, 0, 200, 200), layerBounds);
241 248
242 ClipRectsContext contextClip(layer, PaintingClipRects); 249 ClipRectsContext contextClip(layer, PaintingClipRects);
243 layer->clipper().calculateRects(contextClip, infiniteRect, layerBounds, 250 layer->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
244 backgroundRect, foregroundRect); 251 .calculateRects(contextClip, infiniteRect, layerBounds, backgroundRect,
252 foregroundRect);
245 EXPECT_EQ(LayoutRect(0, 0, 200, 200), backgroundRect.rect()); 253 EXPECT_EQ(LayoutRect(0, 0, 200, 200), backgroundRect.rect());
246 EXPECT_EQ(LayoutRect(0, 0, 200, 200), foregroundRect.rect()); 254 EXPECT_EQ(LayoutRect(0, 0, 200, 200), foregroundRect.rect());
247 EXPECT_EQ(LayoutRect(0, 0, 200, 200), layerBounds); 255 EXPECT_EQ(LayoutRect(0, 0, 200, 200), layerBounds);
248 } 256 }
249 257
250 TEST_P(PaintLayerClipperTest, NestedContainPaintClip) { 258 TEST_P(PaintLayerClipperTest, NestedContainPaintClip) {
251 setBodyInnerHTML( 259 setBodyInnerHTML(
252 "<div style='contain: paint; width: 200px; height: 200px; overflow: " 260 "<div style='contain: paint; width: 200px; height: 200px; overflow: "
253 "auto'>" 261 "auto'>"
254 " <div id='target' style='contain: paint; height: 400px'>" 262 " <div id='target' style='contain: paint; height: 400px'>"
255 " </div>" 263 " </div>"
256 "</div>"); 264 "</div>");
257 265
258 LayoutRect infiniteRect(LayoutRect::infiniteIntRect()); 266 LayoutRect infiniteRect(LayoutRect::infiniteIntRect());
259 PaintLayer* layer = 267 PaintLayer* layer =
260 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); 268 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer();
261 ClipRectsContext context(layer->parent(), 269 ClipRectsContext context(layer->parent(),
262 PaintingClipRectsIgnoringOverflowClip); 270 PaintingClipRectsIgnoringOverflowClip);
263 LayoutRect layerBounds; 271 LayoutRect layerBounds;
264 ClipRect backgroundRect, foregroundRect; 272 ClipRect backgroundRect, foregroundRect;
265 layer->clipper().calculateRects(context, infiniteRect, layerBounds, 273 layer->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
266 backgroundRect, foregroundRect); 274 .calculateRects(context, infiniteRect, layerBounds, backgroundRect,
275 foregroundRect);
267 EXPECT_EQ(LayoutRect(0, 0, 200, 400), backgroundRect.rect()); 276 EXPECT_EQ(LayoutRect(0, 0, 200, 400), backgroundRect.rect());
268 EXPECT_EQ(LayoutRect(0, 0, 200, 400), foregroundRect.rect()); 277 EXPECT_EQ(LayoutRect(0, 0, 200, 400), foregroundRect.rect());
269 EXPECT_EQ(LayoutRect(0, 0, 200, 400), layerBounds); 278 EXPECT_EQ(LayoutRect(0, 0, 200, 400), layerBounds);
270 279
271 ClipRectsContext contextClip(layer->parent(), PaintingClipRects); 280 ClipRectsContext contextClip(layer->parent(), PaintingClipRects);
272 layer->clipper().calculateRects(contextClip, infiniteRect, layerBounds, 281 layer->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
273 backgroundRect, foregroundRect); 282 .calculateRects(contextClip, infiniteRect, layerBounds, backgroundRect,
283 foregroundRect);
274 EXPECT_EQ(LayoutRect(0, 0, 200, 200), backgroundRect.rect()); 284 EXPECT_EQ(LayoutRect(0, 0, 200, 200), backgroundRect.rect());
275 EXPECT_EQ(LayoutRect(0, 0, 200, 200), foregroundRect.rect()); 285 EXPECT_EQ(LayoutRect(0, 0, 200, 200), foregroundRect.rect());
276 EXPECT_EQ(LayoutRect(0, 0, 200, 400), layerBounds); 286 EXPECT_EQ(LayoutRect(0, 0, 200, 400), layerBounds);
277 } 287 }
278 288
279 TEST_P(PaintLayerClipperTest, LocalClipRectFixedUnderTransform) { 289 TEST_P(PaintLayerClipperTest, LocalClipRectFixedUnderTransform) {
280 setBodyInnerHTML( 290 setBodyInnerHTML(
281 "<div id='transformed'" 291 "<div id='transformed'"
282 " style='will-change: transform; width: 100px; height: 100px;" 292 " style='will-change: transform; width: 100px; height: 100px;"
283 " overflow: hidden'>" 293 " overflow: hidden'>"
284 " <div id='fixed' " 294 " <div id='fixed' "
285 " style='position: fixed; width: 100px; height: 100px;" 295 " style='position: fixed; width: 100px; height: 100px;"
286 " top: -50px'>" 296 " top: -50px'>"
287 " </div>" 297 " </div>"
288 "</div>"); 298 "</div>");
289 299
290 LayoutRect infiniteRect(LayoutRect::infiniteIntRect()); 300 LayoutRect infiniteRect(LayoutRect::infiniteIntRect());
291 PaintLayer* transformed = 301 PaintLayer* transformed =
292 toLayoutBoxModelObject(getLayoutObjectByElementId("transformed")) 302 toLayoutBoxModelObject(getLayoutObjectByElementId("transformed"))
293 ->layer(); 303 ->layer();
294 PaintLayer* fixed = 304 PaintLayer* fixed =
295 toLayoutBoxModelObject(getLayoutObjectByElementId("fixed"))->layer(); 305 toLayoutBoxModelObject(getLayoutObjectByElementId("fixed"))->layer();
296 306
297 EXPECT_EQ(LayoutRect(0, 0, 100, 100), 307 EXPECT_EQ(
298 transformed->clipper().localClipRect(*transformed)); 308 LayoutRect(0, 0, 100, 100),
299 EXPECT_EQ(LayoutRect(0, 50, 100, 100), 309 transformed
300 fixed->clipper().localClipRect(*transformed)); 310 ->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
311 .localClipRect(*transformed));
312 EXPECT_EQ(
313 LayoutRect(0, 50, 100, 100),
314 fixed->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
315 .localClipRect(*transformed));
301 } 316 }
302 317
303 TEST_P(PaintLayerClipperTest, ClearClipRectsRecursive) { 318 TEST_P(PaintLayerClipperTest, ClearClipRectsRecursive) {
304 // SPv2 will re-use a global GeometryMapper, so this 319 // SPv2 will re-use a global GeometryMapper, so this
305 // logic does not apply. 320 // logic does not apply.
306 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 321 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
307 return; 322 return;
308 323
309 setBodyInnerHTML( 324 setBodyInnerHTML(
310 "<style>" 325 "<style>"
311 "div { " 326 "div { "
312 " width: 5px; height: 5px; background: blue; overflow: hidden;" 327 " width: 5px; height: 5px; background: blue; overflow: hidden;"
313 " position: relative;" 328 " position: relative;"
314 "}" 329 "}"
315 "</style>" 330 "</style>"
316 "<div id='parent'>" 331 "<div id='parent'>"
317 " <div id='child'>" 332 " <div id='child'>"
318 " <div id='grandchild'></div>" 333 " <div id='grandchild'></div>"
319 " </div>" 334 " </div>"
320 "</div>"); 335 "</div>");
321 336
322 PaintLayer* parent = 337 PaintLayer* parent =
323 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); 338 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer();
324 PaintLayer* child = 339 PaintLayer* child =
325 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); 340 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer();
326 341
327 EXPECT_TRUE(parent->clipRectsCache()); 342 EXPECT_TRUE(parent->clipRectsCache());
328 EXPECT_TRUE(child->clipRectsCache()); 343 EXPECT_TRUE(child->clipRectsCache());
329 344
330 parent->clipper().clearClipRectsIncludingDescendants(); 345 parent->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
346 .clearClipRectsIncludingDescendants();
331 347
332 EXPECT_FALSE(parent->clipRectsCache()); 348 EXPECT_FALSE(parent->clipRectsCache());
333 EXPECT_FALSE(child->clipRectsCache()); 349 EXPECT_FALSE(child->clipRectsCache());
334 } 350 }
335 351
336 TEST_P(PaintLayerClipperTest, ClearClipRectsRecursiveChild) { 352 TEST_P(PaintLayerClipperTest, ClearClipRectsRecursiveChild) {
337 // SPv2 will re-use a global GeometryMapper, so this 353 // SPv2 will re-use a global GeometryMapper, so this
338 // logic does not apply. 354 // logic does not apply.
339 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 355 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
340 return; 356 return;
(...skipping 12 matching lines...) Expand all
353 "</div>"); 369 "</div>");
354 370
355 PaintLayer* parent = 371 PaintLayer* parent =
356 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); 372 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer();
357 PaintLayer* child = 373 PaintLayer* child =
358 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); 374 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer();
359 375
360 EXPECT_TRUE(parent->clipRectsCache()); 376 EXPECT_TRUE(parent->clipRectsCache());
361 EXPECT_TRUE(child->clipRectsCache()); 377 EXPECT_TRUE(child->clipRectsCache());
362 378
363 child->clipper().clearClipRectsIncludingDescendants(); 379 child->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
380 .clearClipRectsIncludingDescendants();
364 381
365 EXPECT_TRUE(parent->clipRectsCache()); 382 EXPECT_TRUE(parent->clipRectsCache());
366 EXPECT_FALSE(child->clipRectsCache()); 383 EXPECT_FALSE(child->clipRectsCache());
367 } 384 }
368 385
369 TEST_P(PaintLayerClipperTest, ClearClipRectsRecursiveOneType) { 386 TEST_P(PaintLayerClipperTest, ClearClipRectsRecursiveOneType) {
370 // SPv2 will re-use a global GeometryMapper, so this 387 // SPv2 will re-use a global GeometryMapper, so this
371 // logic does not apply. 388 // logic does not apply.
372 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 389 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
373 return; 390 return;
374 391
375 setBodyInnerHTML( 392 setBodyInnerHTML(
376 "<style>" 393 "<style>"
377 "div { " 394 "div { "
378 " width: 5px; height: 5px; background: blue;" 395 " width: 5px; height: 5px; background: blue;"
379 " position: relative;" 396 " position: relative;"
380 "}" 397 "}"
381 "</style>" 398 "</style>"
382 "<div id='parent'>" 399 "<div id='parent'>"
383 " <div id='child'>" 400 " <div id='child'>"
384 " <div id='grandchild'></div>" 401 " <div id='grandchild'></div>"
385 " </div>" 402 " </div>"
386 "</div>"); 403 "</div>");
387 404
388 PaintLayer* parent = 405 PaintLayer* parent =
389 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); 406 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer();
390 PaintLayer* child = 407 PaintLayer* child =
391 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); 408 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer();
392 409
393 EXPECT_TRUE(parent->clipRectsCache()); 410 EXPECT_TRUE(parent->clipRectsCache());
394 EXPECT_TRUE(child->clipRectsCache()); 411 EXPECT_TRUE(child->clipRectsCache());
395 EXPECT_TRUE(parent->clipRectsCache()->get(AbsoluteClipRects).root); 412 EXPECT_TRUE(parent->clipRectsCache()->get(AbsoluteClipRects).root);
396 EXPECT_TRUE(child->clipRectsCache()->get(AbsoluteClipRects).root); 413 EXPECT_TRUE(child->clipRectsCache()->get(AbsoluteClipRects).root);
397 414
398 parent->clipper().clearClipRectsIncludingDescendants(AbsoluteClipRects); 415 parent->clipper(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
416 .clearClipRectsIncludingDescendants(AbsoluteClipRects);
399 417
400 EXPECT_TRUE(parent->clipRectsCache()); 418 EXPECT_TRUE(parent->clipRectsCache());
401 EXPECT_TRUE(child->clipRectsCache()); 419 EXPECT_TRUE(child->clipRectsCache());
402 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); 420 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root);
403 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); 421 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root);
404 } 422 }
405 423
406 } // namespace blink 424 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698