From d69e62a8fd6c27bc384c4a08faac589b2b7a19f5 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Thu, 18 Feb 2021 20:41:40 +0000 Subject: [PATCH] Bug 1692607 - Make table columns without an originating cell have cell spacing if their corresponding has a non-zero definite computed size/min-size. r=dholbert Differential Revision: https://phabricator.services.mozilla.com/D105543 --- ...444928-3-notref.html => 444928-3-ref.html} | 0 layout/reftests/bugs/reftest.list | 2 +- layout/tables/nsTableFrame.cpp | 36 +++- .../html5-table-formatting-2.html.ini | 7 - .../col-definite-max-size-001-ref.html | 131 +++++++++++++ .../css-tables/col-definite-max-size-001.html | 172 ++++++++++++++++++ .../css-tables/col-definite-min-size-001.html | 67 +++++++ .../css-tables/col-definite-size-001-ref.html | 45 +++++ .../css/css-tables/col-definite-size-001.html | 67 +++++++ 9 files changed, 513 insertions(+), 14 deletions(-) rename layout/reftests/bugs/{444928-3-notref.html => 444928-3-ref.html} (100%) delete mode 100644 testing/web-platform/meta/css/css-tables/html5-table-formatting-2.html.ini create mode 100644 testing/web-platform/tests/css/css-tables/col-definite-max-size-001-ref.html create mode 100644 testing/web-platform/tests/css/css-tables/col-definite-max-size-001.html create mode 100644 testing/web-platform/tests/css/css-tables/col-definite-min-size-001.html create mode 100644 testing/web-platform/tests/css/css-tables/col-definite-size-001-ref.html create mode 100644 testing/web-platform/tests/css/css-tables/col-definite-size-001.html diff --git a/layout/reftests/bugs/444928-3-notref.html b/layout/reftests/bugs/444928-3-ref.html similarity index 100% rename from layout/reftests/bugs/444928-3-notref.html rename to layout/reftests/bugs/444928-3-ref.html diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index 4f79f78199dc..9ef76219ddea 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1138,7 +1138,7 @@ fuzzy-if(skiaContent,0-1,0-3) == 442542-1.html 442542-1-ref.html == 444375-1.html 444375-1-ref.html == 444928-1.html 444928-1-ref.html == 444928-2.html 444928-2-ref.html -!= 444928-3.html 444928-3-notref.html +== 444928-3.html 444928-3-ref.html random == 445004-1.html 445004-1-ref.html # bug 472268 == 445142-1a.html 445142-1-ref.html == 445142-1b.html 445142-1-ref.html diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 36a1ef5583af..7168721558ec 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -3871,14 +3871,38 @@ void nsTableFrame::Dump(bool aDumpRows, bool aDumpCols, bool aDumpCellMap) { #endif bool nsTableFrame::ColumnHasCellSpacingBefore(int32_t aColIndex) const { + if (aColIndex == 0) { + return true; + } // Since fixed-layout tables should not have their column sizes change // as they load, we assume that all columns are significant. - if (LayoutStrategy()->GetType() == nsITableLayoutStrategy::Fixed) return true; - // the first column is always significant - if (aColIndex == 0) return true; - nsTableCellMap* cellMap = GetCellMap(); - if (!cellMap) return false; - return cellMap->GetNumCellsOriginatingInCol(aColIndex) > 0; + auto* fif = static_cast(FirstInFlow()); + if (fif->LayoutStrategy()->GetType() == nsITableLayoutStrategy::Fixed) { + return true; + } + nsTableCellMap* cellMap = fif->GetCellMap(); + if (!cellMap) { + return false; + } + if (cellMap->GetNumCellsOriginatingInCol(aColIndex) > 0) { + return true; + } + // Check if we have a element with a non-zero definite inline size. + // Note: percentages and calc(%) are intentionally not considered. + if (const auto* col = fif->GetColFrame(aColIndex)) { + const auto& iSize = col->StylePosition()->ISize(GetWritingMode()); + if (iSize.ConvertsToLength() && iSize.ToLength() > 0) { + const auto& maxISize = col->StylePosition()->MaxISize(GetWritingMode()); + if (!maxISize.ConvertsToLength() || maxISize.ToLength() > 0) { + return true; + } + } + const auto& minISize = col->StylePosition()->MinISize(GetWritingMode()); + if (minISize.ConvertsToLength() && minISize.ToLength() > 0) { + return true; + } + } + return false; } /******************************************************************************** diff --git a/testing/web-platform/meta/css/css-tables/html5-table-formatting-2.html.ini b/testing/web-platform/meta/css/css-tables/html5-table-formatting-2.html.ini deleted file mode 100644 index 8113f79bccac..000000000000 --- a/testing/web-platform/meta/css/css-tables/html5-table-formatting-2.html.ini +++ /dev/null @@ -1,7 +0,0 @@ -[html5-table-formatting-2.html] - [Border-spacing is added between any two unmerged columns (1)] - expected: FAIL - - [Border-spacing is added between any two unmerged columns (5)] - expected: FAIL - diff --git a/testing/web-platform/tests/css/css-tables/col-definite-max-size-001-ref.html b/testing/web-platform/tests/css/css-tables/col-definite-max-size-001-ref.html new file mode 100644 index 000000000000..835113b2e61d --- /dev/null +++ b/testing/web-platform/tests/css/css-tables/col-definite-max-size-001-ref.html @@ -0,0 +1,131 @@ + + + + + + + + + + +
12
+ + + + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + + + +
12
+ + + + + + + + +
12
+ + + + + + + + +
12
+ + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + +
12
+ + + + + + + + +
12
+ + + + + + + + +
12
diff --git a/testing/web-platform/tests/css/css-tables/col-definite-max-size-001.html b/testing/web-platform/tests/css/css-tables/col-definite-max-size-001.html new file mode 100644 index 000000000000..bcd7ca2fd89c --- /dev/null +++ b/testing/web-platform/tests/css/css-tables/col-definite-max-size-001.html @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
diff --git a/testing/web-platform/tests/css/css-tables/col-definite-min-size-001.html b/testing/web-platform/tests/css/css-tables/col-definite-min-size-001.html new file mode 100644 index 000000000000..7fb6632eec48 --- /dev/null +++ b/testing/web-platform/tests/css/css-tables/col-definite-min-size-001.html @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
diff --git a/testing/web-platform/tests/css/css-tables/col-definite-size-001-ref.html b/testing/web-platform/tests/css/css-tables/col-definite-size-001-ref.html new file mode 100644 index 000000000000..7f666ef0a397 --- /dev/null +++ b/testing/web-platform/tests/css/css-tables/col-definite-size-001-ref.html @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + +
12
+ + + + + + + + +
12
+ + + + + + + + +
12
+ + + + + + + + +
12
diff --git a/testing/web-platform/tests/css/css-tables/col-definite-size-001.html b/testing/web-platform/tests/css/css-tables/col-definite-size-001.html new file mode 100644 index 000000000000..7f30417557fb --- /dev/null +++ b/testing/web-platform/tests/css/css-tables/col-definite-size-001.html @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12
+ + + + + + + + + + + + + + +
12