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

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

Issue 847783003: New display item caching (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: New method, supporting partial paint Created 5 years, 11 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/ViewDisplayListTest.cpp
diff --git a/Source/core/paint/ViewDisplayListTest.cpp b/Source/core/paint/ViewDisplayListTest.cpp
index 7f1e3b1d01c81e6f2607f24bacb6a19948f679fe..26301ecbbeffd370b6f7056c8e6ce47f950a192a 100644
--- a/Source/core/paint/ViewDisplayListTest.cpp
+++ b/Source/core/paint/ViewDisplayListTest.cpp
@@ -7,6 +7,7 @@
#include "core/paint/LayerClipRecorder.h"
#include "core/paint/LayerPainter.h"
#include "core/paint/RenderDrawingRecorder.h"
+#include "core/paint/SubtreeInfoRecorder.h"
#include "core/rendering/RenderView.h"
#include "core/rendering/RenderingTestHelper.h"
#include "core/rendering/compositing/RenderLayerCompositor.h"
@@ -42,7 +43,6 @@ private:
virtual void TearDown() override
{
RuntimeEnabledFeatures::setSlimmingPaintEnabled(false);
- RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(false);
}
RenderView* m_renderView;
@@ -60,8 +60,8 @@ public:
};
#ifndef NDEBUG
-#define TRACE_DISPLAY_ITEMS(expected, actual) \
- String trace = "Expected: " + (expected).asDebugString() + " Actual: " + (actual).asDebugString(); \
+#define TRACE_DISPLAY_ITEMS(i, expected, actual) \
+ String trace = String::format("%d: ", (int)i) + "Expected: " + (expected).asDebugString() + " Actual: " + (actual).asDebugString(); \
SCOPED_TRACE(trace.utf8().data());
#else
#define TRACE_DISPLAY_ITEMS(expected, actual)
@@ -71,7 +71,7 @@ public:
EXPECT_EQ((size_t)expectedSize, actual.size()); \
const TestDisplayItem expected[] = { __VA_ARGS__ }; \
for (size_t index = 0; index < std::min<size_t>(actual.size(), expectedSize); index++) { \
- TRACE_DISPLAY_ITEMS(expected[index], *actual[index]); \
+ TRACE_DISPLAY_ITEMS(index, expected[index], *actual[index]); \
EXPECT_EQ(expected[index].client(), actual[index]->client()); \
EXPECT_EQ(expected[index].type(), actual[index]->type()); \
} \
@@ -94,7 +94,7 @@ void drawClippedRect(GraphicsContext* context, RenderLayerModelObject* renderer,
drawRect(context, renderer, phase, bound);
}
-TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders)
+TEST_F(ViewDisplayListTest, NestedRecorders)
{
GraphicsContext context(nullptr, &rootDisplayItemList());
FloatRect bound = renderView()->viewRect();
@@ -108,7 +108,7 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders)
TestDisplayItem(renderView(), DisplayItem::EndClip));
}
-TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic)
+TEST_F(ViewDisplayListTest, UpdateBasic)
{
setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
RenderObject* first = document().body()->firstChild()->renderer();
@@ -135,7 +135,7 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic)
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
}
-TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
+TEST_F(ViewDisplayListTest, UpdateSwapOrder)
{
setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaffected'></div>");
RenderObject* first = document().body()->firstChild()->renderer();
@@ -165,7 +165,7 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackground));
}
-TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle)
+TEST_F(ViewDisplayListTest, UpdateNewItemInMiddle)
{
setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></div></div>");
RenderObject* first = document().body()->firstChild()->renderer();
@@ -193,7 +193,7 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle)
TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground));
}
-TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
+TEST_F(ViewDisplayListTest, UpdateInvalidationWithPhases)
{
setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='third'></div>");
RenderObject* first = document().body()->firstChild()->renderer();
@@ -260,40 +260,7 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
#endif
}
-// This test is only applicable when we support incremental paint.
-TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstNoOverlap)
-{
- setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
- RenderObject* first = document().body()->firstChild()->renderer();
- RenderObject* second = document().body()->firstChild()->nextSibling()->renderer();
- GraphicsContext context(nullptr, &rootDisplayItemList());
-
- drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
- drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
-
- EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
- TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
- TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
-
- rootDisplayItemList().invalidate(first->displayItemClient());
- drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50));
- drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50));
-
- EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
- TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
- TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
- TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
- TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
-
- rootDisplayItemList().invalidate(first->displayItemClient());
-
- EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
- TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
- TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
-}
-
-// This test is only applicable when we support incremental paint.
-TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstOverlap)
+TEST_F(ViewDisplayListTest, UpdateAddFirstOverlap)
{
setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
RenderObject* first = document().body()->firstChild()->renderer();
@@ -302,6 +269,7 @@ TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstOverlap)
drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -313,6 +281,7 @@ TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstOverlap)
drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -323,46 +292,14 @@ TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstOverlap)
rootDisplayItemList().invalidate(first->displayItemClient());
drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
}
-// This test is only applicable when we support incremental paint.
-TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastNoOverlap)
-{
- setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
- RenderObject* first = document().body()->firstChild()->renderer();
- RenderObject* second = document().body()->firstChild()->nextSibling()->renderer();
- GraphicsContext context(nullptr, &rootDisplayItemList());
-
- drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50));
- drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50));
-
- EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
- TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
- TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
-
- rootDisplayItemList().invalidate(second->displayItemClient());
- drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
- drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
-
- EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
- TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
- TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline),
- TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
- TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
-
- rootDisplayItemList().invalidate(second->displayItemClient());
-
- EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
- TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
- TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
-}
-
-// This test is only applicable when we support incremental paint.
-TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastOverlap)
+TEST_F(ViewDisplayListTest, UpdateAddLastOverlap)
{
setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
RenderObject* first = document().body()->firstChild()->renderer();
@@ -371,6 +308,7 @@ TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastOverlap)
drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -382,6 +320,7 @@ TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastOverlap)
drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -393,13 +332,14 @@ TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastOverlap)
rootDisplayItemList().invalidate(second->displayItemClient());
drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
}
-TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip)
+TEST_F(ViewDisplayListTest, UpdateClip)
{
setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document().body()->firstChild()->renderer());
@@ -447,8 +387,6 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip)
TEST_F(ViewDisplayListTest, CachedDisplayItems)
{
- RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true);
-
setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document().body()->firstChild()->renderer());
RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document().body()->firstChild()->firstChild()->renderer());
@@ -495,6 +433,8 @@ TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret)
RenderView* renderView = document().renderView();
RenderLayer* rootLayer = renderView->layer();
RenderObject* htmlRenderer = document().documentElement()->renderer();
+ showRenderTree(htmlRenderer);
+ RenderObject* bodyRenderer = document().body()->renderer();
Element* div = toElement(document().body()->firstChild());
RenderObject* divRenderer = document().body()->firstChild()->renderer();
RenderObject* textRenderer = div->firstChild()->renderer();
@@ -505,9 +445,25 @@ TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret)
LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLayerPaintingCompositingAllPhases);
rootDisplayItemList().endNewPaints();
- EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
+ EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 17,
+ TestDisplayItem(renderView, DisplayItem::DrawingPaintPhaseBlockBackground),
TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
- TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground));
+ TestDisplayItem(bodyRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(bodyRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(renderView, DisplayItem::DrawingPaintPhaseBlockBackground),
+
+ TestDisplayItem(renderView, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(bodyRenderer, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(bodyRenderer, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(renderView, DisplayItem::DrawingPaintPhaseForeground));
div->focus();
document().view()->updateLayoutAndStyleForPainting();
@@ -520,5 +476,160 @@ TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret)
TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseCaret));
}
+TEST_F(ViewDisplayListTest, ComplexUpdateSwapOrder)
+{
+ setBodyInnerHTML("<div id='container1'><div id='content1'></div></div>"
+ "<div id='container2'><div id='content2'></div></div>");
+ RenderObject* container1 = document().body()->firstChild()->renderer();
+ RenderObject* content1 = document().body()->firstChild()->firstChild()->renderer();
+ RenderObject* container2 = document().body()->firstChild()->nextSibling()->renderer();
+ RenderObject* content2 = document().body()->firstChild()->nextSibling()->firstChild()->renderer();
+ GraphicsContext context(nullptr, &rootDisplayItemList());
+
+ drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
+ drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
+ drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 50, 200));
+ drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100, 100));
+ drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100, 200, 100, 100));
+ drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 200, 50, 200));
+ drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 50, 200));
+ drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200, 100, 100));
+ rootDisplayItemList().endNewPaints();
+
+ EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 8,
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground));
+
+ // Simulate the situation when container1 e.g. gets a z-index that is now greater than container2.
+ rootDisplayItemList().invalidate(container1->displayItemClient());
+ drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100, 200, 100, 100));
+ drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 200, 50, 200));
+ drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 50, 200));
+ drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200, 100, 100));
+ drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
+ drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
+ drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 50, 200));
+ drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100, 100));
+ rootDisplayItemList().endNewPaints();
+
+ EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 8,
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground));
+}
+
+TEST_F(ViewDisplayListTest, CachedSubtreeSwapOrder)
+{
+ setBodyInnerHTML("<div id='container1'><div id='content1'></div></div>"
+ "<div id='container2'><div id='content2'></div></div>");
+ RenderObject* container1 = document().body()->firstChild()->renderer();
+ RenderObject* content1 = document().body()->firstChild()->firstChild()->renderer();
+ RenderObject* container2 = document().body()->firstChild()->nextSibling()->renderer();
+ RenderObject* content2 = document().body()->firstChild()->nextSibling()->firstChild()->renderer();
+ GraphicsContext context(nullptr, &rootDisplayItemList());
+
+ {
+ SubtreeInfoRecorder r(&context, *container1, PaintPhaseBlockBackground);
+ r.begin();
+ drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
+ drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
+ }
+ {
+ SubtreeInfoRecorder r(&context, *container1, PaintPhaseForeground);
+ r.begin();
+ drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 50, 200));
+ drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100, 100));
+ }
+ {
+ SubtreeInfoRecorder r(&context, *container2, PaintPhaseBlockBackground);
+ r.begin();
+ drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100, 200, 100, 100));
+ drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 200, 50, 200));
+ }
+ {
+ SubtreeInfoRecorder r(&context, *container2, PaintPhaseForeground);
+ r.begin();
+ drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 50, 200));
+ drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200, 100, 100));
+ }
+ rootDisplayItemList().endNewPaints();
+
+ // FIXME: Too many empty BeginSubtree and EndSubtree pairs.
+ EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 16,
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackground), // BeginSubtree
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackground), // EndSubtree
+
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground), // BeginSubtree
+ TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground), // EndSubtree
+
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackground), // BeginSubtree
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackground), // EndSubtree
+
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground), // BeginSubtree
+ TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground)); // EndSubtree
+
+ // Simulate the situation when container1 e.g. gets a z-index that is now greater than container2,
+ // and at the same time container2 is scrolled out of viewport.
+ {
+ SubtreeInfoRecorder r(&context, *container2, PaintPhaseBlockBackground);
+ }
+ {
+ SubtreeInfoRecorder r(&context, *container2, PaintPhaseForeground);
+ }
+ {
+ SubtreeInfoRecorder r(&context, *container1, PaintPhaseBlockBackground);
+ r.begin();
+ drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
+ drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
+ }
+ {
+ SubtreeInfoRecorder r(&context, *container1, PaintPhaseForeground);
+ r.begin();
+ drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 50, 200));
+ drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100, 100));
+ }
+ rootDisplayItemList().endNewPaints();
+
+ EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 16,
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackground), // BeginSubtree
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackground), // EndSubtree
+
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground), // BeginSubtree
+ TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground), // EndSubtree
+
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackground), // BeginSubtree
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackground), // EndSubtree
+
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground), // BeginSubtree
+ TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground)); // EndSubtree
+}
+
} // anonymous namespace
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698