OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "core/paint/PaintControllerPaintTest.h" | |
6 #include "platform/graphics/paint/DrawingDisplayItem.h" | |
7 | |
8 namespace blink { | |
9 | |
10 using TablePainterTest = PaintControllerPaintTest; | |
11 | |
12 TEST_F(TablePainterTest, CollapsedBorderInterestRectChange) { | |
13 setBodyInnerHTML( | |
14 "<style>" | |
15 " table { border-collapse: collapse; position: absolute; }" | |
16 " td { width: 100px; height: 100px; border: 2px solid blue; }" | |
17 "</style>" | |
18 "<table id='table'>" | |
19 " <tr><td></td><td></td><td></td><td></td></tr>" | |
20 " <tr><td></td><td></td><td></td><td></td></tr>" | |
21 " <tr><td></td><td></td><td></td><td></td></tr>" | |
22 " <tr><td></td><td></td><td></td><td></td></tr>" | |
23 "</table>"); | |
24 | |
25 PaintLayer& htmlLayer = | |
26 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) | |
27 ->layer(); | |
28 LayoutObject& table = *getLayoutObjectByElementId("table"); | |
29 | |
30 rootPaintController().invalidateAll(); | |
31 document().view()->updateAllLifecyclePhasesExceptPaint(); | |
32 IntRect interestRect(300, 300, 300, 300); | |
33 paint(&interestRect); | |
34 | |
35 EXPECT_DISPLAY_LIST( | |
36 rootPaintController().getDisplayItemList(), 4, | |
37 TestDisplayItem(layoutView(), documentBackgroundType), | |
38 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | |
39 TestDisplayItem(table, DisplayItem::kTableCollapsedBorders), | |
40 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | |
41 // Painted collapsed borders of the central 4 cells, each 4 operations. | |
42 EXPECT_EQ(16, static_cast<const DrawingDisplayItem&>( | |
43 rootPaintController().getDisplayItemList()[2]) | |
44 .picture() | |
45 ->approximateOpCount()); | |
46 | |
47 // Should repaint collapsed borders if the previous paint didn't fully paint | |
48 // and interest rect changes. | |
49 document().view()->updateAllLifecyclePhasesExceptPaint(); | |
50 interestRect = IntRect(0, 0, 1000, 1000); | |
51 EXPECT_TRUE(paintWithoutCommit(&interestRect)); | |
52 EXPECT_EQ(1, numCachedNewItems()); | |
53 commit(); | |
54 EXPECT_DISPLAY_LIST( | |
55 rootPaintController().getDisplayItemList(), 4, | |
56 TestDisplayItem(layoutView(), documentBackgroundType), | |
57 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | |
58 TestDisplayItem(table, DisplayItem::kTableCollapsedBorders), | |
59 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | |
60 // Painted collapsed borders of all 16 cells, each 4 operations. | |
61 EXPECT_EQ(64, static_cast<const DrawingDisplayItem&>( | |
62 rootPaintController().getDisplayItemList()[2]) | |
63 .picture() | |
64 ->approximateOpCount()); | |
65 | |
66 // Should not repaint collapsed borders if the previous paint fully painted | |
67 // and interest rect changes. | |
68 document().view()->updateAllLifecyclePhasesExceptPaint(); | |
69 interestRect = IntRect(0, 0, 400, 400); | |
70 EXPECT_TRUE(paintWithoutCommit(&interestRect)); | |
71 EXPECT_EQ(4, numCachedNewItems()); | |
72 commit(); | |
73 } | |
74 | |
75 } // namespace blink | |
OLD | NEW |