Bug 403519: Support cells w/ prefWidth=nscoord_MAX when computing column intrinsic widths. r+sr=roc, a=mtschrep
authordholbert@cs.stanford.edu
Mon, 12 Nov 2007 17:11:20 -0800
changeset 7882 bb89f72d29c58f064944894a2aebea9084223d24
parent 7881 ccb150c83218fe8f138064b298f4fa616e93f2cf
child 7883 841461f0a87fe79ab05b77b65c96f5cb06daa508
push idunknown
push userunknown
push dateunknown
reviewersmtschrep
bugs403519
milestone1.9b2pre
Bug 403519: Support cells w/ prefWidth=nscoord_MAX when computing column intrinsic widths. r+sr=roc, a=mtschrep
layout/tables/BasicTableLayoutStrategy.cpp
--- a/layout/tables/BasicTableLayoutStrategy.cpp
+++ b/layout/tables/BasicTableLayoutStrategy.cpp
@@ -370,33 +370,38 @@ BasicTableLayoutStrategy::ComputeColumnI
                 if (!scolFrame) {
                     NS_ERROR("column frames out of sync with cell map");
                     continue;
                 }
 
                 if (mTableFrame->GetNumCellsOriginatingInCol(scol) &&
                     scol != col) {
                     info.minCoord -= spacing;
-                    info.prefCoord -= spacing;
+                    info.prefCoord = NSCoordSaturatingSubtract(info.prefCoord,
+                                                               spacing,
+                                                               nscoord_MAX);
                 }
 
                 totalSPref += scolFrame->GetPrefCoord();
                 totalSMin += scolFrame->GetMinCoord();
                 if (!scolFrame->GetHasSpecifiedCoord()) {
                     totalSAutoPref += scolFrame->GetPrefCoord();
                 }
                 float scolPct = scolFrame->GetPrefPercent();
                 if (scolPct == 0.0f) {
                     totalSNonPctPref += scolFrame->GetPrefCoord();
                     ++nonPctCount;
                 } else {
                     info.prefPercent -= scolPct;
                 }
                 info.minCoord -= scolFrame->GetMinCoord();
-                info.prefCoord -= scolFrame->GetPrefCoord();
+                info.prefCoord = 
+                    NSCoordSaturatingSubtract(info.prefCoord,
+                                              scolFrame->GetPrefCoord(),
+                                              nscoord_MAX);
             }
 
             if (info.minCoord < 0)
                 info.minCoord = 0;
             if (info.prefCoord < 0)
                 info.prefCoord = 0;
             if (info.prefPercent < 0.0f)
                 info.prefPercent = 0.0f;
@@ -491,17 +496,19 @@ BasicTableLayoutStrategy::ComputeColumnI
                 nscoord allocatedMinOutsidePref =
                     NSToCoordRound(float(minOutsidePref) * coordRatio);
                 nscoord allocatedPref = 
                     (info.prefCoord == nscoord_MAX ? 
                      nscoord_MAX : 
                      NSToCoordRound(float(info.prefCoord) * coordRatio));
                 nscoord spanMin = scolFrame->GetMinCoord() +
                         allocatedMinWithinPref + allocatedMinOutsidePref;
-                nscoord spanPref = scolFrame->GetPrefCoord() + allocatedPref;
+                nscoord spanPref = 
+                    NSCoordSaturatingAdd(scolFrame->GetPrefCoord(),
+                                         allocatedPref);
                 scolFrame->AddSpanCoords(spanMin, spanPref,
                                          info.hasSpecifiedWidth);
 
                 // To avoid accumulating rounding error from division,
                 // subtract everything to do with the column we've
                 // passed from the totals.
                 minWithinPref -= allocatedMinWithinPref;
                 minOutsidePref -= allocatedMinOutsidePref;