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