         }
         
         if (showHSB)
-        {
             measuredH += Math.max(minViewportInset, hsb.getPreferredBoundsHeight());
-            minW += hsb.getMinBoundsWidth();              
-            minH += Math.max(minViewportInset, hsb.getMinBoundsHeight());  
-        }
         else
-        {
             measuredH += minViewportInset;
-            minH += minViewportInset;
-        }
 
         if (showVSB)
-        {
             measuredW += Math.max(minViewportInset, vsb.getPreferredBoundsWidth());
-            minW += Math.max(minViewportInset, vsb.getMinBoundsWidth());
-            minH += vsb.getMinBoundsHeight();
-        }
         else
-        {
             measuredW += minViewportInset;
-            minW += minViewportInset;
-        }
 
         // The measured size of the viewport is just its preferredBounds, except:
         // don't give up space if doing so would make an auto scrollbar visible.
         // In other words, if an auto scrollbar isn't already showing, and using
         // the preferred size would force it to show, and the current size would not,
         // then use its current size as the measured size.
+
         var viewport:IViewport = scroller.viewport;
         if (viewport)
         {
             var contentSize:Point = getLayoutContentSize(viewport);
 
-            var viewportPreferredW:Number = viewport.getPreferredBoundsWidth();
+            var viewportPreferredW:Number =  viewport.getPreferredBoundsWidth();
             var viewportContentW:Number = contentSize.x;
             var viewportW:Number = viewport.getLayoutBoundsWidth();  // "current" size
-            if (hAuto && !showHSB && (viewportPreferredW < viewportContentW) && (viewportW >= viewportContentW))
+            var currentSizeNoHSB:Boolean = !isNaN(viewportW) && (viewportW >= viewportContentW);
+            if (hAuto && !showHSB && (viewportPreferredW < viewportContentW) && currentSizeNoHSB)
                 measuredW += viewportW;
             else
                 measuredW += viewportPreferredW;

    }

    /**
     *  Returns the viewport's content size transformed into the Scroller's coordiante
     *  system.   This makes it possible to compare the viewport size (also reported
     *  relative to the Scroller) and the content size when a transform has been applied

            return new Point(0,0);
        return MatrixUtil.transformSize(new Point(cw, ch), viewport.getLayoutMatrix());
    }

    //----------------------------------
    //  hsbVisible
    //----------------------------------    
    
    private var hsbScaleX:Number = 1;
    private var hsbScaleY:Number = 1;

    /**
     *  @private
     */
    private function get hsbVisible():Boolean
    {
        var hsb:ScrollBar = getScroller().horizontalScrollBar;
        return hsb && hsb.visible;
    }

    /**
     *  @private 
     *  To make the scrollbars invisible to methods like getRect() and getBounds() 
     *  as well as to methods based on them like hitTestPoint(), we set their scale 
     *  to 0.  More info about this here: http://bugs.adobe.com/jira/browse/SDK-21540
     */
    private function set hsbVisible(value:Boolean):void
    {
        var hsb:ScrollBar = getScroller().horizontalScrollBar;
        if (!hsb)
            return;

        hsb.includeInLayout = hsb.visible = value;
        if (value)
        {
            if (hsb.scaleX == 0) 
                hsb.scaleX = hsbScaleX;
            if (hsb.scaleY == 0) 
                hsb.scaleY = hsbScaleY;
        }
        else 
        {
            if (hsb.scaleX != 0)
                hsbScaleX = hsb.scaleX;
            if (hsb.scaleY != 0)
                hsbScaleY = hsb.scaleY;
            hsb.scaleX = hsb.scaleY = 0;            
        }
    }

    /**
     *  @private
     *  Return true if the specified dimensions provide enough space to layout 
     *  the horizontal scrollbar (hsb) at its minimum size.   The HSB is assumed 
     *  to be non-null and visible.
     */
    private function hsbFits(w:Number, h:Number):Boolean
    {
        if (vsbVisible)
        {
            var vsb:ScrollBar = getScroller().verticalScrollBar;            
            w -= vsb.getPreferredBoundsWidth();
            h -= vsb.getMinBoundsHeight();
        }
        var hsb:ScrollBar = getScroller().horizontalScrollBar;        
        return (w >= hsb.getMinBoundsWidth()) && (h >= hsb.getPreferredBoundsHeight());
    }
    
    //----------------------------------
    //  vsbVisible
    //----------------------------------    

    private var vsbScaleX:Number = 1;
    private var vsbScaleY:Number = 1;

    /**
     *  @private
     */
    private function get vsbVisible():Boolean
    {
        var vsb:ScrollBar = getScroller().verticalScrollBar;
        return vsb && vsb.visible;
    }
    
    /**
     *  @private
     *  The logic here is the same as for the horizontal scrollbar, see above.
     */
    private function set vsbVisible(value:Boolean):void
    {
        var vsb:ScrollBar = getScroller().verticalScrollBar;
        if (!vsb)
            return;
        
        vsb.includeInLayout = vsb.visible = value;
        if (value)
        {
            if (vsb.scaleX == 0) 
                vsb.scaleX = vsbScaleX;
            if (vsb.scaleY == 0) 
                vsb.scaleY = vsbScaleY;
        }
        else 
        {
            if (vsb.scaleX != 0)
                vsbScaleX = vsb.scaleX;
            if (vsb.scaleY != 0)
                vsbScaleY = vsb.scaleY;
            vsb.scaleX = vsb.scaleY = 0;            
        }
    }

    /**
     *  @private
     *  Return true if the specified dimensions provide enough space to layout 
     *  the vertical scrollbar (vsb) at its minimum size.   The VSB is assumed 
     *  to be non-null and visible.
     */
    private function vsbFits(w:Number, h:Number):Boolean
    {
        if (hsbVisible)
        {
            var hsb:ScrollBar = getScroller().horizontalScrollBar;            
            w -= hsb.getMinBoundsWidth();
            h -= hsb.getPreferredBoundsHeight();
        }
        var vsb:ScrollBar = getScroller().verticalScrollBar;  
        return (w >= vsb.getPreferredBoundsWidth()) && (h >= vsb.getMinBoundsHeight());
    }
        
    /**
     * @private
     *  Computes the union of the preferred size of the visible 
