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

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

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

Powered by Google App Engine
This is Rietveld 408576698