         {
             if (measuredSizeIncludesScrollBars)
             {
+                var contentSize:Point = getLayoutContentSize(viewport);
+    
                 var viewportPreferredW:Number =  viewport.getPreferredBoundsWidth();
-                measuredW += Math.max(viewportPreferredW, (showHSB) ? hsb.getMinBoundsWidth() : 0);
+                var viewportContentW:Number = contentSize.x;
+                var viewportW:Number = viewport.getLayoutBoundsWidth();  // "current" size
+                var currentSizeNoHSB:Boolean = !isNaN(viewportW) && ((viewportW + SDT) > viewportContentW);
+                if (hAuto && !showHSB && ((viewportPreferredW + SDT) <= viewportContentW) && currentSizeNoHSB)
+                    measuredW += viewportW;
+                else
+                    measuredW += Math.max(viewportPreferredW, (showHSB) ? hsb.getMinBoundsWidth() : 0);
     
                 var viewportPreferredH:Number = viewport.getPreferredBoundsHeight();
-                measuredH += Math.max(viewportPreferredH, (showVSB) ? vsb.getMinBoundsHeight() : 0);
+                var viewportContentH:Number = contentSize.y;
+                var viewportH:Number = viewport.getLayoutBoundsHeight();  // "current" size
+                var currentSizeNoVSB:Boolean = !isNaN(viewportH) && ((viewportH + SDT) > viewportContentH);
+                if (vAuto && !showVSB && ((viewportPreferredH + SDT) <= viewportContentH) && currentSizeNoVSB)
+                    measuredH += viewportH;
+                else
+                    measuredH += Math.max(viewportPreferredH, (showVSB) ? vsb.getMinBoundsHeight() : 0);
             }
             else
             {

{
import flash.geom.Point;

import mx.core.FlexVersion;
import mx.core.IContainerInvalidating;
import mx.core.ILayoutElement;
import mx.core.IUIComponent;
import mx.core.InteractionMode;
import mx.core.ScrollPolicy;
import mx.core.UIComponentGlobals;
import mx.core.mx_internal;
import mx.managers.ILayoutManagerClient;
import mx.managers.ILayoutManagerContainerClient;
import mx.utils.MatrixUtil;

import spark.components.Scroller;


        if (viewport)
        {
            viewport.setLayoutBoundsSize(viewportW, viewportH);
            viewport.setLayoutBoundsPosition(minViewportInset, minViewportInset);
        }
