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
authorL. David Baron <dbaron@dbaron.org>
Wed, 17 Aug 2011 17:54:59 -0700
changeset 75436 4789623b77f2e792c0d348f25598f361736ba168
parent 75435 d5c8e4c01f13cd5c8e0f04e6b0c7af7e393a6015
child 75437 c54c3b67c10288c7ef0013a6cb17340cb9fe20cd
push id1290
push userdbaron@mozilla.com
push dateThu, 18 Aug 2011 00:56:24 +0000
treeherdermozilla-inbound@4789623b77f2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs677091
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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 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) {