         releaseSelectionManager();
         
     }
-    
-    /**
-     *  @private
-     *  If the explicit widths and heights are not set to NaN, the 
-     *  measuredWidth and measuredHeight are clamped down to these values
-     *  when measure() returns to UIComponent.measureSizes().
-     */
-    private function measureForAutoSize():void
-    {        
-        var composeWidth:Number;                                       
-
-        // Need to set a width to cause a wrap.  Use constrainedWidth,
-        // explicit maxWidth or default for maxWidth, in that order.
-        // Never compose over max width because the width will always be 
-        // adjusted down to this and it's easy to get into an infinite 
-        // measure/update display loop.            
-        if (hostFormat.lineBreak == "toFit")
-        {
-            // Constrain the width if it's less than maxWidth.
-            if (!isNaN(widthConstraint) && widthConstraint <= maxWidth)
-            {
-                composeWidth = widthConstraint
-            }
-            else
-            {
-                // The default maxWidth is 10000 which isn't a 
-                // reasonable default for the autoSize width so use the default
-                // measured width which is 160 instead.
-                composeWidth = !isNaN(explicitMaxWidth) ?
-                               explicitMaxWidth : 
-                               UIComponent.DEFAULT_MEASURED_WIDTH;
-            }
-            explicitMinWidth = NaN;
-        }
-        else
-        {             
-            // Let the text determine the width.  Ignore explicit widths.
-            composeWidth = NaN;
-            explicitMinWidth = explicitMaxWidth = NaN;                
-        }
-        
-        // Ignore all explicit heights.
-        explicitMinHeight = explicitMaxHeight = NaN;
-                                  
+        
+    /**
+     *  @private
+     *  Return true if there is a width and height to use for the measure.
+     */
+    private function isMeasureFixed():Boolean
+    {
+        return ((!isNaN(explicitWidth) || !isNaN(_widthInChars)) &&
+                (!isNaN(explicitHeight) || !isNaN(_heightInLines)) ||
+                hostFormat.blockProgression != BlockProgression.TB);   
+    }
+            
+    /**
+     *  @private
+     *  Returns the bounds of the measured text.  The initial composeWidth may
+     *  be adjusted for minWidth or maxWidth.  The value used for the compose
+     *  is in _textContainerManager.compositionWidth.
+     */
+    private function measureTextSize(composeWidth:Number):Rectangle
+    {             
+        var clampWidth:Boolean = isNaN(explicitWidth);
+               
+        // Don't want to trigger a another remeasure when we compose the text.
+        ignoreDamageEvent = true;
+
+        // Up the composeWidth if it isn't at least minWidth so we get an 
+        // accurate measurement.
+        if (clampWidth &&
+            !isNaN(explicitMinWidth) && composeWidth < explicitMinWidth)
+        {
+            composeWidth = explicitMinWidth;
+        }
+        
         // The bottom border can grow to allow all the text to fit.
         // If dimension is NaN, composer will measure text in that 
-        // direction. 
+        // direction.  This can cause a damage event if changed. 
         _textContainerManager.compositionWidth = composeWidth;
         _textContainerManager.compositionHeight = NaN;
 
-        // Compose only.  The display is not updated.
+        // Compose only.  The display should not be updated.
         _textContainerManager.compose();
 
-        var contentBounds:Rectangle = _textContainerManager.getContentBounds();
-        
+        var bounds:Rectangle = _textContainerManager.getContentBounds();        
+
+        // Remeasure if the composed width was restricted by max width.
+        // Typical this is done in validateSize() after returing from measure() 
+        // but it impacts our calculations so we need to do it now.
+        if (clampWidth &&
+            !isNaN(explicitMaxWidth) && bounds.width > explicitMaxWidth)
+        {
+            _textContainerManager.compositionWidth = composeWidth;
+            _textContainerManager.compose();
+            bounds = _textContainerManager.getContentBounds();
+        }
+            
         // If it's an empty text flow, there is one line with one
-        // character so the height is good for the line.
-        measuredHeight = Math.ceil(contentBounds.height);
-
-        if (_textContainerManager.getText().length > 0) 
-        {
-            // Text flow with a terminator (which has width).
-            measuredWidth = Math.ceil(contentBounds.width);
-        }
-        else
+        // character so the height is good for the line but we
+        // need to give it some width.
+        
+         if (_textContainerManager.getText().length == 0) 
         {
             // Empty text flow.  One Em wide so there
             // is a place to put the insertion cursor.
-            measuredWidth = Math.ceil(contentBounds.width +
-                                       getStyle("fontSize"));
+            bounds.width = bounds.width + getStyle("fontSize");
        }
+       
+       ignoreDamageEvent = false;
+       
+       //trace("measureTextSize", composeWidth, "->", bounds.width, bounds.height);
+        
+       return bounds;
+    }
+
+            
+    /**
+     *  @private
+     * 
+     *  This assumes one of width or height is constrained, but not both.
+     *  If both are constrained there is no need to remeasure the text.
+     */
+    private function remeasureConstrainedText(
+                                width:Number, height:Number,
+                                postLayoutTransform:Boolean = true):void
+    {        
+        // If we have a transform we don't support reflow.
+        // We could add support for scale, but not skew or rotation.
+        if (postLayoutTransform && nonDeltaLayoutMatrix() != null)
+        {
+            autoSize = false;
+            return;
+        }
+        
+        if (!isNaN(width))
+        {
+            // Did we already constrain the width?
+            if (widthConstraint == width) 
+                return;
+        
+            // Note that we compare with measuredWidth,
+            // as for example the RichEditableText 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.
+            if (width == measuredWidth || width == 0)                 
+                return;
+                               
+            // No reflow for explicit lineBreak
+            if (hostFormat.lineBreak == "explicit")
+                return;
+
+            // Do we have a constrained width and an explicit height?
+            // If so, the sizes are set so no need to remeasure now.
+            if (!isNaN(explicitHeight) || !isNaN(_heightInLines))
+            {
+                autoSize = false;
+                return;
+            }
+                        
+            widthConstraint = width;
+        } 
+        else
+        {
+            // Did we already constrain the height?
+            if (height == heightConstraint)
+                return;
+        
+            if (height == measuredHeight || height == 0)
+                return;
+
+            // Do we have a constrained height and an explicit width?
+            // If so, the sizes are set so no need to remeasure now.
+            if (!isNaN(explicitWidth) || !isNaN(_widthInChars))
+            {
+                autoSize = false;
+                return;
+            }
+
+            heightConstraint = height;
+        }                       
+
+        // Force the remeasure now.  We don't want to do it in two passes
+        // because there is flicker as the display objects are updated with the 
+        // sizes and positions from layout pass1 and then from layout pass 2.
+        invalidateSize();
+        validateSize();
     }
 
     /**

                // change the displayed text.
                _text = text;
                
                // FIXME (cframpto): if content, should the paragraph terminators 
                // be left in the string so the displayAsPassword string has the
                // same form as the original string?  This is only an issue
                // for TextArea.
                var textToDisplay:String = StringUtil.repeat(
                    passwordChar, _text.length);
                    

     */
    private function textContainerManager_damageHandler(event:DamageEvent):void
    {
        // setText triggers a damage event which we want to ignore.  We 
        // override TCM.setText() in RETCM and set this flag before calling the
        // superclass.
        if (ignoreDamageEvent || event.damageLength == 0)
            return;

        //trace("damageHandler", id, event.damageAbsoluteStart, event.damageLength);

        // If there are pending changes, don't wipe them out.  We have
        // not gotten to commitProperties() yet.
