Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1337)

Unified Diff: Source/core/paint/DisplayItemListPaintTest.cpp

Issue 1294233004: Subtree caching implementation in blink-core (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add a complex-subtree-update test Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/paint/DisplayItemListPaintTest.cpp
diff --git a/Source/core/paint/DisplayItemListPaintTest.cpp b/Source/core/paint/DisplayItemListPaintTest.cpp
index 7a161d5da682c29ef42e148539d6f54c457ca88a..f22747ad6d1ea93740d7fb1c25f361be0783c544 100644
--- a/Source/core/paint/DisplayItemListPaintTest.cpp
+++ b/Source/core/paint/DisplayItemListPaintTest.cpp
@@ -67,6 +67,10 @@ protected:
DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graphicsLayerBacking()->displayItemList(); }
const DisplayItems& newPaintListBeforeUpdate() { return rootDisplayItemList().m_newDisplayItems; }
+ // Expose some document lifecycle steps.
+ void updateLifecyclePhasesToPaintForSlimmingPaintV2Clean() { document().view()->updateLifecyclePhasesInternal(FrameView::OnlyUpToPaintForSlimmingPaintV2Clean); }
+ void compositeForSlimmingPaintV2() { document().view()->compositeForSlimmingPaintV2(); }
+
private:
void SetUp() override
{
@@ -255,4 +259,41 @@ TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout)
TestDisplayItem(divBlock, DisplayItem::paintPhaseToEndSubtreeType(PaintPhaseForeground)));
}
+TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, SubtreeCache)
+{
+ setBodyInnerHTML(
+ "<div id='container1' style='width: 200px; height: 200px; background-color: blue'>"
+ " <div id='content1a'>AAA</div>"
+ " <div id='content1b' style='width: 100px; height: 100px; background-color: red'>BBB</div>"
+ "</div>"
+ "<div id='container2' style='width: 200px; height: 200px; background-color: blue'>"
+ " <div id='content2a'>CCC</div>"
+ " <div id='content2b' style='width: 100px; height: 100px; background-color: green'>DDD</div>"
+ "</div>");
+ document().view()->updateAllLifecyclePhases();
+
+ size_t displayItemCount = rootDisplayItemList().displayItems().size();
+
+ Element& content1b = *document().getElementById("content1b");
+ content1b.setAttribute(HTMLNames::styleAttr, "width: 100px; height: 100px; background-color: green");
+
+ updateLifecyclePhasesToPaintForSlimmingPaintV2Clean();
+ const LayoutObject* container2 = document().getElementById("container2")->layoutObject();
+ int cachedSubtreeCount = 0;
+ for (auto& item : newPaintListBeforeUpdate()) {
+ if (item.isCachedSubtree()) {
+ ++cachedSubtreeCount;
+ EXPECT_EQ(container2->displayItemClient(), item.client());
+ if (cachedSubtreeCount == 1)
+ EXPECT_EQ(item.type(), DisplayItem::paintPhaseToCachedSubtreeType(PaintPhaseChildBlockBackground));
+ else if (cachedSubtreeCount == 2)
+ EXPECT_EQ(item.type(), DisplayItem::paintPhaseToCachedSubtreeType(PaintPhaseForeground));
+ }
+ }
+ EXPECT_EQ(2, cachedSubtreeCount);
+
+ compositeForSlimmingPaintV2();
+ EXPECT_EQ(displayItemCount, rootDisplayItemList().displayItems().size());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698