Clamp the result to the valid nscoord range. b=541869 r=roc
authorMats Palmgren <matspal@gmail.com>
Wed, 27 Jan 2010 09:35:41 +0100
changeset 37535 5f631340007c22da2d33ddcd06810f989b4718a2
parent 37534 f155f30508750f0856eabf2bc0934b6c4c8e2b2b
child 37536 bcd9709de08a36b136670cd6c94a867b1e6ff0ea
push id11363
push usermpalmgren@mozilla.com
push dateWed, 27 Jan 2010 08:35:53 +0000
treeherdermozilla-central@5f631340007c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs541869
milestone1.9.3a1pre
Clamp the result to the valid nscoord range. b=541869 r=roc
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -2186,17 +2186,18 @@ nsLayoutUtils::ComputeWidthDependentValu
 {
   NS_PRECONDITION(aContainingBlockWidth != NS_UNCONSTRAINEDSIZE,
                   "unconstrained widths no longer supported");
 
   if (eStyleUnit_Coord == aCoord.GetUnit()) {
     return aCoord.GetCoordValue();
   }
   if (eStyleUnit_Percent == aCoord.GetUnit()) {
-    return NSToCoordFloor(aContainingBlockWidth * aCoord.GetPercentValue());
+    return NSToCoordFloorClamped(aContainingBlockWidth *
+                                 aCoord.GetPercentValue());
   }
   NS_ASSERTION(aCoord.GetUnit() == eStyleUnit_None ||
                aCoord.GetUnit() == eStyleUnit_Auto,
                "unexpected width value");
   return 0;
 }
 
 /* static */ nscoord
@@ -2219,17 +2220,18 @@ nsLayoutUtils::ComputeWidthValue(
 
   nscoord result;
   if (eStyleUnit_Coord == aCoord.GetUnit()) {
     result = aCoord.GetCoordValue();
     NS_ASSERTION(result >= 0, "width less than zero");
     result -= aContentEdgeToBoxSizing;
   } else if (eStyleUnit_Percent == aCoord.GetUnit()) {
     NS_ASSERTION(aCoord.GetPercentValue() >= 0.0f, "width less than zero");
-    result = NSToCoordFloor(aContainingBlockWidth * aCoord.GetPercentValue()) -
+    result = NSToCoordFloorClamped(aContainingBlockWidth *
+                                   aCoord.GetPercentValue()) -
              aContentEdgeToBoxSizing;
   } else if (eStyleUnit_Enumerated == aCoord.GetUnit()) {
     PRInt32 val = aCoord.GetIntValue();
     switch (val) {
       case NS_STYLE_WIDTH_MAX_CONTENT:
         result = aFrame->GetPrefWidth(aRenderingContext);
         NS_ASSERTION(result >= 0, "width less than zero");
         break;
@@ -2276,17 +2278,18 @@ nsLayoutUtils::ComputeHeightDependentVal
     // be inside the percentage case.  However, it would be much more
     // likely to catch problems if it were at the start of the function.
     // XXXldb Many callers pass a non-'auto' containing block height when
     // according to CSS2.1 they should be passing 'auto'.
     NS_PRECONDITION(NS_AUTOHEIGHT != aContainingBlockHeight,
                     "unexpected 'containing block height'");
 
     if (NS_AUTOHEIGHT != aContainingBlockHeight) {
-      return NSToCoordFloor(aContainingBlockHeight * aCoord.GetPercentValue());
+      return NSToCoordFloorClamped(aContainingBlockHeight *
+                                   aCoord.GetPercentValue());
     }
   }
   NS_ASSERTION(aCoord.GetUnit() == eStyleUnit_None ||
                aCoord.GetUnit() == eStyleUnit_Auto,
                "unexpected height value");
   return 0;
 }