OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 TEST_F(LayoutTableRowDeathTest, CrashIfRowOverflowOnSetting) { | 63 TEST_F(LayoutTableRowDeathTest, CrashIfRowOverflowOnSetting) { |
64 ASSERT_DEATH(row_->SetRowIndex(kMaxRowIndex + 1), ""); | 64 ASSERT_DEATH(row_->SetRowIndex(kMaxRowIndex + 1), ""); |
65 } | 65 } |
66 | 66 |
67 TEST_F(LayoutTableRowDeathTest, CrashIfSettingUnsetRowIndex) { | 67 TEST_F(LayoutTableRowDeathTest, CrashIfSettingUnsetRowIndex) { |
68 ASSERT_DEATH(row_->SetRowIndex(kUnsetRowIndex), ""); | 68 ASSERT_DEATH(row_->SetRowIndex(kUnsetRowIndex), ""); |
69 } | 69 } |
70 | 70 |
71 #endif | 71 #endif |
72 | 72 |
73 using LayoutTableRowTest = RenderingTest; | 73 class LayoutTableRowTest : public RenderingTest { |
| 74 protected: |
| 75 LayoutTableRow* GetRowByElementId(const char* id) { |
| 76 return ToLayoutTableRow(GetLayoutObjectByElementId(id)); |
| 77 } |
| 78 }; |
74 | 79 |
75 TEST_F(LayoutTableRowTest, | 80 TEST_F(LayoutTableRowTest, |
76 BackgroundIsKnownToBeOpaqueWithLayerAndCollapsedBorder) { | 81 BackgroundIsKnownToBeOpaqueWithLayerAndCollapsedBorder) { |
77 SetBodyInnerHTML( | 82 SetBodyInnerHTML( |
78 "<table style='border-collapse: collapse'>" | 83 "<table style='border-collapse: collapse'>" |
79 "<tr style='will-change: transform; background-color: " | 84 " <tr id='row' style='will-change: transform;" |
80 "blue'><td>Cell</td></tr>" | 85 " background-color: blue'>" |
| 86 " <td>Cell</td>" |
| 87 " </tr>" |
81 "</table>"); | 88 "</table>"); |
82 | 89 |
83 LayoutTableRow* row = ToLayoutTableRow(GetDocument() | 90 EXPECT_FALSE(GetRowByElementId("row")->BackgroundIsKnownToBeOpaqueInRect( |
84 .body() | 91 LayoutRect(0, 0, 1, 1))); |
85 ->firstChild() | |
86 ->firstChild() | |
87 ->firstChild() | |
88 ->GetLayoutObject()); | |
89 EXPECT_FALSE(row->BackgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1))); | |
90 } | 92 } |
91 | 93 |
92 TEST_F(LayoutTableRowTest, BackgroundIsKnownToBeOpaqueWithBorderSpacing) { | 94 TEST_F(LayoutTableRowTest, BackgroundIsKnownToBeOpaqueWithBorderSpacing) { |
93 SetBodyInnerHTML( | 95 SetBodyInnerHTML( |
94 "<table style='border-spacing: 10px'>" | 96 "<table style='border-spacing: 10px'>" |
95 "<tr style='background-color: blue'><td>Cell</td></tr>" | 97 " <tr id='row' style='background-color: blue'><td>Cell</td></tr>" |
96 "</table>"); | 98 "</table>"); |
97 | 99 |
98 LayoutTableRow* row = ToLayoutTableRow(GetDocument() | 100 EXPECT_FALSE(GetRowByElementId("row")->BackgroundIsKnownToBeOpaqueInRect( |
99 .body() | 101 LayoutRect(0, 0, 1, 1))); |
100 ->firstChild() | |
101 ->firstChild() | |
102 ->firstChild() | |
103 ->GetLayoutObject()); | |
104 EXPECT_FALSE(row->BackgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1))); | |
105 } | 102 } |
106 | 103 |
107 TEST_F(LayoutTableRowTest, BackgroundIsKnownToBeOpaqueWithEmptyCell) { | 104 TEST_F(LayoutTableRowTest, BackgroundIsKnownToBeOpaqueWithEmptyCell) { |
108 SetBodyInnerHTML( | 105 SetBodyInnerHTML( |
109 "<table style='border-spacing: 10px'>" | 106 "<table style='border-spacing: 10px'>" |
110 "<tr style='background-color: blue'><td>Cell</td></tr>" | 107 " <tr id='row' style='background-color: blue'><td>Cell</td></tr>" |
111 "<tr style='background-color: blue'><td>Cell</td><td>Cell</td></tr>" | 108 " <tr style='background-color: blue'><td>Cell</td><td>Cell</td></tr>" |
112 "</table>"); | 109 "</table>"); |
113 | 110 |
114 LayoutTableRow* row = ToLayoutTableRow(GetDocument() | 111 EXPECT_FALSE(GetRowByElementId("row")->BackgroundIsKnownToBeOpaqueInRect( |
115 .body() | 112 LayoutRect(0, 0, 1, 1))); |
116 ->firstChild() | 113 } |
117 ->firstChild() | 114 |
118 ->firstChild() | 115 TEST_F(LayoutTableRowTest, VisualOverflow) { |
119 ->GetLayoutObject()); | 116 // +---+---+---+ |
120 EXPECT_FALSE(row->BackgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1))); | 117 // | A | | | row1 |
| 118 // |---| B | |---+ |
| 119 // | D | | C | | row2 |
| 120 // |---|---| | E | |
| 121 // | F | | | | row3 |
| 122 // +---+ +---+---+ |
| 123 // Cell D has an outline which creates overflow. |
| 124 SetBodyInnerHTML( |
| 125 "<style>" |
| 126 " td { width: 100px; height: 100px; padding: 0 }" |
| 127 "</style>" |
| 128 "<table style='border-spacing: 10px'>" |
| 129 " <tr id='row1'>" |
| 130 " <td>A</td>" |
| 131 " <td rowspan='2'>B</td>" |
| 132 " <td rowspan='3'>C</td>" |
| 133 " </tr>" |
| 134 " <tr id='row2'>" |
| 135 " <td style='outline: 10px solid blue'>D</td>" |
| 136 " <td rowspan='2'>E</td>" |
| 137 " </tr>" |
| 138 " <tr id='row3'>" |
| 139 " <td>F</td>" |
| 140 " </tr>" |
| 141 "</table>"); |
| 142 |
| 143 auto* row1 = GetRowByElementId("row1"); |
| 144 EXPECT_EQ(LayoutRect(120, 0, 210, 320), row1->ContentsVisualOverflowRect()); |
| 145 EXPECT_EQ(LayoutRect(0, 0, 450, 320), row1->SelfVisualOverflowRect()); |
| 146 |
| 147 auto* row2 = GetRowByElementId("row2"); |
| 148 EXPECT_EQ(LayoutRect(0, -10, 440, 220), row2->ContentsVisualOverflowRect()); |
| 149 EXPECT_EQ(LayoutRect(0, 0, 450, 210), row2->SelfVisualOverflowRect()); |
| 150 |
| 151 auto* row3 = GetRowByElementId("row3"); |
| 152 EXPECT_EQ(LayoutRect(), row3->ContentsVisualOverflowRect()); |
| 153 EXPECT_EQ(LayoutRect(0, 0, 450, 100), row3->SelfVisualOverflowRect()); |
| 154 } |
| 155 |
| 156 TEST_F(LayoutTableRowTest, LayoutOverflow) { |
| 157 SetBodyInnerHTML( |
| 158 "<table style='border-spacing: 0'>" |
| 159 " <tr id='row'>" |
| 160 " <td style='100px; height: 100px; padding: 0'>" |
| 161 " <div style='position: relative; top: 50px; left: 50px;" |
| 162 " width: 100px; height: 100px'></div>" |
| 163 " </td>" |
| 164 " </tr>" |
| 165 "</table>"); |
| 166 |
| 167 EXPECT_EQ(LayoutRect(0, 0, 150, 150), |
| 168 GetRowByElementId("row")->LayoutOverflowRect()); |
121 } | 169 } |
122 | 170 |
123 } // anonymous namespace | 171 } // anonymous namespace |
124 | 172 |
125 } // namespace blink | 173 } // namespace blink |
OLD | NEW |