| 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/paint/PaintLayerPainter.h" | 5 #include "core/paint/PaintLayerPainter.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutBoxModelObject.h" | 7 #include "core/layout/LayoutBoxModelObject.h" |
| 8 #include "core/layout/compositing/CompositedLayerMapping.h" | 8 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 9 #include "core/paint/PaintControllerPaintTest.h" | 9 #include "core/paint/PaintControllerPaintTest.h" |
| 10 #include "platform/graphics/GraphicsContext.h" | 10 #include "platform/graphics/GraphicsContext.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 " <div id='content1' style='position: absolute; width: 100px; height: " | 62 " <div id='content1' style='position: absolute; width: 100px; height: " |
| 63 "100px; background-color: red'></div>" | 63 "100px; background-color: red'></div>" |
| 64 "</div>" | 64 "</div>" |
| 65 "<div id='container2' style='position: relative; z-index: 1; width: " | 65 "<div id='container2' style='position: relative; z-index: 1; width: " |
| 66 "200px; height: 200px; background-color: blue'>" | 66 "200px; height: 200px; background-color: blue'>" |
| 67 " <div id='content2' style='position: absolute; width: 100px; height: " | 67 " <div id='content2' style='position: absolute; width: 100px; height: " |
| 68 "100px; background-color: green'></div>" | 68 "100px; background-color: green'></div>" |
| 69 "</div>"); | 69 "</div>"); |
| 70 document().view()->updateAllLifecyclePhases(); | 70 document().view()->updateAllLifecyclePhases(); |
| 71 | 71 |
| 72 PaintLayer& htmlLayer = | |
| 73 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) | |
| 74 ->layer(); | |
| 75 LayoutObject& container1 = | 72 LayoutObject& container1 = |
| 76 *document().getElementById("container1")->layoutObject(); | 73 *document().getElementById("container1")->layoutObject(); |
| 77 PaintLayer& container1Layer = *toLayoutBoxModelObject(container1).layer(); | |
| 78 LayoutObject& content1 = | 74 LayoutObject& content1 = |
| 79 *document().getElementById("content1")->layoutObject(); | 75 *document().getElementById("content1")->layoutObject(); |
| 80 LayoutObject& container2 = | 76 LayoutObject& container2 = |
| 81 *document().getElementById("container2")->layoutObject(); | 77 *document().getElementById("container2")->layoutObject(); |
| 82 PaintLayer& container2Layer = *toLayoutBoxModelObject(container2).layer(); | |
| 83 LayoutObject& content2 = | 78 LayoutObject& content2 = |
| 84 *document().getElementById("content2")->layoutObject(); | 79 *document().getElementById("content2")->layoutObject(); |
| 85 | 80 |
| 86 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 81 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 87 EXPECT_DISPLAY_LIST( | 82 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 5, |
| 88 rootPaintController().getDisplayItemList(), 13, | 83 TestDisplayItem(layoutView(), documentBackgroundType), |
| 89 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), | 84 TestDisplayItem(container1, backgroundType), |
| 90 TestDisplayItem(layoutView(), documentBackgroundType), | 85 TestDisplayItem(content1, backgroundType), |
| 91 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 86 TestDisplayItem(container2, backgroundType), |
| 92 TestDisplayItem(container1Layer, DisplayItem::kSubsequence), | 87 TestDisplayItem(content2, backgroundType)); |
| 93 TestDisplayItem(container1, backgroundType), | |
| 94 TestDisplayItem(content1, backgroundType), | |
| 95 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence), | |
| 96 TestDisplayItem(container2Layer, DisplayItem::kSubsequence), | |
| 97 TestDisplayItem(container2, backgroundType), | |
| 98 TestDisplayItem(content2, backgroundType), | |
| 99 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence), | |
| 100 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), | |
| 101 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); | |
| 102 } else { | 88 } else { |
| 103 EXPECT_DISPLAY_LIST( | 89 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 5, |
| 104 rootPaintController().getDisplayItemList(), 11, | 90 TestDisplayItem(layoutView(), documentBackgroundType), |
| 105 TestDisplayItem(layoutView(), documentBackgroundType), | 91 TestDisplayItem(container1, backgroundType), |
| 106 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 92 TestDisplayItem(content1, backgroundType), |
| 107 TestDisplayItem(container1Layer, DisplayItem::kSubsequence), | 93 TestDisplayItem(container2, backgroundType), |
| 108 TestDisplayItem(container1, backgroundType), | 94 TestDisplayItem(content2, backgroundType)); |
| 109 TestDisplayItem(content1, backgroundType), | |
| 110 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence), | |
| 111 TestDisplayItem(container2Layer, DisplayItem::kSubsequence), | |
| 112 TestDisplayItem(container2, backgroundType), | |
| 113 TestDisplayItem(content2, backgroundType), | |
| 114 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence), | |
| 115 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | |
| 116 } | 95 } |
| 117 | 96 |
| 118 toHTMLElement(content1.node()) | 97 toHTMLElement(content1.node()) |
| 119 ->setAttribute(HTMLNames::styleAttr, | 98 ->setAttribute(HTMLNames::styleAttr, |
| 120 "position: absolute; width: 100px; height: 100px; " | 99 "position: absolute; width: 100px; height: 100px; " |
| 121 "background-color: green"); | 100 "background-color: green"); |
| 122 document().view()->updateAllLifecyclePhasesExceptPaint(); | 101 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 123 EXPECT_TRUE(paintWithoutCommit()); | 102 EXPECT_TRUE(paintWithoutCommit()); |
| 124 | 103 |
| 125 EXPECT_EQ(6, numCachedNewItems()); | 104 EXPECT_EQ(4, numCachedNewItems()); |
| 126 | 105 |
| 127 commit(); | 106 commit(); |
| 128 | 107 |
| 129 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 108 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 130 EXPECT_DISPLAY_LIST( | 109 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 5, |
| 131 rootPaintController().getDisplayItemList(), 13, | 110 TestDisplayItem(layoutView(), documentBackgroundType), |
| 132 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), | 111 TestDisplayItem(container1, backgroundType), |
| 133 TestDisplayItem(layoutView(), documentBackgroundType), | 112 TestDisplayItem(content1, backgroundType), |
| 134 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 113 TestDisplayItem(container2, backgroundType), |
| 135 TestDisplayItem(container1Layer, DisplayItem::kSubsequence), | 114 TestDisplayItem(content2, backgroundType)); |
| 136 TestDisplayItem(container1, backgroundType), | |
| 137 TestDisplayItem(content1, backgroundType), | |
| 138 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence), | |
| 139 TestDisplayItem(container2Layer, DisplayItem::kSubsequence), | |
| 140 TestDisplayItem(container2, backgroundType), | |
| 141 TestDisplayItem(content2, backgroundType), | |
| 142 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence), | |
| 143 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), | |
| 144 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); | |
| 145 } else { | 115 } else { |
| 146 EXPECT_DISPLAY_LIST( | 116 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 5, |
| 147 rootPaintController().getDisplayItemList(), 11, | 117 TestDisplayItem(layoutView(), documentBackgroundType), |
| 148 TestDisplayItem(layoutView(), documentBackgroundType), | 118 TestDisplayItem(container1, backgroundType), |
| 149 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 119 TestDisplayItem(content1, backgroundType), |
| 150 TestDisplayItem(container1Layer, DisplayItem::kSubsequence), | 120 TestDisplayItem(container2, backgroundType), |
| 151 TestDisplayItem(container1, backgroundType), | 121 TestDisplayItem(content2, backgroundType)); |
| 152 TestDisplayItem(content1, backgroundType), | |
| 153 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence), | |
| 154 TestDisplayItem(container2Layer, DisplayItem::kSubsequence), | |
| 155 TestDisplayItem(container2, backgroundType), | |
| 156 TestDisplayItem(content2, backgroundType), | |
| 157 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence), | |
| 158 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | |
| 159 } | 122 } |
| 160 } | 123 } |
| 161 | 124 |
| 162 TEST_P(PaintLayerPainterTest, CachedSubsequenceForSVGRoot) { | 125 TEST_P(PaintLayerPainterTest, CachedSubsequenceForSVGRoot) { |
| 163 setBodyInnerHTML( | 126 setBodyInnerHTML( |
| 164 "<svg id='svg' style='position: relative'>" | 127 "<svg id='svg' style='position: relative'>" |
| 165 " <rect id='rect' x='10' y='10' width='100' height='100' rx='15' " | 128 " <rect id='rect' x='10' y='10' width='100' height='100' rx='15' " |
| 166 "ry='15'/>" | 129 "ry='15'/>" |
| 167 "</svg>" | 130 "</svg>" |
| 168 "<div id='div' style='position: relative; width: 50x; height: " | 131 "<div id='div' style='position: relative; width: 50x; height: " |
| 169 "50px'></div>"); | 132 "50px'></div>"); |
| 170 document().view()->updateAllLifecyclePhases(); | 133 document().view()->updateAllLifecyclePhases(); |
| 171 | 134 |
| 172 PaintLayer& htmlLayer = | |
| 173 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) | |
| 174 ->layer(); | |
| 175 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 135 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
| 176 PaintLayer& svgLayer = *toLayoutBoxModelObject(svg).layer(); | |
| 177 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); | 136 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); |
| 178 LayoutObject& div = *document().getElementById("div")->layoutObject(); | 137 LayoutObject& div = *document().getElementById("div")->layoutObject(); |
| 179 | 138 |
| 180 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 139 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 181 // SPv2 slips the clip box (see BoxClipper). | 140 // SPv2 slips the clip box (see BoxClipper). |
| 182 EXPECT_DISPLAY_LIST( | 141 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, |
| 183 rootPaintController().getDisplayItemList(), 8, | 142 TestDisplayItem(layoutView(), documentBackgroundType), |
| 184 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), | 143 TestDisplayItem(rect, foregroundType)); |
| 185 TestDisplayItem(layoutView(), documentBackgroundType), | |
| 186 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | |
| 187 TestDisplayItem(svgLayer, DisplayItem::kSubsequence), | |
| 188 TestDisplayItem(rect, foregroundType), | |
| 189 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence), | |
| 190 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), | |
| 191 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); | |
| 192 } else { | 144 } else { |
| 193 EXPECT_DISPLAY_LIST( | 145 EXPECT_DISPLAY_LIST( |
| 194 rootPaintController().getDisplayItemList(), 10, | 146 rootPaintController().getDisplayItemList(), 6, |
| 195 TestDisplayItem(layoutView(), documentBackgroundType), | 147 TestDisplayItem(layoutView(), documentBackgroundType), |
| 196 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | |
| 197 TestDisplayItem(svgLayer, DisplayItem::kSubsequence), | |
| 198 TestDisplayItem(svg, DisplayItem::kClipLayerForeground), | 148 TestDisplayItem(svg, DisplayItem::kClipLayerForeground), |
| 199 TestDisplayItem(svg, DisplayItem::kBeginTransform), | 149 TestDisplayItem(svg, DisplayItem::kBeginTransform), |
| 200 TestDisplayItem(rect, foregroundType), | 150 TestDisplayItem(rect, foregroundType), |
| 201 TestDisplayItem(svg, DisplayItem::kEndTransform), | 151 TestDisplayItem(svg, DisplayItem::kEndTransform), |
| 202 TestDisplayItem(svg, DisplayItem::clipTypeToEndClipType( | 152 TestDisplayItem(svg, DisplayItem::clipTypeToEndClipType( |
| 203 DisplayItem::kClipLayerForeground)), | 153 DisplayItem::kClipLayerForeground))); |
| 204 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence), | |
| 205 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | |
| 206 } | 154 } |
| 207 | 155 |
| 208 // Change the color of the div. This should not invalidate the subsequence | 156 // Change the color of the div. This should not invalidate the subsequence |
| 209 // for the SVG root. | 157 // for the SVG root. |
| 210 toHTMLElement(div.node()) | 158 toHTMLElement(div.node()) |
| 211 ->setAttribute(HTMLNames::styleAttr, | 159 ->setAttribute(HTMLNames::styleAttr, |
| 212 "position: relative; width: 50x; height: 50px; " | 160 "position: relative; width: 50x; height: 50px; " |
| 213 "background-color: green"); | 161 "background-color: green"); |
| 214 document().view()->updateAllLifecyclePhasesExceptPaint(); | 162 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 215 EXPECT_TRUE(paintWithoutCommit()); | 163 EXPECT_TRUE(paintWithoutCommit()); |
| 216 | 164 |
| 217 // Reuse of SVG and document background. 2 fewer with SPv2 enabled because | 165 // Reuse of SVG and document background. 2 fewer with SPv2 enabled because |
| 218 // clip display items don't appear in SPv2 display lists. | 166 // clip display items don't appear in SPv2 display lists. |
| 219 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 167 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 220 EXPECT_EQ(4, numCachedNewItems()); | 168 EXPECT_EQ(2, numCachedNewItems()); |
| 221 else | 169 else |
| 222 EXPECT_EQ(8, numCachedNewItems()); | 170 EXPECT_EQ(6, numCachedNewItems()); |
| 223 | 171 |
| 224 commit(); | 172 commit(); |
| 225 | 173 |
| 226 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 174 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 227 EXPECT_DISPLAY_LIST( | 175 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3, |
| 228 rootPaintController().getDisplayItemList(), 9, | 176 TestDisplayItem(layoutView(), documentBackgroundType), |
| 229 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), | 177 TestDisplayItem(rect, foregroundType), |
| 230 TestDisplayItem(layoutView(), documentBackgroundType), | 178 TestDisplayItem(div, backgroundType)); |
| 231 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | |
| 232 TestDisplayItem(svgLayer, DisplayItem::kSubsequence), | |
| 233 TestDisplayItem(rect, foregroundType), | |
| 234 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence), | |
| 235 TestDisplayItem(div, backgroundType), | |
| 236 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), | |
| 237 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); | |
| 238 } else { | 179 } else { |
| 239 EXPECT_DISPLAY_LIST( | 180 EXPECT_DISPLAY_LIST( |
| 240 rootPaintController().getDisplayItemList(), 11, | 181 rootPaintController().getDisplayItemList(), 7, |
| 241 TestDisplayItem(layoutView(), documentBackgroundType), | 182 TestDisplayItem(layoutView(), documentBackgroundType), |
| 242 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | |
| 243 TestDisplayItem(svgLayer, DisplayItem::kSubsequence), | |
| 244 TestDisplayItem(svg, DisplayItem::kClipLayerForeground), | 183 TestDisplayItem(svg, DisplayItem::kClipLayerForeground), |
| 245 TestDisplayItem(svg, DisplayItem::kBeginTransform), | 184 TestDisplayItem(svg, DisplayItem::kBeginTransform), |
| 246 TestDisplayItem(rect, foregroundType), | 185 TestDisplayItem(rect, foregroundType), |
| 247 TestDisplayItem(svg, DisplayItem::kEndTransform), | 186 TestDisplayItem(svg, DisplayItem::kEndTransform), |
| 248 TestDisplayItem(svg, DisplayItem::clipTypeToEndClipType( | 187 TestDisplayItem(svg, DisplayItem::clipTypeToEndClipType( |
| 249 DisplayItem::kClipLayerForeground)), | 188 DisplayItem::kClipLayerForeground)), |
| 250 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence), | |
| 251 TestDisplayItem(div, backgroundType), | 189 TestDisplayItem(div, backgroundType), |
| 252 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), | |
| 253 TestDisplayItem(layoutView(), | 190 TestDisplayItem(layoutView(), |
| 254 DisplayItem::clipTypeToEndClipType( | 191 DisplayItem::clipTypeToEndClipType( |
| 255 DisplayItem::kClipFrameToVisibleContentRect))); | 192 DisplayItem::kClipFrameToVisibleContentRect))); |
| 256 } | 193 } |
| 257 } | 194 } |
| 258 | 195 |
| 259 TEST_P(PaintLayerPainterTest, CachedSubsequenceOnInterestRectChange) { | 196 TEST_P(PaintLayerPainterTest, CachedSubsequenceOnInterestRectChange) { |
| 260 // TODO(wangxianzhu): SPv2 deals with interest rect differently, so disable | 197 // TODO(wangxianzhu): SPv2 deals with interest rect differently, so disable |
| 261 // this test for SPv2 temporarily. | 198 // this test for SPv2 temporarily. |
| 262 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 199 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 275 " <div id='content2b' style='position: absolute; top: 200px; width: " | 212 " <div id='content2b' style='position: absolute; top: 200px; width: " |
| 276 "100px; height: 100px; background-color: green'></div>" | 213 "100px; height: 100px; background-color: green'></div>" |
| 277 "</div>" | 214 "</div>" |
| 278 "<div id='container3' style='position: absolute; z-index: 2; left: " | 215 "<div id='container3' style='position: absolute; z-index: 2; left: " |
| 279 "300px; top: 0; width: 200px; height: 200px; background-color: blue'>" | 216 "300px; top: 0; width: 200px; height: 200px; background-color: blue'>" |
| 280 " <div id='content3' style='position: absolute; width: 200px; height: " | 217 " <div id='content3' style='position: absolute; width: 200px; height: " |
| 281 "200px; background-color: green'></div>" | 218 "200px; background-color: green'></div>" |
| 282 "</div>"); | 219 "</div>"); |
| 283 rootPaintController().invalidateAll(); | 220 rootPaintController().invalidateAll(); |
| 284 | 221 |
| 285 PaintLayer& htmlLayer = | |
| 286 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) | |
| 287 ->layer(); | |
| 288 LayoutObject& container1 = | 222 LayoutObject& container1 = |
| 289 *document().getElementById("container1")->layoutObject(); | 223 *document().getElementById("container1")->layoutObject(); |
| 290 PaintLayer& container1Layer = *toLayoutBoxModelObject(container1).layer(); | |
| 291 LayoutObject& content1 = | 224 LayoutObject& content1 = |
| 292 *document().getElementById("content1")->layoutObject(); | 225 *document().getElementById("content1")->layoutObject(); |
| 293 LayoutObject& container2 = | 226 LayoutObject& container2 = |
| 294 *document().getElementById("container2")->layoutObject(); | 227 *document().getElementById("container2")->layoutObject(); |
| 295 PaintLayer& container2Layer = *toLayoutBoxModelObject(container2).layer(); | |
| 296 LayoutObject& content2a = | 228 LayoutObject& content2a = |
| 297 *document().getElementById("content2a")->layoutObject(); | 229 *document().getElementById("content2a")->layoutObject(); |
| 298 LayoutObject& content2b = | 230 LayoutObject& content2b = |
| 299 *document().getElementById("content2b")->layoutObject(); | 231 *document().getElementById("content2b")->layoutObject(); |
| 300 LayoutObject& container3 = | 232 LayoutObject& container3 = |
| 301 *document().getElementById("container3")->layoutObject(); | 233 *document().getElementById("container3")->layoutObject(); |
| 302 PaintLayer& container3Layer = *toLayoutBoxModelObject(container3).layer(); | |
| 303 LayoutObject& content3 = | 234 LayoutObject& content3 = |
| 304 *document().getElementById("content3")->layoutObject(); | 235 *document().getElementById("content3")->layoutObject(); |
| 305 | 236 |
| 306 document().view()->updateAllLifecyclePhasesExceptPaint(); | 237 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 307 IntRect interestRect(0, 0, 400, 300); | 238 IntRect interestRect(0, 0, 400, 300); |
| 308 paint(&interestRect); | 239 paint(&interestRect); |
| 309 | 240 |
| 310 // Container1 is fully in the interest rect; | 241 // Container1 is fully in the interest rect; |
| 311 // Container2 is partly (including its stacking chidren) in the interest rect; | 242 // Container2 is partly (including its stacking chidren) in the interest rect; |
| 312 // Content2b is out of the interest rect and output nothing; | 243 // Content2b is out of the interest rect and output nothing; |
| 313 // Container3 is partly in the interest rect. | 244 // Container3 is partly in the interest rect. |
| 314 EXPECT_DISPLAY_LIST( | 245 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 7, |
| 315 rootPaintController().getDisplayItemList(), 15, | 246 TestDisplayItem(layoutView(), documentBackgroundType), |
| 316 TestDisplayItem(layoutView(), documentBackgroundType), | 247 TestDisplayItem(container1, backgroundType), |
| 317 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 248 TestDisplayItem(content1, backgroundType), |
| 318 TestDisplayItem(container1Layer, DisplayItem::kSubsequence), | 249 TestDisplayItem(container2, backgroundType), |
| 319 TestDisplayItem(container1, backgroundType), | 250 TestDisplayItem(content2a, backgroundType), |
| 320 TestDisplayItem(content1, backgroundType), | 251 TestDisplayItem(container3, backgroundType), |
| 321 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence), | 252 TestDisplayItem(content3, backgroundType)); |
| 322 TestDisplayItem(container2Layer, DisplayItem::kSubsequence), | |
| 323 TestDisplayItem(container2, backgroundType), | |
| 324 TestDisplayItem(content2a, backgroundType), | |
| 325 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence), | |
| 326 TestDisplayItem(container3Layer, DisplayItem::kSubsequence), | |
| 327 TestDisplayItem(container3, backgroundType), | |
| 328 TestDisplayItem(content3, backgroundType), | |
| 329 TestDisplayItem(container3Layer, DisplayItem::kEndSubsequence), | |
| 330 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | |
| 331 | 253 |
| 332 document().view()->updateAllLifecyclePhasesExceptPaint(); | 254 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 333 IntRect newInterestRect(0, 100, 300, 1000); | 255 IntRect newInterestRect(0, 100, 300, 1000); |
| 334 EXPECT_TRUE(paintWithoutCommit(&newInterestRect)); | 256 EXPECT_TRUE(paintWithoutCommit(&newInterestRect)); |
| 335 | 257 |
| 336 // Container1 becomes partly in the interest rect, but uses cached subsequence | 258 // Container1 becomes partly in the interest rect, but uses cached subsequence |
| 337 // because it was fully painted before; | 259 // because it was fully painted before; |
| 338 // Container2's intersection with the interest rect changes; | 260 // Container2's intersection with the interest rect changes; |
| 339 // Content2b is out of the interest rect and outputs nothing; | 261 // Content2b is out of the interest rect and outputs nothing; |
| 340 // Container3 becomes out of the interest rect and outputs empty subsequence | 262 // Container3 becomes out of the interest rect and outputs empty subsequence |
| 341 // pair. | 263 // pair. |
| 342 EXPECT_EQ(7, numCachedNewItems()); | 264 EXPECT_EQ(5, numCachedNewItems()); |
| 343 | 265 |
| 344 commit(); | 266 commit(); |
| 345 | 267 |
| 346 EXPECT_DISPLAY_LIST( | 268 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 6, |
| 347 rootPaintController().getDisplayItemList(), 14, | 269 TestDisplayItem(layoutView(), documentBackgroundType), |
| 348 TestDisplayItem(layoutView(), documentBackgroundType), | 270 TestDisplayItem(container1, backgroundType), |
| 349 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 271 TestDisplayItem(content1, backgroundType), |
| 350 TestDisplayItem(container1Layer, DisplayItem::kSubsequence), | 272 TestDisplayItem(container2, backgroundType), |
| 351 TestDisplayItem(container1, backgroundType), | 273 TestDisplayItem(content2a, backgroundType), |
| 352 TestDisplayItem(content1, backgroundType), | 274 TestDisplayItem(content2b, backgroundType)); |
| 353 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence), | |
| 354 TestDisplayItem(container2Layer, DisplayItem::kSubsequence), | |
| 355 TestDisplayItem(container2, backgroundType), | |
| 356 TestDisplayItem(content2a, backgroundType), | |
| 357 TestDisplayItem(content2b, backgroundType), | |
| 358 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence), | |
| 359 TestDisplayItem(container3Layer, DisplayItem::kSubsequence), | |
| 360 TestDisplayItem(container3Layer, DisplayItem::kEndSubsequence), | |
| 361 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | |
| 362 } | 275 } |
| 363 | 276 |
| 364 TEST_P(PaintLayerPainterTest, | 277 TEST_P(PaintLayerPainterTest, |
| 365 CachedSubsequenceOnStyleChangeWithInterestRectClipping) { | 278 CachedSubsequenceOnStyleChangeWithInterestRectClipping) { |
| 366 setBodyInnerHTML( | 279 setBodyInnerHTML( |
| 367 "<div id='container1' style='position: relative; z-index: 1; width: " | 280 "<div id='container1' style='position: relative; z-index: 1; width: " |
| 368 "200px; height: 200px; background-color: blue'>" | 281 "200px; height: 200px; background-color: blue'>" |
| 369 " <div id='content1' style='position: absolute; width: 100px; height: " | 282 " <div id='content1' style='position: absolute; width: 100px; height: " |
| 370 "100px; background-color: red'></div>" | 283 "100px; background-color: red'></div>" |
| 371 "</div>" | 284 "</div>" |
| 372 "<div id='container2' style='position: relative; z-index: 1; width: " | 285 "<div id='container2' style='position: relative; z-index: 1; width: " |
| 373 "200px; height: 200px; background-color: blue'>" | 286 "200px; height: 200px; background-color: blue'>" |
| 374 " <div id='content2' style='position: absolute; width: 100px; height: " | 287 " <div id='content2' style='position: absolute; width: 100px; height: " |
| 375 "100px; background-color: green'></div>" | 288 "100px; background-color: green'></div>" |
| 376 "</div>"); | 289 "</div>"); |
| 377 document().view()->updateAllLifecyclePhasesExceptPaint(); | 290 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 378 // PaintResult of all subsequences will be MayBeClippedByPaintDirtyRect. | 291 // PaintResult of all subsequences will be MayBeClippedByPaintDirtyRect. |
| 379 IntRect interestRect(0, 0, 50, 300); | 292 IntRect interestRect(0, 0, 50, 300); |
| 380 paint(&interestRect); | 293 paint(&interestRect); |
| 381 | 294 |
| 382 PaintLayer& htmlLayer = | |
| 383 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) | |
| 384 ->layer(); | |
| 385 LayoutObject& container1 = | 295 LayoutObject& container1 = |
| 386 *document().getElementById("container1")->layoutObject(); | 296 *document().getElementById("container1")->layoutObject(); |
| 387 PaintLayer& container1Layer = *toLayoutBoxModelObject(container1).layer(); | |
| 388 LayoutObject& content1 = | 297 LayoutObject& content1 = |
| 389 *document().getElementById("content1")->layoutObject(); | 298 *document().getElementById("content1")->layoutObject(); |
| 390 LayoutObject& container2 = | 299 LayoutObject& container2 = |
| 391 *document().getElementById("container2")->layoutObject(); | 300 *document().getElementById("container2")->layoutObject(); |
| 392 PaintLayer& container2Layer = *toLayoutBoxModelObject(container2).layer(); | |
| 393 LayoutObject& content2 = | 301 LayoutObject& content2 = |
| 394 *document().getElementById("content2")->layoutObject(); | 302 *document().getElementById("content2")->layoutObject(); |
| 395 | 303 |
| 396 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 304 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 397 EXPECT_DISPLAY_LIST( | 305 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 5, |
| 398 rootPaintController().getDisplayItemList(), 13, | 306 TestDisplayItem(layoutView(), documentBackgroundType), |
| 399 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), | 307 TestDisplayItem(container1, backgroundType), |
| 400 TestDisplayItem(layoutView(), documentBackgroundType), | 308 TestDisplayItem(content1, backgroundType), |
| 401 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 309 TestDisplayItem(container2, backgroundType), |
| 402 TestDisplayItem(container1Layer, DisplayItem::kSubsequence), | 310 TestDisplayItem(content2, backgroundType)); |
| 403 TestDisplayItem(container1, backgroundType), | |
| 404 TestDisplayItem(content1, backgroundType), | |
| 405 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence), | |
| 406 TestDisplayItem(container2Layer, DisplayItem::kSubsequence), | |
| 407 TestDisplayItem(container2, backgroundType), | |
| 408 TestDisplayItem(content2, backgroundType), | |
| 409 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence), | |
| 410 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), | |
| 411 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); | |
| 412 } else { | 311 } else { |
| 413 EXPECT_DISPLAY_LIST( | 312 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 5, |
| 414 rootPaintController().getDisplayItemList(), 11, | 313 TestDisplayItem(layoutView(), documentBackgroundType), |
| 415 TestDisplayItem(layoutView(), documentBackgroundType), | 314 TestDisplayItem(container1, backgroundType), |
| 416 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 315 TestDisplayItem(content1, backgroundType), |
| 417 TestDisplayItem(container1Layer, DisplayItem::kSubsequence), | 316 TestDisplayItem(container2, backgroundType), |
| 418 TestDisplayItem(container1, backgroundType), | 317 TestDisplayItem(content2, backgroundType)); |
| 419 TestDisplayItem(content1, backgroundType), | |
| 420 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence), | |
| 421 TestDisplayItem(container2Layer, DisplayItem::kSubsequence), | |
| 422 TestDisplayItem(container2, backgroundType), | |
| 423 TestDisplayItem(content2, backgroundType), | |
| 424 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence), | |
| 425 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | |
| 426 } | 318 } |
| 427 | 319 |
| 428 toHTMLElement(content1.node()) | 320 toHTMLElement(content1.node()) |
| 429 ->setAttribute(HTMLNames::styleAttr, | 321 ->setAttribute(HTMLNames::styleAttr, |
| 430 "position: absolute; width: 100px; height: 100px; " | 322 "position: absolute; width: 100px; height: 100px; " |
| 431 "background-color: green"); | 323 "background-color: green"); |
| 432 document().view()->updateAllLifecyclePhasesExceptPaint(); | 324 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 433 EXPECT_TRUE(paintWithoutCommit(&interestRect)); | 325 EXPECT_TRUE(paintWithoutCommit(&interestRect)); |
| 434 | 326 |
| 435 EXPECT_EQ(6, numCachedNewItems()); | 327 EXPECT_EQ(4, numCachedNewItems()); |
| 436 | 328 |
| 437 commit(); | 329 commit(); |
| 438 | 330 |
| 439 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 331 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 440 EXPECT_DISPLAY_LIST( | 332 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 5, |
| 441 rootPaintController().getDisplayItemList(), 13, | 333 TestDisplayItem(layoutView(), documentBackgroundType), |
| 442 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), | 334 TestDisplayItem(container1, backgroundType), |
| 443 TestDisplayItem(layoutView(), documentBackgroundType), | 335 TestDisplayItem(content1, backgroundType), |
| 444 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 336 TestDisplayItem(container2, backgroundType), |
| 445 TestDisplayItem(container1Layer, DisplayItem::kSubsequence), | 337 TestDisplayItem(content2, backgroundType)); |
| 446 TestDisplayItem(container1, backgroundType), | |
| 447 TestDisplayItem(content1, backgroundType), | |
| 448 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence), | |
| 449 TestDisplayItem(container2Layer, DisplayItem::kSubsequence), | |
| 450 TestDisplayItem(container2, backgroundType), | |
| 451 TestDisplayItem(content2, backgroundType), | |
| 452 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence), | |
| 453 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), | |
| 454 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); | |
| 455 } else { | 338 } else { |
| 456 EXPECT_DISPLAY_LIST( | 339 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 5, |
| 457 rootPaintController().getDisplayItemList(), 11, | 340 TestDisplayItem(layoutView(), documentBackgroundType), |
| 458 TestDisplayItem(layoutView(), documentBackgroundType), | 341 TestDisplayItem(container1, backgroundType), |
| 459 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 342 TestDisplayItem(content1, backgroundType), |
| 460 TestDisplayItem(container1Layer, DisplayItem::kSubsequence), | 343 TestDisplayItem(container2, backgroundType), |
| 461 TestDisplayItem(container1, backgroundType), | 344 TestDisplayItem(content2, backgroundType)); |
| 462 TestDisplayItem(content1, backgroundType), | |
| 463 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence), | |
| 464 TestDisplayItem(container2Layer, DisplayItem::kSubsequence), | |
| 465 TestDisplayItem(container2, backgroundType), | |
| 466 TestDisplayItem(content2, backgroundType), | |
| 467 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence), | |
| 468 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | |
| 469 } | 345 } |
| 470 } | 346 } |
| 471 | 347 |
| 472 TEST_P(PaintLayerPainterTest, PaintPhaseOutline) { | 348 TEST_P(PaintLayerPainterTest, PaintPhaseOutline) { |
| 473 AtomicString styleWithoutOutline = | 349 AtomicString styleWithoutOutline = |
| 474 "width: 50px; height: 50px; background-color: green"; | 350 "width: 50px; height: 50px; background-color: green"; |
| 475 AtomicString styleWithOutline = | 351 AtomicString styleWithOutline = |
| 476 "outline: 1px solid blue; " + styleWithoutOutline; | 352 "outline: 1px solid blue; " + styleWithoutOutline; |
| 477 setBodyInnerHTML( | 353 setBodyInnerHTML( |
| 478 "<div id='self-painting-layer' style='position: absolute'>" | 354 "<div id='self-painting-layer' style='position: absolute'>" |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 842 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 967 EXPECT_TRUE( | 843 EXPECT_TRUE( |
| 968 PaintLayerPainter(*targetLayer).paintedOutputInvisible(paintingInfo)); | 844 PaintLayerPainter(*targetLayer).paintedOutputInvisible(paintingInfo)); |
| 969 } else { | 845 } else { |
| 970 EXPECT_FALSE( | 846 EXPECT_FALSE( |
| 971 PaintLayerPainter(*targetLayer).paintedOutputInvisible(paintingInfo)); | 847 PaintLayerPainter(*targetLayer).paintedOutputInvisible(paintingInfo)); |
| 972 } | 848 } |
| 973 } | 849 } |
| 974 | 850 |
| 975 } // namespace blink | 851 } // namespace blink |
| OLD | NEW |