Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutTableRowTest.cpp

Issue 2861653006: Fix LayoutTableRow::AddOverflowFromCell() (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..027ef973c655e8a549923008b967635b8a7a9a52 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTableRowTest.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTableRowTest.cpp
@@ -70,54 +70,81 @@ 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, ContentsVisualOverflowCellRowSpan) {
+ // +---+---+---+
+ // | | | | row1
+ // | |---| |
+ // | | | | row2
+ // |---| | |
+ // | | | | row3
+ // +---+---+---+
+ SetBodyInnerHTML(
+ "<style>"
+ " td { width: 100px; height: 100px; padding: 0; background: blue }"
+ "</style>"
+ "<table style='border-spacing: 0'>"
+ " <tr id='row1'>"
+ " <td rowspan='2'></td><td></td><td rowspan='3'></td>"
+ " </tr>"
+ " <tr id='row2'>"
+ " <td rowspan='2'></td>"
+ " </tr>"
+ " <tr id='row3'>"
+ " <td></td>"
+ " </tr>"
"</table>");
- LayoutTableRow* row = ToLayoutTableRow(GetDocument()
- .body()
- ->firstChild()
- ->firstChild()
- ->firstChild()
- ->GetLayoutObject());
- EXPECT_FALSE(row->BackgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1)));
+ // The left cell with rowspan=2 and the right cell with rowspan=3.
+ EXPECT_EQ(LayoutRect(0, 0, 300, 300),
+ GetRowByElementId("row1")->ContentsVisualOverflowRect());
+ // The middle cell with rowspan=2.
+ EXPECT_EQ(LayoutRect(100, 0, 100, 200),
+ GetRowByElementId("row2")->ContentsVisualOverflowRect());
+ // No cell overflow.
+ EXPECT_EQ(LayoutRect(),
+ GetRowByElementId("row3")->ContentsVisualOverflowRect());
}
} // anonymous namespace

Powered by Google App Engine
This is Rietveld 408576698