      *  The value of bounds.height, before the compose was done.
      */
     mx_internal var _composeHeight:Number;
+    
+    /**
+     *  @private
+     *  Cache the width constraint as set by the layout in setLayoutBoundsSize()
+     *  so that text reflow can be calculated during a subsequent measure pass.
+     */
+    private var _widthConstraint:Number = NaN;
     
     /**
      *  @private

                                                 height:Number,
                                                 postLayoutTransform:Boolean = true):void
    {
		if (FlexVersion.compatibilityVersion >= FlexVersion.VERSION_4_5)
		{
			var newEstimates:Boolean = false;
			var cw:Number = estimatedWidth;
			var ch:Number = estimatedHeight;
			var oldcw:Number = cw;
			var oldch:Number = ch;
			// we got lied to, probably the constraints weren't accurate or
			// couldn't be computed
			if (!isNaN(width))
			{
				if (isNaN(estimatedWidth) || width != estimatedWidth)
				{
					cw = width;
					newEstimates = true;
				}
			}
			// we got lied to, probably the constraints weren't accurate or
			// couldn't be computed
			if (!isNaN(height))
			{
				if (isNaN(estimatedHeight) || height != estimatedHeight)
				{
					ch = height;
					newEstimates = true;
				}
			}
			if (newEstimates)
			{
				setEstimatedSize(cw, ch);
				
				// re-measure with the new estimated size
				UIComponentGlobals.layoutManager.validateClient(this, true);
				
				// set estimated size back to what it was
				setEstimatedSize(oldcw, oldch, false);
			}
		}
        super.setLayoutBoundsSize(width, height, postLayoutTransform);
        
        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_5)
        {
            // TODO (egeorgie): possible optimization - if we reflow the text
            // immediately, we'll be able to detect whether the estimated
            // width causes the measured height to change.
            // Also certain layouts like vertical/horizontal will
            // be able to get the better performance as subsequent elements
            // will not go through updateDisplayList twice. This also has the
            // potential of avoiding text compositing during measure.
            
            // Did we already constrain the width?
            if (estimatedWidth == width)
                return;
            
            // No reflow for explicit lineBreak
            if (getStyle("lineBreak") == "explicit")
                return;
            
            // If we don't measure
            if (canSkipMeasurement())
                return;
            
            if (!isNaN(explicitHeight))
                return;
            
            // We support reflow only in the case of constrained width and
            // constrained height. Note that we compare with measuredWidth,
            // as for example the TextBase can be
            // constrained by the layout with "left" and "right", but the
            // container width itself may not be constrained and it would depend
            // on the element's measuredWidth.
            var widthConstrained:Boolean = !isNaN(width) && (width != measuredWidth) && (width != 0); 
            if (!widthConstrained)
                return;
            
            // Special case - if we have a single line, then having a constraint larger
            // than the measuredWidth will not result in measuredHeight change, as we
            // will still have only a single line
            if (_measuredOneTextLine && width > measuredWidth)
                return;
            
            // We support reflow only when we don't have a transform.
            // We could add support for scale, but not skew or rotation.
            if (postLayoutTransform && hasComplexLayoutMatrix)
                return;
            
            setEstimatedSize(width, estimatedHeight);
            invalidateSize();
        }
    }
    
    /**
     *  @private
     */


import flashx.textLayout.compose.TextLineRecycler;

import mx.core.IFlexModuleFactory;
import mx.core.UIComponent;
import mx.core.mx_internal;
import mx.events.FlexEvent;
import mx.resources.IResourceManager;
