| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/LayoutObjectDrawingRecorder.h" | 6 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 7 | 7 |
| 8 #include "core/layout/LayoutTestHelper.h" | 8 #include "core/layout/LayoutTestHelper.h" |
| 9 #include "core/layout/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
| 10 #include "core/paint/DeprecatedPaintLayer.h" | 10 #include "core/paint/DeprecatedPaintLayer.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 void drawRect(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase
, const FloatRect& bound) | 62 void drawRect(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase
, const FloatRect& bound) |
| 63 { | 63 { |
| 64 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun
d); | 64 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun
d); |
| 65 if (drawingRecorder.canUseCachedDrawing()) | 65 if (drawingRecorder.canUseCachedDrawing()) |
| 66 return; | 66 return; |
| 67 IntRect rect(0, 0, 10, 10); | 67 IntRect rect(0, 0, 10, 10); |
| 68 context.drawRect(rect); | 68 context.drawRect(rect); |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool isDrawing(const DisplayItems::ItemHandle& item) | 71 bool isDrawing(const DisplayItem& item) |
| 72 { | 72 { |
| 73 return DisplayItem::isDrawingType(item.type()); | 73 return DisplayItem::isDrawingType(item.type()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool isCached(const DisplayItems::ItemHandle& item) | 76 bool isCached(const DisplayItem& item) |
| 77 { | 77 { |
| 78 return DisplayItem::isCachedType(item.type()); | 78 return DisplayItem::isCachedType(item.type()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 TEST_F(LayoutObjectDrawingRecorderTest, Nothing) | 81 TEST_F(LayoutObjectDrawingRecorderTest, Nothing) |
| 82 { | 82 { |
| 83 GraphicsContext context(&rootDisplayItemList()); | 83 GraphicsContext context(&rootDisplayItemList()); |
| 84 FloatRect bound = layoutView().viewRect(); | 84 FloatRect bound = layoutView().viewRect(); |
| 85 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); | 85 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); |
| 86 | 86 |
| 87 drawNothing(context, layoutView(), PaintPhaseForeground, bound); | 87 drawNothing(context, layoutView(), PaintPhaseForeground, bound); |
| 88 rootDisplayItemList().commitNewDisplayItems(); | 88 rootDisplayItemList().commitNewDisplayItems(); |
| 89 EXPECT_EQ((size_t)1, rootDisplayItemList().displayItems().size()); | 89 EXPECT_EQ((size_t)1, rootDisplayItemList().displayItems().size()); |
| 90 const auto& item = rootDisplayItemList().displayItems()[0]; | 90 const auto& item = rootDisplayItemList().displayItems()[0]; |
| 91 ASSERT_TRUE(isDrawing(item)); | 91 ASSERT_TRUE(isDrawing(item)); |
| 92 EXPECT_FALSE(item.picture()); | 92 EXPECT_FALSE(static_cast<const DrawingDisplayItem&>(item).picture()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 TEST_F(LayoutObjectDrawingRecorderTest, Rect) | 95 TEST_F(LayoutObjectDrawingRecorderTest, Rect) |
| 96 { | 96 { |
| 97 GraphicsContext context(&rootDisplayItemList()); | 97 GraphicsContext context(&rootDisplayItemList()); |
| 98 FloatRect bound = layoutView().viewRect(); | 98 FloatRect bound = layoutView().viewRect(); |
| 99 drawRect(context, layoutView(), PaintPhaseForeground, bound); | 99 drawRect(context, layoutView(), PaintPhaseForeground, bound); |
| 100 rootDisplayItemList().commitNewDisplayItems(); | 100 rootDisplayItemList().commitNewDisplayItems(); |
| 101 EXPECT_EQ((size_t)1, rootDisplayItemList().displayItems().size()); | 101 EXPECT_EQ((size_t)1, rootDisplayItemList().displayItems().size()); |
| 102 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[0])); | 102 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[0])); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 119 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[0])); | 119 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[0])); |
| 120 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[1])); | 120 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[1])); |
| 121 rootDisplayItemList().commitNewDisplayItems(); | 121 rootDisplayItemList().commitNewDisplayItems(); |
| 122 EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size()); | 122 EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size()); |
| 123 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[0])); | 123 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[0])); |
| 124 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[1])); | 124 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[1])); |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace | 127 } // namespace |
| 128 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |