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