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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 6
7 #include "core/paint/LayerClipRecorder.h" 7 #include "core/paint/LayerClipRecorder.h"
8 #include "core/paint/LayerPainter.h" 8 #include "core/paint/LayerPainter.h"
9 #include "core/paint/RenderDrawingRecorder.h" 9 #include "core/paint/RenderDrawingRecorder.h"
10 #include "core/paint/SubtreeInfoRecorder.h"
10 #include "core/rendering/RenderView.h" 11 #include "core/rendering/RenderView.h"
11 #include "core/rendering/RenderingTestHelper.h" 12 #include "core/rendering/RenderingTestHelper.h"
12 #include "core/rendering/compositing/RenderLayerCompositor.h" 13 #include "core/rendering/compositing/RenderLayerCompositor.h"
13 #include "platform/graphics/GraphicsContext.h" 14 #include "platform/graphics/GraphicsContext.h"
14 #include "platform/graphics/GraphicsLayer.h" 15 #include "platform/graphics/GraphicsLayer.h"
15 #include "platform/graphics/paint/DisplayItemList.h" 16 #include "platform/graphics/paint/DisplayItemList.h"
16 #include "third_party/skia/include/core/SkCanvas.h" 17 #include "third_party/skia/include/core/SkCanvas.h"
17 #include <gtest/gtest.h> 18 #include <gtest/gtest.h>
18 19
19 namespace blink { 20 namespace blink {
(...skipping 15 matching lines...) Expand all
35 RenderingTest::SetUp(); 36 RenderingTest::SetUp();
36 enableCompositing(); 37 enableCompositing();
37 38
38 m_renderView = document().view()->renderView(); 39 m_renderView = document().view()->renderView();
39 ASSERT_TRUE(m_renderView); 40 ASSERT_TRUE(m_renderView);
40 } 41 }
41 42
42 virtual void TearDown() override 43 virtual void TearDown() override
43 { 44 {
44 RuntimeEnabledFeatures::setSlimmingPaintEnabled(false); 45 RuntimeEnabledFeatures::setSlimmingPaintEnabled(false);
45 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(false);
46 } 46 }
47 47
48 RenderView* m_renderView; 48 RenderView* m_renderView;
49 }; 49 };
50 50
51 class TestDisplayItem : public DisplayItem { 51 class TestDisplayItem : public DisplayItem {
52 public: 52 public:
53 TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(rende rer->displayItemClient(), type) { } 53 TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(rende rer->displayItemClient(), type) { }
54 54
55 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); } 55 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); }
56 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override final { ASSERT_NOT_REACHED(); } 56 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override final { ASSERT_NOT_REACHED(); }
57 #ifndef NDEBUG 57 #ifndef NDEBUG
58 virtual const char* name() const override final { return "Test"; } 58 virtual const char* name() const override final { return "Test"; }
59 #endif 59 #endif
60 }; 60 };
61 61
62 #ifndef NDEBUG 62 #ifndef NDEBUG
63 #define TRACE_DISPLAY_ITEMS(expected, actual) \ 63 #define TRACE_DISPLAY_ITEMS(i, expected, actual) \
64 String trace = "Expected: " + (expected).asDebugString() + " Actual: " + (ac tual).asDebugString(); \ 64 String trace = String::format("%d: ", (int)i) + "Expected: " + (expected).as DebugString() + " Actual: " + (actual).asDebugString(); \
65 SCOPED_TRACE(trace.utf8().data()); 65 SCOPED_TRACE(trace.utf8().data());
66 #else 66 #else
67 #define TRACE_DISPLAY_ITEMS(expected, actual) 67 #define TRACE_DISPLAY_ITEMS(expected, actual)
68 #endif 68 #endif
69 69
70 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \ 70 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \
71 EXPECT_EQ((size_t)expectedSize, actual.size()); \ 71 EXPECT_EQ((size_t)expectedSize, actual.size()); \
72 const TestDisplayItem expected[] = { __VA_ARGS__ }; \ 72 const TestDisplayItem expected[] = { __VA_ARGS__ }; \
73 for (size_t index = 0; index < std::min<size_t>(actual.size(), expectedSize) ; index++) { \ 73 for (size_t index = 0; index < std::min<size_t>(actual.size(), expectedSize) ; index++) { \
74 TRACE_DISPLAY_ITEMS(expected[index], *actual[index]); \ 74 TRACE_DISPLAY_ITEMS(index, expected[index], *actual[index]); \
75 EXPECT_EQ(expected[index].client(), actual[index]->client()); \ 75 EXPECT_EQ(expected[index].client(), actual[index]->client()); \
76 EXPECT_EQ(expected[index].type(), actual[index]->type()); \ 76 EXPECT_EQ(expected[index].type(), actual[index]->type()); \
77 } \ 77 } \
78 } 78 }
79 79
80 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase , const FloatRect& bound) 80 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase , const FloatRect& bound)
81 { 81 {
82 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); 82 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound);
83 if (drawingRecorder.canUseCachedDrawing()) 83 if (drawingRecorder.canUseCachedDrawing())
84 return; 84 return;
85 IntRect rect(0, 0, 10, 10); 85 IntRect rect(0, 0, 10, 10);
86 context->drawRect(rect); 86 context->drawRect(rect);
87 } 87 }
88 88
89 void drawClippedRect(GraphicsContext* context, RenderLayerModelObject* renderer, PaintPhase phase, const FloatRect& bound) 89 void drawClippedRect(GraphicsContext* context, RenderLayerModelObject* renderer, PaintPhase phase, const FloatRect& bound)
90 { 90 {
91 IntRect rect(1, 1, 9, 9); 91 IntRect rect(1, 1, 9, 9);
92 ClipRect clipRect(rect); 92 ClipRect clipRect(rect);
93 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags()); 93 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags());
94 drawRect(context, renderer, phase, bound); 94 drawRect(context, renderer, phase, bound);
95 } 95 }
96 96
97 TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders) 97 TEST_F(ViewDisplayListTest, NestedRecorders)
98 { 98 {
99 GraphicsContext context(nullptr, &rootDisplayItemList()); 99 GraphicsContext context(nullptr, &rootDisplayItemList());
100 FloatRect bound = renderView()->viewRect(); 100 FloatRect bound = renderView()->viewRect();
101 101
102 drawClippedRect(&context, renderView(), PaintPhaseForeground, bound); 102 drawClippedRect(&context, renderView(), PaintPhaseForeground, bound);
103 rootDisplayItemList().endNewPaints(); 103 rootDisplayItemList().endNewPaints();
104 104
105 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 105 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
106 TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground), 106 TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground),
107 TestDisplayItem(renderView(), DisplayItem::DrawingPaintPhaseForeground), 107 TestDisplayItem(renderView(), DisplayItem::DrawingPaintPhaseForeground),
108 TestDisplayItem(renderView(), DisplayItem::EndClip)); 108 TestDisplayItem(renderView(), DisplayItem::EndClip));
109 } 109 }
110 110
111 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic) 111 TEST_F(ViewDisplayListTest, UpdateBasic)
112 { 112 {
113 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); 113 setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
114 RenderObject* first = document().body()->firstChild()->renderer(); 114 RenderObject* first = document().body()->firstChild()->renderer();
115 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 115 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
116 GraphicsContext context(nullptr, &rootDisplayItemList()); 116 GraphicsContext context(nullptr, &rootDisplayItemList());
117 117
118 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300 , 300)); 118 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300 , 300));
119 drawRect(&context, second, PaintPhaseChildBlockBackground, FloatRect(100, 10 0, 200, 200)); 119 drawRect(&context, second, PaintPhaseChildBlockBackground, FloatRect(100, 10 0, 200, 200));
120 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); 120 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
121 rootDisplayItemList().endNewPaints(); 121 rootDisplayItemList().endNewPaints();
122 122
123 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 123 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
124 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 124 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
125 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseChildBlockBackgrou nd), 125 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseChildBlockBackgrou nd),
126 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); 126 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
127 127
128 rootDisplayItemList().invalidate(second->displayItemClient()); 128 rootDisplayItemList().invalidate(second->displayItemClient());
129 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300 , 300)); 129 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300 , 300));
130 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); 130 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
131 rootDisplayItemList().endNewPaints(); 131 rootDisplayItemList().endNewPaints();
132 132
133 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 133 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
134 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 134 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
135 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); 135 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
136 } 136 }
137 137
138 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder) 138 TEST_F(ViewDisplayListTest, UpdateSwapOrder)
139 { 139 {
140 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaf fected'></div>"); 140 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaf fected'></div>");
141 RenderObject* first = document().body()->firstChild()->renderer(); 141 RenderObject* first = document().body()->firstChild()->renderer();
142 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 142 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
143 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r enderer(); 143 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r enderer();
144 GraphicsContext context(nullptr, &rootDisplayItemList()); 144 GraphicsContext context(nullptr, &rootDisplayItemList());
145 145
146 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 146 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
147 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 147 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
148 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300 , 10, 10)); 148 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300 , 10, 10));
149 rootDisplayItemList().endNewPaints(); 149 rootDisplayItemList().endNewPaints();
150 150
151 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 151 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
152 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 152 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
153 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), 153 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
154 TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackgroun d)); 154 TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackgroun d));
155 155
156 rootDisplayItemList().invalidate(second->displayItemClient()); 156 rootDisplayItemList().invalidate(second->displayItemClient());
157 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 157 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
158 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 158 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
159 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300 , 10, 10)); 159 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300 , 10, 10));
160 rootDisplayItemList().endNewPaints(); 160 rootDisplayItemList().endNewPaints();
161 161
162 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 162 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
163 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), 163 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
164 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 164 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
165 TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackgroun d)); 165 TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackgroun d));
166 } 166 }
167 167
168 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle) 168 TEST_F(ViewDisplayListTest, UpdateNewItemInMiddle)
169 { 169 {
170 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d iv></div>"); 170 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d iv></div>");
171 RenderObject* first = document().body()->firstChild()->renderer(); 171 RenderObject* first = document().body()->firstChild()->renderer();
172 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 172 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
173 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh ild()->renderer(); 173 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh ild()->renderer();
174 GraphicsContext context(nullptr, &rootDisplayItemList()); 174 GraphicsContext context(nullptr, &rootDisplayItemList());
175 175
176 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 176 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
177 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 177 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
178 rootDisplayItemList().endNewPaints(); 178 rootDisplayItemList().endNewPaints();
179 179
180 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 180 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
181 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 181 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
182 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground)); 182 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground));
183 183
184 rootDisplayItemList().invalidate(third->displayItemClient()); 184 rootDisplayItemList().invalidate(third->displayItemClient());
185 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 185 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
186 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200 , 50)); 186 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200 , 50));
187 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 187 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
188 rootDisplayItemList().endNewPaints(); 188 rootDisplayItemList().endNewPaints();
189 189
190 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 190 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
191 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 191 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
192 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground), 192 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
193 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground)); 193 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground));
194 } 194 }
195 195
196 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases) 196 TEST_F(ViewDisplayListTest, UpdateInvalidationWithPhases)
197 { 197 {
198 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir d'></div>"); 198 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir d'></div>");
199 RenderObject* first = document().body()->firstChild()->renderer(); 199 RenderObject* first = document().body()->firstChild()->renderer();
200 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 200 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
201 RenderObject* third = document().body()->firstChild()->nextSibling()->render er(); 201 RenderObject* third = document().body()->firstChild()->nextSibling()->render er();
202 GraphicsContext context(nullptr, &rootDisplayItemList()); 202 GraphicsContext context(nullptr, &rootDisplayItemList());
203 203
204 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 204 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
205 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 205 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
206 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50, 50)); 206 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50, 50));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 6, 253 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 6,
254 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 254 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
255 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground), 255 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
256 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground), 256 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground),
257 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground), 257 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground),
258 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline), 258 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
259 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline)); 259 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline));
260 #endif 260 #endif
261 } 261 }
262 262
263 // This test is only applicable when we support incremental paint. 263 TEST_F(ViewDisplayListTest, UpdateAddFirstOverlap)
264 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstNoOverlap )
265 { 264 {
266 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); 265 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
267 RenderObject* first = document().body()->firstChild()->renderer(); 266 RenderObject* first = document().body()->firstChild()->renderer();
268 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
269 GraphicsContext context(nullptr, &rootDisplayItemList());
270
271 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50));
272 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
273
274 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
275 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
276 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
277
278 rootDisplayItemList().invalidate(first->displayItemClient());
279 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50));
280 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50));
281
282 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
283 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
284 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
285 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
286 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
287
288 rootDisplayItemList().invalidate(first->displayItemClient());
289
290 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
291 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
292 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
293 }
294
295 // This test is only applicable when we support incremental paint.
296 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstOverlap)
297 {
298 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
299 RenderObject* first = document().body()->firstChild()->renderer();
300 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); 267 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
301 GraphicsContext context(nullptr, &rootDisplayItemList()); 268 GraphicsContext context(nullptr, &rootDisplayItemList());
302 269
303 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50)); 270 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50));
304 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 271 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
272 rootDisplayItemList().endNewPaints();
305 273
306 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 274 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
307 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), 275 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
308 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); 276 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
309 277
310 rootDisplayItemList().invalidate(first->displayItemClient()); 278 rootDisplayItemList().invalidate(first->displayItemClient());
311 rootDisplayItemList().invalidate(second->displayItemClient()); 279 rootDisplayItemList().invalidate(second->displayItemClient());
312 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150)); 280 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150));
313 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 281 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
314 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50)); 282 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50));
315 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 283 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
284 rootDisplayItemList().endNewPaints();
316 285
317 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, 286 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
318 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 287 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
319 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline), 288 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
320 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), 289 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
321 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); 290 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
322 291
323 rootDisplayItemList().invalidate(first->displayItemClient()); 292 rootDisplayItemList().invalidate(first->displayItemClient());
324 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50)); 293 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50));
325 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 294 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
295 rootDisplayItemList().endNewPaints();
326 296
327 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 297 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
328 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), 298 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
329 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); 299 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
330 } 300 }
331 301
332 // This test is only applicable when we support incremental paint. 302 TEST_F(ViewDisplayListTest, UpdateAddLastOverlap)
333 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastNoOverlap)
334 { 303 {
335 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); 304 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
336 RenderObject* first = document().body()->firstChild()->renderer(); 305 RenderObject* first = document().body()->firstChild()->renderer();
337 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
338 GraphicsContext context(nullptr, &rootDisplayItemList());
339
340 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50));
341 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50));
342
343 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
344 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
345 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
346
347 rootDisplayItemList().invalidate(second->displayItemClient());
348 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50));
349 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
350
351 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
352 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
353 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline),
354 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
355 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
356
357 rootDisplayItemList().invalidate(second->displayItemClient());
358
359 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
360 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
361 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
362 }
363
364 // This test is only applicable when we support incremental paint.
365 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastOverlap)
366 {
367 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
368 RenderObject* first = document().body()->firstChild()->renderer();
369 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); 306 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
370 GraphicsContext context(nullptr, &rootDisplayItemList()); 307 GraphicsContext context(nullptr, &rootDisplayItemList());
371 308
372 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150)); 309 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150));
373 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 310 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
311 rootDisplayItemList().endNewPaints();
374 312
375 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 313 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
376 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 314 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
377 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); 315 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
378 316
379 rootDisplayItemList().invalidate(first->displayItemClient()); 317 rootDisplayItemList().invalidate(first->displayItemClient());
380 rootDisplayItemList().invalidate(second->displayItemClient()); 318 rootDisplayItemList().invalidate(second->displayItemClient());
381 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150)); 319 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150));
382 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 320 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
383 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50)); 321 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50));
384 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 322 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
323 rootDisplayItemList().endNewPaints();
385 324
386 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, 325 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
387 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 326 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
388 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline), 327 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
389 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), 328 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
390 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); 329 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
391 330
392 rootDisplayItemList().invalidate(first->displayItemClient()); 331 rootDisplayItemList().invalidate(first->displayItemClient());
393 rootDisplayItemList().invalidate(second->displayItemClient()); 332 rootDisplayItemList().invalidate(second->displayItemClient());
394 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150)); 333 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150));
395 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 334 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
335 rootDisplayItemList().endNewPaints();
396 336
397 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 337 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
398 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 338 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
399 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); 339 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
400 } 340 }
401 341
402 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip) 342 TEST_F(ViewDisplayListTest, UpdateClip)
403 { 343 {
404 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); 344 setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
405 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer()); 345 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer());
406 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer()); 346 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer());
407 GraphicsContext context(nullptr, &rootDisplayItemList()); 347 GraphicsContext context(nullptr, &rootDisplayItemList());
408 348
409 ClipRect firstClipRect(IntRect(1, 1, 2, 2)); 349 ClipRect firstClipRect(IntRect(1, 1, 2, 2));
410 { 350 {
411 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem ::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags()); 351 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem ::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags());
412 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1 00, 100, 150, 150)); 352 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1 00, 100, 150, 150));
(...skipping 27 matching lines...) Expand all
440 380
441 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, 381 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
442 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound), 382 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound),
443 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground), 383 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground),
444 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round), 384 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round),
445 TestDisplayItem(secondRenderer, DisplayItem::EndClip)); 385 TestDisplayItem(secondRenderer, DisplayItem::EndClip));
446 } 386 }
447 387
448 TEST_F(ViewDisplayListTest, CachedDisplayItems) 388 TEST_F(ViewDisplayListTest, CachedDisplayItems)
449 { 389 {
450 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true);
451
452 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); 390 setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
453 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer()); 391 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer());
454 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer()); 392 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer());
455 GraphicsContext context(nullptr, &rootDisplayItemList()); 393 GraphicsContext context(nullptr, &rootDisplayItemList());
456 394
457 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 395 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
458 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 396 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
459 rootDisplayItemList().endNewPaints(); 397 rootDisplayItemList().endNewPaints();
460 398
461 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 399 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
(...skipping 26 matching lines...) Expand all
488 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display ItemClient())); 426 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display ItemClient()));
489 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa yItemClient())); 427 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa yItemClient()));
490 } 428 }
491 429
492 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret) 430 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret)
493 { 431 {
494 setBodyInnerHTML("<div id='div' contentEditable='true'>XYZ</div>"); 432 setBodyInnerHTML("<div id='div' contentEditable='true'>XYZ</div>");
495 RenderView* renderView = document().renderView(); 433 RenderView* renderView = document().renderView();
496 RenderLayer* rootLayer = renderView->layer(); 434 RenderLayer* rootLayer = renderView->layer();
497 RenderObject* htmlRenderer = document().documentElement()->renderer(); 435 RenderObject* htmlRenderer = document().documentElement()->renderer();
436 showRenderTree(htmlRenderer);
437 RenderObject* bodyRenderer = document().body()->renderer();
498 Element* div = toElement(document().body()->firstChild()); 438 Element* div = toElement(document().body()->firstChild());
499 RenderObject* divRenderer = document().body()->firstChild()->renderer(); 439 RenderObject* divRenderer = document().body()->firstChild()->renderer();
500 RenderObject* textRenderer = div->firstChild()->renderer(); 440 RenderObject* textRenderer = div->firstChild()->renderer();
501 441
502 SkCanvas canvas(800, 600); 442 SkCanvas canvas(800, 600);
503 GraphicsContext context(&canvas, &rootDisplayItemList()); 443 GraphicsContext context(&canvas, &rootDisplayItemList());
504 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB ehaviorNormal, LayoutSize()); 444 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB ehaviorNormal, LayoutSize());
505 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases); 445 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases);
506 rootDisplayItemList().endNewPaints(); 446 rootDisplayItemList().endNewPaints();
507 447
508 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 448 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 17,
449 TestDisplayItem(renderView, DisplayItem::DrawingPaintPhaseBlockBackgroun d),
509 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und), 450 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und),
510 TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground)) ; 451 TestDisplayItem(bodyRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und),
452 TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseBlockBackgrou nd),
453 TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseBlockBackgrou nd),
454 TestDisplayItem(bodyRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und),
455 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und),
456 TestDisplayItem(renderView, DisplayItem::DrawingPaintPhaseBlockBackgroun d),
457
458 TestDisplayItem(renderView, DisplayItem::DrawingPaintPhaseForeground),
459 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseForeground),
460 TestDisplayItem(bodyRenderer, DisplayItem::DrawingPaintPhaseForeground),
461 TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseForeground),
462 TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground),
463 TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseForeground),
464 TestDisplayItem(bodyRenderer, DisplayItem::DrawingPaintPhaseForeground),
465 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseForeground),
466 TestDisplayItem(renderView, DisplayItem::DrawingPaintPhaseForeground));
511 467
512 div->focus(); 468 div->focus();
513 document().view()->updateLayoutAndStyleForPainting(); 469 document().view()->updateLayoutAndStyleForPainting();
514 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases); 470 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases);
515 rootDisplayItemList().endNewPaints(); 471 rootDisplayItemList().endNewPaints();
516 472
517 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 473 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
518 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und), 474 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und),
519 TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground), 475 TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground),
520 TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseCaret)); 476 TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseCaret));
521 } 477 }
522 478
479 TEST_F(ViewDisplayListTest, ComplexUpdateSwapOrder)
480 {
481 setBodyInnerHTML("<div id='container1'><div id='content1'></div></div>"
482 "<div id='container2'><div id='content2'></div></div>");
483 RenderObject* container1 = document().body()->firstChild()->renderer();
484 RenderObject* content1 = document().body()->firstChild()->firstChild()->rend erer();
485 RenderObject* container2 = document().body()->firstChild()->nextSibling()->r enderer();
486 RenderObject* content2 = document().body()->firstChild()->nextSibling()->fir stChild()->renderer();
487 GraphicsContext context(nullptr, &rootDisplayItemList());
488
489 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100 , 100, 100));
490 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
491 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 50, 2 00));
492 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100 , 100));
493 drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100, 200 , 100, 100));
494 drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 200, 50, 200));
495 drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 50, 2 00));
496 drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200, 100 , 100));
497 rootDisplayItemList().endNewPaints();
498
499 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 8,
500 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackgroun d),
501 TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseBlockBackground) ,
502 TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseForeground),
503 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground),
504 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackgroun d),
505 TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseBlockBackground) ,
506 TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseForeground),
507 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground));
508
509 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2.
510 rootDisplayItemList().invalidate(container1->displayItemClient());
511 drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100, 200 , 100, 100));
512 drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 200, 50, 200));
513 drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 50, 2 00));
514 drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200, 100 , 100));
515 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100 , 100, 100));
516 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
517 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 50, 2 00));
518 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100 , 100));
519 rootDisplayItemList().endNewPaints();
520
521 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 8,
522 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackgroun d),
523 TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseBlockBackground) ,
524 TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseForeground),
525 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground),
526 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackgroun d),
527 TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseBlockBackground) ,
528 TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseForeground),
529 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground));
530 }
531
532 TEST_F(ViewDisplayListTest, CachedSubtreeSwapOrder)
533 {
534 setBodyInnerHTML("<div id='container1'><div id='content1'></div></div>"
535 "<div id='container2'><div id='content2'></div></div>");
536 RenderObject* container1 = document().body()->firstChild()->renderer();
537 RenderObject* content1 = document().body()->firstChild()->firstChild()->rend erer();
538 RenderObject* container2 = document().body()->firstChild()->nextSibling()->r enderer();
539 RenderObject* content2 = document().body()->firstChild()->nextSibling()->fir stChild()->renderer();
540 GraphicsContext context(nullptr, &rootDisplayItemList());
541
542 {
543 SubtreeInfoRecorder r(&context, *container1, PaintPhaseBlockBackground);
544 r.begin();
545 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
546 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 1 00, 50, 200));
547 }
548 {
549 SubtreeInfoRecorder r(&context, *container1, PaintPhaseForeground);
550 r.begin();
551 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 5 0, 200));
552 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100, 100));
553 }
554 {
555 SubtreeInfoRecorder r(&context, *container2, PaintPhaseBlockBackground);
556 r.begin();
557 drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100, 200, 100, 100));
558 drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 2 00, 50, 200));
559 }
560 {
561 SubtreeInfoRecorder r(&context, *container2, PaintPhaseForeground);
562 r.begin();
563 drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 5 0, 200));
564 drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200, 100, 100));
565 }
566 rootDisplayItemList().endNewPaints();
567
568 // FIXME: Too many empty BeginSubtree and EndSubtree pairs.
569 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 16,
570 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackgroun d), // BeginSubtree
571 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackgroun d),
572 TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseBlockBackground) ,
573 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackgroun d), // EndSubtree
574
575 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground), / / BeginSubtree
576 TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseForeground),
577 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground),
578 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground), / / EndSubtree
579
580 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackgroun d), // BeginSubtree
581 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackgroun d),
582 TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseBlockBackground) ,
583 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackgroun d), // EndSubtree
584
585 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground), / / BeginSubtree
586 TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseForeground),
587 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground),
588 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground)); // EndSubtree
589
590 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2,
591 // and at the same time container2 is scrolled out of viewport.
592 {
593 SubtreeInfoRecorder r(&context, *container2, PaintPhaseBlockBackground);
594 }
595 {
596 SubtreeInfoRecorder r(&context, *container2, PaintPhaseForeground);
597 }
598 {
599 SubtreeInfoRecorder r(&context, *container1, PaintPhaseBlockBackground);
600 r.begin();
601 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
602 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 1 00, 50, 200));
603 }
604 {
605 SubtreeInfoRecorder r(&context, *container1, PaintPhaseForeground);
606 r.begin();
607 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 5 0, 200));
608 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100, 100));
609 }
610 rootDisplayItemList().endNewPaints();
611
612 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 16,
613 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackgroun d), // BeginSubtree
614 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackgroun d),
615 TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseBlockBackground) ,
616 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackgroun d), // EndSubtree
617
618 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground), / / BeginSubtree
619 TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseForeground),
620 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground),
621 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground), / / EndSubtree
622
623 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackgroun d), // BeginSubtree
624 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackgroun d),
625 TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseBlockBackground) ,
626 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackgroun d), // EndSubtree
627
628 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground), / / BeginSubtree
629 TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseForeground),
630 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground),
631 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground)); // EndSubtree
632 }
633
523 } // anonymous namespace 634 } // anonymous namespace
524 } // namespace blink 635 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698