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

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

Issue 719353004: [Slimming Paint] Track clip renderers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address reviewer comments Created 6 years, 1 month 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
« no previous file with comments | « Source/core/paint/ViewDisplayList.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/ViewDisplayListTest.cpp
diff --git a/Source/core/paint/ViewDisplayListTest.cpp b/Source/core/paint/ViewDisplayListTest.cpp
index ddbfdfa848ad77c5f0a0e1c63f8127d88d9c60ff..30c5b23f80a4217ae331865946a1650e7db308bd 100644
--- a/Source/core/paint/ViewDisplayListTest.cpp
+++ b/Source/core/paint/ViewDisplayListTest.cpp
@@ -37,6 +37,22 @@ private:
RenderView* m_renderView;
};
+class TestDisplayItem : public DisplayItem {
+public:
+ TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(renderer, type) { }
+
+ virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); }
+};
+
+#define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \
+ EXPECT_EQ((size_t)expectedSize, actual.size()); \
+ const TestDisplayItem expected[] = { __VA_ARGS__ }; \
+ for (size_t index = 0; index < expectedSize; index++) { \
+ EXPECT_EQ(expected[index].renderer(), actual[index]->renderer()); \
+ EXPECT_EQ(expected[index].type(), actual[index]->type()); \
+ } \
+}
+
void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase, const FloatRect& bound)
{
DrawingRecorder drawingRecorder(context, renderer, phase, bound);
@@ -44,12 +60,12 @@ void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase
context->drawRect(rect);
}
-void drawClippedRect(GraphicsContext* context, RenderView* renderView, PaintPhase phase, const FloatRect& bound)
+void drawClippedRect(GraphicsContext* context, RenderLayerModelObject* renderer, PaintPhase phase, const FloatRect& bound)
{
IntRect rect(1, 1, 9, 9);
ClipRect clipRect(rect);
- ClipRecorder clipRecorder(renderView->compositor()->rootRenderLayer(), context, DisplayItem::ClipLayerForeground, clipRect);
- drawRect(context, renderView, phase, bound);
+ ClipRecorder clipRecorder(renderer, context, DisplayItem::ClipLayerForeground, clipRect);
+ drawRect(context, renderer, phase, bound);
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders)
@@ -58,9 +74,11 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders)
FloatRect bound = renderView()->viewRect();
drawClippedRect(context, renderView(), PaintPhaseForeground, bound);
- EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size());
- // TODO(schenney): Check that the IDs are what we expect.
chrishtr 2014/11/14 01:11:26 Just a regular FIXME..
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3,
+ TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground),
+ TestDisplayItem(renderView(), DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(renderView(), DisplayItem::EndClip));
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic)
@@ -74,12 +92,18 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic)
drawRect(context, second, PaintPhaseChildBlockBackground, FloatRect(100, 100, 200, 200));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
- EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseChildBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(second);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
- EXPECT_EQ((size_t)2, renderView()->viewDisplayList().paintList().size());
+
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
@@ -94,21 +118,19 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
drawRect(context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300, 10, 10));
- const PaintList& firstList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)3, firstList.size());
- EXPECT_EQ(first, firstList[0]->renderer());
- EXPECT_EQ(second, firstList[1]->renderer());
- EXPECT_EQ(unaffected, firstList[2]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackground));
renderView()->viewDisplayList().invalidate(second);
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
- const PaintList& secondList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)3, secondList.size());
- EXPECT_EQ(second, secondList[0]->renderer());
- EXPECT_EQ(first, secondList[1]->renderer());
- EXPECT_EQ(unaffected, secondList[2]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3,
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackground));
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle)
@@ -122,21 +144,19 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle)
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
- const PaintList& firstList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)2, firstList.size());
- EXPECT_EQ(first, firstList[0]->renderer());
- EXPECT_EQ(second, firstList[1]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground));
renderView()->viewDisplayList().invalidate(third);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
drawRect(context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200, 50));
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
- const PaintList& secondList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)3, secondList.size());
- EXPECT_EQ(first, secondList[0]->renderer());
- EXPECT_EQ(third, secondList[1]->renderer());
- EXPECT_EQ(second, secondList[2]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground));
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
@@ -157,13 +177,16 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200));
drawRect(context, third, PaintPhaseOutline, FloatRect(300, 100, 50, 50));
- const PaintList& firstList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)9, firstList.size());
- for (int item = 0; item < 9; item += 3) {
- EXPECT_EQ(first, firstList[item % 3 + 0]->renderer());
- EXPECT_EQ(second, firstList[item % 3 + 1]->renderer());
- EXPECT_EQ(third, firstList[item % 3 + 2]->renderer());
- }
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 9,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline),
+ TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(second);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
@@ -173,21 +196,26 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100));
drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200));
- const PaintList& secondList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)9, secondList.size());
- for (int item = 0; item < 9; item += 3) {
- EXPECT_EQ(first, secondList[item % 3 + 0]->renderer());
- EXPECT_EQ(second, secondList[item % 3 + 1]->renderer());
- EXPECT_EQ(third, secondList[item % 3 + 2]->renderer());
- }
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 9,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline),
+ TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(second);
- const PaintList& thirdList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)6, thirdList.size());
- for (int item = 0; item < 6; item += 2) {
- EXPECT_EQ(first, thirdList[item % 2 + 0]->renderer());
- EXPECT_EQ(third, thirdList[item % 2 + 1]->renderer());
- }
+
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 6,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
+ TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline));
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap)
@@ -200,27 +228,25 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap)
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
- const PaintList& firstList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)2, firstList.size());
- EXPECT_EQ(second, firstList[0]->renderer());
- EXPECT_EQ(second, firstList[1]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(first);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50));
- const PaintList& secondList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)4, secondList.size());
- EXPECT_EQ(first, secondList[0]->renderer());
- EXPECT_EQ(first, secondList[1]->renderer());
- EXPECT_EQ(second, secondList[2]->renderer());
- EXPECT_EQ(second, secondList[3]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(first);
- const PaintList& thirdList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)2, thirdList.size());
- EXPECT_EQ(second, thirdList[0]->renderer());
- EXPECT_EQ(second, thirdList[1]->renderer());
+
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap)
@@ -233,10 +259,9 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap)
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
- const PaintList& firstList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)2, firstList.size());
- EXPECT_EQ(second, firstList[0]->renderer());
- EXPECT_EQ(second, firstList[1]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(first);
renderView()->viewDisplayList().invalidate(second);
@@ -245,21 +270,19 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap)
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
- const PaintList& secondList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)4, secondList.size());
- EXPECT_EQ(first, secondList[0]->renderer());
- EXPECT_EQ(first, secondList[1]->renderer());
- EXPECT_EQ(second, secondList[2]->renderer());
- EXPECT_EQ(second, secondList[3]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(first);
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
- const PaintList& thirdList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)2, thirdList.size());
- EXPECT_EQ(second, thirdList[0]->renderer());
- EXPECT_EQ(second, thirdList[1]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap)
@@ -272,27 +295,25 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap)
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50));
- const PaintList& firstList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)2, firstList.size());
- EXPECT_EQ(first, firstList[0]->renderer());
- EXPECT_EQ(first, firstList[1]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(second);
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
- const PaintList& secondList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)4, secondList.size());
- EXPECT_EQ(second, secondList[0]->renderer());
- EXPECT_EQ(second, secondList[1]->renderer());
- EXPECT_EQ(first, secondList[2]->renderer());
- EXPECT_EQ(first, secondList[3]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4,
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(second);
- const PaintList& thirdList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)2, thirdList.size());
- EXPECT_EQ(first, thirdList[0]->renderer());
- EXPECT_EQ(first, thirdList[1]->renderer());
+
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap)
@@ -305,10 +326,9 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap)
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
- const PaintList& firstList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)2, firstList.size());
- EXPECT_EQ(first, firstList[0]->renderer());
- EXPECT_EQ(first, firstList[1]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(first);
renderView()->viewDisplayList().invalidate(second);
@@ -317,22 +337,63 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap)
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
- const PaintList& secondList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)4, secondList.size());
- EXPECT_EQ(first, secondList[0]->renderer());
- EXPECT_EQ(first, secondList[1]->renderer());
- EXPECT_EQ(second, secondList[2]->renderer());
- EXPECT_EQ(second, secondList[3]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(first);
renderView()->viewDisplayList().invalidate(second);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
- const PaintList& thirdList = renderView()->viewDisplayList().paintList();
- EXPECT_EQ((size_t)2, thirdList.size());
- EXPECT_EQ(first, thirdList[0]->renderer());
- EXPECT_EQ(first, thirdList[1]->renderer());
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
+}
+
+TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip)
+{
+ setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
+ RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document().body()->firstChild()->renderer());
+ RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document().body()->firstChild()->firstChild()->renderer());
+ GraphicsContext* context = new GraphicsContext(nullptr);
+
+ ClipRect firstClipRect(IntRect(1, 1, 2, 2));
+ {
+ ClipRecorder clipRecorder(firstRenderer, context, DisplayItem::ClipLayerForeground, firstClipRect);
+ drawRect(context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
+ drawRect(context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
+ }
+
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4,
+ TestDisplayItem(firstRenderer, DisplayItem::ClipLayerForeground),
+ TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(firstRenderer, DisplayItem::EndClip));
+
+ renderView()->viewDisplayList().invalidate(firstRenderer);
+ drawRect(context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
+ drawRect(context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
+
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
+ TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackground));
+
+ renderView()->viewDisplayList().invalidate(secondRenderer);
+ drawRect(context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
+ ClipRect secondClipRect(IntRect(1, 1, 2, 2));
+ {
+ ClipRecorder clipRecorder(secondRenderer, context, DisplayItem::ClipLayerForeground, secondClipRect);
+ drawRect(context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
+ }
+
+ EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4,
+ TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground),
+ TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
+ TestDisplayItem(secondRenderer, DisplayItem::EndClip));
}
}
« no previous file with comments | « Source/core/paint/ViewDisplayList.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698