             else
                 vsb.setLayoutBoundsPosition(w - vsbW - 3, 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) && (((vsbVisible != oldShowVSB) && vAuto) || ((hsbVisible != oldShowHSB) && hAuto)))
-        {
-            target.invalidateSize();
-            
-            // If the viewport's layout is virtual, it's possible that its
-            // measured size changed as a consequence of laying it out,
-            // so we invalidate its size as well.
-            var viewportGroup:GroupBase = viewport as GroupBase;
-            if (viewportGroup && viewportGroup.layout && viewportGroup.layout.useVirtualLayout)
-                viewportGroup.invalidateSize();
-            
-            invalidationCount += 1; 
-        }
-        else
-            invalidationCount = 0;
-             
+        
+		var viewportGroup:GroupBase;
+        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_5)
+        {
+            // 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) && (((vsbVisible != oldShowVSB) && vAuto) || ((hsbVisible != oldShowHSB) && hAuto)))
+            {
+                target.invalidateSize();
+                
+                // If the viewport's layout is virtual, it's possible that its
+                // measured size changed as a consequence of laying it out,
+                // so we invalidate its size as well.
+                viewportGroup = viewport as GroupBase;
+                if (viewportGroup && viewportGroup.layout && viewportGroup.layout.useVirtualLayout)
+                    viewportGroup.invalidateSize();
+                
+                invalidationCount += 1; 
+            }
+            else
+                invalidationCount = 0;
+        }
+		else
+		{
+			if (((vsbVisible != oldShowVSB) && vAuto) || ((hsbVisible != oldShowHSB) && hAuto))
+			{
+				const measuredSizeIncludesScrollBars:Boolean = scroller.measuredSizeIncludesScrollBars && (scroller.getStyle("interactionMode") == InteractionMode.MOUSE);
+				if (measuredSizeIncludesScrollBars)
+				{
+					target.invalidateSize();
+					
+					// If the viewport's layout is virtual, it's possible that its
+					// measured size changed as a consequence of laying it out,
+					// so we invalidate its size as well.
+					viewportGroup = viewport as GroupBase;
+					if (viewportGroup && viewportGroup.layout && viewportGroup.layout.useVirtualLayout)
+						viewportGroup.invalidateSize();
+				}
+			}
+		}
+        
         target.setContentSize(w, h);
     }
 

{
import flash.geom.Point;

import mx.core.IUIComponent;
import mx.core.InteractionMode;
import mx.core.ScrollPolicy;
import mx.core.mx_internal;
import mx.utils.MatrixUtil;

import spark.components.Scroller;


        if (viewport)
        {
            if (FlexVersion.compatibilityVersion >= FlexVersion.VERSION_4_5)
            {
                estimateSizesOfElements();
                if (viewport is ILayoutManagerClient)
                    UIComponentGlobals.layoutManager.validateClient(ILayoutManagerClient(viewport), true);
            }
            viewport.setLayoutBoundsSize(viewportW, viewportH);
            viewport.setLayoutBoundsPosition(minViewportInset, minViewportInset);
        }
