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 #include "core/paint/ViewDisplayList.h" |
7 | 7 |
8 #include "core/paint/ClipRecorder.h" | 8 #include "core/paint/ClipRecorder.h" |
9 #include "core/paint/DrawingRecorder.h" | 9 #include "core/paint/DrawingRecorder.h" |
10 #include "core/rendering/RenderView.h" | 10 #include "core/rendering/RenderView.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 | 30 |
31 RenderingTest::SetUp(); | 31 RenderingTest::SetUp(); |
32 | 32 |
33 m_renderView = document().view()->renderView(); | 33 m_renderView = document().view()->renderView(); |
34 ASSERT_TRUE(m_renderView); | 34 ASSERT_TRUE(m_renderView); |
35 } | 35 } |
36 | 36 |
37 RenderView* m_renderView; | 37 RenderView* m_renderView; |
38 }; | 38 }; |
39 | 39 |
40 class TestDisplayItem : public DisplayItem { | |
41 public: | |
42 TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(rende rer, type) { } | |
43 | |
44 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); } | |
45 }; | |
46 | |
47 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \ | |
48 EXPECT_EQ((size_t)expectedSize, actual.size()); \ | |
49 const TestDisplayItem expected[] = { __VA_ARGS__ }; \ | |
50 for (size_t index = 0; index < expectedSize; index++) { \ | |
51 EXPECT_EQ(expected[index].renderer(), actual[index]->renderer()); \ | |
52 EXPECT_EQ(expected[index].type(), actual[index]->type()); \ | |
53 } \ | |
54 } | |
55 | |
40 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase , const FloatRect& bound) | 56 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase , const FloatRect& bound) |
41 { | 57 { |
42 DrawingRecorder drawingRecorder(context, renderer, phase, bound); | 58 DrawingRecorder drawingRecorder(context, renderer, phase, bound); |
43 IntRect rect(0, 0, 10, 10); | 59 IntRect rect(0, 0, 10, 10); |
44 context->drawRect(rect); | 60 context->drawRect(rect); |
45 } | 61 } |
46 | 62 |
47 void drawClippedRect(GraphicsContext* context, RenderView* renderView, PaintPhas e phase, const FloatRect& bound) | 63 void drawClippedRect(GraphicsContext* context, RenderLayerModelObject* renderer, PaintPhase phase, const FloatRect& bound) |
48 { | 64 { |
49 IntRect rect(1, 1, 9, 9); | 65 IntRect rect(1, 1, 9, 9); |
50 ClipRect clipRect(rect); | 66 ClipRect clipRect(rect); |
51 ClipRecorder clipRecorder(renderView->compositor()->rootRenderLayer(), conte xt, DisplayItem::ClipLayerForeground, clipRect); | 67 ClipRecorder clipRecorder(renderer, context, DisplayItem::ClipLayerForegroun d, clipRect); |
52 drawRect(context, renderView, phase, bound); | 68 drawRect(context, renderer, phase, bound); |
53 } | 69 } |
54 | 70 |
55 TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders) | 71 TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders) |
56 { | 72 { |
57 GraphicsContext* context = new GraphicsContext(nullptr); | 73 GraphicsContext* context = new GraphicsContext(nullptr); |
58 FloatRect bound = renderView()->viewRect(); | 74 FloatRect bound = renderView()->viewRect(); |
59 | 75 |
60 drawClippedRect(context, renderView(), PaintPhaseForeground, bound); | 76 drawClippedRect(context, renderView(), PaintPhaseForeground, bound); |
61 EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size()); | |
62 | 77 |
63 // TODO(schenney): Check that the IDs are what we expect. | 78 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3, |
chrishtr
2014/11/14 01:11:26
Just a regular FIXME..
| |
79 TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground), | |
80 TestDisplayItem(renderView(), DisplayItem::DrawingPaintPhaseForeground), | |
81 TestDisplayItem(renderView(), DisplayItem::EndClip)); | |
64 } | 82 } |
65 | 83 |
66 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic) | 84 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic) |
67 { | 85 { |
68 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); | 86 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); |
69 RenderObject* first = document().body()->firstChild()->renderer(); | 87 RenderObject* first = document().body()->firstChild()->renderer(); |
70 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); | 88 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); |
71 GraphicsContext* context = new GraphicsContext(nullptr); | 89 GraphicsContext* context = new GraphicsContext(nullptr); |
72 | 90 |
73 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300)); | 91 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300)); |
74 drawRect(context, second, PaintPhaseChildBlockBackground, FloatRect(100, 100 , 200, 200)); | 92 drawRect(context, second, PaintPhaseChildBlockBackground, FloatRect(100, 100 , 200, 200)); |
75 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); | 93 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); |
76 | 94 |
77 EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size()); | 95 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3, |
96 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), | |
97 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseChildBlockBackgrou nd), | |
98 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); | |
78 | 99 |
79 renderView()->viewDisplayList().invalidate(second); | 100 renderView()->viewDisplayList().invalidate(second); |
80 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300)); | 101 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300)); |
81 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); | 102 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); |
82 EXPECT_EQ((size_t)2, renderView()->viewDisplayList().paintList().size()); | 103 |
104 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2, | |
105 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), | |
106 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); | |
83 } | 107 } |
84 | 108 |
85 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder) | 109 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder) |
86 { | 110 { |
87 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaf fected'></div>"); | 111 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaf fected'></div>"); |
88 RenderObject* first = document().body()->firstChild()->renderer(); | 112 RenderObject* first = document().body()->firstChild()->renderer(); |
89 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); | 113 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); |
90 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r enderer(); | 114 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r enderer(); |
91 GraphicsContext* context = new GraphicsContext(nullptr); | 115 GraphicsContext* context = new GraphicsContext(nullptr); |
92 | 116 |
93 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); | 117 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); |
94 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); | 118 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); |
95 drawRect(context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300, 10, 10)); | 119 drawRect(context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300, 10, 10)); |
96 | 120 |
97 const PaintList& firstList = renderView()->viewDisplayList().paintList(); | 121 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3, |
98 EXPECT_EQ((size_t)3, firstList.size()); | 122 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
99 EXPECT_EQ(first, firstList[0]->renderer()); | 123 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), |
100 EXPECT_EQ(second, firstList[1]->renderer()); | 124 TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackgroun d)); |
101 EXPECT_EQ(unaffected, firstList[2]->renderer()); | |
102 | 125 |
103 renderView()->viewDisplayList().invalidate(second); | 126 renderView()->viewDisplayList().invalidate(second); |
104 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); | 127 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); |
105 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); | 128 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); |
106 | 129 |
107 const PaintList& secondList = renderView()->viewDisplayList().paintList(); | 130 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3, |
108 EXPECT_EQ((size_t)3, secondList.size()); | 131 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), |
109 EXPECT_EQ(second, secondList[0]->renderer()); | 132 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
110 EXPECT_EQ(first, secondList[1]->renderer()); | 133 TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackgroun d)); |
111 EXPECT_EQ(unaffected, secondList[2]->renderer()); | |
112 } | 134 } |
113 | 135 |
114 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle) | 136 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle) |
115 { | 137 { |
116 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d iv></div>"); | 138 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d iv></div>"); |
117 RenderObject* first = document().body()->firstChild()->renderer(); | 139 RenderObject* first = document().body()->firstChild()->renderer(); |
118 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); | 140 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); |
119 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh ild()->renderer(); | 141 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh ild()->renderer(); |
120 GraphicsContext* context = new GraphicsContext(nullptr); | 142 GraphicsContext* context = new GraphicsContext(nullptr); |
121 | 143 |
122 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); | 144 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); |
123 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); | 145 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); |
124 | 146 |
125 const PaintList& firstList = renderView()->viewDisplayList().paintList(); | 147 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2, |
126 EXPECT_EQ((size_t)2, firstList.size()); | 148 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
127 EXPECT_EQ(first, firstList[0]->renderer()); | 149 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground)); |
128 EXPECT_EQ(second, firstList[1]->renderer()); | |
129 | 150 |
130 renderView()->viewDisplayList().invalidate(third); | 151 renderView()->viewDisplayList().invalidate(third); |
131 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); | 152 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); |
132 drawRect(context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200, 50)); | 153 drawRect(context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200, 50)); |
133 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); | 154 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); |
134 | 155 |
135 const PaintList& secondList = renderView()->viewDisplayList().paintList(); | 156 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3, |
136 EXPECT_EQ((size_t)3, secondList.size()); | 157 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
137 EXPECT_EQ(first, secondList[0]->renderer()); | 158 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground), |
138 EXPECT_EQ(third, secondList[1]->renderer()); | 159 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground)); |
139 EXPECT_EQ(second, secondList[2]->renderer()); | |
140 } | 160 } |
141 | 161 |
142 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases) | 162 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases) |
143 { | 163 { |
144 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir d'></div>"); | 164 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir d'></div>"); |
145 RenderObject* first = document().body()->firstChild()->renderer(); | 165 RenderObject* first = document().body()->firstChild()->renderer(); |
146 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); | 166 RenderObject* second = document().body()->firstChild()->firstChild()->render er(); |
147 RenderObject* third = document().body()->firstChild()->nextSibling()->render er(); | 167 RenderObject* third = document().body()->firstChild()->nextSibling()->render er(); |
148 GraphicsContext* context = new GraphicsContext(nullptr); | 168 GraphicsContext* context = new GraphicsContext(nullptr); |
149 | 169 |
150 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); | 170 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); |
151 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); | 171 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); |
152 drawRect(context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50, 50)); | 172 drawRect(context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50, 50)); |
153 drawRect(context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100) ); | 173 drawRect(context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100) ); |
154 drawRect(context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200) ); | 174 drawRect(context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200) ); |
155 drawRect(context, third, PaintPhaseForeground, FloatRect(300, 100, 50, 50)); | 175 drawRect(context, third, PaintPhaseForeground, FloatRect(300, 100, 50, 50)); |
156 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100)); | 176 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100)); |
157 drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200)); | 177 drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200)); |
158 drawRect(context, third, PaintPhaseOutline, FloatRect(300, 100, 50, 50)); | 178 drawRect(context, third, PaintPhaseOutline, FloatRect(300, 100, 50, 50)); |
159 | 179 |
160 const PaintList& firstList = renderView()->viewDisplayList().paintList(); | 180 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 9, |
161 EXPECT_EQ((size_t)9, firstList.size()); | 181 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
162 for (int item = 0; item < 9; item += 3) { | 182 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), |
163 EXPECT_EQ(first, firstList[item % 3 + 0]->renderer()); | 183 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground), |
164 EXPECT_EQ(second, firstList[item % 3 + 1]->renderer()); | 184 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground), |
165 EXPECT_EQ(third, firstList[item % 3 + 2]->renderer()); | 185 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseForeground), |
166 } | 186 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground), |
187 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline), | |
188 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline), | |
189 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline)); | |
167 | 190 |
168 renderView()->viewDisplayList().invalidate(second); | 191 renderView()->viewDisplayList().invalidate(second); |
169 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); | 192 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); |
170 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); | 193 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); |
171 drawRect(context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100) ); | 194 drawRect(context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100) ); |
172 drawRect(context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200) ); | 195 drawRect(context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200) ); |
173 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100)); | 196 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100)); |
174 drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200)); | 197 drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200)); |
175 | 198 |
176 const PaintList& secondList = renderView()->viewDisplayList().paintList(); | 199 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 9, |
177 EXPECT_EQ((size_t)9, secondList.size()); | 200 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
178 for (int item = 0; item < 9; item += 3) { | 201 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), |
179 EXPECT_EQ(first, secondList[item % 3 + 0]->renderer()); | 202 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground), |
180 EXPECT_EQ(second, secondList[item % 3 + 1]->renderer()); | 203 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground), |
181 EXPECT_EQ(third, secondList[item % 3 + 2]->renderer()); | 204 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseForeground), |
182 } | 205 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground), |
206 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline), | |
207 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline), | |
208 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline)); | |
183 | 209 |
184 renderView()->viewDisplayList().invalidate(second); | 210 renderView()->viewDisplayList().invalidate(second); |
185 const PaintList& thirdList = renderView()->viewDisplayList().paintList(); | 211 |
186 EXPECT_EQ((size_t)6, thirdList.size()); | 212 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 6, |
187 for (int item = 0; item < 6; item += 2) { | 213 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
188 EXPECT_EQ(first, thirdList[item % 2 + 0]->renderer()); | 214 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground), |
189 EXPECT_EQ(third, thirdList[item % 2 + 1]->renderer()); | 215 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground), |
190 } | 216 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground), |
217 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline), | |
218 TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline)); | |
191 } | 219 } |
192 | 220 |
193 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap) | 221 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap) |
194 { | 222 { |
195 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); | 223 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); |
196 RenderObject* first = document().body()->firstChild()->renderer(); | 224 RenderObject* first = document().body()->firstChild()->renderer(); |
197 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); | 225 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); |
198 GraphicsContext* context = new GraphicsContext(nullptr); | 226 GraphicsContext* context = new GraphicsContext(nullptr); |
199 | 227 |
200 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); | 228 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); |
201 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); | 229 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); |
202 | 230 |
203 const PaintList& firstList = renderView()->viewDisplayList().paintList(); | 231 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2, |
204 EXPECT_EQ((size_t)2, firstList.size()); | 232 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), |
205 EXPECT_EQ(second, firstList[0]->renderer()); | 233 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); |
206 EXPECT_EQ(second, firstList[1]->renderer()); | |
207 | 234 |
208 renderView()->viewDisplayList().invalidate(first); | 235 renderView()->viewDisplayList().invalidate(first); |
209 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50)); | 236 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50)); |
210 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50)); | 237 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50)); |
211 | 238 |
212 const PaintList& secondList = renderView()->viewDisplayList().paintList(); | 239 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4, |
213 EXPECT_EQ((size_t)4, secondList.size()); | 240 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
214 EXPECT_EQ(first, secondList[0]->renderer()); | 241 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline), |
215 EXPECT_EQ(first, secondList[1]->renderer()); | 242 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), |
216 EXPECT_EQ(second, secondList[2]->renderer()); | 243 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); |
217 EXPECT_EQ(second, secondList[3]->renderer()); | |
218 | 244 |
219 renderView()->viewDisplayList().invalidate(first); | 245 renderView()->viewDisplayList().invalidate(first); |
220 const PaintList& thirdList = renderView()->viewDisplayList().paintList(); | 246 |
221 EXPECT_EQ((size_t)2, thirdList.size()); | 247 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2, |
222 EXPECT_EQ(second, thirdList[0]->renderer()); | 248 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), |
223 EXPECT_EQ(second, thirdList[1]->renderer()); | 249 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); |
224 } | 250 } |
225 | 251 |
226 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap) | 252 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap) |
227 { | 253 { |
228 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); | 254 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); |
229 RenderObject* first = document().body()->firstChild()->renderer(); | 255 RenderObject* first = document().body()->firstChild()->renderer(); |
230 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); | 256 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); |
231 GraphicsContext* context = new GraphicsContext(nullptr); | 257 GraphicsContext* context = new GraphicsContext(nullptr); |
232 | 258 |
233 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); | 259 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); |
234 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); | 260 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); |
235 | 261 |
236 const PaintList& firstList = renderView()->viewDisplayList().paintList(); | 262 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2, |
237 EXPECT_EQ((size_t)2, firstList.size()); | 263 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), |
238 EXPECT_EQ(second, firstList[0]->renderer()); | 264 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); |
239 EXPECT_EQ(second, firstList[1]->renderer()); | |
240 | 265 |
241 renderView()->viewDisplayList().invalidate(first); | 266 renderView()->viewDisplayList().invalidate(first); |
242 renderView()->viewDisplayList().invalidate(second); | 267 renderView()->viewDisplayList().invalidate(second); |
243 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); | 268 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); |
244 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); | 269 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); |
245 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); | 270 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); |
246 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); | 271 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); |
247 | 272 |
248 const PaintList& secondList = renderView()->viewDisplayList().paintList(); | 273 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4, |
249 EXPECT_EQ((size_t)4, secondList.size()); | 274 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
250 EXPECT_EQ(first, secondList[0]->renderer()); | 275 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline), |
251 EXPECT_EQ(first, secondList[1]->renderer()); | 276 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), |
252 EXPECT_EQ(second, secondList[2]->renderer()); | 277 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); |
253 EXPECT_EQ(second, secondList[3]->renderer()); | |
254 | 278 |
255 renderView()->viewDisplayList().invalidate(first); | 279 renderView()->viewDisplayList().invalidate(first); |
256 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); | 280 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); |
257 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); | 281 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); |
258 | 282 |
259 const PaintList& thirdList = renderView()->viewDisplayList().paintList(); | 283 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2, |
260 EXPECT_EQ((size_t)2, thirdList.size()); | 284 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), |
261 EXPECT_EQ(second, thirdList[0]->renderer()); | 285 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); |
262 EXPECT_EQ(second, thirdList[1]->renderer()); | |
263 } | 286 } |
264 | 287 |
265 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap) | 288 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap) |
266 { | 289 { |
267 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); | 290 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); |
268 RenderObject* first = document().body()->firstChild()->renderer(); | 291 RenderObject* first = document().body()->firstChild()->renderer(); |
269 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); | 292 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); |
270 GraphicsContext* context = new GraphicsContext(nullptr); | 293 GraphicsContext* context = new GraphicsContext(nullptr); |
271 | 294 |
272 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50)); | 295 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50)); |
273 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50)); | 296 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50)); |
274 | 297 |
275 const PaintList& firstList = renderView()->viewDisplayList().paintList(); | 298 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2, |
276 EXPECT_EQ((size_t)2, firstList.size()); | 299 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
277 EXPECT_EQ(first, firstList[0]->renderer()); | 300 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); |
278 EXPECT_EQ(first, firstList[1]->renderer()); | |
279 | 301 |
280 renderView()->viewDisplayList().invalidate(second); | 302 renderView()->viewDisplayList().invalidate(second); |
281 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); | 303 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); |
282 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); | 304 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); |
283 | 305 |
284 const PaintList& secondList = renderView()->viewDisplayList().paintList(); | 306 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4, |
285 EXPECT_EQ((size_t)4, secondList.size()); | 307 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), |
286 EXPECT_EQ(second, secondList[0]->renderer()); | 308 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline), |
287 EXPECT_EQ(second, secondList[1]->renderer()); | 309 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
288 EXPECT_EQ(first, secondList[2]->renderer()); | 310 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); |
289 EXPECT_EQ(first, secondList[3]->renderer()); | |
290 | 311 |
291 renderView()->viewDisplayList().invalidate(second); | 312 renderView()->viewDisplayList().invalidate(second); |
292 const PaintList& thirdList = renderView()->viewDisplayList().paintList(); | 313 |
293 EXPECT_EQ((size_t)2, thirdList.size()); | 314 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2, |
294 EXPECT_EQ(first, thirdList[0]->renderer()); | 315 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
295 EXPECT_EQ(first, thirdList[1]->renderer()); | 316 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); |
296 } | 317 } |
297 | 318 |
298 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap) | 319 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap) |
299 { | 320 { |
300 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); | 321 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); |
301 RenderObject* first = document().body()->firstChild()->renderer(); | 322 RenderObject* first = document().body()->firstChild()->renderer(); |
302 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); | 323 RenderObject* second = document().body()->firstChild()->nextSibling()->rende rer(); |
303 GraphicsContext* context = new GraphicsContext(nullptr); | 324 GraphicsContext* context = new GraphicsContext(nullptr); |
304 | 325 |
305 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); | 326 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); |
306 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); | 327 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); |
307 | 328 |
308 const PaintList& firstList = renderView()->viewDisplayList().paintList(); | 329 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2, |
309 EXPECT_EQ((size_t)2, firstList.size()); | 330 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
310 EXPECT_EQ(first, firstList[0]->renderer()); | 331 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); |
311 EXPECT_EQ(first, firstList[1]->renderer()); | |
312 | 332 |
313 renderView()->viewDisplayList().invalidate(first); | 333 renderView()->viewDisplayList().invalidate(first); |
314 renderView()->viewDisplayList().invalidate(second); | 334 renderView()->viewDisplayList().invalidate(second); |
315 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); | 335 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); |
316 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); | 336 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); |
317 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); | 337 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); |
318 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); | 338 drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); |
319 | 339 |
320 const PaintList& secondList = renderView()->viewDisplayList().paintList(); | 340 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4, |
321 EXPECT_EQ((size_t)4, secondList.size()); | 341 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
322 EXPECT_EQ(first, secondList[0]->renderer()); | 342 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline), |
323 EXPECT_EQ(first, secondList[1]->renderer()); | 343 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground), |
324 EXPECT_EQ(second, secondList[2]->renderer()); | 344 TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline)); |
325 EXPECT_EQ(second, secondList[3]->renderer()); | |
326 | 345 |
327 renderView()->viewDisplayList().invalidate(first); | 346 renderView()->viewDisplayList().invalidate(first); |
328 renderView()->viewDisplayList().invalidate(second); | 347 renderView()->viewDisplayList().invalidate(second); |
329 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); | 348 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); |
330 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); | 349 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); |
331 | 350 |
332 const PaintList& thirdList = renderView()->viewDisplayList().paintList(); | 351 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2, |
333 EXPECT_EQ((size_t)2, thirdList.size()); | 352 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground), |
334 EXPECT_EQ(first, thirdList[0]->renderer()); | 353 TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline)); |
335 EXPECT_EQ(first, thirdList[1]->renderer()); | 354 } |
355 | |
356 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip) | |
357 { | |
358 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); | |
359 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer()); | |
360 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer()); | |
361 GraphicsContext* context = new GraphicsContext(nullptr); | |
362 | |
363 ClipRect firstClipRect(IntRect(1, 1, 2, 2)); | |
364 { | |
365 ClipRecorder clipRecorder(firstRenderer, context, DisplayItem::ClipLayer Foreground, firstClipRect); | |
366 drawRect(context, firstRenderer, PaintPhaseBlockBackground, FloatRect(10 0, 100, 150, 150)); | |
367 drawRect(context, secondRenderer, PaintPhaseBlockBackground, FloatRect(1 00, 100, 150, 150)); | |
368 } | |
369 | |
370 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4, | |
371 TestDisplayItem(firstRenderer, DisplayItem::ClipLayerForeground), | |
372 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound), | |
373 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round), | |
374 TestDisplayItem(firstRenderer, DisplayItem::EndClip)); | |
375 | |
376 renderView()->viewDisplayList().invalidate(firstRenderer); | |
377 drawRect(context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 1 00, 150, 150)); | |
378 drawRect(context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); | |
379 | |
380 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2, | |
381 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound), | |
382 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round)); | |
383 | |
384 renderView()->viewDisplayList().invalidate(secondRenderer); | |
385 drawRect(context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 1 00, 150, 150)); | |
386 ClipRect secondClipRect(IntRect(1, 1, 2, 2)); | |
387 { | |
388 ClipRecorder clipRecorder(secondRenderer, context, DisplayItem::ClipLaye rForeground, secondClipRect); | |
389 drawRect(context, secondRenderer, PaintPhaseBlockBackground, FloatRect(1 00, 100, 150, 150)); | |
390 } | |
391 | |
392 EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4, | |
393 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound), | |
394 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground), | |
395 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round), | |
396 TestDisplayItem(secondRenderer, DisplayItem::EndClip)); | |
336 } | 397 } |
337 | 398 |
338 } | 399 } |
339 | 400 |
340 } | 401 } |
OLD | NEW |