| 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 | 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/paint/LayerClipRecorder.h" | 9 #include "core/paint/LayerClipRecorder.h" |
| 10 #include "core/paint/LayerPainter.h" | 10 #include "core/paint/LayerPainter.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 { | 45 { |
| 46 RuntimeEnabledFeatures::setSlimmingPaintEnabled(false); | 46 RuntimeEnabledFeatures::setSlimmingPaintEnabled(false); |
| 47 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(false); | 47 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(false); |
| 48 } | 48 } |
| 49 | 49 |
| 50 RenderView* m_renderView; | 50 RenderView* m_renderView; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 class TestDisplayItem : public DisplayItem { | 53 class TestDisplayItem : public DisplayItem { |
| 54 public: | 54 public: |
| 55 TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(rende
rer->displayItemClient(), type) { } | 55 TestDisplayItem(const LayoutObject* renderer, Type type) : DisplayItem(rende
rer->displayItemClient(), type) { } |
| 56 TestDisplayItem(DisplayItemClient displayItemClient, Type type) : DisplayIte
m(displayItemClient, type) { } | 56 TestDisplayItem(DisplayItemClient displayItemClient, Type type) : DisplayIte
m(displayItemClient, type) { } |
| 57 | 57 |
| 58 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED();
} | 58 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED();
} |
| 59 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override
final { ASSERT_NOT_REACHED(); } | 59 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override
final { ASSERT_NOT_REACHED(); } |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 #ifndef NDEBUG | 62 #ifndef NDEBUG |
| 63 #define TRACE_DISPLAY_ITEMS(expected, actual) \ | 63 #define TRACE_DISPLAY_ITEMS(expected, actual) \ |
| 64 String trace = "Expected: " + (expected).asDebugString() + " Actual: " + (ac
tual).asDebugString(); \ | 64 String trace = "Expected: " + (expected).asDebugString() + " Actual: " + (ac
tual).asDebugString(); \ |
| 65 SCOPED_TRACE(trace.utf8().data()); | 65 SCOPED_TRACE(trace.utf8().data()); |
| 66 #else | 66 #else |
| 67 #define TRACE_DISPLAY_ITEMS(expected, actual) | 67 #define TRACE_DISPLAY_ITEMS(expected, actual) |
| 68 #endif | 68 #endif |
| 69 | 69 |
| 70 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \ | 70 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \ |
| 71 EXPECT_EQ((size_t)expectedSize, actual.size()); \ | 71 EXPECT_EQ((size_t)expectedSize, actual.size()); \ |
| 72 const TestDisplayItem expected[] = { __VA_ARGS__ }; \ | 72 const TestDisplayItem expected[] = { __VA_ARGS__ }; \ |
| 73 for (size_t index = 0; index < std::min<size_t>(actual.size(), expectedSize)
; index++) { \ | 73 for (size_t index = 0; index < std::min<size_t>(actual.size(), expectedSize)
; index++) { \ |
| 74 TRACE_DISPLAY_ITEMS(expected[index], *actual[index]); \ | 74 TRACE_DISPLAY_ITEMS(expected[index], *actual[index]); \ |
| 75 EXPECT_EQ(expected[index].client(), actual[index]->client()); \ | 75 EXPECT_EQ(expected[index].client(), actual[index]->client()); \ |
| 76 EXPECT_EQ(expected[index].type(), actual[index]->type()); \ | 76 EXPECT_EQ(expected[index].type(), actual[index]->type()); \ |
| 77 } \ | 77 } \ |
| 78 } | 78 } |
| 79 | 79 |
| 80 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase
, const FloatRect& bound) | 80 void drawRect(GraphicsContext* context, LayoutObject* renderer, PaintPhase phase
, const FloatRect& bound) |
| 81 { | 81 { |
| 82 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); | 82 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); |
| 83 if (drawingRecorder.canUseCachedDrawing()) | 83 if (drawingRecorder.canUseCachedDrawing()) |
| 84 return; | 84 return; |
| 85 IntRect rect(0, 0, 10, 10); | 85 IntRect rect(0, 0, 10, 10); |
| 86 context->drawRect(rect); | 86 context->drawRect(rect); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void drawClippedRect(GraphicsContext* context, LayoutLayerModelObject* renderer,
PaintPhase phase, const FloatRect& bound) | 89 void drawClippedRect(GraphicsContext* context, LayoutLayerModelObject* renderer,
PaintPhase phase, const FloatRect& bound) |
| 90 { | 90 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 104 | 104 |
| 105 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 105 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
| 106 TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground), | 106 TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground), |
| 107 TestDisplayItem(renderView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground)), | 107 TestDisplayItem(renderView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground)), |
| 108 TestDisplayItem(renderView(), DisplayItem::clipTypeToEndClipType(Display
Item::ClipLayerForeground))); | 108 TestDisplayItem(renderView(), DisplayItem::clipTypeToEndClipType(Display
Item::ClipLayerForeground))); |
| 109 } | 109 } |
| 110 | 110 |
| 111 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic) | 111 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic) |
| 112 { | 112 { |
| 113 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); | 113 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); |
| 114 RenderObject* first = document().body()->firstChild()->renderer(); | 114 LayoutObject* first = document().body()->firstChild()->renderer(); |
| 115 RenderObject* second = document().body()->firstChild()->firstChild()->render
er(); | 115 LayoutObject* second = document().body()->firstChild()->firstChild()->render
er(); |
| 116 GraphicsContext context(nullptr, &rootDisplayItemList()); | 116 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 117 | 117 |
| 118 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300
, 300)); | 118 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300
, 300)); |
| 119 drawRect(&context, second, PaintPhaseChildBlockBackground, FloatRect(100, 10
0, 200, 200)); | 119 drawRect(&context, second, PaintPhaseChildBlockBackground, FloatRect(100, 10
0, 200, 200)); |
| 120 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); | 120 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); |
| 121 rootDisplayItemList().endNewPaints(); | 121 rootDisplayItemList().endNewPaints(); |
| 122 | 122 |
| 123 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 123 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
| 124 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 124 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 125 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseC
hildBlockBackground)), | 125 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseC
hildBlockBackground)), |
| 126 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 126 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); |
| 127 | 127 |
| 128 rootDisplayItemList().invalidate(second->displayItemClient()); | 128 rootDisplayItemList().invalidate(second->displayItemClient()); |
| 129 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300
, 300)); | 129 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300
, 300)); |
| 130 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); | 130 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); |
| 131 rootDisplayItemList().endNewPaints(); | 131 rootDisplayItemList().endNewPaints(); |
| 132 | 132 |
| 133 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 133 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 134 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 134 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 135 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 135 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); |
| 136 } | 136 } |
| 137 | 137 |
| 138 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder) | 138 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder) |
| 139 { | 139 { |
| 140 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaf
fected'></div>"); | 140 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaf
fected'></div>"); |
| 141 RenderObject* first = document().body()->firstChild()->renderer(); | 141 LayoutObject* first = document().body()->firstChild()->renderer(); |
| 142 RenderObject* second = document().body()->firstChild()->firstChild()->render
er(); | 142 LayoutObject* second = document().body()->firstChild()->firstChild()->render
er(); |
| 143 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r
enderer(); | 143 LayoutObject* unaffected = document().body()->firstChild()->nextSibling()->r
enderer(); |
| 144 GraphicsContext context(nullptr, &rootDisplayItemList()); | 144 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 145 | 145 |
| 146 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); | 146 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); |
| 147 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); | 147 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); |
| 148 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300
, 10, 10)); | 148 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300
, 10, 10)); |
| 149 rootDisplayItemList().endNewPaints(); | 149 rootDisplayItemList().endNewPaints(); |
| 150 | 150 |
| 151 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 151 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
| 152 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 152 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 153 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), | 153 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), |
| 154 TestDisplayItem(unaffected, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground))); | 154 TestDisplayItem(unaffected, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground))); |
| 155 | 155 |
| 156 rootDisplayItemList().invalidate(second->displayItemClient()); | 156 rootDisplayItemList().invalidate(second->displayItemClient()); |
| 157 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); | 157 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); |
| 158 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); | 158 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); |
| 159 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300
, 10, 10)); | 159 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300
, 10, 10)); |
| 160 rootDisplayItemList().endNewPaints(); | 160 rootDisplayItemList().endNewPaints(); |
| 161 | 161 |
| 162 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 162 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
| 163 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), | 163 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), |
| 164 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 164 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 165 TestDisplayItem(unaffected, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground))); | 165 TestDisplayItem(unaffected, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground))); |
| 166 } | 166 } |
| 167 | 167 |
| 168 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle) | 168 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle) |
| 169 { | 169 { |
| 170 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d
iv></div>"); | 170 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d
iv></div>"); |
| 171 RenderObject* first = document().body()->firstChild()->renderer(); | 171 LayoutObject* first = document().body()->firstChild()->renderer(); |
| 172 RenderObject* second = document().body()->firstChild()->firstChild()->render
er(); | 172 LayoutObject* second = document().body()->firstChild()->firstChild()->render
er(); |
| 173 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh
ild()->renderer(); | 173 LayoutObject* third = document().body()->firstChild()->firstChild()->firstCh
ild()->renderer(); |
| 174 GraphicsContext context(nullptr, &rootDisplayItemList()); | 174 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 175 | 175 |
| 176 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); | 176 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); |
| 177 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); | 177 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); |
| 178 rootDisplayItemList().endNewPaints(); | 178 rootDisplayItemList().endNewPaints(); |
| 179 | 179 |
| 180 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 180 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 181 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 181 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 182 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground))); | 182 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground))); |
| 183 | 183 |
| 184 rootDisplayItemList().invalidate(third->displayItemClient()); | 184 rootDisplayItemList().invalidate(third->displayItemClient()); |
| 185 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); | 185 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); |
| 186 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200
, 50)); | 186 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200
, 50)); |
| 187 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); | 187 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); |
| 188 rootDisplayItemList().endNewPaints(); | 188 rootDisplayItemList().endNewPaints(); |
| 189 | 189 |
| 190 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 190 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
| 191 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 191 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 192 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 192 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 193 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground))); | 193 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground))); |
| 194 } | 194 } |
| 195 | 195 |
| 196 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases) | 196 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases) |
| 197 { | 197 { |
| 198 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir
d'></div>"); | 198 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir
d'></div>"); |
| 199 RenderObject* first = document().body()->firstChild()->renderer(); | 199 LayoutObject* first = document().body()->firstChild()->renderer(); |
| 200 RenderObject* second = document().body()->firstChild()->firstChild()->render
er(); | 200 LayoutObject* second = document().body()->firstChild()->firstChild()->render
er(); |
| 201 RenderObject* third = document().body()->firstChild()->nextSibling()->render
er(); | 201 LayoutObject* third = document().body()->firstChild()->nextSibling()->render
er(); |
| 202 GraphicsContext context(nullptr, &rootDisplayItemList()); | 202 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 203 | 203 |
| 204 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); | 204 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); |
| 205 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); | 205 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); |
| 206 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50,
50)); | 206 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50,
50)); |
| 207 drawRect(&context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100
)); | 207 drawRect(&context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100
)); |
| 208 drawRect(&context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200
)); | 208 drawRect(&context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200
)); |
| 209 drawRect(&context, third, PaintPhaseForeground, FloatRect(300, 100, 50, 50))
; | 209 drawRect(&context, third, PaintPhaseForeground, FloatRect(300, 100, 50, 50))
; |
| 210 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100)); | 210 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100)); |
| 211 drawRect(&context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200)); | 211 drawRect(&context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseFo
reground)), | 257 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseFo
reground)), |
| 258 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline)), | 258 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline)), |
| 259 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 259 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); |
| 260 #endif | 260 #endif |
| 261 } | 261 } |
| 262 | 262 |
| 263 // This test is only applicable when we support incremental paint. | 263 // This test is only applicable when we support incremental paint. |
| 264 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstNoOverlap
) | 264 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstNoOverlap
) |
| 265 { | 265 { |
| 266 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); | 266 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); |
| 267 RenderObject* first = document().body()->firstChild()->renderer(); | 267 LayoutObject* first = document().body()->firstChild()->renderer(); |
| 268 RenderObject* second = document().body()->firstChild()->nextSibling()->rende
rer(); | 268 LayoutObject* second = document().body()->firstChild()->nextSibling()->rende
rer(); |
| 269 GraphicsContext context(nullptr, &rootDisplayItemList()); | 269 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 270 | 270 |
| 271 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50
, 50)); | 271 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50
, 50)); |
| 272 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); | 272 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); |
| 273 | 273 |
| 274 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 274 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 275 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), | 275 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), |
| 276 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); | 276 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); |
| 277 | 277 |
| 278 rootDisplayItemList().invalidate(first->displayItemClient()); | 278 rootDisplayItemList().invalidate(first->displayItemClient()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 289 | 289 |
| 290 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 290 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 291 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), | 291 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), |
| 292 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); | 292 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); |
| 293 } | 293 } |
| 294 | 294 |
| 295 // This test is only applicable when we support incremental paint. | 295 // This test is only applicable when we support incremental paint. |
| 296 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstOverlap) | 296 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstOverlap) |
| 297 { | 297 { |
| 298 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); | 298 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); |
| 299 RenderObject* first = document().body()->firstChild()->renderer(); | 299 LayoutObject* first = document().body()->firstChild()->renderer(); |
| 300 RenderObject* second = document().body()->firstChild()->nextSibling()->rende
rer(); | 300 LayoutObject* second = document().body()->firstChild()->nextSibling()->rende
rer(); |
| 301 GraphicsContext context(nullptr, &rootDisplayItemList()); | 301 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 302 | 302 |
| 303 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50
, 50)); | 303 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50
, 50)); |
| 304 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); | 304 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); |
| 305 | 305 |
| 306 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 306 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 307 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), | 307 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), |
| 308 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); | 308 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); |
| 309 | 309 |
| 310 rootDisplayItemList().invalidate(first->displayItemClient()); | 310 rootDisplayItemList().invalidate(first->displayItemClient()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 326 | 326 |
| 327 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 327 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 328 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), | 328 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), |
| 329 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); | 329 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); |
| 330 } | 330 } |
| 331 | 331 |
| 332 // This test is only applicable when we support incremental paint. | 332 // This test is only applicable when we support incremental paint. |
| 333 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastNoOverlap) | 333 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastNoOverlap) |
| 334 { | 334 { |
| 335 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); | 335 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); |
| 336 RenderObject* first = document().body()->firstChild()->renderer(); | 336 LayoutObject* first = document().body()->firstChild()->renderer(); |
| 337 RenderObject* second = document().body()->firstChild()->nextSibling()->rende
rer(); | 337 LayoutObject* second = document().body()->firstChild()->nextSibling()->rende
rer(); |
| 338 GraphicsContext context(nullptr, &rootDisplayItemList()); | 338 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 339 | 339 |
| 340 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50,
50)); | 340 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50,
50)); |
| 341 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50)); | 341 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50)); |
| 342 | 342 |
| 343 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 343 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 344 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 344 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 345 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 345 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); |
| 346 | 346 |
| 347 rootDisplayItemList().invalidate(second->displayItemClient()); | 347 rootDisplayItemList().invalidate(second->displayItemClient()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 358 | 358 |
| 359 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 359 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 360 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 360 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 361 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 361 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); |
| 362 } | 362 } |
| 363 | 363 |
| 364 // This test is only applicable when we support incremental paint. | 364 // This test is only applicable when we support incremental paint. |
| 365 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastOverlap) | 365 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastOverlap) |
| 366 { | 366 { |
| 367 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); | 367 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); |
| 368 RenderObject* first = document().body()->firstChild()->renderer(); | 368 LayoutObject* first = document().body()->firstChild()->renderer(); |
| 369 RenderObject* second = document().body()->firstChild()->nextSibling()->rende
rer(); | 369 LayoutObject* second = document().body()->firstChild()->nextSibling()->rende
rer(); |
| 370 GraphicsContext context(nullptr, &rootDisplayItemList()); | 370 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 371 | 371 |
| 372 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150
, 150)); | 372 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150
, 150)); |
| 373 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); | 373 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); |
| 374 | 374 |
| 375 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 375 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 376 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 376 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 377 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 377 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); |
| 378 | 378 |
| 379 rootDisplayItemList().invalidate(first->displayItemClient()); | 379 rootDisplayItemList().invalidate(first->displayItemClient()); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 rootDisplayItemList().invalidateAll(); | 487 rootDisplayItemList().invalidateAll(); |
| 488 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display
ItemClient())); | 488 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display
ItemClient())); |
| 489 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa
yItemClient())); | 489 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa
yItemClient())); |
| 490 } | 490 } |
| 491 | 491 |
| 492 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret) | 492 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret) |
| 493 { | 493 { |
| 494 setBodyInnerHTML("<div id='div' contentEditable='true'>XYZ</div>"); | 494 setBodyInnerHTML("<div id='div' contentEditable='true'>XYZ</div>"); |
| 495 RenderView* renderView = document().renderView(); | 495 RenderView* renderView = document().renderView(); |
| 496 Layer* rootLayer = renderView->layer(); | 496 Layer* rootLayer = renderView->layer(); |
| 497 RenderObject* htmlRenderer = document().documentElement()->renderer(); | 497 LayoutObject* htmlRenderer = document().documentElement()->renderer(); |
| 498 Element* div = toElement(document().body()->firstChild()); | 498 Element* div = toElement(document().body()->firstChild()); |
| 499 RenderObject* divRenderer = document().body()->firstChild()->renderer(); | 499 LayoutObject* divRenderer = document().body()->firstChild()->renderer(); |
| 500 InlineTextBox* textInlineBox = toRenderText(div->firstChild()->renderer())->
firstTextBox(); | 500 InlineTextBox* textInlineBox = toRenderText(div->firstChild()->renderer())->
firstTextBox(); |
| 501 | 501 |
| 502 SkCanvas canvas(800, 600); | 502 SkCanvas canvas(800, 600); |
| 503 GraphicsContext context(&canvas, &rootDisplayItemList()); | 503 GraphicsContext context(&canvas, &rootDisplayItemList()); |
| 504 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB
ehaviorNormal, LayoutSize()); | 504 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB
ehaviorNormal, LayoutSize()); |
| 505 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); | 505 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); |
| 506 rootDisplayItemList().endNewPaints(); | 506 rootDisplayItemList().endNewPaints(); |
| 507 | 507 |
| 508 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 508 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 509 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), | 509 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), |
| 510 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh
aseToDrawingType(PaintPhaseForeground))); | 510 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh
aseToDrawingType(PaintPhaseForeground))); |
| 511 | 511 |
| 512 div->focus(); | 512 div->focus(); |
| 513 document().view()->updateLayoutAndStyleForPainting(); | 513 document().view()->updateLayoutAndStyleForPainting(); |
| 514 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); | 514 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); |
| 515 rootDisplayItemList().endNewPaints(); | 515 rootDisplayItemList().endNewPaints(); |
| 516 | 516 |
| 517 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 517 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
| 518 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), | 518 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), |
| 519 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh
aseToDrawingType(PaintPhaseForeground)), | 519 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh
aseToDrawingType(PaintPhaseForeground)), |
| 520 TestDisplayItem(divRenderer, DisplayItem::Caret)); | 520 TestDisplayItem(divRenderer, DisplayItem::Caret)); |
| 521 } | 521 } |
| 522 | 522 |
| 523 } // anonymous namespace | 523 } // anonymous namespace |
| 524 } // namespace blink | 524 } // namespace blink |
| OLD | NEW |