Bug 1187846 Stack layout doesn't honour min/max sizes for positioned elements r=Enn
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Fri, 31 Jul 2015 23:21:28 +0100
changeset 287415 71d335f1a4a3fe6aa24b933eb35e8b6592f2dae7
parent 287414 51d2109c72dcb27394e043c0390bdc982c2771de
child 287416 37ce03221f95f5f147ae1daae7dbf604565bd702
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEnn
bugs1187846
milestone42.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
Bug 1187846 Stack layout doesn't honour min/max sizes for positioned elements r=Enn
layout/xul/nsStackLayout.cpp
--- a/layout/xul/nsStackLayout.cpp
+++ b/layout/xul/nsStackLayout.cpp
@@ -293,47 +293,49 @@ nsStackLayout::Layout(nsIFrame* aBox, ns
           //   left only - offset from left edge, preferred width
           //   right only - offset from right edge, preferred width
           //   left and right - offset from left and right edges, width in between this
           //   neither - no offset, full width of stack
           // Vertical direction is similar.
           //
           // Margins on the child are also included in the edge offsets
           if (offsetSpecified) {
+            nsSize min = child->GetMinSize(aState);
+            nsSize max = child->GetMaxSize(aState);
             if (offsetSpecified & SPECIFIED_LEFT) {
               childRect.x = clientRect.x + offset.left + margin.left;
               if (offsetSpecified & SPECIFIED_RIGHT) {
-                nsSize min = child->GetMinSize(aState);
-                nsSize max = child->GetMaxSize(aState);
                 nscoord width = clientRect.width - offset.LeftRight() - margin.LeftRight();
                 childRect.width = clamped(width, min.width, max.width);
               }
               else {
-                childRect.width = child->GetPrefSize(aState).width;
+                nscoord width = child->GetPrefSize(aState).width;
+                childRect.width = clamped(width, min.width, max.width);
               }
             }
             else if (offsetSpecified & SPECIFIED_RIGHT) {
-              childRect.width = child->GetPrefSize(aState).width;
+              nscoord width = child->GetPrefSize(aState).width;
+              childRect.width = clamped(width, min.width, max.width);
               childRect.x = clientRect.XMost() - offset.right - margin.right - childRect.width;
             }
 
             if (offsetSpecified & SPECIFIED_TOP) {
               childRect.y = clientRect.y + offset.top + margin.top;
               if (offsetSpecified & SPECIFIED_BOTTOM) {
-                nsSize min = child->GetMinSize(aState);
-                nsSize max = child->GetMaxSize(aState);
                 nscoord height = clientRect.height - offset.TopBottom() - margin.TopBottom();
                 childRect.height = clamped(height, min.height, max.height);
               }
               else {
-                childRect.height = child->GetPrefSize(aState).height;
+                nscoord height = child->GetPrefSize(aState).height;
+                childRect.height = clamped(height, min.height, max.height);
               }
             }
             else if (offsetSpecified & SPECIFIED_BOTTOM) {
-              childRect.height = child->GetPrefSize(aState).height;
+              nscoord height = child->GetPrefSize(aState).height;
+              childRect.height = clamped(height, min.height, max.height);
               childRect.y = clientRect.YMost() - offset.bottom - margin.bottom - childRect.height;
             }
           }
 
           // Now place the child.
           child->SetBounds(aState, childRect);
 
           // Flow the child.