 import flashx.textLayout.formats.LineBreak;
 
 import mx.core.DPIClassification;
-import mx.core.DesignLayer;
 import mx.core.FlexGlobals;
-import mx.core.IInvalidating;
-import mx.core.IVisualElement;
 import mx.core.LayoutDirection;
 import mx.core.UIComponent;
-import mx.core.UITextFormat;
 import mx.core.mx_internal;
+import mx.events.EffectEvent;
 import mx.events.FlexEvent;
-import mx.geom.TransformOffsets;
-import mx.managers.FocusManager;
-import mx.styles.CSSStyleDeclaration;
-import mx.styles.ISimpleStyleClient;
-import mx.styles.IStyleClient;
-
+import mx.events.MoveEvent;
+import mx.events.ResizeEvent;
+import mx.managers.SystemManager;
+
+import spark.components.Application;
 import spark.core.IEditableText;
 import spark.core.ISoftKeyboardHintClient;
 import spark.events.TextOperationEvent;
-import spark.primitives.Rect;
 
 use namespace mx_internal;
 

    override public function get baselinePosition():Number
    {
        return measureTextLineHeight();
    }
    
    //----------------------------------

        return lineMetrics.height + internalPadding.y;
    }
    
    private var ancestorsVisible:Boolean;
    private var ancestorsVisibleInvalidateFlag:Boolean = true;
    
    /**
     *  Returns true if every ancestor of this object is visible.
     */
    private function calcAncestorsVisible():Boolean
    {
        if (ancestorsVisibleInvalidateFlag)
        {
            var result:Boolean = visible;
            var ancestor:DisplayObject = parent;
            
            while (result && ancestor)
            {
                result = ancestor.visible;
                ancestor = ancestor.parent;
            }
            
            ancestorsVisible = result;
            ancestorsVisibleInvalidateFlag = false;
        }
        
        return ancestorsVisible;
    }
    
    private var watchedAncestors:Vector.<UIComponent> = new Vector.<UIComponent>();
    
    private function gatherAncestorComponents():Vector.<UIComponent>
    {
        var ancestors:Vector.<UIComponent> = new Vector.<UIComponent>();
        var ancestorObj:DisplayObject = parent;
        
        while (ancestorObj)
        {
            if (ancestorObj is UIComponent)
                ancestors.push(ancestorObj as UIComponent);
            
            ancestorObj = ancestorObj.parent;
        }
        
        return ancestors;
    }
    
    /**
     *  Search for ancestor components and add listeners to them for changes in
     *  visibility or geometry. This is necessary because StageText is separate
     *  from the display object hierarchy and must have its position and 
     *  visibilty updated manually to account for changes in the hierarchy.
     *  Listeners are needed on all ancestor components because components will
     *  not dispatch move, resize, show, or hide events unless they have
     *  listeners for those events.
     */
    private function updateWatchedAncestors():void
    {
        var newWatchedAncestors:Vector.<UIComponent> = gatherAncestorComponents();
        
        var i:int;
        for (i = 0; i < watchedAncestors.length; i++)
        {
            var ancestor:UIComponent = watchedAncestors[i];
            
            if (newWatchedAncestors.indexOf(ancestor) == -1)
            {
                ancestor.removeEventListener(MoveEvent.MOVE, ancestor_moveHandler);
                ancestor.removeEventListener(ResizeEvent.RESIZE, ancestor_resizeHandler);
                ancestor.removeEventListener(FlexEvent.SHOW, ancestor_showHandler);
                ancestor.removeEventListener(FlexEvent.HIDE, ancestor_hideHandler);
            }
        }
        
        for (i = 0; i < newWatchedAncestors.length; i++)
        {
            var newAncestor:UIComponent = newWatchedAncestors[i];
            
            if (watchedAncestors.indexOf(newAncestor) == -1)
            {
                newAncestor.addEventListener(MoveEvent.MOVE, ancestor_moveHandler, false, 0, true);
                newAncestor.addEventListener(ResizeEvent.RESIZE, ancestor_resizeHandler, false, 0, true);
                newAncestor.addEventListener(FlexEvent.SHOW, ancestor_showHandler, false, 0, true);
                newAncestor.addEventListener(FlexEvent.HIDE, ancestor_hideHandler, false, 0, true);
            }
        }
        
        watchedAncestors = newWatchedAncestors;
    }
    
    //--------------------------------------------------------------------------
    //
    //  Overridden event handlers
