Fix nsLayoutUtils::ComputeSizeWithIntrinsicDimensions to produce correct results when one of the tentative height/width (i.e., the intrinsic height/width) is 0. (Bug 677091) r=roc approval-mozilla-aurora=asa
authorL. David Baron <dbaron@dbaron.org>
Wed, 17 Aug 2011 17:54:59 -0700
changeset 76170 620e3bda721bf3fde4456288bac4ea548f7c5833
parent 76169 ebff1f7b2beecac6bc554588798f3b7521df1253
child 76171 9efe51ddbfb0b68070f2a1be3cb8b5cfd20f641f
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs677091
milestone8.0a2
Fix nsLayoutUtils::ComputeSizeWithIntrinsicDimensions to produce correct results when one of the tentative height/width (i.e., the intrinsic height/width) is 0. (Bug 677091) r=roc approval-mozilla-aurora=asa When either the intrinsic width or the intrinsic height is 0, the element does not have an intrinsic ratio, and thus the table that ComputeAutoSizeWithIntrinsicDimensions is implementing technically doesn't apply. However, it can quite straightforwardly produce the correct results despite that, if we correctly apply the min/max-width/height properties.
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -2757,30 +2757,28 @@ nsLayoutUtils::ComputeAutoSizeWithIntrin
   if (tentWidth > 0) {
     heightAtMaxWidth = MULDIV(maxWidth, tentHeight, tentWidth);
     if (heightAtMaxWidth < minHeight)
       heightAtMaxWidth = minHeight;
     heightAtMinWidth = MULDIV(minWidth, tentHeight, tentWidth);
     if (heightAtMinWidth > maxHeight)
       heightAtMinWidth = maxHeight;
   } else {
-    heightAtMaxWidth = tentHeight;
-    heightAtMinWidth = tentHeight;
+    heightAtMaxWidth = heightAtMinWidth = NS_CSS_MINMAX(tentHeight, minHeight, maxHeight);
   }
 
   if (tentHeight > 0) {
     widthAtMaxHeight = MULDIV(maxHeight, tentWidth, tentHeight);
     if (widthAtMaxHeight < minWidth)
       widthAtMaxHeight = minWidth;
     widthAtMinHeight = MULDIV(minHeight, tentWidth, tentHeight);
     if (widthAtMinHeight > maxWidth)
       widthAtMinHeight = maxWidth;
   } else {
-    widthAtMaxHeight = tentWidth;
-    widthAtMinHeight = tentWidth;
+    widthAtMaxHeight = widthAtMinHeight = NS_CSS_MINMAX(tentWidth, minWidth, maxWidth);
   }
 
   // The table at http://www.w3.org/TR/CSS21/visudet.html#min-max-widths :
 
   nscoord width, height;
 
   if (tentWidth > maxWidth) {
     if (tentHeight > maxHeight) {