         var scroller:Scroller = getScroller();
         if (!scroller) 
             return;
+
         var viewport:IViewport = scroller.viewport;
         var hsb:ScrollBar = scroller.horizontalScrollBar;
         var vsb:ScrollBar = scroller.verticalScrollBar;
         var minViewportInset:Number = scroller.minViewportInset;
         
-        var vsbW:Number = (vsb) ? vsb.getPreferredBoundsWidth() : 0;
-        var hsbH:Number = (hsb) ? hsb.getPreferredBoundsHeight() : 0;
-        
         var contentW:Number = 0;
         var contentH:Number = 0;
         if (viewport)

            contentH = contentSize.y;
        }
    
        var oldShowHSB:Boolean = hsb && hsb.visible;
        var oldShowVSB:Boolean = vsb && vsb.visible;
        
        // If the viewport's size has been explicitly set (not typical) then use it 
        var viewportUIC:IUIComponent = viewport as IUIComponent;
        var explicitViewportW:Number = viewportUIC ? viewportUIC.explicitWidth : NaN;
        var explicitViewportH:Number = viewportUIC ? viewportUIC.explicitHeight : NaN;
        
        // Decide which scrollbars will be visible based on the viewport's content size
        // See the method doc above for more information.

        var showHSB:Boolean = false;
        var hAuto:Boolean = false; 
        switch(scroller.getStyle("horizontalScrollPolicy")) {
            case ScrollPolicy.ON: 
                if (hsb) showHSB = true; 
                break;
            case ScrollPolicy.AUTO: 
                if (hsb && viewport)
                {
                    hAuto = true;
                    var viewportW:Number = 
                        isNaN(explicitViewportW) ? (w - (minViewportInset * 2)) : explicitViewportW;
                    showHSB = (contentW > viewportW) && (w >= hsb.minWidth);
                } 
                break;
        } 

        var showVSB:Boolean = false;
        var vAuto:Boolean = false;
        switch(scroller.getStyle("verticalScrollPolicy")) {
           case ScrollPolicy.ON: 
                if (vsb) showVSB = true; 
                break;
            case ScrollPolicy.AUTO: 
                if (vsb && viewport)
                { 
                    vAuto = true;
                    var viewportH:Number = 
                        isNaN(explicitViewportH) ? (h - (minViewportInset * 2)) : explicitViewportH;
                    showVSB = (contentH > viewportH) && (h >= vsb.minHeight);
                }                        
                break;
        }
        
        // Shrink the viewport's width,height for the visible scrollbars
        
        viewportH = h - minViewportInset;
        if (showHSB) viewportH -= Math.max(minViewportInset, hsbH);
            
        viewportW = w - minViewportInset;
        if (showVSB) viewportW -= Math.max(minViewportInset, vsbW);
        
        // If the scrollBarPolicy is auto, and we're only showing one scrollbar, 
        // the viewport may have shrunk enough to require showing the other one.
        // We only show the other scrollbar, if there's enough space for it.
        if (showVSB && !showHSB && hAuto && (contentW > viewportW))
        {
            viewportH -= Math.max(minViewportInset, hsbH);
            showHSB = w >= (hsb.minWidth + vsb.minWidth); 
        }
        else if (!showVSB && showHSB && vAuto && (contentH > viewportH))
        {
            viewportW -= Math.max(minViewportInset, vsbW);
            showVSB = h >= (hsb.minHeight + vsb.minHeight);
        }
        
        // Factor in scrollBar-side viewportInsets where there aren't scrollbars
        if (!showHSB) viewportH -= minViewportInset;
        if (!showVSB) viewportW -= minViewportInset;
            
        // Special case: viewport's size is explicitly set
        if (!isNaN(explicitViewportW)) viewportW = explicitViewportW;
        if (!isNaN(explicitViewportH)) viewportH = explicitViewportH;
        
        // Layout the viewport.
        if (viewport)
        {
            viewport.setLayoutBoundsSize(viewportW, viewportH);
            viewport.setLayoutBoundsPosition(minViewportInset, minViewportInset);
        }

        // Layout the scrollbars.  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

        if (hsb) hsb.includeInLayout = hsb.visible = showHSB;
        if (showHSB)
        {
            if (hsb.scaleX == 0) hsb.scaleX = hsbScaleX;
            if (hsb.scaleY == 0) hsb.scaleY = hsbScaleY;
            var hsbW:Number = (showVSB) ? w - vsbW : w;
            hsb.setLayoutBoundsSize(Math.max(hsb.getMinBoundsWidth(), hsbW), hsbH);
            hsb.setLayoutBoundsPosition(0, h - hsbH);
        }
        else if (hsb)
        {
            if (hsb.scaleX != 0) hsbScaleX = hsb.scaleX;
            if (hsb.scaleY != 0) hsbScaleY = hsb.scaleY;
            hsb.scaleX = hsb.scaleY = 0;
        }

        if (vsb) vsb.includeInLayout = vsb.visible = showVSB;
        if (showVSB)
        {
            if (vsb.scaleX == 0) vsb.scaleX = vsbScaleX;
            if (vsb.scaleY == 0) vsb.scaleY = vsbScaleY;
            var vsbH:Number = (showHSB) ? h - hsbH : h;
            vsb.setLayoutBoundsSize(vsbW, Math.max(vsb.getMinBoundsHeight(), vsbH));
            vsb.setLayoutBoundsPosition(w - vsbW, 0);
        }
        else if (vsb)
        {
            if (vsb.scaleX != 0) vsbScaleX = vsb.scaleX;
            if (vsb.scaleY != 0) vsbScaleY = vsb.scaleY;
            vsb.scaleX = vsb.scaleY = 0;
        }

        // If we've added an auto scrollbar, then the measured size is likely to have been wrong.
        // There's a risk of looping here, so we count.  
        if ((invalidationCount < 2) && (((showVSB != oldShowVSB) && vAuto) || ((showHSB != oldShowHSB) && hAuto)))
        {
            target.invalidateSize(); 
            invalidationCount += 1; 

            var viewportPreferredH:Number = viewport.getPreferredBoundsHeight();
            var viewportContentH:Number = contentSize.y;
            var viewportH:Number = viewport.getLayoutBoundsHeight();  // "current" size
            var currentSizeNoVSB:Boolean = !isNaN(viewportH) && (viewportH >= viewportContentH);
            if (vAuto && !showVSB && (viewportPreferredH < viewportContentH) && currentSizeNoVSB)
                measuredH += viewportH;
            else
                measuredH += viewportPreferredH;
        }

        var minW:Number = minViewportInset * 2;
        var minH:Number = minViewportInset * 2;

        // If the viewport's explicit size is set, then 
        // include that in the scroller's minimum size

        var viewportUIC:IUIComponent = viewport as IUIComponent;
        var explicitViewportW:Number = viewportUIC ? viewportUIC.explicitWidth : NaN;
        var explicitViewportH:Number = viewportUIC ? viewportUIC.explicitHeight : NaN;

        if (!isNaN(explicitViewportW)) 
            minW += explicitViewportW;

        if (!isNaN(explicitViewportH)) 
            minH += explicitViewportH;
        
        var g:GroupBase = target;
        g.measuredWidth = Math.ceil(measuredW);
        g.measuredHeight = Math.ceil(measuredH);
        g.measuredMinWidth = Math.ceil(minW); 
        g.measuredMinHeight = Math.ceil(minH);
    }
    
    /** 
     *  @private
