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

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

Issue 892293002: First version of new merge algorithm (not enabled yet) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove scope-related code (accidentally mixed in this CL) Created 5 years, 10 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/layout/compositing/RenderLayerCompositor.h" 7 #include "core/layout/compositing/RenderLayerCompositor.h"
8 #include "core/page/FocusController.h"
8 #include "core/paint/LayerClipRecorder.h" 9 #include "core/paint/LayerClipRecorder.h"
9 #include "core/paint/LayerPainter.h" 10 #include "core/paint/LayerPainter.h"
10 #include "core/paint/RenderDrawingRecorder.h" 11 #include "core/paint/RenderDrawingRecorder.h"
12 #include "core/paint/SubtreeInfoRecorder.h"
11 #include "core/rendering/InlineTextBox.h" 13 #include "core/rendering/InlineTextBox.h"
12 #include "core/rendering/RenderText.h" 14 #include "core/rendering/RenderText.h"
13 #include "core/rendering/RenderView.h" 15 #include "core/rendering/RenderView.h"
14 #include "core/rendering/RenderingTestHelper.h" 16 #include "core/rendering/RenderingTestHelper.h"
15 #include "platform/graphics/GraphicsContext.h" 17 #include "platform/graphics/GraphicsContext.h"
16 #include "platform/graphics/GraphicsLayer.h" 18 #include "platform/graphics/GraphicsLayer.h"
17 #include "platform/graphics/paint/DisplayItemList.h" 19 #include "platform/graphics/paint/DisplayItemList.h"
18 #include "third_party/skia/include/core/SkCanvas.h" 20 #include "third_party/skia/include/core/SkCanvas.h"
19 #include <gtest/gtest.h> 21 #include <gtest/gtest.h>
20 22
21 namespace blink { 23 namespace blink {
22 namespace {
23 24
24 class ViewDisplayListTest : public RenderingTest { 25 class ViewDisplayListTest : public RenderingTest {
25 public: 26 public:
26 ViewDisplayListTest() : m_renderView(nullptr) { } 27 ViewDisplayListTest() : m_renderView(nullptr) { }
27 28
28 protected: 29 protected:
29 RenderView* renderView() { return m_renderView; } 30 RenderView* renderView() { return m_renderView; }
30 DisplayItemList& rootDisplayItemList() { return *renderView()->layer()->grap hicsLayerBacking()->displayItemList(); } 31 DisplayItemList& rootDisplayItemList() { return *renderView()->layer()->grap hicsLayerBacking()->displayItemList(); }
32 const Vector<OwnPtr<DisplayItem>>& newPaintListBeforeUpdate() { return rootD isplayItemList().m_newPaints; }
31 33
32 private: 34 private:
33 virtual void SetUp() override 35 virtual void SetUp() override
34 { 36 {
35 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); 37 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
36 38
37 RenderingTest::SetUp(); 39 RenderingTest::SetUp();
38 enableCompositing(); 40 enableCompositing();
39 41
40 m_renderView = document().view()->renderView(); 42 m_renderView = document().view()->renderView();
(...skipping 12 matching lines...) Expand all
53 class TestDisplayItem : public DisplayItem { 55 class TestDisplayItem : public DisplayItem {
54 public: 56 public:
55 TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(rende rer->displayItemClient(), type) { } 57 TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(rende rer->displayItemClient(), type) { }
56 TestDisplayItem(DisplayItemClient displayItemClient, Type type) : DisplayIte m(displayItemClient, type) { } 58 TestDisplayItem(DisplayItemClient displayItemClient, Type type) : DisplayIte m(displayItemClient, type) { }
57 59
58 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); } 60 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); }
59 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override final { ASSERT_NOT_REACHED(); } 61 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override final { ASSERT_NOT_REACHED(); }
60 }; 62 };
61 63
62 #ifndef NDEBUG 64 #ifndef NDEBUG
63 #define TRACE_DISPLAY_ITEMS(expected, actual) \ 65 #define TRACE_DISPLAY_ITEMS(i, expected, actual) \
64 String trace = "Expected: " + (expected).asDebugString() + " Actual: " + (ac tual).asDebugString(); \ 66 String trace = String::format("%d: ", (int)i) + "Expected: " + (expected).as DebugString() + " Actual: " + (actual).asDebugString(); \
65 SCOPED_TRACE(trace.utf8().data()); 67 SCOPED_TRACE(trace.utf8().data());
66 #else 68 #else
67 #define TRACE_DISPLAY_ITEMS(expected, actual) 69 #define TRACE_DISPLAY_ITEMS(i, expected, actual)
68 #endif 70 #endif
69 71
70 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \ 72 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \
71 EXPECT_EQ((size_t)expectedSize, actual.size()); \ 73 EXPECT_EQ((size_t)expectedSize, actual.size()); \
72 const TestDisplayItem expected[] = { __VA_ARGS__ }; \ 74 const TestDisplayItem expected[] = { __VA_ARGS__ }; \
73 for (size_t index = 0; index < std::min<size_t>(actual.size(), expectedSize) ; index++) { \ 75 for (size_t index = 0; index < std::min<size_t>(actual.size(), expectedSize) ; index++) { \
74 TRACE_DISPLAY_ITEMS(expected[index], *actual[index]); \ 76 TRACE_DISPLAY_ITEMS(index, expected[index], *actual[index]); \
75 EXPECT_EQ(expected[index].client(), actual[index]->client()); \ 77 EXPECT_EQ(expected[index].client(), actual[index]->client()); \
76 EXPECT_EQ(expected[index].type(), actual[index]->type()); \ 78 EXPECT_EQ(expected[index].type(), actual[index]->type()); \
77 } \ 79 } \
78 } 80 }
79 81
80 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase , const FloatRect& bound) 82 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase , const FloatRect& bound)
81 { 83 {
82 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); 84 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound);
83 if (drawingRecorder.canUseCachedDrawing()) 85 if (drawingRecorder.canUseCachedDrawing())
84 return; 86 return;
85 IntRect rect(0, 0, 10, 10); 87 IntRect rect(0, 0, 10, 10);
86 context->drawRect(rect); 88 context->drawRect(rect);
87 } 89 }
88 90
89 void drawClippedRect(GraphicsContext* context, RenderLayerModelObject* renderer, PaintPhase phase, const FloatRect& bound) 91 void drawClippedRect(GraphicsContext* context, RenderLayerModelObject* renderer, PaintPhase phase, const FloatRect& bound)
90 { 92 {
91 IntRect rect(1, 1, 9, 9); 93 IntRect rect(1, 1, 9, 9);
92 ClipRect clipRect(rect); 94 ClipRect clipRect(rect);
93 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags()); 95 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags());
94 drawRect(context, renderer, phase, bound); 96 drawRect(context, renderer, phase, bound);
95 } 97 }
96 98
97 TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders) 99 TEST_F(ViewDisplayListTest, NestedRecorders)
98 { 100 {
99 GraphicsContext context(nullptr, &rootDisplayItemList()); 101 GraphicsContext context(nullptr, &rootDisplayItemList());
100 FloatRect bound = renderView()->viewRect(); 102 FloatRect bound = renderView()->viewRect();
101 103
102 drawClippedRect(&context, renderView(), PaintPhaseForeground, bound); 104 drawClippedRect(&context, renderView(), PaintPhaseForeground, bound);
103 rootDisplayItemList().endNewPaints(); 105 rootDisplayItemList().endNewPaints();
104 106
105 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 107 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
106 TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground), 108 TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground),
107 TestDisplayItem(renderView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground)), 109 TestDisplayItem(renderView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground)),
108 TestDisplayItem(renderView(), DisplayItem::clipTypeToEndClipType(Display Item::ClipLayerForeground))); 110 TestDisplayItem(renderView(), DisplayItem::clipTypeToEndClipType(Display Item::ClipLayerForeground)));
109 } 111 }
110 112
111 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic) 113 TEST_F(ViewDisplayListTest, UpdateBasic)
112 { 114 {
113 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); 115 setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
114 RenderObject* first = document().body()->firstChild()->renderer(); 116 RenderObject* first = document().body()->firstChild()->renderer();
115 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 117 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
116 GraphicsContext context(nullptr, &rootDisplayItemList()); 118 GraphicsContext context(nullptr, &rootDisplayItemList());
117 119
118 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300 , 300)); 120 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300 , 300));
119 drawRect(&context, second, PaintPhaseChildBlockBackground, FloatRect(100, 10 0, 200, 200)); 121 drawRect(&context, second, PaintPhaseChildBlockBackground, FloatRect(100, 10 0, 200, 200));
120 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); 122 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
121 rootDisplayItemList().endNewPaints(); 123 rootDisplayItemList().endNewPaints();
122 124
123 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 125 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
124 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)), 126 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
125 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseC hildBlockBackground)), 127 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseC hildBlockBackground)),
126 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline))); 128 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)));
127 129
128 rootDisplayItemList().invalidate(second->displayItemClient()); 130 rootDisplayItemList().invalidate(second->displayItemClient());
129 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300 , 300)); 131 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300 , 300));
130 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); 132 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
131 rootDisplayItemList().endNewPaints(); 133 rootDisplayItemList().endNewPaints();
132 134
133 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 135 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
134 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)), 136 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
135 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline))); 137 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)));
136 } 138 }
137 139
138 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder) 140 TEST_F(ViewDisplayListTest, UpdateSwapOrder)
139 { 141 {
140 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>");
141 RenderObject* first = document().body()->firstChild()->renderer(); 143 RenderObject* first = document().body()->firstChild()->renderer();
142 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 144 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
143 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r enderer(); 145 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r enderer();
144 GraphicsContext context(nullptr, &rootDisplayItemList()); 146 GraphicsContext context(nullptr, &rootDisplayItemList());
145 147
146 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 148 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
147 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 149 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
148 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300 , 10, 10)); 150 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300 , 10, 10));
149 rootDisplayItemList().endNewPaints(); 151 rootDisplayItemList().endNewPaints();
150 152
151 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 153 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
152 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)), 154 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
153 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)), 155 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)),
154 TestDisplayItem(unaffected, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground))); 156 TestDisplayItem(unaffected, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground)));
155 157
156 rootDisplayItemList().invalidate(second->displayItemClient()); 158 rootDisplayItemList().invalidate(second->displayItemClient());
157 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 159 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
158 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 160 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
159 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300 , 10, 10)); 161 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300 , 10, 10));
160 rootDisplayItemList().endNewPaints(); 162 rootDisplayItemList().endNewPaints();
161 163
162 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 164 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
163 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)), 165 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)),
164 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)), 166 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
165 TestDisplayItem(unaffected, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground))); 167 TestDisplayItem(unaffected, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground)));
166 } 168 }
167 169
168 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle) 170 TEST_F(ViewDisplayListTest, UpdateNewItemInMiddle)
169 { 171 {
170 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d iv></div>"); 172 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d iv></div>");
171 RenderObject* first = document().body()->firstChild()->renderer(); 173 RenderObject* first = document().body()->firstChild()->renderer();
172 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 174 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
173 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh ild()->renderer(); 175 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh ild()->renderer();
174 GraphicsContext context(nullptr, &rootDisplayItemList()); 176 GraphicsContext context(nullptr, &rootDisplayItemList());
175 177
176 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 178 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
177 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 179 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
178 rootDisplayItemList().endNewPaints(); 180 rootDisplayItemList().endNewPaints();
179 181
180 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 182 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
181 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)), 183 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
182 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground))); 184 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)));
183 185
184 rootDisplayItemList().invalidate(third->displayItemClient()); 186 rootDisplayItemList().invalidate(third->displayItemClient());
185 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 187 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
186 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200 , 50)); 188 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200 , 50));
187 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 189 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
188 rootDisplayItemList().endNewPaints(); 190 rootDisplayItemList().endNewPaints();
189 191
190 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 192 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
191 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)), 193 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
192 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)), 194 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
193 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground))); 195 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)));
194 } 196 }
195 197
196 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases) 198 TEST_F(ViewDisplayListTest, UpdateInvalidationWithPhases)
197 { 199 {
198 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir d'></div>"); 200 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir d'></div>");
199 RenderObject* first = document().body()->firstChild()->renderer(); 201 RenderObject* first = document().body()->firstChild()->renderer();
200 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 202 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
201 RenderObject* third = document().body()->firstChild()->nextSibling()->render er(); 203 RenderObject* third = document().body()->firstChild()->nextSibling()->render er();
202 GraphicsContext context(nullptr, &rootDisplayItemList()); 204 GraphicsContext context(nullptr, &rootDisplayItemList());
203 205
204 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100)); 206 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100 , 100));
205 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200)); 207 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50 , 200));
206 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50, 50)); 208 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50, 50));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 9, 240 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 9,
239 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)), 241 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
240 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)), 242 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)),
241 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)), 243 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
242 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseFo reground)), 244 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseFo reground)),
243 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseF oreground)), 245 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseF oreground)),
244 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseFo reground)), 246 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseFo reground)),
245 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)), 247 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)),
246 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline)), 248 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline)),
247 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline))); 249 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)));
248
249 // The following is only applicable when we support incremental paint.
250 #if 0
251 rootDisplayItemList().invalidate(second->displayItemClient());
252
253 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 6,
254 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
255 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
256 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseFo reground)),
257 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseFo reground)),
258 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)),
259 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)));
260 #endif
261 } 250 }
262 251
263 // This test is only applicable when we support incremental paint. 252 TEST_F(ViewDisplayListTest, UpdateAddFirstOverlap)
264 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstNoOverlap )
265 { 253 {
266 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); 254 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
267 RenderObject* first = document().body()->firstChild()->renderer(); 255 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::paintPhaseToDrawingType(PaintPhaseB lockBackground)),
276 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline)));
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::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
284 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)),
285 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)),
286 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline)));
287
288 rootDisplayItemList().invalidate(first->displayItemClient());
289
290 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
291 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)),
292 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline)));
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(); 256 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
301 GraphicsContext context(nullptr, &rootDisplayItemList()); 257 GraphicsContext context(nullptr, &rootDisplayItemList());
302 258
303 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50)); 259 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50));
304 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 260 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
261 rootDisplayItemList().endNewPaints();
305 262
306 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 263 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
307 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)), 264 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)),
308 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline))); 265 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline)));
309 266
310 rootDisplayItemList().invalidate(first->displayItemClient()); 267 rootDisplayItemList().invalidate(first->displayItemClient());
311 rootDisplayItemList().invalidate(second->displayItemClient()); 268 rootDisplayItemList().invalidate(second->displayItemClient());
312 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150)); 269 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150));
313 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 270 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
314 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50)); 271 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50));
315 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 272 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
273 rootDisplayItemList().endNewPaints();
316 274
317 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, 275 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
318 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)), 276 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
319 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)), 277 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)),
320 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)), 278 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)),
321 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline))); 279 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline)));
322 280
323 rootDisplayItemList().invalidate(first->displayItemClient()); 281 rootDisplayItemList().invalidate(first->displayItemClient());
324 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50)); 282 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50));
325 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 283 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
284 rootDisplayItemList().endNewPaints();
326 285
327 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 286 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
328 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)), 287 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)),
329 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline))); 288 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline)));
330 } 289 }
331 290
332 // This test is only applicable when we support incremental paint. 291 TEST_F(ViewDisplayListTest, UpdateAddLastOverlap)
333 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastNoOverlap)
334 { 292 {
335 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); 293 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
336 RenderObject* first = document().body()->firstChild()->renderer(); 294 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::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
345 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)));
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::paintPhaseToDrawingType(PaintPhaseB lockBackground)),
353 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline)),
354 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
355 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)));
356
357 rootDisplayItemList().invalidate(second->displayItemClient());
358
359 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
360 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
361 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)));
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(); 295 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
370 GraphicsContext context(nullptr, &rootDisplayItemList()); 296 GraphicsContext context(nullptr, &rootDisplayItemList());
371 297
372 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150)); 298 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150));
373 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 299 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
300 rootDisplayItemList().endNewPaints();
374 301
375 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 302 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
376 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)), 303 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
377 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline))); 304 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)));
378 305
379 rootDisplayItemList().invalidate(first->displayItemClient()); 306 rootDisplayItemList().invalidate(first->displayItemClient());
380 rootDisplayItemList().invalidate(second->displayItemClient()); 307 rootDisplayItemList().invalidate(second->displayItemClient());
381 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150)); 308 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150));
382 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 309 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
383 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50)); 310 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50 , 50));
384 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 311 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
312 rootDisplayItemList().endNewPaints();
385 313
386 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, 314 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
387 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)), 315 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
388 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)), 316 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)),
389 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)), 317 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB lockBackground)),
390 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline))); 318 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO utline)));
391 319
392 rootDisplayItemList().invalidate(first->displayItemClient()); 320 rootDisplayItemList().invalidate(first->displayItemClient());
393 rootDisplayItemList().invalidate(second->displayItemClient()); 321 rootDisplayItemList().invalidate(second->displayItemClient());
394 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150)); 322 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150 , 150));
395 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 323 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
324 rootDisplayItemList().endNewPaints();
396 325
397 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 326 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
398 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)), 327 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl ockBackground)),
399 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline))); 328 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu tline)));
400 } 329 }
401 330
402 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip) 331 TEST_F(ViewDisplayListTest, UpdateClip)
403 { 332 {
404 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); 333 setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
405 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer()); 334 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer());
406 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer()); 335 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer());
407 GraphicsContext context(nullptr, &rootDisplayItemList()); 336 GraphicsContext context(nullptr, &rootDisplayItemList());
408 337
409 ClipRect firstClipRect(IntRect(1, 1, 2, 2)); 338 ClipRect firstClipRect(IntRect(1, 1, 2, 2));
410 { 339 {
411 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem ::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags()); 340 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem ::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags());
412 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1 00, 100, 150, 150)); 341 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1 00, 100, 150, 150));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI temClient())); 413 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI temClient()));
485 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display ItemClient())); 414 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display ItemClient()));
486 415
487 rootDisplayItemList().invalidateAll(); 416 rootDisplayItemList().invalidateAll();
488 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display ItemClient())); 417 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display ItemClient()));
489 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa yItemClient())); 418 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa yItemClient()));
490 } 419 }
491 420
492 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret) 421 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret)
493 { 422 {
494 setBodyInnerHTML("<div id='div' contentEditable='true'>XYZ</div>"); 423 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>");
424 document().page()->focusController().setActive(true);
425 document().page()->focusController().setFocused(true);
495 RenderView* renderView = document().renderView(); 426 RenderView* renderView = document().renderView();
496 RenderLayer* rootLayer = renderView->layer(); 427 RenderLayer* rootLayer = renderView->layer();
497 RenderObject* htmlRenderer = document().documentElement()->renderer(); 428 RenderObject* htmlRenderer = document().documentElement()->renderer();
429 RenderObject* bodyRenderer = document().body()->renderer();
498 Element* div = toElement(document().body()->firstChild()); 430 Element* div = toElement(document().body()->firstChild());
499 RenderObject* divRenderer = document().body()->firstChild()->renderer(); 431 RenderObject* divRenderer = document().body()->firstChild()->renderer();
500 InlineTextBox* textInlineBox = toRenderText(div->firstChild()->renderer())-> firstTextBox(); 432 InlineTextBox* textInlineBox = toRenderText(div->firstChild()->renderer())-> firstTextBox();
501 433
502 SkCanvas canvas(800, 600); 434 SkCanvas canvas(800, 600);
503 GraphicsContext context(&canvas, &rootDisplayItemList()); 435 GraphicsContext context(&canvas, &rootDisplayItemList());
504 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB ehaviorNormal, LayoutSize()); 436 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB ehaviorNormal, LayoutSize());
505 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases); 437 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases);
506 rootDisplayItemList().endNewPaints(); 438 rootDisplayItemList().endNewPaints();
507 439
508 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 440 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 10,
chrishtr 2015/02/04 07:08:14 Why are there so many changes in this test?
Xianzhu 2015/02/04 20:46:32 - Some test cases containing incremental painting
509 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), 441 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToBeginSubtreeType( PaintPhaseBlockBackground)),
510 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh aseToDrawingType(PaintPhaseForeground))); 442 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground),
443 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pa intPhaseBlockBackground)),
444 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToBeginSubtreeType( PaintPhaseForeground)),
445 TestDisplayItem(bodyRenderer, DisplayItem::paintPhaseToBeginSubtreeType( PaintPhaseForeground)),
446 TestDisplayItem(divRenderer, DisplayItem::paintPhaseToBeginSubtreeType(P aintPhaseForeground)),
447 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh aseToDrawingType(PaintPhaseForeground)),
448 TestDisplayItem(divRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pai ntPhaseForeground)),
449 TestDisplayItem(bodyRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pa intPhaseForeground)),
450 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pa intPhaseForeground)));
511 451
512 div->focus(); 452 div->focus();
513 document().view()->updateLayoutAndStyleForPainting(); 453 document().view()->updateLayoutAndStyleForPainting();
514 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases); 454 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases);
515 rootDisplayItemList().endNewPaints(); 455 rootDisplayItemList().endNewPaints();
516 456
517 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, 457 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 11,
518 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), 458 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToBeginSubtreeType( PaintPhaseBlockBackground)),
519 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh aseToDrawingType(PaintPhaseForeground)), 459 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground),
520 TestDisplayItem(divRenderer, DisplayItem::paintPhaseToDrawingType(PaintP haseCaret))); 460 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pa intPhaseBlockBackground)),
521 } 461 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToBeginSubtreeType( PaintPhaseForeground)),
522 462 TestDisplayItem(bodyRenderer, DisplayItem::paintPhaseToBeginSubtreeType( PaintPhaseForeground)),
523 } // anonymous namespace 463 TestDisplayItem(divRenderer, DisplayItem::paintPhaseToBeginSubtreeType(P aintPhaseForeground)),
464 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh aseToDrawingType(PaintPhaseForeground)),
465 TestDisplayItem(divRenderer, DisplayItem::paintPhaseToDrawingType(PaintP haseCaret)),
466 TestDisplayItem(divRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pai ntPhaseForeground)),
467 TestDisplayItem(bodyRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pa intPhaseForeground)),
468 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pa intPhaseForeground)));
469 }
470
471 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret_CacheEnabled)
472 {
473 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true);
474
475 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>");
476 document().page()->focusController().setActive(true);
477 document().page()->focusController().setFocused(true);
478 RenderView* renderView = document().renderView();
479 RenderLayer* rootLayer = renderView->layer();
480 RenderObject* htmlRenderer = document().documentElement()->renderer();
481 RenderObject* bodyRenderer = document().body()->renderer();
482 Element* div = toElement(document().body()->firstChild());
483 RenderObject* divRenderer = document().body()->firstChild()->renderer();
484 InlineTextBox* textInlineBox = toRenderText(div->firstChild()->renderer())-> firstTextBox();
485
486 SkCanvas canvas(800, 600);
487 GraphicsContext context(&canvas, &rootDisplayItemList());
488 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB ehaviorNormal, LayoutSize());
489 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases);
490 rootDisplayItemList().endNewPaints();
491
492 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 10,
493 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToBeginSubtreeType( PaintPhaseBlockBackground)),
494 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground),
495 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pa intPhaseBlockBackground)),
496 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToBeginSubtreeType( PaintPhaseForeground)),
497 TestDisplayItem(bodyRenderer, DisplayItem::paintPhaseToBeginSubtreeType( PaintPhaseForeground)),
498 TestDisplayItem(divRenderer, DisplayItem::paintPhaseToBeginSubtreeType(P aintPhaseForeground)),
499 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh aseToDrawingType(PaintPhaseForeground)),
500 TestDisplayItem(divRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pai ntPhaseForeground)),
501 TestDisplayItem(bodyRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pa intPhaseForeground)),
502 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pa intPhaseForeground)));
503
504 div->focus();
505 document().view()->updateLayoutAndStyleForPainting();
506 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(htmlRenderer->displayIt emClient()));
507 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(bodyRenderer->displayIt emClient()));
508 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divRenderer->displayIt emClient()));
509 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(textInlineBox->displayI temClient()));
510 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases);
511 rootDisplayItemList().endNewPaints();
512
513 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 11,
514 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToBeginSubtreeType( PaintPhaseBlockBackground)),
515 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground),
516 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pa intPhaseBlockBackground)),
517 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToBeginSubtreeType( PaintPhaseForeground)),
518 TestDisplayItem(bodyRenderer, DisplayItem::paintPhaseToBeginSubtreeType( PaintPhaseForeground)),
519 TestDisplayItem(divRenderer, DisplayItem::paintPhaseToBeginSubtreeType(P aintPhaseForeground)),
520 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh aseToDrawingType(PaintPhaseForeground)),
521 TestDisplayItem(divRenderer, DisplayItem::paintPhaseToDrawingType(PaintP haseCaret)),
522 TestDisplayItem(divRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pai ntPhaseForeground)),
523 TestDisplayItem(bodyRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pa intPhaseForeground)),
524 TestDisplayItem(htmlRenderer, DisplayItem::paintPhaseToEndSubtreeType(Pa intPhaseForeground)));
525 }
526
527 TEST_F(ViewDisplayListTest, ComplexUpdateSwapOrder)
528 {
529 setBodyInnerHTML("<div id='container1'><div id='content1'></div></div>"
530 "<div id='container2'><div id='content2'></div></div>");
531 RenderObject* container1 = document().body()->firstChild()->renderer();
532 RenderObject* content1 = document().body()->firstChild()->firstChild()->rend erer();
533 RenderObject* container2 = document().body()->firstChild()->nextSibling()->r enderer();
534 RenderObject* content2 = document().body()->firstChild()->nextSibling()->fir stChild()->renderer();
535 GraphicsContext context(nullptr, &rootDisplayItemList());
536
537 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100 , 100, 100));
538 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
539 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 50, 2 00));
540 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100 , 100));
541 drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100, 200 , 100, 100));
542 drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 200, 50, 200));
543 drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 50, 2 00));
544 drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200, 100 , 100));
545 rootDisplayItemList().endNewPaints();
546
547 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 8,
548 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground)),
549 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eBlockBackground)),
550 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eForeground)),
551 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground)),
552 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground)),
553 TestDisplayItem(content2, DisplayItem::paintPhaseToDrawingType(PaintPhas eBlockBackground)),
554 TestDisplayItem(content2, DisplayItem::paintPhaseToDrawingType(PaintPhas eForeground)),
555 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground)));
556
557 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2.
558 rootDisplayItemList().invalidate(container1->displayItemClient());
559 drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100, 200 , 100, 100));
560 drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 200, 50, 200));
561 drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 50, 2 00));
562 drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200, 100 , 100));
563 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100 , 100, 100));
564 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
565 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 50, 2 00));
566 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100 , 100));
567 rootDisplayItemList().endNewPaints();
568
569 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 8,
570 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground)),
571 TestDisplayItem(content2, DisplayItem::paintPhaseToDrawingType(PaintPhas eBlockBackground)),
572 TestDisplayItem(content2, DisplayItem::paintPhaseToDrawingType(PaintPhas eForeground)),
573 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground)),
574 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground)),
575 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eBlockBackground)),
576 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eForeground)),
577 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground)));
578 }
579
580 TEST_F(ViewDisplayListTest, CachedSubtreeSwapOrder)
581 {
582 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true);
583
584 setBodyInnerHTML("<div id='container1'><div id='content1'></div></div>"
585 "<div id='container2'><div id='content2'></div></div>");
586 RenderObject* container1 = document().body()->firstChild()->renderer();
587 RenderObject* content1 = document().body()->firstChild()->firstChild()->rend erer();
588 RenderObject* container2 = document().body()->firstChild()->nextSibling()->r enderer();
589 RenderObject* content2 = document().body()->firstChild()->nextSibling()->fir stChild()->renderer();
590 GraphicsContext context(nullptr, &rootDisplayItemList());
591
592 {
593 SubtreeInfoRecorder r(&context, *container1, PaintPhaseBlockBackground);
594 r.begin();
595 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
596 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 1 00, 50, 200));
597 }
598 {
599 SubtreeInfoRecorder r(&context, *container1, PaintPhaseForeground);
600 r.begin();
601 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 5 0, 200));
602 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100, 100));
603 }
604 {
605 SubtreeInfoRecorder r(&context, *container2, PaintPhaseBlockBackground);
606 r.begin();
607 drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100, 200, 100, 100));
608 drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 2 00, 50, 200));
609 }
610 {
611 SubtreeInfoRecorder r(&context, *container2, PaintPhaseForeground);
612 r.begin();
613 drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 5 0, 200));
614 drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200, 100, 100));
615 }
616 rootDisplayItemList().endNewPaints();
617
618 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 16,
619 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(Pa intPhaseBlockBackground)),
620 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground)),
621 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eBlockBackground)),
622 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(Pain tPhaseBlockBackground)),
623
624 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(Pa intPhaseForeground)),
625 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eForeground)),
626 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground)),
627 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(Pain tPhaseForeground)),
628
629 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(Pa intPhaseBlockBackground)),
630 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground)),
631 TestDisplayItem(content2, DisplayItem::paintPhaseToDrawingType(PaintPhas eBlockBackground)),
632 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(Pain tPhaseBlockBackground)),
633
634 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(Pa intPhaseForeground)),
635 TestDisplayItem(content2, DisplayItem::paintPhaseToDrawingType(PaintPhas eForeground)),
636 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground)),
637 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(Pain tPhaseForeground)));
638
639 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2,
640 // and at the same time container2 is scrolled out of viewport and content2 is invalidated.
641 rootDisplayItemList().invalidate(content2->displayItemClient());
642 {
643 SubtreeInfoRecorder r(&context, *container2, PaintPhaseBlockBackground);
644 }
645 EXPECT_EQ((size_t)1, newPaintListBeforeUpdate().size());
646 EXPECT_TRUE(newPaintListBeforeUpdate().last()->isSubtreeCached());
647 {
648 SubtreeInfoRecorder r(&context, *container2, PaintPhaseForeground);
649 }
650 EXPECT_EQ((size_t)2, newPaintListBeforeUpdate().size());
651 EXPECT_TRUE(newPaintListBeforeUpdate().last()->isSubtreeCached());
652 {
653 SubtreeInfoRecorder r(&context, *container1, PaintPhaseBlockBackground);
654 r.begin();
655 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
656 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 1 00, 50, 200));
657 }
658 {
659 SubtreeInfoRecorder r(&context, *container1, PaintPhaseForeground);
660 r.begin();
661 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 5 0, 200));
662 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100, 100));
663 }
664 rootDisplayItemList().endNewPaints();
665
666 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 14,
667 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(Pa intPhaseBlockBackground)),
668 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground)),
669 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(Pain tPhaseBlockBackground)),
670
671 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(Pa intPhaseForeground)),
672 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground)),
673 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(Pain tPhaseForeground)),
674
675 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(Pa intPhaseBlockBackground)),
676 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground)),
677 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eBlockBackground)),
678 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(Pain tPhaseBlockBackground)),
679
680 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(Pa intPhaseForeground)),
681 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eForeground)),
682 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground)),
683 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(Pain tPhaseForeground)));
684 }
685
524 } // namespace blink 686 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698