| 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/page/FocusController.h" |
| 8 #include "core/paint/LayerClipRecorder.h" | 9 #include "core/paint/LayerClipRecorder.h" |
| 9 #include "core/paint/LayerPainter.h" | 10 #include "core/paint/LayerPainter.h" |
| 10 #include "core/paint/RenderDrawingRecorder.h" | 11 #include "core/paint/RenderDrawingRecorder.h" |
| 12 #include "core/paint/SubtreeInfoRecorder.h" |
| 11 #include "core/rendering/InlineTextBox.h" | 13 #include "core/rendering/InlineTextBox.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 Loading... |
| 53 class TestDisplayItem : public DisplayItem { | 55 class TestDisplayItem : public DisplayItem { |
| 54 public: | 56 public: |
| 55 TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(rende
rer->displayItemClient(), type) { } | 57 TestDisplayItem(const RenderObject* 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 |
| 72 #define EXPECT_DISPLAY_ITEM(i, expected, actual) \ |
| 73 do { \ |
| 74 TRACE_DISPLAY_ITEMS(i, expected, *actual[i]); \ |
| 75 EXPECT_EQ(expected.client(), actual[i]->client()); \ |
| 76 EXPECT_EQ(expected.type(), actual[i]->type()); \ |
| 77 } while (false) |
| 78 |
| 70 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \ | 79 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \ |
| 71 EXPECT_EQ((size_t)expectedSize, actual.size()); \ | 80 EXPECT_EQ((size_t)expectedSize, actual.size()); \ |
| 72 const TestDisplayItem expected[] = { __VA_ARGS__ }; \ | 81 const TestDisplayItem expected[] = { __VA_ARGS__ }; \ |
| 73 for (size_t index = 0; index < std::min<size_t>(actual.size(), expectedSize)
; index++) { \ | 82 for (size_t i = 0; i < std::min<size_t>(actual.size(), expectedSize); i++) \ |
| 74 TRACE_DISPLAY_ITEMS(expected[index], *actual[index]); \ | 83 EXPECT_DISPLAY_ITEM(i, expected[i], actual); \ |
| 75 EXPECT_EQ(expected[index].client(), actual[index]->client()); \ | |
| 76 EXPECT_EQ(expected[index].type(), actual[index]->type()); \ | |
| 77 } \ | |
| 78 } | 84 } |
| 79 | 85 |
| 80 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase
, const FloatRect& bound) | 86 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase
, const FloatRect& bound) |
| 81 { | 87 { |
| 82 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); | 88 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); |
| 83 if (drawingRecorder.canUseCachedDrawing()) | 89 if (drawingRecorder.canUseCachedDrawing()) |
| 84 return; | 90 return; |
| 85 IntRect rect(0, 0, 10, 10); | 91 IntRect rect(0, 0, 10, 10); |
| 86 context->drawRect(rect); | 92 context->drawRect(rect); |
| 87 } | 93 } |
| 88 | 94 |
| 89 void drawClippedRect(GraphicsContext* context, LayoutLayerModelObject* renderer,
PaintPhase phase, const FloatRect& bound) | 95 void drawClippedRect(GraphicsContext* context, LayoutLayerModelObject* renderer,
PaintPhase phase, const FloatRect& bound) |
| 90 { | 96 { |
| 91 IntRect rect(1, 1, 9, 9); | 97 IntRect rect(1, 1, 9, 9); |
| 92 ClipRect clipRect(rect); | 98 ClipRect clipRect(rect); |
| 93 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye
rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags()); | 99 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye
rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags()); |
| 94 drawRect(context, renderer, phase, bound); | 100 drawRect(context, renderer, phase, bound); |
| 95 } | 101 } |
| 96 | 102 |
| 97 TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders) | 103 TEST_F(ViewDisplayListTest, NestedRecorders) |
| 98 { | 104 { |
| 99 GraphicsContext context(nullptr, &rootDisplayItemList()); | 105 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 100 FloatRect bound = renderView()->viewRect(); | 106 FloatRect bound = renderView()->viewRect(); |
| 101 | 107 |
| 102 drawClippedRect(&context, renderView(), PaintPhaseForeground, bound); | 108 drawClippedRect(&context, renderView(), PaintPhaseForeground, bound); |
| 103 rootDisplayItemList().endNewPaints(); | 109 rootDisplayItemList().endNewPaints(); |
| 104 | 110 |
| 105 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 111 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
| 106 TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground), | 112 TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground), |
| 107 TestDisplayItem(renderView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground)), | 113 TestDisplayItem(renderView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground)), |
| 108 TestDisplayItem(renderView(), DisplayItem::clipTypeToEndClipType(Display
Item::ClipLayerForeground))); | 114 TestDisplayItem(renderView(), DisplayItem::clipTypeToEndClipType(Display
Item::ClipLayerForeground))); |
| 109 } | 115 } |
| 110 | 116 |
| 111 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic) | 117 TEST_F(ViewDisplayListTest, UpdateBasic) |
| 112 { | 118 { |
| 113 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); | 119 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); |
| 114 RenderObject* first = document().body()->firstChild()->renderer(); | 120 RenderObject* first = document().body()->firstChild()->renderer(); |
| 115 RenderObject* second = document().body()->firstChild()->firstChild()->render
er(); | 121 RenderObject* second = document().body()->firstChild()->firstChild()->render
er(); |
| 116 GraphicsContext context(nullptr, &rootDisplayItemList()); | 122 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 117 | 123 |
| 118 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300
, 300)); | 124 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300
, 300)); |
| 119 drawRect(&context, second, PaintPhaseChildBlockBackground, FloatRect(100, 10
0, 200, 200)); | 125 drawRect(&context, second, PaintPhaseChildBlockBackground, FloatRect(100, 10
0, 200, 200)); |
| 120 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); | 126 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); |
| 121 rootDisplayItemList().endNewPaints(); | 127 rootDisplayItemList().endNewPaints(); |
| 122 | 128 |
| 123 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 129 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
| 124 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 130 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 125 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseC
hildBlockBackground)), | 131 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseC
hildBlockBackground)), |
| 126 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 132 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); |
| 127 | 133 |
| 128 rootDisplayItemList().invalidate(second->displayItemClient()); | 134 rootDisplayItemList().invalidate(second->displayItemClient()); |
| 129 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300
, 300)); | 135 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300
, 300)); |
| 130 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); | 136 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); |
| 131 rootDisplayItemList().endNewPaints(); | 137 rootDisplayItemList().endNewPaints(); |
| 132 | 138 |
| 133 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 139 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 134 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 140 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 135 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 141 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); |
| 136 } | 142 } |
| 137 | 143 |
| 138 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder) | 144 TEST_F(ViewDisplayListTest, UpdateSwapOrder) |
| 139 { | 145 { |
| 140 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaf
fected'></div>"); | 146 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaf
fected'></div>"); |
| 141 RenderObject* first = document().body()->firstChild()->renderer(); | 147 RenderObject* first = document().body()->firstChild()->renderer(); |
| 142 RenderObject* second = document().body()->firstChild()->firstChild()->render
er(); | 148 RenderObject* second = document().body()->firstChild()->firstChild()->render
er(); |
| 143 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r
enderer(); | 149 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r
enderer(); |
| 144 GraphicsContext context(nullptr, &rootDisplayItemList()); | 150 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 145 | 151 |
| 146 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); | 152 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); |
| 147 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); | 153 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); |
| 148 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300
, 10, 10)); | 154 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300
, 10, 10)); |
| 149 rootDisplayItemList().endNewPaints(); | 155 rootDisplayItemList().endNewPaints(); |
| 150 | 156 |
| 151 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 157 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
| 152 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 158 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 153 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), | 159 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), |
| 154 TestDisplayItem(unaffected, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground))); | 160 TestDisplayItem(unaffected, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground))); |
| 155 | 161 |
| 156 rootDisplayItemList().invalidate(second->displayItemClient()); | 162 rootDisplayItemList().invalidate(second->displayItemClient()); |
| 157 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); | 163 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); |
| 158 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); | 164 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); |
| 159 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300
, 10, 10)); | 165 drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300
, 10, 10)); |
| 160 rootDisplayItemList().endNewPaints(); | 166 rootDisplayItemList().endNewPaints(); |
| 161 | 167 |
| 162 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 168 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
| 163 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), | 169 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), |
| 164 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 170 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 165 TestDisplayItem(unaffected, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground))); | 171 TestDisplayItem(unaffected, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground))); |
| 166 } | 172 } |
| 167 | 173 |
| 168 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle) | 174 TEST_F(ViewDisplayListTest, UpdateNewItemInMiddle) |
| 169 { | 175 { |
| 170 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d
iv></div>"); | 176 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d
iv></div>"); |
| 171 RenderObject* first = document().body()->firstChild()->renderer(); | 177 RenderObject* first = document().body()->firstChild()->renderer(); |
| 172 RenderObject* second = document().body()->firstChild()->firstChild()->render
er(); | 178 RenderObject* second = document().body()->firstChild()->firstChild()->render
er(); |
| 173 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh
ild()->renderer(); | 179 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh
ild()->renderer(); |
| 174 GraphicsContext context(nullptr, &rootDisplayItemList()); | 180 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 175 | 181 |
| 176 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); | 182 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); |
| 177 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); | 183 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); |
| 178 rootDisplayItemList().endNewPaints(); | 184 rootDisplayItemList().endNewPaints(); |
| 179 | 185 |
| 180 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 186 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 181 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 187 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 182 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground))); | 188 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground))); |
| 183 | 189 |
| 184 rootDisplayItemList().invalidate(third->displayItemClient()); | 190 rootDisplayItemList().invalidate(third->displayItemClient()); |
| 185 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); | 191 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); |
| 186 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200
, 50)); | 192 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200
, 50)); |
| 187 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); | 193 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); |
| 188 rootDisplayItemList().endNewPaints(); | 194 rootDisplayItemList().endNewPaints(); |
| 189 | 195 |
| 190 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 196 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
| 191 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 197 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 192 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 198 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 193 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground))); | 199 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground))); |
| 194 } | 200 } |
| 195 | 201 |
| 196 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases) | 202 TEST_F(ViewDisplayListTest, UpdateInvalidationWithPhases) |
| 197 { | 203 { |
| 198 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir
d'></div>"); | 204 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='thir
d'></div>"); |
| 199 RenderObject* first = document().body()->firstChild()->renderer(); | 205 RenderObject* first = document().body()->firstChild()->renderer(); |
| 200 RenderObject* second = document().body()->firstChild()->firstChild()->render
er(); | 206 RenderObject* second = document().body()->firstChild()->firstChild()->render
er(); |
| 201 RenderObject* third = document().body()->firstChild()->nextSibling()->render
er(); | 207 RenderObject* third = document().body()->firstChild()->nextSibling()->render
er(); |
| 202 GraphicsContext context(nullptr, &rootDisplayItemList()); | 208 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 203 | 209 |
| 204 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); | 210 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100
, 100)); |
| 205 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); | 211 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50
, 200)); |
| 206 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50,
50)); | 212 drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50,
50)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 9, | 244 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 9, |
| 239 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 245 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 240 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), | 246 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), |
| 241 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 247 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 242 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseFo
reground)), | 248 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseFo
reground)), |
| 243 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseF
oreground)), | 249 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseF
oreground)), |
| 244 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseFo
reground)), | 250 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseFo
reground)), |
| 245 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline)), | 251 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline)), |
| 246 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline)), | 252 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline)), |
| 247 TestDisplayItem(third, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 253 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 } | 254 } |
| 262 | 255 |
| 263 // This test is only applicable when we support incremental paint. | 256 TEST_F(ViewDisplayListTest, UpdateAddFirstOverlap) |
| 264 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstNoOverlap
) | |
| 265 { | 257 { |
| 266 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); | 258 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); |
| 267 RenderObject* first = document().body()->firstChild()->renderer(); | 259 RenderObject* first = document().body()->firstChild()->renderer(); |
| 268 RenderObject* 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 RenderObject* first = document().body()->firstChild()->renderer(); | |
| 300 RenderObject* second = document().body()->firstChild()->nextSibling()->rende
rer(); | 260 RenderObject* second = document().body()->firstChild()->nextSibling()->rende
rer(); |
| 301 GraphicsContext context(nullptr, &rootDisplayItemList()); | 261 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 302 | 262 |
| 303 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50
, 50)); | 263 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50
, 50)); |
| 304 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); | 264 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); |
| 265 rootDisplayItemList().endNewPaints(); |
| 305 | 266 |
| 306 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 267 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 307 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), | 268 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), |
| 308 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); | 269 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); |
| 309 | 270 |
| 310 rootDisplayItemList().invalidate(first->displayItemClient()); | 271 rootDisplayItemList().invalidate(first->displayItemClient()); |
| 311 rootDisplayItemList().invalidate(second->displayItemClient()); | 272 rootDisplayItemList().invalidate(second->displayItemClient()); |
| 312 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150
, 150)); | 273 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150
, 150)); |
| 313 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); | 274 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); |
| 314 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50
, 50)); | 275 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50
, 50)); |
| 315 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); | 276 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); |
| 277 rootDisplayItemList().endNewPaints(); |
| 316 | 278 |
| 317 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, | 279 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, |
| 318 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 280 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 319 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline)), | 281 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline)), |
| 320 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), | 282 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), |
| 321 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); | 283 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); |
| 322 | 284 |
| 323 rootDisplayItemList().invalidate(first->displayItemClient()); | 285 rootDisplayItemList().invalidate(first->displayItemClient()); |
| 324 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50
, 50)); | 286 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50
, 50)); |
| 325 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); | 287 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); |
| 288 rootDisplayItemList().endNewPaints(); |
| 326 | 289 |
| 327 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 290 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 328 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), | 291 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), |
| 329 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); | 292 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); |
| 330 } | 293 } |
| 331 | 294 |
| 332 // This test is only applicable when we support incremental paint. | 295 TEST_F(ViewDisplayListTest, UpdateAddLastOverlap) |
| 333 TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastNoOverlap) | |
| 334 { | 296 { |
| 335 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); | 297 setBodyInnerHTML("<div id='first'></div><div id='second'></div>"); |
| 336 RenderObject* first = document().body()->firstChild()->renderer(); | 298 RenderObject* first = document().body()->firstChild()->renderer(); |
| 337 RenderObject* 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 RenderObject* first = document().body()->firstChild()->renderer(); | |
| 369 RenderObject* second = document().body()->firstChild()->nextSibling()->rende
rer(); | 299 RenderObject* second = document().body()->firstChild()->nextSibling()->rende
rer(); |
| 370 GraphicsContext context(nullptr, &rootDisplayItemList()); | 300 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 371 | 301 |
| 372 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150
, 150)); | 302 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150
, 150)); |
| 373 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); | 303 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); |
| 304 rootDisplayItemList().endNewPaints(); |
| 374 | 305 |
| 375 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 306 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 376 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 307 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 377 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 308 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); |
| 378 | 309 |
| 379 rootDisplayItemList().invalidate(first->displayItemClient()); | 310 rootDisplayItemList().invalidate(first->displayItemClient()); |
| 380 rootDisplayItemList().invalidate(second->displayItemClient()); | 311 rootDisplayItemList().invalidate(second->displayItemClient()); |
| 381 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150
, 150)); | 312 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150
, 150)); |
| 382 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); | 313 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); |
| 383 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50
, 50)); | 314 drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50
, 50)); |
| 384 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); | 315 drawRect(&context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); |
| 316 rootDisplayItemList().endNewPaints(); |
| 385 | 317 |
| 386 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, | 318 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, |
| 387 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 319 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 388 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline)), | 320 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline)), |
| 389 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), | 321 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseB
lockBackground)), |
| 390 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); | 322 TestDisplayItem(second, DisplayItem::paintPhaseToDrawingType(PaintPhaseO
utline))); |
| 391 | 323 |
| 392 rootDisplayItemList().invalidate(first->displayItemClient()); | 324 rootDisplayItemList().invalidate(first->displayItemClient()); |
| 393 rootDisplayItemList().invalidate(second->displayItemClient()); | 325 rootDisplayItemList().invalidate(second->displayItemClient()); |
| 394 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150
, 150)); | 326 drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150
, 150)); |
| 395 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); | 327 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); |
| 328 rootDisplayItemList().endNewPaints(); |
| 396 | 329 |
| 397 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 330 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 398 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 331 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 399 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 332 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); |
| 400 } | 333 } |
| 401 | 334 |
| 402 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip) | 335 TEST_F(ViewDisplayListTest, UpdateClip) |
| 403 { | 336 { |
| 404 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); | 337 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); |
| 405 LayoutLayerModelObject* firstRenderer = toLayoutLayerModelObject(document().
body()->firstChild()->renderer()); | 338 LayoutLayerModelObject* firstRenderer = toLayoutLayerModelObject(document().
body()->firstChild()->renderer()); |
| 406 LayoutLayerModelObject* secondRenderer = toLayoutLayerModelObject(document()
.body()->firstChild()->firstChild()->renderer()); | 339 LayoutLayerModelObject* secondRenderer = toLayoutLayerModelObject(document()
.body()->firstChild()->firstChild()->renderer()); |
| 407 GraphicsContext context(nullptr, &rootDisplayItemList()); | 340 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 408 | 341 |
| 409 ClipRect firstClipRect(IntRect(1, 1, 2, 2)); | 342 ClipRect firstClipRect(IntRect(1, 1, 2, 2)); |
| 410 { | 343 { |
| 411 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem
::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags()); | 344 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem
::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags()); |
| 412 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1
00, 100, 150, 150)); | 345 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1
00, 100, 150, 150)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI
temClient())); | 417 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI
temClient())); |
| 485 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display
ItemClient())); | 418 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display
ItemClient())); |
| 486 | 419 |
| 487 rootDisplayItemList().invalidateAll(); | 420 rootDisplayItemList().invalidateAll(); |
| 488 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display
ItemClient())); | 421 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display
ItemClient())); |
| 489 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa
yItemClient())); | 422 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa
yItemClient())); |
| 490 } | 423 } |
| 491 | 424 |
| 492 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret) | 425 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret) |
| 493 { | 426 { |
| 494 setBodyInnerHTML("<div id='div' contentEditable='true'>XYZ</div>"); | 427 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); |
| 428 document().page()->focusController().setActive(true); |
| 429 document().page()->focusController().setFocused(true); |
| 495 RenderView* renderView = document().renderView(); | 430 RenderView* renderView = document().renderView(); |
| 496 Layer* rootLayer = renderView->layer(); | 431 Layer* rootLayer = renderView->layer(); |
| 497 RenderObject* htmlRenderer = document().documentElement()->renderer(); | 432 RenderObject* htmlRenderer = document().documentElement()->renderer(); |
| 498 Element* div = toElement(document().body()->firstChild()); | 433 Element* div = toElement(document().body()->firstChild()); |
| 499 RenderObject* divRenderer = document().body()->firstChild()->renderer(); | 434 RenderObject* divRenderer = document().body()->firstChild()->renderer(); |
| 500 InlineTextBox* textInlineBox = toRenderText(div->firstChild()->renderer())->
firstTextBox(); | 435 InlineTextBox* textInlineBox = toRenderText(div->firstChild()->renderer())->
firstTextBox(); |
| 501 | 436 |
| 502 SkCanvas canvas(800, 600); | 437 SkCanvas canvas(800, 600); |
| 503 GraphicsContext context(&canvas, &rootDisplayItemList()); | 438 GraphicsContext context(&canvas, &rootDisplayItemList()); |
| 504 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB
ehaviorNormal, LayoutSize()); | 439 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB
ehaviorNormal, LayoutSize()); |
| 505 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); | 440 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); |
| 506 rootDisplayItemList().endNewPaints(); | 441 rootDisplayItemList().endNewPaints(); |
| 507 | 442 |
| 508 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 443 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 509 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), | 444 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), |
| 510 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh
aseToDrawingType(PaintPhaseForeground))); | 445 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh
aseToDrawingType(PaintPhaseForeground))); |
| 511 | 446 |
| 512 div->focus(); | 447 div->focus(); |
| 513 document().view()->updateLayoutAndStyleForPainting(); | 448 document().view()->updateLayoutAndStyleForPainting(); |
| 514 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); | 449 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); |
| 515 rootDisplayItemList().endNewPaints(); | 450 rootDisplayItemList().endNewPaints(); |
| 516 | 451 |
| 517 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 452 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
| 518 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), | 453 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), |
| 519 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh
aseToDrawingType(PaintPhaseForeground)), | 454 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh
aseToDrawingType(PaintPhaseForeground)), |
| 520 TestDisplayItem(divRenderer, DisplayItem::Caret)); | 455 TestDisplayItem(divRenderer, DisplayItem::Caret)); |
| 521 } | 456 } |
| 522 | 457 |
| 523 } // anonymous namespace | 458 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret_CacheEnabled) |
| 459 { |
| 460 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true); |
| 461 |
| 462 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); |
| 463 document().page()->focusController().setActive(true); |
| 464 document().page()->focusController().setFocused(true); |
| 465 RenderView* renderView = document().renderView(); |
| 466 Layer* rootLayer = renderView->layer(); |
| 467 RenderObject* htmlRenderer = document().documentElement()->renderer(); |
| 468 RenderObject* bodyRenderer = document().body()->renderer(); |
| 469 Element* div = toElement(document().body()->firstChild()); |
| 470 RenderObject* divRenderer = document().body()->firstChild()->renderer(); |
| 471 InlineTextBox* textInlineBox = toRenderText(div->firstChild()->renderer())->
firstTextBox(); |
| 472 |
| 473 SkCanvas canvas(800, 600); |
| 474 GraphicsContext context(&canvas, &rootDisplayItemList()); |
| 475 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB
ehaviorNormal, LayoutSize()); |
| 476 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); |
| 477 rootDisplayItemList().endNewPaints(); |
| 478 |
| 479 EXPECT_EQ((size_t)30, rootDisplayItemList().paintList().size()); |
| 480 EXPECT_DISPLAY_ITEM(1, TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorat
ionBackground), rootDisplayItemList().paintList()); |
| 481 EXPECT_DISPLAY_ITEM(18, TestDisplayItem(textInlineBox->displayItemClient(),
DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)), rootDisplayItemList
().paintList()); |
| 482 // All others are BeginSubtree/EndSubtrees. |
| 483 |
| 484 div->focus(); |
| 485 document().view()->updateLayoutAndStyleForPainting(); |
| 486 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(htmlRenderer->displayIt
emClient())); |
| 487 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(bodyRenderer->displayIt
emClient())); |
| 488 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divRenderer->displayIt
emClient())); |
| 489 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(textInlineBox->displayI
temClient())); |
| 490 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); |
| 491 rootDisplayItemList().endNewPaints(); |
| 492 |
| 493 EXPECT_EQ((size_t)31, rootDisplayItemList().paintList().size()); |
| 494 EXPECT_DISPLAY_ITEM(1, TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorat
ionBackground), rootDisplayItemList().paintList()); |
| 495 EXPECT_DISPLAY_ITEM(18, TestDisplayItem(textInlineBox->displayItemClient(),
DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)), rootDisplayItemList
().paintList()); |
| 496 EXPECT_DISPLAY_ITEM(19, TestDisplayItem(divRenderer, DisplayItem::Caret), ro
otDisplayItemList().paintList()); |
| 497 // All others are BeginSubtree/EndSubtrees. |
| 498 } |
| 499 |
| 500 TEST_F(ViewDisplayListTest, ComplexUpdateSwapOrder) |
| 501 { |
| 502 setBodyInnerHTML("<div id='container1'><div id='content1'></div></div>" |
| 503 "<div id='container2'><div id='content2'></div></div>"); |
| 504 RenderObject* container1 = document().body()->firstChild()->renderer(); |
| 505 RenderObject* content1 = document().body()->firstChild()->firstChild()->rend
erer(); |
| 506 RenderObject* container2 = document().body()->firstChild()->nextSibling()->r
enderer(); |
| 507 RenderObject* content2 = document().body()->firstChild()->nextSibling()->fir
stChild()->renderer(); |
| 508 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 509 |
| 510 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100
, 100, 100)); |
| 511 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 100,
50, 200)); |
| 512 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 50, 2
00)); |
| 513 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100
, 100)); |
| 514 drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100, 200
, 100, 100)); |
| 515 drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 200,
50, 200)); |
| 516 drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 50, 2
00)); |
| 517 drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200, 100
, 100)); |
| 518 rootDisplayItemList().endNewPaints(); |
| 519 |
| 520 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 8, |
| 521 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground)), |
| 522 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas
eBlockBackground)), |
| 523 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas
eForeground)), |
| 524 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh
aseForeground)), |
| 525 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground)), |
| 526 TestDisplayItem(content2, DisplayItem::paintPhaseToDrawingType(PaintPhas
eBlockBackground)), |
| 527 TestDisplayItem(content2, DisplayItem::paintPhaseToDrawingType(PaintPhas
eForeground)), |
| 528 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh
aseForeground))); |
| 529 |
| 530 // Simulate the situation when container1 e.g. gets a z-index that is now gr
eater than container2. |
| 531 rootDisplayItemList().invalidate(container1->displayItemClient()); |
| 532 drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100, 200
, 100, 100)); |
| 533 drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 200,
50, 200)); |
| 534 drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 50, 2
00)); |
| 535 drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200, 100
, 100)); |
| 536 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100
, 100, 100)); |
| 537 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 100,
50, 200)); |
| 538 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 50, 2
00)); |
| 539 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100
, 100)); |
| 540 rootDisplayItemList().endNewPaints(); |
| 541 |
| 542 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 8, |
| 543 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground)), |
| 544 TestDisplayItem(content2, DisplayItem::paintPhaseToDrawingType(PaintPhas
eBlockBackground)), |
| 545 TestDisplayItem(content2, DisplayItem::paintPhaseToDrawingType(PaintPhas
eForeground)), |
| 546 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh
aseForeground)), |
| 547 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground)), |
| 548 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas
eBlockBackground)), |
| 549 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas
eForeground)), |
| 550 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh
aseForeground))); |
| 551 } |
| 552 |
| 553 TEST_F(ViewDisplayListTest, CachedSubtreeSwapOrder) |
| 554 { |
| 555 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true); |
| 556 |
| 557 setBodyInnerHTML("<div id='container1'><div id='content1'></div></div>" |
| 558 "<div id='container2'><div id='content2'></div></div>"); |
| 559 RenderObject* container1 = document().body()->firstChild()->renderer(); |
| 560 RenderObject* content1 = document().body()->firstChild()->firstChild()->rend
erer(); |
| 561 RenderObject* container2 = document().body()->firstChild()->nextSibling()->r
enderer(); |
| 562 RenderObject* content2 = document().body()->firstChild()->nextSibling()->fir
stChild()->renderer(); |
| 563 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 564 |
| 565 { |
| 566 SubtreeInfoRecorder r(&context, *container1, PaintPhaseBlockBackground); |
| 567 r.begin(); |
| 568 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100,
100, 100, 100)); |
| 569 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 1
00, 50, 200)); |
| 570 } |
| 571 { |
| 572 SubtreeInfoRecorder r(&context, *container1, PaintPhaseForeground); |
| 573 r.begin(); |
| 574 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 5
0, 200)); |
| 575 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100,
100, 100)); |
| 576 } |
| 577 { |
| 578 SubtreeInfoRecorder r(&context, *container2, PaintPhaseBlockBackground); |
| 579 r.begin(); |
| 580 drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100,
200, 100, 100)); |
| 581 drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 2
00, 50, 200)); |
| 582 } |
| 583 { |
| 584 SubtreeInfoRecorder r(&context, *container2, PaintPhaseForeground); |
| 585 r.begin(); |
| 586 drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 5
0, 200)); |
| 587 drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200,
100, 100)); |
| 588 } |
| 589 rootDisplayItemList().endNewPaints(); |
| 590 |
| 591 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 16, |
| 592 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(Pa
intPhaseBlockBackground)), |
| 593 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground)), |
| 594 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas
eBlockBackground)), |
| 595 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(Pain
tPhaseBlockBackground)), |
| 596 |
| 597 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(Pa
intPhaseForeground)), |
| 598 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas
eForeground)), |
| 599 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh
aseForeground)), |
| 600 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(Pain
tPhaseForeground)), |
| 601 |
| 602 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(Pa
intPhaseBlockBackground)), |
| 603 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground)), |
| 604 TestDisplayItem(content2, DisplayItem::paintPhaseToDrawingType(PaintPhas
eBlockBackground)), |
| 605 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(Pain
tPhaseBlockBackground)), |
| 606 |
| 607 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(Pa
intPhaseForeground)), |
| 608 TestDisplayItem(content2, DisplayItem::paintPhaseToDrawingType(PaintPhas
eForeground)), |
| 609 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh
aseForeground)), |
| 610 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(Pain
tPhaseForeground))); |
| 611 |
| 612 // Simulate the situation when container1 e.g. gets a z-index that is now gr
eater than container2, |
| 613 // and at the same time container2 is scrolled out of viewport and content2
is invalidated. |
| 614 rootDisplayItemList().invalidate(content2->displayItemClient()); |
| 615 { |
| 616 SubtreeInfoRecorder r(&context, *container2, PaintPhaseBlockBackground); |
| 617 } |
| 618 EXPECT_EQ((size_t)1, newPaintListBeforeUpdate().size()); |
| 619 EXPECT_TRUE(newPaintListBeforeUpdate().last()->isSubtreeCached()); |
| 620 { |
| 621 SubtreeInfoRecorder r(&context, *container2, PaintPhaseForeground); |
| 622 } |
| 623 EXPECT_EQ((size_t)2, newPaintListBeforeUpdate().size()); |
| 624 EXPECT_TRUE(newPaintListBeforeUpdate().last()->isSubtreeCached()); |
| 625 { |
| 626 SubtreeInfoRecorder r(&context, *container1, PaintPhaseBlockBackground); |
| 627 r.begin(); |
| 628 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100,
100, 100, 100)); |
| 629 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 1
00, 50, 200)); |
| 630 } |
| 631 { |
| 632 SubtreeInfoRecorder r(&context, *container1, PaintPhaseForeground); |
| 633 r.begin(); |
| 634 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 5
0, 200)); |
| 635 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100,
100, 100)); |
| 636 } |
| 637 rootDisplayItemList().endNewPaints(); |
| 638 |
| 639 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 14, |
| 640 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(Pa
intPhaseBlockBackground)), |
| 641 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground)), |
| 642 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(Pain
tPhaseBlockBackground)), |
| 643 |
| 644 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(Pa
intPhaseForeground)), |
| 645 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh
aseForeground)), |
| 646 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(Pain
tPhaseForeground)), |
| 647 |
| 648 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(Pa
intPhaseBlockBackground)), |
| 649 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh
aseBlockBackground)), |
| 650 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas
eBlockBackground)), |
| 651 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(Pain
tPhaseBlockBackground)), |
| 652 |
| 653 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(Pa
intPhaseForeground)), |
| 654 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas
eForeground)), |
| 655 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh
aseForeground)), |
| 656 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(Pain
tPhaseForeground))); |
| 657 } |
| 658 |
| 524 } // namespace blink | 659 } // namespace blink |
| OLD | NEW |