From e1b496672492857085213539d77902d23daff77f Mon Sep 17 00:00:00 2001 From: "dholbert%cs.stanford.edu" Date: Fri, 22 Feb 2008 03:25:57 +0000 Subject: [PATCH] Bug 413286: Let empty auto-width columns be expanded. r+sr=dbaron a=blocking1.9+ git-svn-id: svn://10.0.0.236/trunk@246270 18797224-902f-48f8-a5cc-f745e15eee43 --- .../layout/reftests/bugs/413286-1-ref.html | 89 +++++++++++++++ mozilla/layout/reftests/bugs/413286-1a.html | 108 ++++++++++++++++++ mozilla/layout/reftests/bugs/413286-1b.html | 108 ++++++++++++++++++ mozilla/layout/reftests/bugs/413286-1c.html | 108 ++++++++++++++++++ .../layout/reftests/bugs/413286-2-ref.html | 66 +++++++++++ mozilla/layout/reftests/bugs/413286-2a.html | 67 +++++++++++ mozilla/layout/reftests/bugs/413286-2b.html | 68 +++++++++++ mozilla/layout/reftests/bugs/413286-2c.html | 67 +++++++++++ .../layout/reftests/bugs/413286-3-ref.html | 66 +++++++++++ mozilla/layout/reftests/bugs/413286-3.html | 67 +++++++++++ .../layout/reftests/bugs/413286-4-ref.html | 66 +++++++++++ mozilla/layout/reftests/bugs/413286-4a.html | 66 +++++++++++ mozilla/layout/reftests/bugs/413286-4b.html | 70 ++++++++++++ .../layout/reftests/bugs/413286-5-ref.html | 68 +++++++++++ mozilla/layout/reftests/bugs/413286-5.html | 68 +++++++++++ .../layout/reftests/bugs/413286-6-ref.html | 48 ++++++++ mozilla/layout/reftests/bugs/413286-6.html | 51 +++++++++ mozilla/layout/reftests/bugs/reftest.list | 11 ++ .../reftests/table-width/balancing-2-ref.html | 14 +++ .../reftests/table-width/balancing-2.html | 19 ++- .../tables/BasicTableLayoutStrategy.cpp | 49 ++++++-- 21 files changed, 1334 insertions(+), 10 deletions(-) create mode 100644 mozilla/layout/reftests/bugs/413286-1-ref.html create mode 100644 mozilla/layout/reftests/bugs/413286-1a.html create mode 100644 mozilla/layout/reftests/bugs/413286-1b.html create mode 100644 mozilla/layout/reftests/bugs/413286-1c.html create mode 100644 mozilla/layout/reftests/bugs/413286-2-ref.html create mode 100644 mozilla/layout/reftests/bugs/413286-2a.html create mode 100644 mozilla/layout/reftests/bugs/413286-2b.html create mode 100644 mozilla/layout/reftests/bugs/413286-2c.html create mode 100644 mozilla/layout/reftests/bugs/413286-3-ref.html create mode 100644 mozilla/layout/reftests/bugs/413286-3.html create mode 100644 mozilla/layout/reftests/bugs/413286-4-ref.html create mode 100644 mozilla/layout/reftests/bugs/413286-4a.html create mode 100644 mozilla/layout/reftests/bugs/413286-4b.html create mode 100644 mozilla/layout/reftests/bugs/413286-5-ref.html create mode 100644 mozilla/layout/reftests/bugs/413286-5.html create mode 100644 mozilla/layout/reftests/bugs/413286-6-ref.html create mode 100644 mozilla/layout/reftests/bugs/413286-6.html diff --git a/mozilla/layout/reftests/bugs/413286-1-ref.html b/mozilla/layout/reftests/bugs/413286-1-ref.html new file mode 100644 index 00000000000..f4a464e5e67 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-1-ref.html @@ -0,0 +1,89 @@ + + + + + + With colspan: + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + Without colspan: + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + diff --git a/mozilla/layout/reftests/bugs/413286-1a.html b/mozilla/layout/reftests/bugs/413286-1a.html new file mode 100644 index 00000000000..6743a039b61 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-1a.html @@ -0,0 +1,108 @@ + + + + + + With colspan: + + + + + + +
+ + + + + + +
xxx
+ + + + + + +
xxx
+ + + + + + +
xxxxxx
+ + Without colspan: + + + + + + + +
+ + + + + + + +
xxx
+ + + + + + + +
xxx
+ + + + + + + +
xxx
+ + + + + + + +
xxxxxx
+ + + + + + + +
xxxxxx
+ + + + + + + +
xxxxxx
+ + + + + + + +
xxxxxxxxx
+ + diff --git a/mozilla/layout/reftests/bugs/413286-1b.html b/mozilla/layout/reftests/bugs/413286-1b.html new file mode 100644 index 00000000000..31ac0b6aa10 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-1b.html @@ -0,0 +1,108 @@ + + + + + + With colspan: + + + + + + +
+ + + + + + +
xxx
+ + + + + + +
xxx
+ + + + + + +
xxxxxx
+ + Without colspan: + + + + + + + +
+ + + + + + + +
xxx
+ + + + + + + +
xxx
+ + + + + + + +
xxx
+ + + + + + + +
xxxxxx
+ + + + + + + +
xxxxxx
+ + + + + + + +
xxxxxx
+ + + + + + + +
xxxxxxxxx
+ + diff --git a/mozilla/layout/reftests/bugs/413286-1c.html b/mozilla/layout/reftests/bugs/413286-1c.html new file mode 100644 index 00000000000..34761884862 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-1c.html @@ -0,0 +1,108 @@ + + + + + + With colspan: + + + + + + +
+ + + + + + +
xxx
+ + + + + + +
xxx
+ + + + + + +
xxxxxx
+ + Without colspan: + + + + + + + +
+ + + + + + + +
xxx
+ + + + + + + +
xxx
+ + + + + + + +
xxx
+ + + + + + + +
xxxxxx
+ + + + + + + +
xxxxxx
+ + + + + + + +
xxxxxx
+ + + + + + + +
xxxxxxxxx
+ + diff --git a/mozilla/layout/reftests/bugs/413286-2-ref.html b/mozilla/layout/reftests/bugs/413286-2-ref.html new file mode 100644 index 00000000000..fda91a9e6ce --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-2-ref.html @@ -0,0 +1,66 @@ + + + + Reference Case + + + +

No third column

+ + + + + + + + +
+ +

Third column with low percent width

+ + + + + + + + + + +
+ +

Third column with medium percent width

+ + + + + + + + + + +
+ +

Third column with preferred width

+ + + + + + + + + + +
+ + diff --git a/mozilla/layout/reftests/bugs/413286-2a.html b/mozilla/layout/reftests/bugs/413286-2a.html new file mode 100644 index 00000000000..8af608a05f2 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-2a.html @@ -0,0 +1,67 @@ + + + + Spanning cell has no specified width + + + +

No third column

+ + + + + + + +
+ +

Third column with low percent width

+ + + + + + + + + +
+ +

Third column with medium percent width

+ + + + + + + + + +
+ +

Third column with preferred width

+ + + + + + + + + +
+ + diff --git a/mozilla/layout/reftests/bugs/413286-2b.html b/mozilla/layout/reftests/bugs/413286-2b.html new file mode 100644 index 00000000000..d4367a937e1 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-2b.html @@ -0,0 +1,68 @@ + + + + Spanning cell has nonzero pref & min width + + + +

No third column

+ + + + + + + +
text
+ +

Third column with low percent width

+ + + + + + + + + +
text
+ +

Third column with medium percent width

+ + + + + + + + + +
text
+ +

Third column with preferred width

+ + + + + + + + + +
text
+ + diff --git a/mozilla/layout/reftests/bugs/413286-2c.html b/mozilla/layout/reftests/bugs/413286-2c.html new file mode 100644 index 00000000000..38ade8b385f --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-2c.html @@ -0,0 +1,67 @@ + + + + Spanning cell has low percent width + + + +

No third column

+ + + + + + + +
+ +

Third column with low percent width

+ + + + + + + + + +
+ +

Third column with medium percent width

+ + + + + + + + + +
+ +

Third column with preferred width

+ + + + + + + + + +
+ + diff --git a/mozilla/layout/reftests/bugs/413286-3-ref.html b/mozilla/layout/reftests/bugs/413286-3-ref.html new file mode 100644 index 00000000000..be091cdab75 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-3-ref.html @@ -0,0 +1,66 @@ + + + + Reference Case + + + +

No third column

+ + + + + + + + +
+ +

Third column with low percent width

+ + + + + + + + + + +
+ +

Third column with medium percent width

+ + + + + + + + + + +
+ +

Third column with preferred width

+ + + + + + + + + + +
+ + diff --git a/mozilla/layout/reftests/bugs/413286-3.html b/mozilla/layout/reftests/bugs/413286-3.html new file mode 100644 index 00000000000..a5bc1470298 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-3.html @@ -0,0 +1,67 @@ + + + + Spanning cell has high percent width + + + +

No third column

+ + + + + + + +
+ +

Third column with low percent width

+ + + + + + + + + +
+ +

Third column with medium percent width

+ + + + + + + + + +
+ +

Third column with preferred width

+ + + + + + + + + +
+ + diff --git a/mozilla/layout/reftests/bugs/413286-4-ref.html b/mozilla/layout/reftests/bugs/413286-4-ref.html new file mode 100644 index 00000000000..f19e6c3cd89 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-4-ref.html @@ -0,0 +1,66 @@ + + + + First two columns have no width + + + +

No third column

+ + + + + + + + +
+ +

Third column with low percent width

+ + + + + + + + + + +
+ +

Third column with medium percent width

+ + + + + + + + + + +
+ +

Third column with preferred width

+ + + + + + + + + + +
+ + diff --git a/mozilla/layout/reftests/bugs/413286-4a.html b/mozilla/layout/reftests/bugs/413286-4a.html new file mode 100644 index 00000000000..a2c53d88346 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-4a.html @@ -0,0 +1,66 @@ + + + + Span & its columns have no width + + + +

No third column

+ + + + + + + +
+ +

Third column with low percent width

+ + + + + + + + + +
+ +

Third column with medium percent width

+ + + + + + + + + +
+ +

Third column with preferred width

+ + + + + + + + + +
+ + diff --git a/mozilla/layout/reftests/bugs/413286-4b.html b/mozilla/layout/reftests/bugs/413286-4b.html new file mode 100644 index 00000000000..1c2b43efe40 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-4b.html @@ -0,0 +1,70 @@ + + + + First two columns have no width + + + +

No third column

+ + + + + + + + +
+ +

Third column with low percent width

+ + + + + + + + + + +
+ +

Third column with medium percent width

+ + + + + + + + + + +
+ +

Third column with preferred width

+ + + + + + + + + + +
+ + diff --git a/mozilla/layout/reftests/bugs/413286-5-ref.html b/mozilla/layout/reftests/bugs/413286-5-ref.html new file mode 100644 index 00000000000..70b3029542f --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-5-ref.html @@ -0,0 +1,68 @@ + + + + +

Other column fixed-width

+ + + + + +
100 +
+ +

Other column percent-width

+ + + + + +
10% +
+ +

Other column fixed-width; zero column spanned by colspan (crossing other column)

+ + + + + +
100 +
+ +

Other column percent-width; zero column spanned by colspan (crossing other column)

+ + + + + +
10% +
+ +

Other column fixed-width; two zero columns with colspan

+ + + + + +
100 +
+ +

Other column percent-width; two zero columns with colspan

+ + + + + +
10% +
+ + + diff --git a/mozilla/layout/reftests/bugs/413286-5.html b/mozilla/layout/reftests/bugs/413286-5.html new file mode 100644 index 00000000000..df72e6ede07 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-5.html @@ -0,0 +1,68 @@ + + + + +

Other column fixed-width

+ + + + + +
100 +
+ +

Other column percent-width

+ + + + + +
10% +
+ +

Other column fixed-width; zero column spanned by colspan (crossing other column)

+ + + + + + +
100 +
+ +

Other column percent-width; zero column spanned by colspan (crossing other column)

+ + + + + + +
10% +
+ +

Other column fixed-width; two zero columns with colspan

+ + + + + +
100 +
+ +

Other column percent-width; two zero columns with colspan

+ + + + + +
10% +
+ + + diff --git a/mozilla/layout/reftests/bugs/413286-6-ref.html b/mozilla/layout/reftests/bugs/413286-6-ref.html new file mode 100644 index 00000000000..65e3ae50fa8 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-6-ref.html @@ -0,0 +1,48 @@ + + + + +

Other column fixed-width; two zero columns with colspan; explicit 0 width on span

+ + + + + +
100 +
+ +

Other column percent-width; two zero columns with colspan; explicit 0 width on span

+ + + + + +
10% +
+ +

Other column fixed-width; zero-column explicitly zero-width; zero column spanned by colspan (crossing other column)

+ + + + + +
100
+ +

Other column percent-width; zero-column explicitly zero-width; zero column spanned by colspan (crossing other column)

+ + + + + +
10%
+ + + diff --git a/mozilla/layout/reftests/bugs/413286-6.html b/mozilla/layout/reftests/bugs/413286-6.html new file mode 100644 index 00000000000..2b71da8ac23 --- /dev/null +++ b/mozilla/layout/reftests/bugs/413286-6.html @@ -0,0 +1,51 @@ + + + + +

Other column fixed-width; two zero columns with colspan; explicit 0 width on span

+ + + + + +
100 +
+ +

Other column percent-width; two zero columns with colspan; explicit 0 width on span

+ + + + + +
10% +
+ +

Other column fixed-width; zero-column explicitly zero-width; zero column spanned by colspan (crossing other column)

+ + + + + + +
100 +
+ +

Other column percent-width; zero-column explicitly zero-width; zero column spanned by colspan (crossing other column)

+ + + + + + +
10% +
+ + + diff --git a/mozilla/layout/reftests/bugs/reftest.list b/mozilla/layout/reftests/bugs/reftest.list index b725ebda96c..2447225cba9 100644 --- a/mozilla/layout/reftests/bugs/reftest.list +++ b/mozilla/layout/reftests/bugs/reftest.list @@ -708,6 +708,17 @@ random == 403134-1.html 403134-1-ref.html # bug 405377 == 412607-1b.html 412607-1-ref.html == 412679-1.html 412679-1-ref.html == 412679-2.html 412679-2-ref.html +== 413286-1a.html 413286-1-ref.html +== 413286-1b.html 413286-1-ref.html +== 413286-1c.html 413286-1-ref.html +== 413286-2a.html 413286-2-ref.html +== 413286-2b.html 413286-2-ref.html +== 413286-2c.html 413286-2-ref.html +== 413286-3.html 413286-3-ref.html +== 413286-4a.html 413286-4-ref.html +== 413286-4b.html 413286-4-ref.html +== 413286-5.html 413286-5-ref.html +== 413286-6.html 413286-6-ref.html == 413292-1.html 413292-1-ref.html == 413361-1.html 413361-1-ref.html == 413840-background-unchanged.html 413840-background-unchanged-ref.html diff --git a/mozilla/layout/reftests/table-width/balancing-2-ref.html b/mozilla/layout/reftests/table-width/balancing-2-ref.html index 3b5c98b44f5..813710759b6 100644 --- a/mozilla/layout/reftests/table-width/balancing-2-ref.html +++ b/mozilla/layout/reftests/table-width/balancing-2-ref.html @@ -51,6 +51,20 @@ td { background: black; background: currentColor; }   + + + + + +
    
+ + + + + + +
    
+ diff --git a/mozilla/layout/reftests/table-width/balancing-2.html b/mozilla/layout/reftests/table-width/balancing-2.html index bb9d991248b..c43f4147674 100644 --- a/mozilla/layout/reftests/table-width/balancing-2.html +++ b/mozilla/layout/reftests/table-width/balancing-2.html @@ -57,10 +57,11 @@ span {
   
+ - +
@@ -68,11 +69,25 @@ span { - +
+ + + + + +
+ + + + + + +
+ diff --git a/mozilla/layout/tables/BasicTableLayoutStrategy.cpp b/mozilla/layout/tables/BasicTableLayoutStrategy.cpp index 6e0a265c785..2740583c681 100644 --- a/mozilla/layout/tables/BasicTableLayoutStrategy.cpp +++ b/mozilla/layout/tables/BasicTableLayoutStrategy.cpp @@ -672,13 +672,17 @@ BasicTableLayoutStrategy::DistributeWidthToColumns(nscoord aWidth, * percent width have nonzero pref width, in proportion to pref * width [total_flex_pref] * - * b. otherwise, if any columns without percent width have nonzero + * b. (NOTE: this case is for BTLS_FINAL_WIDTH only) otherwise, if any + * columns without a specified coordinate width or percent width have + * zero pref width, equally between these [numNonSpecZeroWidthCols] + * + * c. otherwise, if any columns without percent width have nonzero * pref width, in proportion to pref width [total_fixed_pref] * - * c. otherwise, if any columns have nonzero percentage widths, in + * d. otherwise, if any columns have nonzero percentage widths, in * proportion to the percentage widths [total_pct] * - * d. otherwise, equally. + * e. otherwise, equally. */ // Loop #1 over the columns, to figure out the four values above so @@ -692,6 +696,7 @@ BasicTableLayoutStrategy::DistributeWidthToColumns(nscoord aWidth, total_fixed_pref = 0; float total_pct = 0.0f; // 0.0f to 1.0f PRInt32 numInfiniteWidthCols = 0; + PRInt32 numNonSpecZeroWidthCols = 0; PRInt32 col; for (col = aFirstCol; col < aFirstCol + aColCount; ++col) { @@ -713,7 +718,7 @@ BasicTableLayoutStrategy::DistributeWidthToColumns(nscoord aWidth, } else { nscoord pref_width = colFrame->GetPrefCoord(); if (pref_width == nscoord_MAX) { - numInfiniteWidthCols++; + ++numInfiniteWidthCols; } guess_pref = NSCoordSaturatingAdd(guess_pref, pref_width); guess_min_pct += min_width; @@ -725,6 +730,10 @@ BasicTableLayoutStrategy::DistributeWidthToColumns(nscoord aWidth, guess_min_spec = NSCoordSaturatingAdd(guess_min_spec, delta); total_fixed_pref = NSCoordSaturatingAdd(total_fixed_pref, pref_width); + } else if (pref_width == 0) { + if (aWidthType == BTLS_FINAL_WIDTH) { + ++numNonSpecZeroWidthCols; + } } else { total_flex_pref = NSCoordSaturatingAdd(total_flex_pref, pref_width); @@ -739,9 +748,10 @@ BasicTableLayoutStrategy::DistributeWidthToColumns(nscoord aWidth, FLEX_FIXED_SMALL, // between (2) and (3) above FLEX_FLEX_SMALL, // between (3) and (4) above FLEX_FLEX_LARGE, // greater than (4) above, case (a) - FLEX_FIXED_LARGE, // greater than (4) above, case (b) - FLEX_PCT_LARGE, // greater than (4) above, case (c) - FLEX_ALL_LARGE // greater than (4) above, case (d) + FLEX_FLEX_LARGE_ZERO, // greater than (4) above, case (b) + FLEX_FIXED_LARGE, // greater than (4) above, case (c) + FLEX_PCT_LARGE, // greater than (4) above, case (d) + FLEX_ALL_LARGE // greater than (4) above, case (e) }; Loop2Type l2t; @@ -782,6 +792,12 @@ BasicTableLayoutStrategy::DistributeWidthToColumns(nscoord aWidth, if (total_flex_pref > 0) { l2t = FLEX_FLEX_LARGE; basis.c = total_flex_pref; + } else if (numNonSpecZeroWidthCols > 0) { + NS_ASSERTION(aWidthType == BTLS_FINAL_WIDTH, + "numNonSpecZeroWidthCols should only " + "be set when we're setting final width."); + l2t = FLEX_FLEX_LARGE_ZERO; + basis.c = numNonSpecZeroWidthCols; } else if (total_fixed_pref > 0) { l2t = FLEX_FIXED_LARGE; basis.c = total_fixed_pref; @@ -878,7 +894,7 @@ BasicTableLayoutStrategy::DistributeWidthToColumns(nscoord aWidth, if (numInfiniteWidthCols) { if (colFrame->GetPrefCoord() == nscoord_MAX) { c = c / float(numInfiniteWidthCols); - numInfiniteWidthCols--; + --numInfiniteWidthCols; } else { c = 0.0f; } @@ -908,6 +924,23 @@ BasicTableLayoutStrategy::DistributeWidthToColumns(nscoord aWidth, } } break; + case FLEX_FLEX_LARGE_ZERO: + NS_ASSERTION(aWidthType == BTLS_FINAL_WIDTH, + "FLEX_FLEX_LARGE_ZERO only should be hit " + "when we're setting final width."); + if (pct == 0.0f && + !colFrame->GetHasSpecifiedCoord()) { + + NS_ASSERTION(col_width == 0 && + colFrame->GetPrefCoord() == 0, + "Since we're in FLEX_FLEX_LARGE_ZERO case, " + "all auto-width cols should have zero pref " + "width."); + float c = float(space) / float(basis.c); + col_width += NSToCoordRound(c); + --basis.c; + } + break; case FLEX_FIXED_LARGE: if (pct == 0.0f) { NS_ASSERTION(col_width == colFrame->GetPrefCoord(),