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

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

Issue 702633002: Move ViewDisplayList to GraphicsLayer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: copy & pasted test expectation from the wrong window. sorry. :( Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/ViewDisplayList.cpp ('k') | Source/core/rendering/PaintPhase.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "core/paint/ViewDisplayList.h"
7 6
8 #include "core/paint/ClipRecorder.h" 7 #include "core/paint/ClipRecorder.h"
9 #include "core/paint/DrawingRecorder.h" 8 #include "core/paint/DrawingRecorder.h"
10 #include "core/rendering/RenderView.h" 9 #include "core/rendering/RenderView.h"
11 #include "core/rendering/RenderingTestHelper.h" 10 #include "core/rendering/RenderingTestHelper.h"
12 #include "core/rendering/compositing/RenderLayerCompositor.h" 11 #include "core/rendering/compositing/RenderLayerCompositor.h"
13 #include "platform/graphics/GraphicsContext.h" 12 #include "platform/graphics/GraphicsContext.h"
13 #include "platform/graphics/GraphicsLayer.h"
14 #include "platform/graphics/paint/DisplayItemList.h"
14 #include <gtest/gtest.h> 15 #include <gtest/gtest.h>
15 16
16 namespace blink { 17 namespace blink {
17 namespace { 18 namespace {
18 19
19 class ViewDisplayListTest : public RenderingTest { 20 class ViewDisplayListTest : public RenderingTest {
20 public: 21 public:
21 ViewDisplayListTest() : m_renderView(nullptr) { } 22 ViewDisplayListTest() : m_renderView(nullptr) { }
22 23
23 protected: 24 protected:
24 RenderView* renderView() { return m_renderView; } 25 RenderView* renderView() { return m_renderView; }
26 DisplayItemList& rootDisplayItemList() { return renderView()->layer()->graph icsLayerBacking()->displayItemList(); }
25 27
26 private: 28 private:
27 virtual void SetUp() override 29 virtual void SetUp() override
28 { 30 {
29 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); 31 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
30 32
31 RenderingTest::SetUp(); 33 RenderingTest::SetUp();
34 enableCompositing();
32 35
33 m_renderView = document().view()->renderView(); 36 m_renderView = document().view()->renderView();
34 ASSERT_TRUE(m_renderView); 37 ASSERT_TRUE(m_renderView);
35 } 38 }
36 39
37 RenderView* m_renderView; 40 RenderView* m_renderView;
38 }; 41 };
39 42
40 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase , const FloatRect& bound) 43 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase , const FloatRect& bound)
41 { 44 {
42 DrawingRecorder drawingRecorder(context, renderer, phase, bound); 45 DrawingRecorder drawingRecorder(context, renderer, phase, bound);
43 IntRect rect(0, 0, 10, 10); 46 IntRect rect(0, 0, 10, 10);
44 context->drawRect(rect); 47 context->drawRect(rect);
45 } 48 }
46 49
47 void drawClippedRect(GraphicsContext* context, RenderView* renderView, PaintPhas e phase, const FloatRect& bound) 50 void drawClippedRect(GraphicsContext* context, RenderView* renderView, PaintPhas e phase, const FloatRect& bound)
48 { 51 {
49 IntRect rect(1, 1, 9, 9); 52 IntRect rect(1, 1, 9, 9);
50 ClipRect clipRect(rect); 53 ClipRect clipRect(rect);
51 ClipRecorder clipRecorder(renderView->compositor()->rootRenderLayer(), conte xt, DisplayItem::ClipLayerForeground, clipRect); 54 ClipRecorder clipRecorder(renderView->compositor()->rootRenderLayer(), conte xt, DisplayItem::ClipLayerForeground, clipRect);
52 drawRect(context, renderView, phase, bound); 55 drawRect(context, renderView, phase, bound);
53 } 56 }
54 57
55 TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders) 58 TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders)
56 { 59 {
57 GraphicsContext* context = new GraphicsContext(nullptr); 60 GraphicsContext* context = new GraphicsContext(nullptr);
58 FloatRect bound = renderView()->viewRect(); 61 FloatRect bound = renderView()->viewRect();
59 62
60 drawClippedRect(context, renderView(), PaintPhaseForeground, bound); 63 drawClippedRect(context, renderView(), PaintPhaseForeground, bound);
61 EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size()); 64 EXPECT_EQ((size_t)3, rootDisplayItemList().paintList().size());
62 65
63 // TODO(schenney): Check that the IDs are what we expect. 66 // TODO(schenney): Check that the IDs are what we expect.
64 } 67 }
65 68
66 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic) 69 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic)
67 { 70 {
68 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); 71 setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
69 RenderObject* first = document().body()->firstChild()->renderer(); 72 RenderObject* first = document().body()->firstChild()->renderer();
70 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 73 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
71 GraphicsContext* context = new GraphicsContext(nullptr); 74 GraphicsContext* context = new GraphicsContext(nullptr);
72 75
73 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300)); 76 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300));
74 drawRect(context, second, PaintPhaseChildBlockBackground, FloatRect(100, 100 , 200, 200)); 77 drawRect(context, second, PaintPhaseChildBlockBackground, FloatRect(100, 100 , 200, 200));
75 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); 78 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
76 79
77 EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size()); 80 EXPECT_EQ((size_t)3, rootDisplayItemList().paintList().size());
78 81
79 renderView()->viewDisplayList().invalidate(second); 82 rootDisplayItemList().invalidate(second);
80 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300)); 83 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300));
81 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); 84 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
82 EXPECT_EQ((size_t)2, renderView()->viewDisplayList().paintList().size()); 85 EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size());
83 } 86 }
84 87
85 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder) 88 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
86 { 89 {
87 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaf fected'></div>"); 90 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaf fected'></div>");
88 RenderObject* first = document().body()->firstChild()->renderer(); 91 RenderObject* first = document().body()->firstChild()->renderer();
89 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 92 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
90 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r enderer(); 93 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r enderer();
91 GraphicsContext* context = new GraphicsContext(nullptr); 94 GraphicsContext* context = new GraphicsContext(nullptr);
92 95
93 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); 96 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
94 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); 97 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
95 drawRect(context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300, 10, 10)); 98 drawRect(context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300, 10, 10));
96 99
97 const PaintList& firstList = renderView()->viewDisplayList().paintList(); 100 const PaintList& firstList = rootDisplayItemList().paintList();
98 EXPECT_EQ((size_t)3, firstList.size()); 101 EXPECT_EQ((size_t)3, firstList.size());
99 EXPECT_EQ(first, firstList[0]->renderer()); 102 EXPECT_EQ(first, firstList[0]->client());
100 EXPECT_EQ(second, firstList[1]->renderer()); 103 EXPECT_EQ(second, firstList[1]->client());
101 EXPECT_EQ(unaffected, firstList[2]->renderer()); 104 EXPECT_EQ(unaffected, firstList[2]->client());
102 105
103 renderView()->viewDisplayList().invalidate(second); 106 rootDisplayItemList().invalidate(second);
104 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); 107 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
105 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); 108 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
106 109
107 const PaintList& secondList = renderView()->viewDisplayList().paintList(); 110 const PaintList& secondList = rootDisplayItemList().paintList();
108 EXPECT_EQ((size_t)3, secondList.size()); 111 EXPECT_EQ((size_t)3, secondList.size());
109 EXPECT_EQ(second, secondList[0]->renderer()); 112 EXPECT_EQ(second, secondList[0]->client());
110 EXPECT_EQ(first, secondList[1]->renderer()); 113 EXPECT_EQ(first, secondList[1]->client());
111 EXPECT_EQ(unaffected, secondList[2]->renderer()); 114 EXPECT_EQ(unaffected, secondList[2]->client());
112 } 115 }
113 116
114 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle) 117 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle)
115 { 118 {
116 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d iv></div>"); 119 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d iv></div>");
117 RenderObject* first = document().body()->firstChild()->renderer(); 120 RenderObject* first = document().body()->firstChild()->renderer();
118 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 121 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
119 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh ild()->renderer(); 122 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh ild()->renderer();
120 GraphicsContext* context = new GraphicsContext(nullptr); 123 GraphicsContext* context = new GraphicsContext(nullptr);
121 124
122 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); 125 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
123 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); 126 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
124 127
125 const PaintList& firstList = renderView()->viewDisplayList().paintList(); 128 const PaintList& firstList = rootDisplayItemList().paintList();
126 EXPECT_EQ((size_t)2, firstList.size()); 129 EXPECT_EQ((size_t)2, firstList.size());
127 EXPECT_EQ(first, firstList[0]->renderer()); 130 EXPECT_EQ(first, firstList[0]->client());
128 EXPECT_EQ(second, firstList[1]->renderer()); 131 EXPECT_EQ(second, firstList[1]->client());
129 132
130 renderView()->viewDisplayList().invalidate(third); 133 rootDisplayItemList().invalidate(third);
131 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); 134 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
132 drawRect(context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200, 50)); 135 drawRect(context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200, 50));
133 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); 136 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
134 137
135 const PaintList& secondList = renderView()->viewDisplayList().paintList(); 138 const PaintList& secondList = rootDisplayItemList().paintList();
136 EXPECT_EQ((size_t)3, secondList.size()); 139 EXPECT_EQ((size_t)3, secondList.size());
137 EXPECT_EQ(first, secondList[0]->renderer()); 140 EXPECT_EQ(first, secondList[0]->client());
138 EXPECT_EQ(third, secondList[1]->renderer()); 141 EXPECT_EQ(third, secondList[1]->client());
139 EXPECT_EQ(second, secondList[2]->renderer()); 142 EXPECT_EQ(second, secondList[2]->client());
140 } 143 }
141 144
142 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases) 145 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
143 { 146 {
144 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir d'></div>"); 147 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir d'></div>");
145 RenderObject* first = document().body()->firstChild()->renderer(); 148 RenderObject* first = document().body()->firstChild()->renderer();
146 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); 149 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
147 RenderObject* third = document().body()->firstChild()->nextSibling()->render er(); 150 RenderObject* third = document().body()->firstChild()->nextSibling()->render er();
148 GraphicsContext* context = new GraphicsContext(nullptr); 151 GraphicsContext* context = new GraphicsContext(nullptr);
149 152
150 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); 153 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
151 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); 154 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
152 drawRect(context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50, 50)); 155 drawRect(context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50, 50));
153 drawRect(context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100) ); 156 drawRect(context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100) );
154 drawRect(context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200) ); 157 drawRect(context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200) );
155 drawRect(context, third, PaintPhaseForeground, FloatRect(300, 100, 50, 50)); 158 drawRect(context, third, PaintPhaseForeground, FloatRect(300, 100, 50, 50));
156 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100)); 159 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100));
157 drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200)); 160 drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200));
158 drawRect(context, third, PaintPhaseOutline, FloatRect(300, 100, 50, 50)); 161 drawRect(context, third, PaintPhaseOutline, FloatRect(300, 100, 50, 50));
159 162
160 const PaintList& firstList = renderView()->viewDisplayList().paintList(); 163 const PaintList& firstList = rootDisplayItemList().paintList();
161 EXPECT_EQ((size_t)9, firstList.size()); 164 EXPECT_EQ((size_t)9, firstList.size());
162 for (int item = 0; item < 9; item += 3) { 165 for (int item = 0; item < 9; item += 3) {
163 EXPECT_EQ(first, firstList[item % 3 + 0]->renderer()); 166 EXPECT_EQ(first, firstList[item % 3 + 0]->client());
164 EXPECT_EQ(second, firstList[item % 3 + 1]->renderer()); 167 EXPECT_EQ(second, firstList[item % 3 + 1]->client());
165 EXPECT_EQ(third, firstList[item % 3 + 2]->renderer()); 168 EXPECT_EQ(third, firstList[item % 3 + 2]->client());
166 } 169 }
167 170
168 renderView()->viewDisplayList().invalidate(second); 171 rootDisplayItemList().invalidate(second);
169 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); 172 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
170 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); 173 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
171 drawRect(context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100) ); 174 drawRect(context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100) );
172 drawRect(context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200) ); 175 drawRect(context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200) );
173 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100)); 176 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100));
174 drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200)); 177 drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200));
175 178
176 const PaintList& secondList = renderView()->viewDisplayList().paintList(); 179 const PaintList& secondList = rootDisplayItemList().paintList();
177 EXPECT_EQ((size_t)9, secondList.size()); 180 EXPECT_EQ((size_t)9, secondList.size());
178 for (int item = 0; item < 9; item += 3) { 181 for (int item = 0; item < 9; item += 3) {
179 EXPECT_EQ(first, secondList[item % 3 + 0]->renderer()); 182 EXPECT_EQ(first, secondList[item % 3 + 0]->client());
180 EXPECT_EQ(second, secondList[item % 3 + 1]->renderer()); 183 EXPECT_EQ(second, secondList[item % 3 + 1]->client());
181 EXPECT_EQ(third, secondList[item % 3 + 2]->renderer()); 184 EXPECT_EQ(third, secondList[item % 3 + 2]->client());
182 } 185 }
183 186
184 renderView()->viewDisplayList().invalidate(second); 187 rootDisplayItemList().invalidate(second);
185 const PaintList& thirdList = renderView()->viewDisplayList().paintList(); 188 const PaintList& thirdList = rootDisplayItemList().paintList();
186 EXPECT_EQ((size_t)6, thirdList.size()); 189 EXPECT_EQ((size_t)6, thirdList.size());
187 for (int item = 0; item < 6; item += 2) { 190 for (int item = 0; item < 6; item += 2) {
188 EXPECT_EQ(first, thirdList[item % 2 + 0]->renderer()); 191 EXPECT_EQ(first, thirdList[item % 2 + 0]->client());
189 EXPECT_EQ(third, thirdList[item % 2 + 1]->renderer()); 192 EXPECT_EQ(third, thirdList[item % 2 + 1]->client());
190 } 193 }
191 } 194 }
192 195
193 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap) 196 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap)
194 { 197 {
195 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); 198 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
196 RenderObject* first = document().body()->firstChild()->renderer(); 199 RenderObject* first = document().body()->firstChild()->renderer();
197 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); 200 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
198 GraphicsContext* context = new GraphicsContext(nullptr); 201 GraphicsContext* context = new GraphicsContext(nullptr);
199 202
200 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); 203 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
201 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 204 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
202 205
203 const PaintList& firstList = renderView()->viewDisplayList().paintList(); 206 const PaintList& firstList = rootDisplayItemList().paintList();
204 EXPECT_EQ((size_t)2, firstList.size()); 207 EXPECT_EQ((size_t)2, firstList.size());
205 EXPECT_EQ(second, firstList[0]->renderer()); 208 EXPECT_EQ(second, firstList[0]->client());
206 EXPECT_EQ(second, firstList[1]->renderer()); 209 EXPECT_EQ(second, firstList[1]->client());
207 210
208 renderView()->viewDisplayList().invalidate(first); 211 rootDisplayItemList().invalidate(first);
209 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50)); 212 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50));
210 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50)); 213 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50));
211 214
212 const PaintList& secondList = renderView()->viewDisplayList().paintList(); 215 const PaintList& secondList = rootDisplayItemList().paintList();
213 EXPECT_EQ((size_t)4, secondList.size()); 216 EXPECT_EQ((size_t)4, secondList.size());
214 EXPECT_EQ(first, secondList[0]->renderer()); 217 EXPECT_EQ(first, secondList[0]->client());
215 EXPECT_EQ(first, secondList[1]->renderer()); 218 EXPECT_EQ(first, secondList[1]->client());
216 EXPECT_EQ(second, secondList[2]->renderer()); 219 EXPECT_EQ(second, secondList[2]->client());
217 EXPECT_EQ(second, secondList[3]->renderer()); 220 EXPECT_EQ(second, secondList[3]->client());
218 221
219 renderView()->viewDisplayList().invalidate(first); 222 rootDisplayItemList().invalidate(first);
220 const PaintList& thirdList = renderView()->viewDisplayList().paintList(); 223 const PaintList& thirdList = rootDisplayItemList().paintList();
221 EXPECT_EQ((size_t)2, thirdList.size()); 224 EXPECT_EQ((size_t)2, thirdList.size());
222 EXPECT_EQ(second, thirdList[0]->renderer()); 225 EXPECT_EQ(second, thirdList[0]->client());
223 EXPECT_EQ(second, thirdList[1]->renderer()); 226 EXPECT_EQ(second, thirdList[1]->client());
224 } 227 }
225 228
226 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap) 229 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap)
227 { 230 {
228 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); 231 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
229 RenderObject* first = document().body()->firstChild()->renderer(); 232 RenderObject* first = document().body()->firstChild()->renderer();
230 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); 233 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
231 GraphicsContext* context = new GraphicsContext(nullptr); 234 GraphicsContext* context = new GraphicsContext(nullptr);
232 235
233 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); 236 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
234 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 237 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
235 238
236 const PaintList& firstList = renderView()->viewDisplayList().paintList(); 239 const PaintList& firstList = rootDisplayItemList().paintList();
237 EXPECT_EQ((size_t)2, firstList.size()); 240 EXPECT_EQ((size_t)2, firstList.size());
238 EXPECT_EQ(second, firstList[0]->renderer()); 241 EXPECT_EQ(second, firstList[0]->client());
239 EXPECT_EQ(second, firstList[1]->renderer()); 242 EXPECT_EQ(second, firstList[1]->client());
240 243
241 renderView()->viewDisplayList().invalidate(first); 244 rootDisplayItemList().invalidate(first);
242 renderView()->viewDisplayList().invalidate(second); 245 rootDisplayItemList().invalidate(second);
243 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 246 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
244 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 247 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
245 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); 248 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
246 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 249 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
247 250
248 const PaintList& secondList = renderView()->viewDisplayList().paintList(); 251 const PaintList& secondList = rootDisplayItemList().paintList();
249 EXPECT_EQ((size_t)4, secondList.size()); 252 EXPECT_EQ((size_t)4, secondList.size());
250 EXPECT_EQ(first, secondList[0]->renderer()); 253 EXPECT_EQ(first, secondList[0]->client());
251 EXPECT_EQ(first, secondList[1]->renderer()); 254 EXPECT_EQ(first, secondList[1]->client());
252 EXPECT_EQ(second, secondList[2]->renderer()); 255 EXPECT_EQ(second, secondList[2]->client());
253 EXPECT_EQ(second, secondList[3]->renderer()); 256 EXPECT_EQ(second, secondList[3]->client());
254 257
255 renderView()->viewDisplayList().invalidate(first); 258 rootDisplayItemList().invalidate(first);
256 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); 259 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
257 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 260 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
258 261
259 const PaintList& thirdList = renderView()->viewDisplayList().paintList(); 262 const PaintList& thirdList = rootDisplayItemList().paintList();
260 EXPECT_EQ((size_t)2, thirdList.size()); 263 EXPECT_EQ((size_t)2, thirdList.size());
261 EXPECT_EQ(second, thirdList[0]->renderer()); 264 EXPECT_EQ(second, thirdList[0]->client());
262 EXPECT_EQ(second, thirdList[1]->renderer()); 265 EXPECT_EQ(second, thirdList[1]->client());
263 } 266 }
264 267
265 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap) 268 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap)
266 { 269 {
267 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); 270 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
268 RenderObject* first = document().body()->firstChild()->renderer(); 271 RenderObject* first = document().body()->firstChild()->renderer();
269 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); 272 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
270 GraphicsContext* context = new GraphicsContext(nullptr); 273 GraphicsContext* context = new GraphicsContext(nullptr);
271 274
272 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50)); 275 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50));
273 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50)); 276 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50));
274 277
275 const PaintList& firstList = renderView()->viewDisplayList().paintList(); 278 const PaintList& firstList = rootDisplayItemList().paintList();
276 EXPECT_EQ((size_t)2, firstList.size()); 279 EXPECT_EQ((size_t)2, firstList.size());
277 EXPECT_EQ(first, firstList[0]->renderer()); 280 EXPECT_EQ(first, firstList[0]->client());
278 EXPECT_EQ(first, firstList[1]->renderer()); 281 EXPECT_EQ(first, firstList[1]->client());
279 282
280 renderView()->viewDisplayList().invalidate(second); 283 rootDisplayItemList().invalidate(second);
281 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); 284 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
282 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 285 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
283 286
284 const PaintList& secondList = renderView()->viewDisplayList().paintList(); 287 const PaintList& secondList = rootDisplayItemList().paintList();
285 EXPECT_EQ((size_t)4, secondList.size()); 288 EXPECT_EQ((size_t)4, secondList.size());
286 EXPECT_EQ(second, secondList[0]->renderer()); 289 EXPECT_EQ(second, secondList[0]->client());
287 EXPECT_EQ(second, secondList[1]->renderer()); 290 EXPECT_EQ(second, secondList[1]->client());
288 EXPECT_EQ(first, secondList[2]->renderer()); 291 EXPECT_EQ(first, secondList[2]->client());
289 EXPECT_EQ(first, secondList[3]->renderer()); 292 EXPECT_EQ(first, secondList[3]->client());
290 293
291 renderView()->viewDisplayList().invalidate(second); 294 rootDisplayItemList().invalidate(second);
292 const PaintList& thirdList = renderView()->viewDisplayList().paintList(); 295 const PaintList& thirdList = rootDisplayItemList().paintList();
293 EXPECT_EQ((size_t)2, thirdList.size()); 296 EXPECT_EQ((size_t)2, thirdList.size());
294 EXPECT_EQ(first, thirdList[0]->renderer()); 297 EXPECT_EQ(first, thirdList[0]->client());
295 EXPECT_EQ(first, thirdList[1]->renderer()); 298 EXPECT_EQ(first, thirdList[1]->client());
296 } 299 }
297 300
298 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap) 301 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap)
299 { 302 {
300 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); 303 setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
301 RenderObject* first = document().body()->firstChild()->renderer(); 304 RenderObject* first = document().body()->firstChild()->renderer();
302 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); 305 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer();
303 GraphicsContext* context = new GraphicsContext(nullptr); 306 GraphicsContext* context = new GraphicsContext(nullptr);
304 307
305 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 308 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
306 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 309 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
307 310
308 const PaintList& firstList = renderView()->viewDisplayList().paintList(); 311 const PaintList& firstList = rootDisplayItemList().paintList();
309 EXPECT_EQ((size_t)2, firstList.size()); 312 EXPECT_EQ((size_t)2, firstList.size());
310 EXPECT_EQ(first, firstList[0]->renderer()); 313 EXPECT_EQ(first, firstList[0]->client());
311 EXPECT_EQ(first, firstList[1]->renderer()); 314 EXPECT_EQ(first, firstList[1]->client());
312 315
313 renderView()->viewDisplayList().invalidate(first); 316 rootDisplayItemList().invalidate(first);
314 renderView()->viewDisplayList().invalidate(second); 317 rootDisplayItemList().invalidate(second);
315 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 318 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
316 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 319 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
317 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); 320 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
318 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); 321 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
319 322
320 const PaintList& secondList = renderView()->viewDisplayList().paintList(); 323 const PaintList& secondList = rootDisplayItemList().paintList();
321 EXPECT_EQ((size_t)4, secondList.size()); 324 EXPECT_EQ((size_t)4, secondList.size());
322 EXPECT_EQ(first, secondList[0]->renderer()); 325 EXPECT_EQ(first, secondList[0]->client());
323 EXPECT_EQ(first, secondList[1]->renderer()); 326 EXPECT_EQ(first, secondList[1]->client());
324 EXPECT_EQ(second, secondList[2]->renderer()); 327 EXPECT_EQ(second, secondList[2]->client());
325 EXPECT_EQ(second, secondList[3]->renderer()); 328 EXPECT_EQ(second, secondList[3]->client());
326 329
327 renderView()->viewDisplayList().invalidate(first); 330 rootDisplayItemList().invalidate(first);
328 renderView()->viewDisplayList().invalidate(second); 331 rootDisplayItemList().invalidate(second);
329 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 332 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
330 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 333 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
331 334
332 const PaintList& thirdList = renderView()->viewDisplayList().paintList(); 335 const PaintList& thirdList = rootDisplayItemList().paintList();
333 EXPECT_EQ((size_t)2, thirdList.size()); 336 EXPECT_EQ((size_t)2, thirdList.size());
334 EXPECT_EQ(first, thirdList[0]->renderer()); 337 EXPECT_EQ(first, thirdList[0]->client());
335 EXPECT_EQ(first, thirdList[1]->renderer()); 338 EXPECT_EQ(first, thirdList[1]->client());
336 } 339 }
337 340
338 } 341 }
339 342
340 } 343 }
OLDNEW
« no previous file with comments | « Source/core/paint/ViewDisplayList.cpp ('k') | Source/core/rendering/PaintPhase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698