Index: third_party/WebKit/Source/core/layout/LayoutTableRowTest.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableRowTest.cpp b/third_party/WebKit/Source/core/layout/LayoutTableRowTest.cpp |
index 2e37b0d81f64a822b228c717454820a36a5ab8eb..f5bf70daf33e666c39404666986a178a6eae441f 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutTableRowTest.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutTableRowTest.cpp |
@@ -70,54 +70,102 @@ TEST_F(LayoutTableRowDeathTest, CrashIfSettingUnsetRowIndex) { |
#endif |
-using LayoutTableRowTest = RenderingTest; |
+class LayoutTableRowTest : public RenderingTest { |
+ protected: |
+ LayoutTableRow* GetRowByElementId(const char* id) { |
+ return ToLayoutTableRow(GetLayoutObjectByElementId(id)); |
+ } |
+}; |
TEST_F(LayoutTableRowTest, |
BackgroundIsKnownToBeOpaqueWithLayerAndCollapsedBorder) { |
SetBodyInnerHTML( |
"<table style='border-collapse: collapse'>" |
- "<tr style='will-change: transform; background-color: " |
- "blue'><td>Cell</td></tr>" |
+ " <tr id='row' style='will-change: transform;" |
+ " background-color: blue'>" |
+ " <td>Cell</td>" |
+ " </tr>" |
"</table>"); |
- LayoutTableRow* row = ToLayoutTableRow(GetDocument() |
- .body() |
- ->firstChild() |
- ->firstChild() |
- ->firstChild() |
- ->GetLayoutObject()); |
- EXPECT_FALSE(row->BackgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1))); |
+ EXPECT_FALSE(GetRowByElementId("row")->BackgroundIsKnownToBeOpaqueInRect( |
+ LayoutRect(0, 0, 1, 1))); |
} |
TEST_F(LayoutTableRowTest, BackgroundIsKnownToBeOpaqueWithBorderSpacing) { |
SetBodyInnerHTML( |
"<table style='border-spacing: 10px'>" |
- "<tr style='background-color: blue'><td>Cell</td></tr>" |
+ " <tr id='row' style='background-color: blue'><td>Cell</td></tr>" |
"</table>"); |
- LayoutTableRow* row = ToLayoutTableRow(GetDocument() |
- .body() |
- ->firstChild() |
- ->firstChild() |
- ->firstChild() |
- ->GetLayoutObject()); |
- EXPECT_FALSE(row->BackgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1))); |
+ EXPECT_FALSE(GetRowByElementId("row")->BackgroundIsKnownToBeOpaqueInRect( |
+ LayoutRect(0, 0, 1, 1))); |
} |
TEST_F(LayoutTableRowTest, BackgroundIsKnownToBeOpaqueWithEmptyCell) { |
SetBodyInnerHTML( |
"<table style='border-spacing: 10px'>" |
- "<tr style='background-color: blue'><td>Cell</td></tr>" |
- "<tr style='background-color: blue'><td>Cell</td><td>Cell</td></tr>" |
+ " <tr id='row' style='background-color: blue'><td>Cell</td></tr>" |
+ " <tr style='background-color: blue'><td>Cell</td><td>Cell</td></tr>" |
+ "</table>"); |
+ |
+ EXPECT_FALSE(GetRowByElementId("row")->BackgroundIsKnownToBeOpaqueInRect( |
+ LayoutRect(0, 0, 1, 1))); |
+} |
+ |
+TEST_F(LayoutTableRowTest, VisualOverflow) { |
+ // +---+---+---+ |
+ // | A | | | row1 |
+ // |---| B | |---+ |
+ // | D | | C | | row2 |
+ // |---|---| | E | |
+ // | F | | | | row3 |
+ // +---+ +---+---+ |
+ // Cell D has an outline which creates overflow. |
+ SetBodyInnerHTML( |
+ "<style>" |
+ " td { width: 100px; height: 100px; padding: 0 }" |
+ "</style>" |
+ "<table style='border-spacing: 10px'>" |
+ " <tr id='row1'>" |
+ " <td>A</td>" |
+ " <td rowspan='2'>B</td>" |
+ " <td rowspan='3'>C</td>" |
+ " </tr>" |
+ " <tr id='row2'>" |
+ " <td style='outline: 10px solid blue'>D</td>" |
+ " <td rowspan='2'>E</td>" |
+ " </tr>" |
+ " <tr id='row3'>" |
+ " <td>F</td>" |
+ " </tr>" |
+ "</table>"); |
+ |
+ auto* row1 = GetRowByElementId("row1"); |
+ EXPECT_EQ(LayoutRect(120, 0, 210, 320), row1->ContentsVisualOverflowRect()); |
+ EXPECT_EQ(LayoutRect(0, 0, 450, 320), row1->SelfVisualOverflowRect()); |
+ |
+ auto* row2 = GetRowByElementId("row2"); |
+ EXPECT_EQ(LayoutRect(0, -10, 440, 220), row2->ContentsVisualOverflowRect()); |
+ EXPECT_EQ(LayoutRect(0, 0, 450, 210), row2->SelfVisualOverflowRect()); |
+ |
+ auto* row3 = GetRowByElementId("row3"); |
+ EXPECT_EQ(LayoutRect(), row3->ContentsVisualOverflowRect()); |
+ EXPECT_EQ(LayoutRect(0, 0, 450, 100), row3->SelfVisualOverflowRect()); |
+} |
+ |
+TEST_F(LayoutTableRowTest, LayoutOverflow) { |
+ SetBodyInnerHTML( |
+ "<table style='border-spacing: 0'>" |
+ " <tr id='row'>" |
+ " <td style='100px; height: 100px; padding: 0'>" |
+ " <div style='position: relative; top: 50px; left: 50px;" |
+ " width: 100px; height: 100px'></div>" |
+ " </td>" |
+ " </tr>" |
"</table>"); |
- LayoutTableRow* row = ToLayoutTableRow(GetDocument() |
- .body() |
- ->firstChild() |
- ->firstChild() |
- ->firstChild() |
- ->GetLayoutObject()); |
- EXPECT_FALSE(row->BackgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1))); |
+ EXPECT_EQ(LayoutRect(0, 0, 150, 150), |
+ GetRowByElementId("row")->LayoutOverflowRect()); |
} |
} // anonymous namespace |