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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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& newPaintListBeforeUpdate() { return rootDisplayItemList( ).m_newDisplayItems; } |
69 | 69 |
70 // Expose some document lifecycle steps. | |
71 void updateLifecyclePhasesToPaintForSlimmingPaintV2Clean() { document().view ()->updateLifecyclePhasesInternal(FrameView::OnlyUpToPaintForSlimmingPaintV2Clea n); } | |
72 void compositeForSlimmingPaintV2() { document().view()->compositeForSlimming PaintV2(); } | |
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 |
79 m_layoutView = document().view()->layoutView(); | 83 m_layoutView = document().view()->layoutView(); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); | 252 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); |
249 | 253 |
250 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 5, | 254 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 5, |
251 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), | 255 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
252 TestDisplayItem(divBlock, DisplayItem::paintPhaseToBeginSubtreeType(Pain tPhaseForeground)), | 256 TestDisplayItem(divBlock, DisplayItem::paintPhaseToBeginSubtreeType(Pain tPhaseForeground)), |
253 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)), | 257 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)), |
254 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)), | 258 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)), |
255 TestDisplayItem(divBlock, DisplayItem::paintPhaseToEndSubtreeType(PaintP haseForeground))); | 259 TestDisplayItem(divBlock, DisplayItem::paintPhaseToEndSubtreeType(PaintP haseForeground))); |
256 } | 260 } |
257 | 261 |
262 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, SubtreeCache) | |
pdr.
2015/08/20 22:45:06
Can you add a few more tests of updating subtrees?
Xianzhu
2015/08/21 00:31:38
This seems to test mainly the merge algorithm abou
| |
263 { | |
264 setBodyInnerHTML( | |
265 "<div id='container1' style='width: 200px; height: 200px; background-col or: blue'>" | |
266 " <div id='content1a'>AAA</div>" | |
267 " <div id='content1b' style='width: 100px; height: 100px; background-co lor: red'>BBB</div>" | |
268 "</div>" | |
269 "<div id='container2' style='width: 200px; height: 200px; background-col or: blue'>" | |
270 " <div id='content2a'>CCC</div>" | |
271 " <div id='content2b' style='width: 100px; height: 100px; background-co lor: green'>DDD</div>" | |
272 "</div>"); | |
273 document().view()->updateAllLifecyclePhases(); | |
274 | |
275 size_t displayItemCount = rootDisplayItemList().displayItems().size(); | |
276 | |
277 Element& content1b = *document().getElementById("content1b"); | |
278 content1b.setAttribute(HTMLNames::styleAttr, "width: 100px; height: 100px; b ackground-color: green"); | |
279 | |
280 updateLifecyclePhasesToPaintForSlimmingPaintV2Clean(); | |
281 const LayoutObject* container2 = document().getElementById("container2")->la youtObject(); | |
282 int cachedSubtreeCount = 0; | |
283 for (auto& item : newPaintListBeforeUpdate()) { | |
284 if (item.isCachedSubtree()) { | |
285 ++cachedSubtreeCount; | |
286 EXPECT_EQ(container2->displayItemClient(), item.client()); | |
287 if (cachedSubtreeCount == 1) | |
288 EXPECT_EQ(item.type(), DisplayItem::paintPhaseToCachedSubtreeTyp e(PaintPhaseChildBlockBackground)); | |
289 else if (cachedSubtreeCount == 2) | |
290 EXPECT_EQ(item.type(), DisplayItem::paintPhaseToCachedSubtreeTyp e(PaintPhaseForeground)); | |
291 } | |
292 } | |
293 EXPECT_EQ(2, cachedSubtreeCount); | |
294 | |
295 compositeForSlimmingPaintV2(); | |
296 EXPECT_EQ(displayItemCount, rootDisplayItemList().displayItems().size()); | |
297 } | |
298 | |
258 } // namespace blink | 299 } // namespace blink |
OLD | NEW |