OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
6 #include "platform/graphics/paint/DisplayItemList.h" | 6 #include "platform/graphics/paint/DisplayItemList.h" |
7 | 7 |
8 #include "core/layout/LayoutTestHelper.h" | 8 #include "core/layout/LayoutTestHelper.h" |
9 #include "core/layout/LayoutText.h" | 9 #include "core/layout/LayoutText.h" |
10 #include "core/layout/LayoutView.h" | 10 #include "core/layout/LayoutView.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 class DisplayItemListPaintTest : public RenderingTest { | 25 class DisplayItemListPaintTest : public RenderingTest { |
26 public: | 26 public: |
27 DisplayItemListPaintTest() | 27 DisplayItemListPaintTest() |
28 : m_layoutView(nullptr) | 28 : m_layoutView(nullptr) |
29 , m_originalSlimmingPaintEnabled(RuntimeEnabledFeatures::slimmingPaintEn
abled()) { } | 29 , m_originalSlimmingPaintEnabled(RuntimeEnabledFeatures::slimmingPaintEn
abled()) { } |
30 | 30 |
31 protected: | 31 protected: |
32 LayoutView& layoutView() { return *m_layoutView; } | 32 LayoutView& layoutView() { return *m_layoutView; } |
33 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } | 33 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } |
34 const DisplayItems& newPaintListBeforeUpdate() { return rootDisplayItemList(
).m_newDisplayItems; } | 34 const DisplayItems& newDisplayItemsBeforeUpdate() { return rootDisplayItemLi
st().m_newDisplayItems; } |
35 | 35 |
36 private: | 36 private: |
37 void SetUp() override | 37 void SetUp() override |
38 { | 38 { |
39 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); | 39 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); |
40 | 40 |
41 RenderingTest::SetUp(); | 41 RenderingTest::SetUp(); |
42 enableCompositing(); | 42 enableCompositing(); |
43 | 43 |
44 m_layoutView = document().view()->layoutView(); | 44 m_layoutView = document().view()->layoutView(); |
(...skipping 13 matching lines...) Expand all Loading... |
58 // class is used to test only v2 behavior while maintaining v1 test coverage. | 58 // class is used to test only v2 behavior while maintaining v1 test coverage. |
59 class DisplayItemListPaintTestForSlimmingPaintV2 : public RenderingTest { | 59 class DisplayItemListPaintTestForSlimmingPaintV2 : public RenderingTest { |
60 public: | 60 public: |
61 DisplayItemListPaintTestForSlimmingPaintV2() | 61 DisplayItemListPaintTestForSlimmingPaintV2() |
62 : m_layoutView(nullptr) | 62 : m_layoutView(nullptr) |
63 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } | 63 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } |
64 | 64 |
65 protected: | 65 protected: |
66 LayoutView& layoutView() { return *m_layoutView; } | 66 LayoutView& layoutView() { return *m_layoutView; } |
67 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } | 67 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } |
68 const DisplayItems& newPaintListBeforeUpdate() { return rootDisplayItemList(
).m_newDisplayItems; } | 68 const DisplayItems& newDisplayItemsBeforeUpdate() { return rootDisplayItemLi
st().m_newDisplayItems; } |
| 69 |
| 70 // Expose some document lifecycle steps. |
| 71 void updateLifecyclePhasesToPaintForSlimmingPaintV2Clean() { document().view
()->updateLifecyclePhasesInternal(FrameView::OnlyUpToPaintForSlimmingPaintV2Clea
n); } |
| 72 void compositeForSlimmingPaintV2() { document().view()->compositeForSlimming
PaintV2(); } |
69 | 73 |
70 private: | 74 private: |
71 void SetUp() override | 75 void SetUp() override |
72 { | 76 { |
73 ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 77 ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
74 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 78 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
75 | 79 |
76 RenderingTest::SetUp(); | 80 RenderingTest::SetUp(); |
77 enableCompositing(); | 81 enableCompositing(); |
78 | 82 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 EXPECT_EQ(expected[index].type(), actual[index].type()); \ | 121 EXPECT_EQ(expected[index].type(), actual[index].type()); \ |
118 } \ | 122 } \ |
119 } while (false); | 123 } while (false); |
120 | 124 |
121 #ifndef NDEBUG | 125 #ifndef NDEBUG |
122 #define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(actual, expectedSizeWithoutFi
ll, ...) \ | 126 #define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(actual, expectedSizeWithoutFi
ll, ...) \ |
123 EXPECT_DISPLAY_LIST_BASE( \ | 127 EXPECT_DISPLAY_LIST_BASE( \ |
124 actual, expectedSizeWithoutFill + 1, \ | 128 actual, expectedSizeWithoutFill + 1, \ |
125 TestDisplayItem(*document().layoutView()->layer()->graphicsLayerBacking(
), DisplayItem::DebugRedFill), \ | 129 TestDisplayItem(*document().layoutView()->layer()->graphicsLayerBacking(
), DisplayItem::DebugRedFill), \ |
126 __VA_ARGS__) | 130 __VA_ARGS__) |
| 131 #define EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(actual, expectedSizeWi
thoutFill, ...) \ |
| 132 EXPECT_DISPLAY_LIST_BASE( \ |
| 133 actual, expectedSizeWithoutFill + 1, \ |
| 134 TestDisplayItem(*document().layoutView()->layer()->graphicsLayerBacking(
), DisplayItem::drawingTypeToCachedDrawingType(DisplayItem::DebugRedFill)), \ |
| 135 __VA_ARGS__) |
127 #else | 136 #else |
128 #define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG EXPECT_DISPLAY_LIST_BASE | 137 #define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG EXPECT_DISPLAY_LIST_BASE |
| 138 #define EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG EXPECT_DISPLAY_LIST_BA
SE |
129 #endif | 139 #endif |
130 | 140 |
131 TEST_F(DisplayItemListPaintTest, FullDocumentPaintingWithCaret) | 141 TEST_F(DisplayItemListPaintTest, FullDocumentPaintingWithCaret) |
132 { | 142 { |
133 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); | 143 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); |
134 document().page()->focusController().setActive(true); | 144 document().page()->focusController().setActive(true); |
135 document().page()->focusController().setFocused(true); | 145 document().page()->focusController().setFocused(true); |
136 LayoutView& layoutView = *document().layoutView(); | 146 LayoutView& layoutView = *document().layoutView(); |
137 DeprecatedPaintLayer& rootLayer = *layoutView.layer(); | 147 DeprecatedPaintLayer& rootLayer = *layoutView.layer(); |
138 Element& div = *toElement(document().body()->firstChild()); | 148 Element& div = *toElement(document().body()->firstChild()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground)), | 209 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground)), |
200 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground))); | 210 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground))); |
201 } | 211 } |
202 | 212 |
203 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, FullDocumentPaintingWithCaret
) | 213 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, FullDocumentPaintingWithCaret
) |
204 { | 214 { |
205 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); | 215 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); |
206 document().page()->focusController().setActive(true); | 216 document().page()->focusController().setActive(true); |
207 document().page()->focusController().setFocused(true); | 217 document().page()->focusController().setFocused(true); |
208 LayoutView& layoutView = *document().layoutView(); | 218 LayoutView& layoutView = *document().layoutView(); |
| 219 LayoutObject& html = *document().documentElement()->layoutObject(); |
209 Element& div = *toElement(document().body()->firstChild()); | 220 Element& div = *toElement(document().body()->firstChild()); |
210 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); | 221 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); |
211 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); | 222 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); |
212 | 223 |
213 document().view()->updateAllLifecyclePhases(); | 224 document().view()->updateAllLifecyclePhases(); |
214 | 225 |
215 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 2, | 226 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 4, |
216 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), | 227 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
217 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground))); | 228 TestDisplayItem(html, DisplayItem::BeginSubsequence), |
| 229 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground)), |
| 230 TestDisplayItem(html, DisplayItem::EndSubsequence)); |
218 | 231 |
219 div.focus(); | 232 div.focus(); |
220 document().view()->updateAllLifecyclePhases(); | 233 document().view()->updateAllLifecyclePhases(); |
221 | 234 |
222 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 3, | 235 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 5, |
223 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), | 236 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
| 237 TestDisplayItem(html, DisplayItem::BeginSubsequence), |
224 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground)), | 238 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground)), |
225 TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New! | 239 TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New! |
| 240 TestDisplayItem(html, DisplayItem::EndSubsequence)); |
226 } | 241 } |
227 | 242 |
228 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout) | 243 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout) |
229 { | 244 { |
230 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); | 245 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); |
231 LayoutView& layoutView = *document().layoutView(); | 246 LayoutView& layoutView = *document().layoutView(); |
| 247 LayoutObject& html = *document().documentElement()->layoutObject(); |
232 Element& div = *toElement(document().body()->firstChild()); | 248 Element& div = *toElement(document().body()->firstChild()); |
233 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); | 249 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); |
234 LayoutText& text = *toLayoutText(divBlock.firstChild()); | 250 LayoutText& text = *toLayoutText(divBlock.firstChild()); |
235 InlineTextBox& firstTextBox = *text.firstTextBox(); | 251 InlineTextBox& firstTextBox = *text.firstTextBox(); |
236 | 252 |
237 document().view()->updateAllLifecyclePhases(); | 253 document().view()->updateAllLifecyclePhases(); |
238 | 254 |
239 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 2, | 255 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 4, |
240 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), | 256 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
241 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground))); | 257 TestDisplayItem(html, DisplayItem::BeginSubsequence), |
| 258 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground)), |
| 259 TestDisplayItem(html, DisplayItem::EndSubsequence)); |
242 | 260 |
243 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); | 261 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); |
244 document().view()->updateAllLifecyclePhases(); | 262 document().view()->updateAllLifecyclePhases(); |
245 | 263 |
246 LayoutText& newText = *toLayoutText(divBlock.firstChild()); | 264 LayoutText& newText = *toLayoutText(divBlock.firstChild()); |
247 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); | 265 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); |
248 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); | 266 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); |
249 | 267 |
250 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 3, | 268 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 5, |
251 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), | 269 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
| 270 TestDisplayItem(html, DisplayItem::BeginSubsequence), |
252 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground)), | 271 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground)), |
253 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground))); | 272 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground)), |
| 273 TestDisplayItem(html, DisplayItem::EndSubsequence)); |
| 274 } |
| 275 |
| 276 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequence) |
| 277 { |
| 278 setBodyInnerHTML( |
| 279 "<div id='container1' style='position: relative; width: 200px; height: 2
00px; background-color: blue'>" |
| 280 " <div id='content1' style='width: 100px; height: 100px; background-col
or: red'></div>" |
| 281 "</div>" |
| 282 "<div id='container2' style='position: relative; width: 200px; height: 2
00px; background-color: blue'>" |
| 283 " <div id='content2' style='width: 100px; height: 100px; background-col
or: green'></div>" |
| 284 "</div>"); |
| 285 document().view()->updateAllLifecyclePhases(); |
| 286 |
| 287 LayoutView& layoutView = *document().layoutView(); |
| 288 LayoutObject& html = *document().documentElement()->layoutObject(); |
| 289 LayoutObject& container1 = *document().getElementById("container1")->layoutO
bject(); |
| 290 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec
t(); |
| 291 LayoutObject& container2 = *document().getElementById("container2")->layoutO
bject(); |
| 292 LayoutObject& content2 = *document().getElementById("content2")->layoutObjec
t(); |
| 293 |
| 294 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 11, |
| 295 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
| 296 TestDisplayItem(html, DisplayItem::BeginSubsequence), |
| 297 TestDisplayItem(container1, DisplayItem::BeginSubsequence), |
| 298 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground), |
| 299 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), |
| 300 TestDisplayItem(container1, DisplayItem::EndSubsequence), |
| 301 TestDisplayItem(container2, DisplayItem::BeginSubsequence), |
| 302 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground), |
| 303 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground), |
| 304 TestDisplayItem(container2, DisplayItem::EndSubsequence), |
| 305 TestDisplayItem(html, DisplayItem::EndSubsequence)); |
| 306 |
| 307 toHTMLElement(content1.node())->setAttribute(HTMLNames::styleAttr, "width: 1
00px; height: 100px; background-color: green"); |
| 308 updateLifecyclePhasesToPaintForSlimmingPaintV2Clean(); |
| 309 |
| 310 EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(newDisplayItemsBeforeUpdat
e(), 8, |
| 311 TestDisplayItem(layoutView, DisplayItem::drawingTypeToCachedDrawingType(
DisplayItem::BoxDecorationBackground)), |
| 312 TestDisplayItem(html, DisplayItem::BeginSubsequence), |
| 313 TestDisplayItem(container1, DisplayItem::BeginSubsequence), |
| 314 TestDisplayItem(container1, DisplayItem::drawingTypeToCachedDrawingType(
DisplayItem::BoxDecorationBackground)), |
| 315 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), |
| 316 TestDisplayItem(container1, DisplayItem::EndSubsequence), |
| 317 TestDisplayItem(container2, DisplayItem::CachedSubsequence), |
| 318 TestDisplayItem(html, DisplayItem::EndSubsequence)); |
| 319 |
| 320 compositeForSlimmingPaintV2(); |
| 321 |
| 322 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 11, |
| 323 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
| 324 TestDisplayItem(html, DisplayItem::BeginSubsequence), |
| 325 TestDisplayItem(container1, DisplayItem::BeginSubsequence), |
| 326 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground), |
| 327 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), |
| 328 TestDisplayItem(container1, DisplayItem::EndSubsequence), |
| 329 TestDisplayItem(container2, DisplayItem::BeginSubsequence), |
| 330 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground), |
| 331 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground), |
| 332 TestDisplayItem(container2, DisplayItem::EndSubsequence), |
| 333 TestDisplayItem(html, DisplayItem::EndSubsequence)); |
254 } | 334 } |
255 | 335 |
256 } // namespace blink | 336 } // namespace blink |
OLD | NEW |