Bug 403579: Don't scale up width by a pct when it's nscoord_MAX. Also, use NSCoordSaturating function with guess_pref since it could be nscoord_MAX. r+sr=roc, a=mtschrep
authordholbert@cs.stanford.edu
Thu, 15 Nov 2007 10:04:16 -0800
changeset 8042 99b6c36ac21a904a315a85e5e99335feeb7bdec3
parent 8041 de94472e93a93eac40b54fc1aecd50e158320e0c
child 8043 19a74abd50b038257bcdd96d8f2a9bcb8eeab684
push idunknown
push userunknown
push dateunknown
reviewersmtschrep
bugs403579
milestone1.9b2pre
Bug 403579: Don't scale up width by a pct when it's nscoord_MAX. Also, use NSCoordSaturating function with guess_pref since it could be nscoord_MAX. r+sr=roc, a=mtschrep
layout/tables/BasicTableLayoutStrategy.cpp
--- a/layout/tables/BasicTableLayoutStrategy.cpp
+++ b/layout/tables/BasicTableLayoutStrategy.cpp
@@ -641,18 +641,20 @@ BasicTableLayoutStrategy::ComputeIntrins
                  "column percentage widths not adjusted down to 100%");
     if (pct_total == 1.0f) {
         if (nonpct_pref_total > 0) {
             pref_pct_expand = nscoord_MAX;
             // XXX Or should I use some smaller value?  (Test this using
             // nested tables!)
         }
     } else {
-        nscoord large_pct_pref = nscoord(float(nonpct_pref_total) /
-                                         (1.0f - pct_total));
+        nscoord large_pct_pref =
+            (nonpct_pref_total == nscoord_MAX ?
+             nscoord_MAX :
+             nscoord(float(nonpct_pref_total) / (1.0f - pct_total)));
         if (large_pct_pref > pref_pct_expand)
             pref_pct_expand = large_pct_pref;
     }
 
     // border-spacing isn't part of the basis for percentages
     if (colCount > 0) {
         min += add;
         pref = NSCoordSaturatingAdd(pref, add);
@@ -777,17 +779,17 @@ BasicTableLayoutStrategy::ComputeColumnW
         guess_min += min_width;
         if (colFrame->GetPrefPercent() != 0.0f) {
             float pct = colFrame->GetPrefPercent();
             total_pct += pct;
             nscoord val = nscoord(float(width) * pct);
             if (val < min_width)
                 val = min_width;
             guess_min_pct += val;
-            guess_pref += val;
+            guess_pref = NSCoordSaturatingAdd(guess_pref, val);
         } else {
             nscoord pref_width = colFrame->GetPrefCoord();
             if (pref_width == nscoord_MAX) {
                 numInfiniteWidthCols++;
             }
             guess_pref = NSCoordSaturatingAdd(guess_pref, pref_width);
             guess_min_pct += min_width;
             if (colFrame->GetHasSpecifiedCoord()) {