| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "core/paint/PaintControllerPaintTest.h" | 5 #include "core/paint/PaintControllerPaintTest.h" |
| 6 #include "core/paint/PaintLayerPainter.h" | 6 #include "core/paint/PaintLayerPainter.h" |
| 7 | 7 |
| 8 // This file contains tests testing TablePainter, TableSectionPainter, |
| 9 // TableRowPainter and TableCellPainter. It's difficult to separate the tests |
| 10 // into individual files because of dependencies among the painter classes. |
| 11 |
| 8 namespace blink { | 12 namespace blink { |
| 9 | 13 |
| 10 using TableCellPainterTest = PaintControllerPaintTest; | 14 using TablePainterTest = PaintControllerPaintTest; |
| 11 | 15 |
| 12 TEST_F(TableCellPainterTest, Background) { | 16 TEST_F(TablePainterTest, Background) { |
| 13 setBodyInnerHTML( | 17 setBodyInnerHTML( |
| 14 "<style>" | 18 "<style>" |
| 15 " td { width: 200px; height: 200px; border: none; }" | 19 " td { width: 200px; height: 200px; border: none; }" |
| 16 " tr { background-color: blue; }" | 20 " tr { background-color: blue; }" |
| 17 " table { border: none; border-spacing: 0; border-collapse: collapse; }" | 21 " table { border: none; border-spacing: 0; border-collapse: collapse; }" |
| 18 "</style>" | 22 "</style>" |
| 19 "<table>" | 23 "<table>" |
| 20 " <tr><td id='cell1'></td></tr>" | 24 " <tr id='row1'><td></td></tr>" |
| 21 " <tr><td id='cell2'></td></tr>" | 25 " <tr id='row2'><td></td></tr>" |
| 22 "</table>"); | 26 "</table>"); |
| 23 | 27 |
| 24 LayoutView& layoutView = *document().layoutView(); | 28 LayoutView& layoutView = *document().layoutView(); |
| 25 LayoutObject& cell1 = *getLayoutObjectByElementId("cell1"); | 29 LayoutObject& row1 = *getLayoutObjectByElementId("row1"); |
| 26 LayoutObject& cell2 = *getLayoutObjectByElementId("cell2"); | 30 LayoutObject& row2 = *getLayoutObjectByElementId("row2"); |
| 27 | 31 |
| 28 rootPaintController().invalidateAll(); | 32 rootPaintController().invalidateAll(); |
| 29 document().view()->updateAllLifecyclePhasesExceptPaint(); | 33 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 30 IntRect interestRect(0, 0, 200, 200); | 34 IntRect interestRect(0, 0, 200, 200); |
| 31 paint(&interestRect); | 35 paint(&interestRect); |
| 32 | 36 |
| 33 EXPECT_DISPLAY_LIST( | 37 EXPECT_DISPLAY_LIST( |
| 34 rootPaintController().getDisplayItemList(), 2, | 38 rootPaintController().getDisplayItemList(), 2, |
| 35 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), | 39 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), |
| 36 TestDisplayItem(cell1, DisplayItem::kTableCellBackgroundFromRow)); | 40 TestDisplayItem(row1, DisplayItem::kBoxDecorationBackground)); |
| 37 | 41 |
| 38 document().view()->updateAllLifecyclePhasesExceptPaint(); | 42 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 39 interestRect = IntRect(0, 300, 200, 1000); | 43 interestRect = IntRect(0, 300, 200, 1000); |
| 40 paint(&interestRect); | 44 paint(&interestRect); |
| 41 | 45 |
| 42 EXPECT_DISPLAY_LIST( | 46 EXPECT_DISPLAY_LIST( |
| 43 rootPaintController().getDisplayItemList(), 2, | 47 rootPaintController().getDisplayItemList(), 2, |
| 44 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), | 48 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), |
| 45 TestDisplayItem(cell2, DisplayItem::kTableCellBackgroundFromRow)); | 49 TestDisplayItem(row2, DisplayItem::kBoxDecorationBackground)); |
| 46 } | 50 } |
| 47 | 51 |
| 48 TEST_F(TableCellPainterTest, BackgroundWithCellSpacing) { | 52 TEST_F(TablePainterTest, BackgroundWithCellSpacing) { |
| 49 setBodyInnerHTML( | 53 setBodyInnerHTML( |
| 50 "<style>" | 54 "<style>" |
| 51 " body { margin: 0; }" | 55 " body { margin: 0; }" |
| 52 " td { width: 200px; height: 150px; border: 0; background-color: green; " | 56 " td { width: 200px; height: 150px; border: 0; background-color: green; " |
| 53 "}" | 57 " }" |
| 54 " tr { background-color: blue; }" | 58 " tr { background-color: blue; }" |
| 55 " table { border: none; border-spacing: 100px; border-collapse: " | 59 " table { border: none; border-spacing: 100px; border-collapse: " |
| 56 "separate; }" | 60 "separate; }" |
| 57 "</style>" | 61 "</style>" |
| 58 "<table>" | 62 "<table>" |
| 59 " <tr><td id='cell1'></td></tr>" | 63 " <tr id='row1'><td id='cell1'></td></tr>" |
| 60 " <tr><td id='cell2'></td></tr>" | 64 " <tr id='row2'><td id='cell2'></td></tr>" |
| 61 "</table>"); | 65 "</table>"); |
| 62 | 66 |
| 63 LayoutView& layoutView = *document().layoutView(); | 67 LayoutView& layoutView = *document().layoutView(); |
| 68 LayoutObject& row1 = *getLayoutObjectByElementId("row1"); |
| 69 LayoutObject& row2 = *getLayoutObjectByElementId("row2"); |
| 64 LayoutObject& cell1 = *getLayoutObjectByElementId("cell1"); | 70 LayoutObject& cell1 = *getLayoutObjectByElementId("cell1"); |
| 65 LayoutObject& cell2 = *getLayoutObjectByElementId("cell2"); | 71 LayoutObject& cell2 = *getLayoutObjectByElementId("cell2"); |
| 66 | 72 |
| 67 rootPaintController().invalidateAll(); | 73 rootPaintController().invalidateAll(); |
| 68 document().view()->updateAllLifecyclePhasesExceptPaint(); | 74 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 69 // Intersects cell1 and the spacing between cell1 and cell2. | 75 // Intersects cell1 and the spacing between cell1 and cell2. |
| 70 IntRect interestRect(0, 200, 200, 150); | 76 IntRect interestRect(0, 200, 200, 150); |
| 71 paint(&interestRect); | 77 paint(&interestRect); |
| 72 | 78 |
| 73 EXPECT_DISPLAY_LIST( | 79 EXPECT_DISPLAY_LIST( |
| 74 rootPaintController().getDisplayItemList(), 3, | 80 rootPaintController().getDisplayItemList(), 3, |
| 75 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), | 81 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), |
| 76 TestDisplayItem(cell1, DisplayItem::kTableCellBackgroundFromRow), | 82 TestDisplayItem(row1, DisplayItem::kBoxDecorationBackground), |
| 77 TestDisplayItem(cell1, DisplayItem::kBoxDecorationBackground)); | 83 TestDisplayItem(cell1, DisplayItem::kBoxDecorationBackground)); |
| 78 | 84 |
| 79 document().view()->updateAllLifecyclePhasesExceptPaint(); | 85 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 80 // Intersects the spacing only. | 86 // Intersects the spacing only. |
| 81 interestRect = IntRect(0, 250, 100, 100); | 87 interestRect = IntRect(0, 250, 100, 100); |
| 82 paint(&interestRect); | 88 paint(&interestRect); |
| 83 | 89 |
| 84 EXPECT_DISPLAY_LIST( | 90 EXPECT_DISPLAY_LIST( |
| 85 rootPaintController().getDisplayItemList(), 1, | 91 rootPaintController().getDisplayItemList(), 2, |
| 86 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground)); | 92 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), |
| 93 TestDisplayItem(row1, DisplayItem::kBoxDecorationBackground)); |
| 87 | 94 |
| 88 document().view()->updateAllLifecyclePhasesExceptPaint(); | 95 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 89 // Intersects cell2 only. | 96 // Intersects cell2 only. |
| 90 interestRect = IntRect(0, 350, 200, 150); | 97 interestRect = IntRect(0, 350, 200, 150); |
| 91 paint(&interestRect); | 98 paint(&interestRect); |
| 92 | 99 |
| 93 EXPECT_DISPLAY_LIST( | 100 EXPECT_DISPLAY_LIST( |
| 94 rootPaintController().getDisplayItemList(), 3, | 101 rootPaintController().getDisplayItemList(), 3, |
| 95 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), | 102 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), |
| 96 TestDisplayItem(cell2, DisplayItem::kTableCellBackgroundFromRow), | 103 TestDisplayItem(row2, DisplayItem::kBoxDecorationBackground), |
| 97 TestDisplayItem(cell2, DisplayItem::kBoxDecorationBackground)); | 104 TestDisplayItem(cell2, DisplayItem::kBoxDecorationBackground)); |
| 98 } | 105 } |
| 99 | 106 |
| 100 TEST_F(TableCellPainterTest, BackgroundInSelfPaintingRow) { | 107 TEST_F(TablePainterTest, BackgroundInSelfPaintingRow) { |
| 101 setBodyInnerHTML( | 108 setBodyInnerHTML( |
| 102 "<style>" | 109 "<style>" |
| 103 " body { margin: 0 }" | 110 " body { margin: 0 }" |
| 104 " td { width: 200px; height: 200px; border: 0; background-color: green; " | 111 " td { width: 200px; height: 200px; border: 0; background-color: green; " |
| 105 "}" | 112 "}" |
| 106 " tr { background-color: blue; opacity: 0.5; }" | 113 " tr { background-color: blue; opacity: 0.5; }" |
| 107 " table { border: none; border-spacing: 100px; border-collapse: " | 114 " table { border: none; border-spacing: 100px; border-collapse: " |
| 108 "separate; }" | 115 "separate; }" |
| 109 "</style>" | 116 "</style>" |
| 110 "<table>" | 117 "<table>" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 123 document().view()->updateAllLifecyclePhasesExceptPaint(); | 130 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 124 // Intersects cell1 and the spacing between cell1 and cell2. | 131 // Intersects cell1 and the spacing between cell1 and cell2. |
| 125 IntRect interestRect(200, 0, 200, 200); | 132 IntRect interestRect(200, 0, 200, 200); |
| 126 paint(&interestRect); | 133 paint(&interestRect); |
| 127 | 134 |
| 128 EXPECT_DISPLAY_LIST( | 135 EXPECT_DISPLAY_LIST( |
| 129 rootPaintController().getDisplayItemList(), 7, | 136 rootPaintController().getDisplayItemList(), 7, |
| 130 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), | 137 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), |
| 131 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 138 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), |
| 132 TestDisplayItem(row, DisplayItem::kBeginCompositing), | 139 TestDisplayItem(row, DisplayItem::kBeginCompositing), |
| 133 TestDisplayItem(cell1, DisplayItem::kTableCellBackgroundFromRow), | 140 TestDisplayItem(row, DisplayItem::kBoxDecorationBackground), |
| 134 TestDisplayItem(cell1, DisplayItem::kBoxDecorationBackground), | 141 TestDisplayItem(cell1, DisplayItem::kBoxDecorationBackground), |
| 135 TestDisplayItem(row, DisplayItem::kEndCompositing), | 142 TestDisplayItem(row, DisplayItem::kEndCompositing), |
| 136 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | 143 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); |
| 137 | 144 |
| 138 document().view()->updateAllLifecyclePhasesExceptPaint(); | 145 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 139 // Intersects the spacing only. | 146 // Intersects the spacing only. |
| 140 interestRect = IntRect(300, 0, 100, 100); | 147 interestRect = IntRect(300, 0, 100, 100); |
| 141 paint(&interestRect); | 148 paint(&interestRect); |
| 142 | 149 |
| 143 EXPECT_DISPLAY_LIST( | 150 EXPECT_DISPLAY_LIST( |
| 144 rootPaintController().getDisplayItemList(), 3, | 151 rootPaintController().getDisplayItemList(), 3, |
| 145 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), | 152 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), |
| 146 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 153 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), |
| 147 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | 154 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); |
| 148 | 155 |
| 149 document().view()->updateAllLifecyclePhasesExceptPaint(); | 156 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 150 // Intersects cell2 only. | 157 // Intersects cell2 only. |
| 151 interestRect = IntRect(450, 0, 200, 200); | 158 interestRect = IntRect(450, 0, 200, 200); |
| 152 paint(&interestRect); | 159 paint(&interestRect); |
| 153 | 160 |
| 154 EXPECT_DISPLAY_LIST( | 161 EXPECT_DISPLAY_LIST( |
| 155 rootPaintController().getDisplayItemList(), 7, | 162 rootPaintController().getDisplayItemList(), 7, |
| 156 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), | 163 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), |
| 157 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 164 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), |
| 158 TestDisplayItem(row, DisplayItem::kBeginCompositing), | 165 TestDisplayItem(row, DisplayItem::kBeginCompositing), |
| 159 TestDisplayItem(cell2, DisplayItem::kTableCellBackgroundFromRow), | 166 TestDisplayItem(row, DisplayItem::kBoxDecorationBackground), |
| 160 TestDisplayItem(cell2, DisplayItem::kBoxDecorationBackground), | 167 TestDisplayItem(cell2, DisplayItem::kBoxDecorationBackground), |
| 161 TestDisplayItem(row, DisplayItem::kEndCompositing), | 168 TestDisplayItem(row, DisplayItem::kEndCompositing), |
| 162 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | 169 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); |
| 163 } | 170 } |
| 164 | 171 |
| 165 TEST_F(TableCellPainterTest, CollapsedBorderAndOverflow) { | 172 TEST_F(TablePainterTest, CollapsedBorderAndOverflow) { |
| 166 setBodyInnerHTML( | 173 setBodyInnerHTML( |
| 167 "<style>" | 174 "<style>" |
| 168 " body { margin: 0 }" | 175 " body { margin: 0 }" |
| 169 " td { width: 100px; height: 100px; border: 100px solid blue; outline: " | 176 " td { width: 100px; height: 100px; border: 100px solid blue; outline: " |
| 170 "100px solid yellow; background: green; }" | 177 "100px solid yellow; background: green; }" |
| 171 " table { margin: 100px; border-collapse: collapse; }" | 178 " table { margin: 100px; border-collapse: collapse; }" |
| 172 "</style>" | 179 "</style>" |
| 173 "<table>" | 180 "<table>" |
| 174 " <tr><td id='cell'></td></tr>" | 181 " <tr><td id='cell'></td></tr>" |
| 175 "</table>"); | 182 "</table>"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 187 EXPECT_DISPLAY_LIST( | 194 EXPECT_DISPLAY_LIST( |
| 188 rootPaintController().getDisplayItemList(), 4, | 195 rootPaintController().getDisplayItemList(), 4, |
| 189 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), | 196 TestDisplayItem(layoutView, DisplayItem::kDocumentBackground), |
| 190 TestDisplayItem(cell, DisplayItem::kBoxDecorationBackground), | 197 TestDisplayItem(cell, DisplayItem::kBoxDecorationBackground), |
| 191 TestDisplayItem(cell, DisplayItem::kTableCollapsedBorderLast), | 198 TestDisplayItem(cell, DisplayItem::kTableCollapsedBorderLast), |
| 192 TestDisplayItem(cell, DisplayItem::paintPhaseToDrawingType( | 199 TestDisplayItem(cell, DisplayItem::paintPhaseToDrawingType( |
| 193 PaintPhaseSelfOutlineOnly))); | 200 PaintPhaseSelfOutlineOnly))); |
| 194 } | 201 } |
| 195 | 202 |
| 196 } // namespace blink | 203 } // namespace blink |
| OLD | NEW |