| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/layout/LayoutBoxModelObject.h" | 5 #include "core/layout/LayoutBoxModelObject.h" |
| 6 #include "core/layout/compositing/CompositedLayerMapping.h" | 6 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 7 #include "core/paint/PaintControllerPaintTest.h" | 7 #include "core/paint/PaintControllerPaintTest.h" |
| 8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
| 9 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 9 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| 10 | 10 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 TestDisplayItem(content1, backgroundType), | 190 TestDisplayItem(content1, backgroundType), |
| 191 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence), | 191 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence), |
| 192 TestDisplayItem(container2Layer, DisplayItem::kSubsequence), | 192 TestDisplayItem(container2Layer, DisplayItem::kSubsequence), |
| 193 TestDisplayItem(container2, backgroundType), | 193 TestDisplayItem(container2, backgroundType), |
| 194 TestDisplayItem(content2, backgroundType), | 194 TestDisplayItem(content2, backgroundType), |
| 195 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence), | 195 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence), |
| 196 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | 196 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 TEST_P(PaintLayerPainterTest, CachedSubsequenceForSVGRoot) { |
| 201 setBodyInnerHTML( |
| 202 "<svg id='svg' style='position: relative'>" |
| 203 " <rect id='rect' x='10' y='10' width='100' height='100' rx='15' " |
| 204 "ry='15'/>" |
| 205 "</svg>" |
| 206 "<div id='div' style='position: relative; width: 50x; height: " |
| 207 "50px'></div>"); |
| 208 document().view()->updateAllLifecyclePhases(); |
| 209 |
| 210 PaintLayer& htmlLayer = |
| 211 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) |
| 212 ->layer(); |
| 213 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
| 214 PaintLayer& svgLayer = *toLayoutBoxModelObject(svg).layer(); |
| 215 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); |
| 216 LayoutObject& div = *document().getElementById("div")->layoutObject(); |
| 217 |
| 218 DisplayItem::Type clipBoxBegin = |
| 219 DisplayItem::paintPhaseToClipBoxType(PaintPhaseForeground); |
| 220 DisplayItem::Type clipBoxEnd = |
| 221 DisplayItem::clipTypeToEndClipType(clipBoxBegin); |
| 222 |
| 223 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 224 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 225 // SPv2 slips the clip box (see BoxClipper). |
| 226 EXPECT_DISPLAY_LIST( |
| 227 rootPaintController().getDisplayItemList(), 10, |
| 228 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 229 TestDisplayItem(layoutView(), documentBackgroundType), |
| 230 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), |
| 231 TestDisplayItem(svgLayer, DisplayItem::kSubsequence), |
| 232 TestDisplayItem(svg, DisplayItem::kBeginTransform), |
| 233 TestDisplayItem(rect, foregroundType), |
| 234 TestDisplayItem(svg, DisplayItem::kEndTransform), |
| 235 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence), |
| 236 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), |
| 237 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); |
| 238 } else { |
| 239 // SPv2 slips the clip box (see BoxClipper). |
| 240 EXPECT_DISPLAY_LIST( |
| 241 rootPaintController().getDisplayItemList(), 12, |
| 242 TestDisplayItem(layoutView(), |
| 243 DisplayItem::kClipFrameToVisibleContentRect), |
| 244 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 245 TestDisplayItem(layoutView(), documentBackgroundType), |
| 246 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), |
| 247 TestDisplayItem(svgLayer, DisplayItem::kSubsequence), |
| 248 TestDisplayItem(svg, DisplayItem::kBeginTransform), |
| 249 TestDisplayItem(rect, foregroundType), |
| 250 TestDisplayItem(svg, DisplayItem::kEndTransform), |
| 251 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence), |
| 252 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), |
| 253 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence), |
| 254 TestDisplayItem(layoutView(), |
| 255 DisplayItem::clipTypeToEndClipType( |
| 256 DisplayItem::kClipFrameToVisibleContentRect))); |
| 257 } |
| 258 } else { |
| 259 EXPECT_DISPLAY_LIST( |
| 260 rootPaintController().getDisplayItemList(), 10, |
| 261 TestDisplayItem(layoutView(), documentBackgroundType), |
| 262 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), |
| 263 TestDisplayItem(svgLayer, DisplayItem::kSubsequence), |
| 264 TestDisplayItem(svg, clipBoxBegin), |
| 265 TestDisplayItem(svg, DisplayItem::kBeginTransform), |
| 266 TestDisplayItem(rect, foregroundType), |
| 267 TestDisplayItem(svg, DisplayItem::kEndTransform), |
| 268 TestDisplayItem(svg, clipBoxEnd), |
| 269 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence), |
| 270 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); |
| 271 } |
| 272 |
| 273 // Change the color of the div. This should not invalidate the subsequence |
| 274 // for the SVG root. |
| 275 toHTMLElement(div.node()) |
| 276 ->setAttribute(HTMLNames::styleAttr, |
| 277 "position: relative; width: 50x; height: 50px; " |
| 278 "background-color: green"); |
| 279 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 280 EXPECT_TRUE(paintWithoutCommit()); |
| 281 |
| 282 // Reuse of SVG and document background. 2 fewer with SPv2 enabled because |
| 283 // clip display items don't appear in SPv2 display lists. |
| 284 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 285 EXPECT_EQ(6, numCachedNewItems()); |
| 286 else |
| 287 EXPECT_EQ(8, numCachedNewItems()); |
| 288 |
| 289 commit(); |
| 290 |
| 291 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 292 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 293 EXPECT_DISPLAY_LIST( |
| 294 rootPaintController().getDisplayItemList(), 11, |
| 295 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 296 TestDisplayItem(layoutView(), documentBackgroundType), |
| 297 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), |
| 298 TestDisplayItem(svgLayer, DisplayItem::kSubsequence), |
| 299 TestDisplayItem(svg, DisplayItem::kBeginTransform), |
| 300 TestDisplayItem(rect, foregroundType), |
| 301 TestDisplayItem(svg, DisplayItem::kEndTransform), |
| 302 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence), |
| 303 TestDisplayItem(div, backgroundType), |
| 304 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), |
| 305 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); |
| 306 } else { |
| 307 EXPECT_DISPLAY_LIST( |
| 308 rootPaintController().getDisplayItemList(), 13, |
| 309 TestDisplayItem(layoutView(), |
| 310 DisplayItem::kClipFrameToVisibleContentRect), |
| 311 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 312 TestDisplayItem(layoutView(), documentBackgroundType), |
| 313 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), |
| 314 TestDisplayItem(svgLayer, DisplayItem::kSubsequence), |
| 315 TestDisplayItem(svg, DisplayItem::kBeginTransform), |
| 316 TestDisplayItem(rect, foregroundType), |
| 317 TestDisplayItem(svg, DisplayItem::kEndTransform), |
| 318 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence), |
| 319 TestDisplayItem(div, backgroundType), |
| 320 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), |
| 321 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence), |
| 322 TestDisplayItem(layoutView(), |
| 323 DisplayItem::clipTypeToEndClipType( |
| 324 DisplayItem::kClipFrameToVisibleContentRect))); |
| 325 } |
| 326 } else { |
| 327 EXPECT_DISPLAY_LIST( |
| 328 rootPaintController().getDisplayItemList(), 11, |
| 329 TestDisplayItem(layoutView(), documentBackgroundType), |
| 330 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), |
| 331 TestDisplayItem(svgLayer, DisplayItem::kSubsequence), |
| 332 TestDisplayItem(svg, clipBoxBegin), |
| 333 TestDisplayItem(svg, DisplayItem::kBeginTransform), |
| 334 TestDisplayItem(rect, foregroundType), |
| 335 TestDisplayItem(svg, DisplayItem::kEndTransform), |
| 336 TestDisplayItem(svg, clipBoxEnd), |
| 337 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence), |
| 338 TestDisplayItem(div, backgroundType), |
| 339 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), |
| 340 TestDisplayItem(layoutView(), |
| 341 DisplayItem::clipTypeToEndClipType( |
| 342 DisplayItem::kClipFrameToVisibleContentRect))); |
| 343 } |
| 344 } |
| 345 |
| 200 TEST_P(PaintLayerPainterTest, CachedSubsequenceOnInterestRectChange) { | 346 TEST_P(PaintLayerPainterTest, CachedSubsequenceOnInterestRectChange) { |
| 201 // TODO(wangxianzhu): SPv2 deals with interest rect differently, so disable | 347 // TODO(wangxianzhu): SPv2 deals with interest rect differently, so disable |
| 202 // this test for SPv2 temporarily. | 348 // this test for SPv2 temporarily. |
| 203 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 349 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 204 return; | 350 return; |
| 205 | 351 |
| 206 setBodyInnerHTML( | 352 setBodyInnerHTML( |
| 207 "<div id='container1' style='position: relative; z-index: 1; width: " | 353 "<div id='container1' style='position: relative; z-index: 1; width: " |
| 208 "200px; height: 200px; background-color: blue'>" | 354 "200px; height: 200px; background-color: blue'>" |
| 209 " <div id='content1' style='position: absolute; width: 100px; height: " | 355 " <div id='content1' style='position: absolute; width: 100px; height: " |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 EXPECT_FALSE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 998 EXPECT_FALSE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 853 | 999 |
| 854 toHTMLElement(table.node()) | 1000 toHTMLElement(table.node()) |
| 855 ->setAttribute(HTMLNames::styleAttr, | 1001 ->setAttribute(HTMLNames::styleAttr, |
| 856 "position: relative; border-collapse: collapse"); | 1002 "position: relative; border-collapse: collapse"); |
| 857 document().view()->updateAllLifecyclePhases(); | 1003 document().view()->updateAllLifecyclePhases(); |
| 858 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 1004 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 859 } | 1005 } |
| 860 | 1006 |
| 861 } // namespace blink | 1007 } // namespace blink |
| OLD | NEW |