| 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/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
| 8 #include "core/layout/compositing/LayerCompositor.h" | 8 #include "core/layout/compositing/LayerCompositor.h" |
| 9 #include "core/layout/line/InlineTextBox.h" | 9 #include "core/layout/line/InlineTextBox.h" |
| 10 #include "core/page/FocusController.h" | 10 #include "core/page/FocusController.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 void drawRect(GraphicsContext* context, LayoutObject* renderer, PaintPhase phase
, const FloatRect& bound) | 88 void drawRect(GraphicsContext* context, LayoutObject* renderer, PaintPhase phase
, const FloatRect& bound) |
| 89 { | 89 { |
| 90 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); | 90 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); |
| 91 if (drawingRecorder.canUseCachedDrawing()) | 91 if (drawingRecorder.canUseCachedDrawing()) |
| 92 return; | 92 return; |
| 93 IntRect rect(0, 0, 10, 10); | 93 IntRect rect(0, 0, 10, 10); |
| 94 context->drawRect(rect); | 94 context->drawRect(rect); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void drawClippedRect(GraphicsContext* context, LayoutLayerModelObject* renderer,
PaintPhase phase, const FloatRect& bound) | 97 void drawClippedRect(GraphicsContext* context, LayoutBoxModelObject* renderer, P
aintPhase phase, const FloatRect& bound) |
| 98 { | 98 { |
| 99 IntRect rect(1, 1, 9, 9); | 99 IntRect rect(1, 1, 9, 9); |
| 100 ClipRect clipRect(rect); | 100 ClipRect clipRect(rect); |
| 101 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye
rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags()); | 101 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye
rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags()); |
| 102 drawRect(context, renderer, phase, bound); | 102 drawRect(context, renderer, phase, bound); |
| 103 } | 103 } |
| 104 | 104 |
| 105 TEST_F(ViewDisplayListTest, NestedRecorders) | 105 TEST_F(ViewDisplayListTest, NestedRecorders) |
| 106 { | 106 { |
| 107 GraphicsContext context(nullptr, &rootDisplayItemList()); | 107 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 rootDisplayItemList().endNewPaints(); | 330 rootDisplayItemList().endNewPaints(); |
| 331 | 331 |
| 332 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 332 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 333 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 333 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
| 334 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 334 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); |
| 335 } | 335 } |
| 336 | 336 |
| 337 TEST_F(ViewDisplayListTest, UpdateClip) | 337 TEST_F(ViewDisplayListTest, UpdateClip) |
| 338 { | 338 { |
| 339 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); | 339 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); |
| 340 LayoutLayerModelObject* firstRenderer = toLayoutLayerModelObject(document().
body()->firstChild()->renderer()); | 340 LayoutBoxModelObject* firstRenderer = toLayoutBoxModelObject(document().body
()->firstChild()->renderer()); |
| 341 LayoutLayerModelObject* secondRenderer = toLayoutLayerModelObject(document()
.body()->firstChild()->firstChild()->renderer()); | 341 LayoutBoxModelObject* secondRenderer = toLayoutBoxModelObject(document().bod
y()->firstChild()->firstChild()->renderer()); |
| 342 GraphicsContext context(nullptr, &rootDisplayItemList()); | 342 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 343 | 343 |
| 344 ClipRect firstClipRect(IntRect(1, 1, 2, 2)); | 344 ClipRect firstClipRect(IntRect(1, 1, 2, 2)); |
| 345 { | 345 { |
| 346 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem
::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags()); | 346 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem
::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags()); |
| 347 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1
00, 100, 150, 150)); | 347 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1
00, 100, 150, 150)); |
| 348 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(
100, 100, 150, 150)); | 348 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(
100, 100, 150, 150)); |
| 349 } | 349 } |
| 350 rootDisplayItemList().endNewPaints(); | 350 rootDisplayItemList().endNewPaints(); |
| 351 | 351 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 378 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground), | 378 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground), |
| 379 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground)), | 379 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground)), |
| 380 TestDisplayItem(secondRenderer, DisplayItem::clipTypeToEndClipType(Displ
ayItem::ClipLayerForeground))); | 380 TestDisplayItem(secondRenderer, DisplayItem::clipTypeToEndClipType(Displ
ayItem::ClipLayerForeground))); |
| 381 } | 381 } |
| 382 | 382 |
| 383 TEST_F(ViewDisplayListTest, CachedDisplayItems) | 383 TEST_F(ViewDisplayListTest, CachedDisplayItems) |
| 384 { | 384 { |
| 385 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true); | 385 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true); |
| 386 | 386 |
| 387 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); | 387 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); |
| 388 LayoutLayerModelObject* firstRenderer = toLayoutLayerModelObject(document().
body()->firstChild()->renderer()); | 388 LayoutBoxModelObject* firstRenderer = toLayoutBoxModelObject(document().body
()->firstChild()->renderer()); |
| 389 LayoutLayerModelObject* secondRenderer = toLayoutLayerModelObject(document()
.body()->firstChild()->firstChild()->renderer()); | 389 LayoutBoxModelObject* secondRenderer = toLayoutBoxModelObject(document().bod
y()->firstChild()->firstChild()->renderer()); |
| 390 GraphicsContext context(nullptr, &rootDisplayItemList()); | 390 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 391 | 391 |
| 392 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); | 392 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); |
| 393 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); | 393 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); |
| 394 rootDisplayItemList().endNewPaints(); | 394 rootDisplayItemList().endNewPaints(); |
| 395 | 395 |
| 396 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 396 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
| 397 TestDisplayItem(firstRenderer, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseBlockBackground)), | 397 TestDisplayItem(firstRenderer, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseBlockBackground)), |
| 398 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground))); | 398 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground))); |
| 399 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI
temClient())); | 399 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI
temClient())); |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, | 751 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, |
| 752 TestDisplayItem(multicol, DisplayItem::paintPhaseToDrawingType(PaintPhas
eBlockBackground)), | 752 TestDisplayItem(multicol, DisplayItem::paintPhaseToDrawingType(PaintPhas
eBlockBackground)), |
| 753 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase
Foreground)), | 753 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase
Foreground)), |
| 754 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase
Foreground)), | 754 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase
Foreground)), |
| 755 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase
Foreground))); | 755 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase
Foreground))); |
| 756 EXPECT_NE(picture1, static_cast<DrawingDisplayItem*>(rootDisplayItemList().p
aintList()[1].get())->picture()); | 756 EXPECT_NE(picture1, static_cast<DrawingDisplayItem*>(rootDisplayItemList().p
aintList()[1].get())->picture()); |
| 757 EXPECT_NE(picture2, static_cast<DrawingDisplayItem*>(rootDisplayItemList().p
aintList()[2].get())->picture()); | 757 EXPECT_NE(picture2, static_cast<DrawingDisplayItem*>(rootDisplayItemList().p
aintList()[2].get())->picture()); |
| 758 } | 758 } |
| 759 | 759 |
| 760 } // namespace blink | 760 } // namespace blink |
| OLD | NEW |