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

Side by Side Diff: Source/core/paint/ViewDisplayListTest.cpp

Issue 860563003: Disable display item caching (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase 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/rendering/RenderView.h" 10 #include "core/rendering/RenderView.h"
(...skipping 20 matching lines...) Expand all
31 { 31 {
32 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); 32 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
33 33
34 RenderingTest::SetUp(); 34 RenderingTest::SetUp();
35 enableCompositing(); 35 enableCompositing();
36 36
37 m_renderView = document().view()->renderView(); 37 m_renderView = document().view()->renderView();
38 ASSERT_TRUE(m_renderView); 38 ASSERT_TRUE(m_renderView);
39 } 39 }
40 40
41 virtual void TearDown() override
42 {
43 RuntimeEnabledFeatures::setSlimmingPaintEnabled(false);
44 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(false);
45 }
46
41 RenderView* m_renderView; 47 RenderView* m_renderView;
42 }; 48 };
43 49
44 class TestDisplayItem : public DisplayItem { 50 class TestDisplayItem : public DisplayItem {
45 public: 51 public:
46 TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(rende rer->displayItemClient(), type) { } 52 TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(rende rer->displayItemClient(), type) { }
47 53
48 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); } 54 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); }
49 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override final { ASSERT_NOT_REACHED(); } 55 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override final { ASSERT_NOT_REACHED(); }
50 #ifndef NDEBUG 56 #ifndef NDEBUG
51 virtual const char* name() const override final { return "Test"; } 57 virtual const char* name() const override final { return "Test"; }
52 #endif 58 #endif
53 }; 59 };
54 60
55 #ifndef NDEBUG 61 #ifndef NDEBUG
56 #define TRACE_DISPLAY_ITEMS(expected, actual) \ 62 #define TRACE_DISPLAY_ITEMS(expected, actual) \
57 String trace = "Expected: " + (expected).asDebugString() + " Actual: " + (ac tual).asDebugString(); \ 63 String trace = "Expected: " + (expected).asDebugString() + " Actual: " + (ac tual).asDebugString(); \
58 SCOPED_TRACE(trace.utf8().data()); 64 SCOPED_TRACE(trace.utf8().data());
59 #else 65 #else
60 #define TRACE_DISPLAY_ITEMS(expected, actual) 66 #define TRACE_DISPLAY_ITEMS(expected, actual)
61 #endif 67 #endif
62 68
63 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \ 69 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \
64 EXPECT_EQ((size_t)expectedSize, actual.size()); \ 70 EXPECT_EQ((size_t)expectedSize, actual.size()); \
65 const TestDisplayItem expected[] = { __VA_ARGS__ }; \ 71 const TestDisplayItem expected[] = { __VA_ARGS__ }; \
66 for (size_t index = 0; index < expectedSize; index++) { \ 72 for (size_t index = 0; index < std::min<size_t>(actual.size(), expectedSize) ; index++) { \
67 TRACE_DISPLAY_ITEMS(expected[index], *actual[index]); \ 73 TRACE_DISPLAY_ITEMS(expected[index], *actual[index]); \
68 EXPECT_EQ(expected[index].client(), actual[index]->client()); \ 74 EXPECT_EQ(expected[index].client(), actual[index]->client()); \
69 EXPECT_EQ(expected[index].type(), actual[index]->type()); \ 75 EXPECT_EQ(expected[index].type(), actual[index]->type()); \
70 } \ 76 } \
71 } 77 }
72 78
73 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase , const FloatRect& bound) 79 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase , const FloatRect& bound)
74 { 80 {
75 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); 81 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound);
76 if (drawingRecorder.canUseCachedDrawing()) 82 if (drawingRecorder.canUseCachedDrawing())
77 return; 83 return;
78 IntRect rect(0, 0, 10, 10); 84 IntRect rect(0, 0, 10, 10);
79 context->drawRect(rect); 85 context->drawRect(rect);
80 } 86 }
81 87
82 void drawClippedRect(GraphicsContext* context, RenderLayerModelObject* renderer, PaintPhase phase, const FloatRect& bound) 88 void drawClippedRect(GraphicsContext* context, RenderLayerModelObject* renderer, PaintPhase phase, const FloatRect& bound)
83 { 89 {
84 IntRect rect(1, 1, 9, 9); 90 IntRect rect(1, 1, 9, 9);
85 ClipRect clipRect(rect); 91 ClipRect clipRect(rect);
86 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags()); 92 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags());
87 drawRect(context, renderer, phase, bound); 93 drawRect(context, renderer, phase, bound);
88 } 94 }
89 95
90 TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders) 96 TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders)
91 { 97 {
92 GraphicsContext context(nullptr, &rootDisplayItemList()); 98 GraphicsContext context(nullptr, &rootDisplayItemList());
93 FloatRect bound = renderView()->viewRect(); 99 FloatRect bound = renderView()->viewRect();
94 100
101 rootDisplayItemList().beginNewPaints();
95 drawClippedRect(&context, renderView(), PaintPhaseForeground, bound); 102 drawClippedRect(&context, renderView(), PaintPhaseForeground, bound);
103 rootDisplayItemList().endNewPaints();
96 104
97 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 105 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
98 TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground), 106 TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground),
99 TestDisplayItem(renderView(), DisplayItem::DrawingPaintPhaseForeground), 107 TestDisplayItem(renderView(), DisplayItem::DrawingPaintPhaseForeground),
100 TestDisplayItem(renderView(), DisplayItem::EndClip)); 108 TestDisplayItem(renderView(), DisplayItem::EndClip));
101 } 109 }
102 110
103 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic) 111 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic)
104 { 112 {
105 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); 113 setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
106 RenderObject* first = document().body()->firstChild()->renderer(); 114 RenderObject* first = document().body()->firstChild()->renderer();
107 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 115 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
108 GraphicsContext context(nullptr, &rootDisplayItemList()); 116 GraphicsContext context(nullptr, &rootDisplayItemList());
109 117
118 rootDisplayItemList().beginNewPaints();
110 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300 , 300)); 119 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300 , 300));
111 drawRect(&context, second, PaintPhaseChildBlockBackground, FloatRect(100, 10 0, 200, 200)); 120 drawRect(&context, second, PaintPhaseChildBlockBackground, FloatRect(100, 10 0, 200, 200));
112 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); 121 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
122 rootDisplayItemList().endNewPaints();
113 123
114 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 124 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
115 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 125 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
116 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseChildBlockBackgrou nd), 126 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseChildBlockBackgrou nd),
117 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); 127 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
118 128
119 rootDisplayItemList().invalidate(second->displayItemClient()); 129 rootDisplayItemList().invalidate(second->displayItemClient());
130 rootDisplayItemList().beginNewPaints();
120 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300 , 300)); 131 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300 , 300));
121 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); 132 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
133 rootDisplayItemList().endNewPaints();
122 134
123 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 135 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
124 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 136 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
125 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); 137 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
126 } 138 }
127 139
128 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder) 140 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
129 { 141 {
130 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaf fected'></div>"); 142 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaf fected'></div>");
131 RenderObject* first = document().body()->firstChild()->renderer(); 143 RenderObject* first = document().body()->firstChild()->renderer();
132 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 144 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
133 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r enderer(); 145 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r enderer();
134 GraphicsContext context(nullptr, &rootDisplayItemList()); 146 GraphicsContext context(nullptr, &rootDisplayItemList());
135 147
148 rootDisplayItemList().beginNewPaints();
136 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 149 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
137 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 150 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
138 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300 , 10, 10)); 151 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300 , 10, 10));
152 rootDisplayItemList().endNewPaints();
139 153
140 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 154 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
141 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 155 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
142 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), 156 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
143 TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackgroun d)); 157 TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackgroun d));
144 158
145 rootDisplayItemList().invalidate(second->displayItemClient()); 159 rootDisplayItemList().invalidate(second->displayItemClient());
160 rootDisplayItemList().beginNewPaints();
146 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 161 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
147 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 162 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
163 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300 , 10, 10));
164 rootDisplayItemList().endNewPaints();
148 165
149 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 166 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
150 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), 167 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
151 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 168 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
152 TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackgroun d)); 169 TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackgroun d));
153 } 170 }
154 171
155 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle) 172 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle)
156 { 173 {
157 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d iv></div>"); 174 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d iv></div>");
158 RenderObject* first = document().body()->firstChild()->renderer(); 175 RenderObject* first = document().body()->firstChild()->renderer();
159 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 176 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
160 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh ild()->renderer(); 177 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh ild()->renderer();
161 GraphicsContext context(nullptr, &rootDisplayItemList()); 178 GraphicsContext context(nullptr, &rootDisplayItemList());
162 179
180 rootDisplayItemList().beginNewPaints();
163 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 181 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
164 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 182 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
183 rootDisplayItemList().endNewPaints();
165 184
166 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 185 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
167 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 186 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
168 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground)); 187 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground));
169 188
170 rootDisplayItemList().invalidate(third->displayItemClient()); 189 rootDisplayItemList().invalidate(third->displayItemClient());
190 rootDisplayItemList().beginNewPaints();
171 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 191 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
172 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200 , 50)); 192 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200 , 50));
173 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 193 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
194 rootDisplayItemList().endNewPaints();
174 195
175 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 196 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
176 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 197 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
177 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground), 198 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
178 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground)); 199 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground));
179 } 200 }
180 201
181 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases) 202 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
182 { 203 {
183 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir d'></div>"); 204 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir d'></div>");
184 RenderObject* first = document().body()->firstChild()->renderer(); 205 RenderObject* first = document().body()->firstChild()->renderer();
185 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 206 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
186 RenderObject* third = document().body()->firstChild()->nextSibling()->render er(); 207 RenderObject* third = document().body()->firstChild()->nextSibling()->render er();
187 GraphicsContext context(nullptr, &rootDisplayItemList()); 208 GraphicsContext context(nullptr, &rootDisplayItemList());
188 209
210 rootDisplayItemList().beginNewPaints();
189 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 211 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
190 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 212 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
191 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50, 50)); 213 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50, 50));
192 drawRect(&context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100 )); 214 drawRect(&context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100 ));
193 drawRect(&context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200 )); 215 drawRect(&context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200 ));
194 drawRect(&context, third, PaintPhaseForeground, FloatRect(300, 100, 50, 50)) ; 216 drawRect(&context, third, PaintPhaseForeground, FloatRect(300, 100, 50, 50)) ;
195 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100)); 217 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100));
196 drawRect(&context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200)); 218 drawRect(&context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200));
197 drawRect(&context, third, PaintPhaseOutline, FloatRect(300, 100, 50, 50)); 219 drawRect(&context, third, PaintPhaseOutline, FloatRect(300, 100, 50, 50));
220 rootDisplayItemList().endNewPaints();
198 221
199 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 9, 222 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 9,
200 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 223 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
201 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), 224 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
202 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground), 225 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
203 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground), 226 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground),
204 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseForeground), 227 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseForeground),
205 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground), 228 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground),
206 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline), 229 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
207 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline), 230 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline),
208 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline)); 231 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline));
209 232
210 rootDisplayItemList().invalidate(second->displayItemClient()); 233 rootDisplayItemList().invalidate(second->displayItemClient());
234 rootDisplayItemList().beginNewPaints();
211 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 235 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
212 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 236 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
237 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50, 50));
213 drawRect(&context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100 )); 238 drawRect(&context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100 ));
214 drawRect(&context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200 )); 239 drawRect(&context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200 ));
240 drawRect(&context, third, PaintPhaseForeground, FloatRect(300, 100, 50, 50)) ;
215 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100)); 241 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100));
216 drawRect(&context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200)); 242 drawRect(&context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200));
243 drawRect(&context, third, PaintPhaseOutline, FloatRect(300, 100, 50, 50));
244 rootDisplayItemList().endNewPaints();
217 245
218 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 9, 246 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 9,
219 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 247 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
220 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), 248 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
221 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground), 249 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
222 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground), 250 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground),
223 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseForeground), 251 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseForeground),
224 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground), 252 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground),
225 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline), 253 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
226 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline), 254 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline),
227 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline)); 255 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline));
228 256
257 // The following is only applicable when we support incremental paint.
258 #if 0
229 rootDisplayItemList().invalidate(second->displayItemClient()); 259 rootDisplayItemList().invalidate(second->displayItemClient());
230 260
231 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 6, 261 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 6,
232 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 262 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
233 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground), 263 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
234 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground), 264 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground),
235 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground), 265 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground),
236 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline), 266 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
237 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline)); 267 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline));
268 #endif
238 } 269 }
239 270
240 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap) 271 // This test is only applicable when we support incremental paint.
272 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstNoOverlap )
241 { 273 {
242 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); 274 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
243 RenderObject* first = document().body()->firstChild()->renderer(); 275 RenderObject* first = document().body()->firstChild()->renderer();
244 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); 276 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
245 GraphicsContext context(nullptr, &rootDisplayItemList()); 277 GraphicsContext context(nullptr, &rootDisplayItemList());
246 278
247 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50)); 279 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50));
248 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 280 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
249 281
250 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 282 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
(...skipping 10 matching lines...) Expand all
261 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), 293 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
262 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); 294 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
263 295
264 rootDisplayItemList().invalidate(first->displayItemClient()); 296 rootDisplayItemList().invalidate(first->displayItemClient());
265 297
266 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 298 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
267 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), 299 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
268 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); 300 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
269 } 301 }
270 302
271 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap) 303 // This test is only applicable when we support incremental paint.
304 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstOverlap)
272 { 305 {
273 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); 306 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
274 RenderObject* first = document().body()->firstChild()->renderer(); 307 RenderObject* first = document().body()->firstChild()->renderer();
275 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); 308 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
276 GraphicsContext context(nullptr, &rootDisplayItemList()); 309 GraphicsContext context(nullptr, &rootDisplayItemList());
277 310
278 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50)); 311 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50));
279 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 312 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
280 313
281 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 314 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
(...skipping 15 matching lines...) Expand all
297 330
298 rootDisplayItemList().invalidate(first->displayItemClient()); 331 rootDisplayItemList().invalidate(first->displayItemClient());
299 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50)); 332 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50));
300 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 333 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
301 334
302 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 335 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
303 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), 336 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
304 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); 337 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
305 } 338 }
306 339
307 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap) 340 // This test is only applicable when we support incremental paint.
341 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastNoOverlap)
308 { 342 {
309 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); 343 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
310 RenderObject* first = document().body()->firstChild()->renderer(); 344 RenderObject* first = document().body()->firstChild()->renderer();
311 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); 345 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
312 GraphicsContext context(nullptr, &rootDisplayItemList()); 346 GraphicsContext context(nullptr, &rootDisplayItemList());
313 347
314 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50)); 348 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50));
315 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50)); 349 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50));
316 350
317 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 351 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
(...skipping 10 matching lines...) Expand all
328 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 362 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
329 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); 363 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
330 364
331 rootDisplayItemList().invalidate(second->displayItemClient()); 365 rootDisplayItemList().invalidate(second->displayItemClient());
332 366
333 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 367 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
334 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), 368 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
335 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); 369 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
336 } 370 }
337 371
338 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap) 372 // This test is only applicable when we support incremental paint.
373 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastOverlap)
339 { 374 {
340 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); 375 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
341 RenderObject* first = document().body()->firstChild()->renderer(); 376 RenderObject* first = document().body()->firstChild()->renderer();
342 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); 377 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
343 GraphicsContext context(nullptr, &rootDisplayItemList()); 378 GraphicsContext context(nullptr, &rootDisplayItemList());
344 379
345 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150)); 380 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150));
346 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 381 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
347 382
348 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 383 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
(...skipping 23 matching lines...) Expand all
372 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); 407 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
373 } 408 }
374 409
375 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip) 410 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip)
376 { 411 {
377 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); 412 setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
378 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer()); 413 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer());
379 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer()); 414 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer());
380 GraphicsContext context(nullptr, &rootDisplayItemList()); 415 GraphicsContext context(nullptr, &rootDisplayItemList());
381 416
417 rootDisplayItemList().beginNewPaints();
382 ClipRect firstClipRect(IntRect(1, 1, 2, 2)); 418 ClipRect firstClipRect(IntRect(1, 1, 2, 2));
383 { 419 {
384 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem ::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags()); 420 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem ::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags());
385 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1 00, 100, 150, 150)); 421 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1 00, 100, 150, 150));
386 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect( 100, 100, 150, 150)); 422 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect( 100, 100, 150, 150));
387 } 423 }
424 rootDisplayItemList().endNewPaints();
388 425
389 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, 426 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
390 TestDisplayItem(firstRenderer, DisplayItem::ClipLayerForeground), 427 TestDisplayItem(firstRenderer, DisplayItem::ClipLayerForeground),
391 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound), 428 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound),
392 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round), 429 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round),
393 TestDisplayItem(firstRenderer, DisplayItem::EndClip)); 430 TestDisplayItem(firstRenderer, DisplayItem::EndClip));
394 431
395 rootDisplayItemList().invalidate(firstRenderer->displayItemClient()); 432 rootDisplayItemList().invalidate(firstRenderer->displayItemClient());
433 rootDisplayItemList().beginNewPaints();
396 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 434 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
397 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 435 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
436 rootDisplayItemList().endNewPaints();
398 437
399 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 438 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
400 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound), 439 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound),
401 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round)); 440 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round));
402 441
403 rootDisplayItemList().invalidate(secondRenderer->displayItemClient()); 442 rootDisplayItemList().invalidate(secondRenderer->displayItemClient());
443 rootDisplayItemList().beginNewPaints();
404 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 444 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
405 ClipRect secondClipRect(IntRect(1, 1, 2, 2)); 445 ClipRect secondClipRect(IntRect(1, 1, 2, 2));
406 { 446 {
407 LayerClipRecorder layerClipRecorder(secondRenderer, &context, DisplayIte m::ClipLayerForeground, secondClipRect, 0, LayoutPoint(), PaintLayerFlags()); 447 LayerClipRecorder layerClipRecorder(secondRenderer, &context, DisplayIte m::ClipLayerForeground, secondClipRect, 0, LayoutPoint(), PaintLayerFlags());
408 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect( 100, 100, 150, 150)); 448 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect( 100, 100, 150, 150));
409 } 449 }
450 rootDisplayItemList().endNewPaints();
410 451
411 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, 452 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
412 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound), 453 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound),
413 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground), 454 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground),
414 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round), 455 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round),
415 TestDisplayItem(secondRenderer, DisplayItem::EndClip)); 456 TestDisplayItem(secondRenderer, DisplayItem::EndClip));
416 } 457 }
417 458
418 TEST_F(ViewDisplayListTest, CachedDisplayItems) 459 TEST_F(ViewDisplayListTest, CachedDisplayItems)
419 { 460 {
461 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true);
462
420 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); 463 setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
421 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer()); 464 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer());
422 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer()); 465 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer());
423 GraphicsContext context(nullptr, &rootDisplayItemList()); 466 GraphicsContext context(nullptr, &rootDisplayItemList());
424 467
468 rootDisplayItemList().beginNewPaints();
425 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 469 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
426 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 470 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
471 rootDisplayItemList().endNewPaints();
427 472
428 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 473 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
429 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound), 474 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound),
430 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round)); 475 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round));
431 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI temClient())); 476 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI temClient()));
432 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display ItemClient())); 477 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display ItemClient()));
433 DisplayItem* firstDisplayItem = rootDisplayItemList().paintList()[0].get(); 478 DisplayItem* firstDisplayItem = rootDisplayItemList().paintList()[0].get();
434 DisplayItem* secondDisplayItem = rootDisplayItemList().paintList()[1].get(); 479 DisplayItem* secondDisplayItem = rootDisplayItemList().paintList()[1].get();
435 480
436 rootDisplayItemList().invalidate(firstRenderer->displayItemClient()); 481 rootDisplayItemList().invalidate(firstRenderer->displayItemClient());
437 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display ItemClient())); 482 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display ItemClient()));
438 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display ItemClient())); 483 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display ItemClient()));
439 484
485 rootDisplayItemList().beginNewPaints();
440 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 486 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
441 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 487 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
488 rootDisplayItemList().endNewPaints();
442 489
443 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 490 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
444 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound), 491 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound),
445 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round)); 492 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round));
446 // The first display item should be updated. 493 // The first display item should be updated.
447 EXPECT_NE(firstDisplayItem, rootDisplayItemList().paintList()[0].get()); 494 EXPECT_NE(firstDisplayItem, rootDisplayItemList().paintList()[0].get());
448 // The second display item should be cached. 495 // The second display item should be cached.
449 EXPECT_EQ(secondDisplayItem, rootDisplayItemList().paintList()[1].get()); 496 EXPECT_EQ(secondDisplayItem, rootDisplayItemList().paintList()[1].get());
450 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI temClient())); 497 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI temClient()));
451 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display ItemClient())); 498 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display ItemClient()));
452 499
453 rootDisplayItemList().invalidateAll(); 500 rootDisplayItemList().invalidateAll();
454 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display ItemClient())); 501 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display ItemClient()));
455 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa yItemClient())); 502 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa yItemClient()));
456 } 503 }
457 504
458 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret) 505 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret)
459 { 506 {
460 setBodyInnerHTML("<div id='div' contentEditable='true'>XYZ</div>"); 507 setBodyInnerHTML("<div id='div' contentEditable='true'>XYZ</div>");
461 RenderView* renderView = document().renderView(); 508 RenderView* renderView = document().renderView();
462 RenderLayer* rootLayer = renderView->layer(); 509 RenderLayer* rootLayer = renderView->layer();
463 RenderObject* htmlRenderer = document().documentElement()->renderer(); 510 RenderObject* htmlRenderer = document().documentElement()->renderer();
464 Element* div = toElement(document().body()->firstChild()); 511 Element* div = toElement(document().body()->firstChild());
465 RenderObject* divRenderer = document().body()->firstChild()->renderer(); 512 RenderObject* divRenderer = document().body()->firstChild()->renderer();
466 RenderObject* textRenderer = div->firstChild()->renderer(); 513 RenderObject* textRenderer = div->firstChild()->renderer();
467 514
468 SkCanvas canvas(800, 600); 515 SkCanvas canvas(800, 600);
469 GraphicsContext context(&canvas, &rootDisplayItemList()); 516 GraphicsContext context(&canvas, &rootDisplayItemList());
470 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB ehaviorNormal, LayoutSize()); 517 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB ehaviorNormal, LayoutSize());
518 rootDisplayItemList().beginNewPaints();
471 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases); 519 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases);
520 rootDisplayItemList().endNewPaints();
472 521
473 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 522 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
474 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und), 523 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und),
475 TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground)) ; 524 TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground)) ;
476 525
477 div->focus(); 526 div->focus();
478 document().view()->updateLayoutAndStyleForPainting(); 527 document().view()->updateLayoutAndStyleForPainting();
528 rootDisplayItemList().beginNewPaints();
479 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases); 529 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases);
530 rootDisplayItemList().endNewPaints();
480 531
481 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 532 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
482 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und), 533 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und),
483 TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground), 534 TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground),
484 TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseCaret)); 535 TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseCaret));
485 } 536 }
486 537
487 } // anonymous namespace 538 } // anonymous namespace
488 } // namespace blink 539 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698