flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject [13/42] flex-asjs git commit: And here’s TLF…
Date Thu, 16 Mar 2017 13:37:33 GMT
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextFlow.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextFlow.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextFlow.as
new file mode 100644
index 0000000..5ccd042
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextFlow.as
@@ -0,0 +1,1247 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.EventDispatcher;
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.compose.ISWFContext;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.compose.utils.ContextUtil;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.edit.ISelectionManager;
+	import org.apache.flex.textLayout.elements.utils.BackgroundHelper;
+	import org.apache.flex.textLayout.events.DamageEvent;
+	import org.apache.flex.textLayout.events.ModelChange;
+	import org.apache.flex.textLayout.factory.ITLFFactory;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.utils.CreateTLFUtil;
+	import org.apache.flex.utils.ObjectMap;
+
+		
+
+	
+	/**
+	 *
+	 *  @eventType org.apache.flex.textLayout.events.FlowOperationEvent.FLOW_OPERATION_BEGIN
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+	[Event(name="flowOperationBegin", type="org.apache.flex.textLayout.events.FlowOperationEvent")]
+	
+	/**
+	 * 
+	 * @eventType org.apache.flex.textLayout.events.FlowOperationEvent.FLOW_OPERATION_END
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+	[Event(name="flowOperationEnd", type="org.apache.flex.textLayout.events.FlowOperationEvent")]
+	
+	/**
+	 * 
+	 * @eventType org.apache.flex.textLayout.events.FlowOperationEvent.FLOW_OPERATION_COMPLETE
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="flowOperationComplete", type="org.apache.flex.textLayout.events.FlowOperationEvent")]
+	
+	/** Dispatched whenever the selection is changed.  Primarily used to update selection-dependent user interface. 
+	 * It can also be used to alter the selection, but cannot be used to alter the TextFlow itself.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="selectionChange", type="org.apache.flex.textLayout.events.SelectionEvent")]
+	
+	/** Dispatched after every recompose. 
+	*
+	* @playerversion Flash 10
+	* @playerversion AIR 1.5
+	* @langversion 3.0
+	*/
+	
+	[Event(name="compositionComplete", type="org.apache.flex.textLayout.events.CompositionCompleteEvent")]
+	
+	/** Dispatched when the mouse is pressed down over any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="mouseDown", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** Dispatched when the mouse is released over any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="mouseUp", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** Dispatched when the mouse passes over any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="mouseMove", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]	
+	
+	/** Dispatched when the mouse first enters any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="rollOver", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** Dispatched when the mouse goes out of any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="rollOut", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]	
+	
+	/** Dispatched when any link is clicked. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="click", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** Dispatched when a InlineGraphicElement is resized due to having width or height as auto or percent 
+	 * and the graphic has finished loading. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="inlineGraphicStatusChanged", type="org.apache.flex.textLayout.events.StatusChangeEvent")]
+	
+	/** Dispatched by a TextFlow object after text is scrolled within a controller container.  
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="scroll", type="org.apache.flex.textLayout.events.TextLayoutEvent")]
+	
+	/** Dispatched by a TextFlow object each time it is damaged 
+	 * 
+	 * You can use this event to find out that the TextFlow has changed, but do not access the TextFlow itself when this event 
+	 * is sent out. This event is sent when TextFlow changes are partially complete, so it can be in an inconsistent state: 
+	 * some changes have been mad already, and other changes are still pending. Get the information you need from the event, and make 
+	 * required changes after control returns to your application.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="damage", type="org.apache.flex.textLayout.events.DamageEvent")]
+
+	/** Dispatched by a TextFlow object each time a container has had new DisplayObjects added or updated as a result of composition.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="updateComplete", type="org.apache.flex.textLayout.events.UpdateCompleteEvent")]
+
+
+	/**
+	 * The TextFlow class is responsible for managing all the text content of a story. In TextLayout, text is stored in a 
+	 * hierarchical tree of elements. TextFlow is the root object of the element tree. All elements on the tree
+	 * derive from the base class, FlowElement. 
+	 *
+	 * <p>A TextFlow object can have ParagraphElement, ListElement and DivElement objects as children. A div (DivElement
+	 * object) represents a group of paragraphs (ParagraphElement objects). A ListElement contains ListItemElement objects
+	 * which in turn contain one or more ParagraphElement objects. A paragraph can have SpanElement, InlineGraphicElement, 
+	 * LinkElement, and TCYElement objects as children.</p>
+	 * 
+	 * <p>A span (SpanElement) is a range of text in a paragraph that has the same attributes. An image
+	 * (InlineGraphicElement) represents an arbitrary graphic that appears as a single character in a line of text. A 
+	 * LinkElement represents a hyperlink, or HTML <code>a</code> tag, and it can contain multiple spans. A TCYElement object
+	 * is used in Japanese text when there is a small run of text that appears perpendicular to the line, as in a horizontal
+	 * run within a vertical line. A TCYElement also can contain multiple spans.</p>
+	 
+	 * <p>TextFlow also derives from the ContainerFormattedElement class, which is the root class for all container-level block 
+	 * elements.</p>
+ 	 * <p>The following illustration shows the relationship of other elements, such as spans and paragraphs, to the TextFlow 
+ 	 * object.</p>
+ 	 * <p><img src="../../../images/textLayout_textFlowHierarchy.gif" alt="example TextFlow hierarchy"></img></p>
+ 	 *
+ 	 * <p>Each TextFlow object has a corresponding Configuration object that allows you to specify initial character and 
+ 	 * paragraph formats and the initial container format. It also allows you to specify attributes for selection, links, 
+ 	 * focus, and scrolling. When you supply a Configuration object as parameter to the <code>TextFlow()</code>
+ 	 * constructor, it creates a read-only snapshot that you can access through the <code>TextFlow.configuration</code>
+ 	 * property. After creation, you can't change the TextFlow's configuration. If you do not specify a Configuration, you 
+ 	 * can access the default configuration through the <code>TextFlow.defaultConfiguration</code> property.</p>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see #configuration
+	 * @see IConfiguration
+	 * @see DivElement
+	 * @see FlowElement
+	 * @see IFlowGroupElement
+	 * @see FlowLeafElement
+	 * @see org.apache.flex.textLayout.compose.IFlowComposer IFlowComposer
+	 * @see ParagraphElement
+	 * @see SpanElement
+	 */
+	public class TextFlow extends ContainerFormattedElement implements ITextFlow
+	{		
+		private var _flowComposer:IFlowComposer;
+		
+		/** References the Selection manager attached to this TextFlow object. */
+		private var _interactionManager:ISelectionManager;
+		
+		/** References the Configuration object for this TextFlow object. */
+		
+		private var _configuration:IConfiguration;
+		
+		/** Manages computing and drawing backgroundColor attribute */
+		private var _backgroundManager:IBackgroundManager;
+		
+		/** Default configuration for all new TextFlow objects if the configuration is not specified. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see Configuration
+		 */
+								
+		// normalize support
+		private var normalizeStart:int = 0;
+		private var normalizeLen:int = 0;
+		
+		// event dispatch support; lazy initialization
+		private var _eventDispatcher:EventDispatcher;
+		
+		// textflow specific generation support - used to validate undo
+		private var _generation:uint;
+		// next generation number to hand out - these just have to be unique so share one.
+		// 0 is reserved to mean "not set"
+		static private var _nextGeneration:uint = 1;
+		
+		// styling support
+		private var _formatResolver:IFormatResolver;
+		
+		// interactive object count - now LinkElements later add in elements with eventMirrors
+		private var _interactiveObjectCount:int;
+		
+		// ILG count
+		private var _graphicObjectCount:int;
+		
+		// nested TextFlow support
+		private var _parentElement:IFlowGroupElement;
+				
+		/** 
+		 * Constructor - creates a new TextFlow instance.
+		 *
+		 * <p>If you provide a <code>config</code> parameter, the contents of the Configuration object are copied and
+		 * you cannot make changes. You can access configuration settings, however, through the 
+		 * <code>configuration</code> property. If the <code>config</code> parameter is null, you can access the default
+		 * configuration settings through the <code>defaultConfiguration</code> property.</p> 
+		 *
+		 * <p>The Configuration object provides a mechanism for setting configurable default attributes on a TextFlow.  
+		 * While you can't make changes to the Configuration object, you can override default attributes, if necessary, 
+		 * by setting the attributes of TextFlow and its children.</p>
+		 * 
+		 * @param config Specifies the configuration to use for this TextFlow object. If it's null, use 
+		 * <code>TextFlow.defaultConfiguration</code> to access configuration values. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 * 
+	 	 * @see Configuration
+	 	 * @see #configuration
+	 	 * @see #defaultConfiguration
+		 * 
+		 */
+		 
+		public function TextFlow(tlfFactory:ITLFFactory,config:IConfiguration = null)
+		{
+			_tlfFactory = tlfFactory;
+			super();
+			initializeForConstructor(config);
+		}
+		
+		override public function get className():String
+		{
+			return "TextFlow";
+		}
+		private var _tlfFactory:ITLFFactory;
+		public function get tlfFactory() : ITLFFactory {
+			return _tlfFactory;
+		}
+		
+		private function initializeForConstructor(config:IConfiguration):void
+		{
+			if (config == null)
+				config = ConfigurationHelper.defaultConfiguration;
+			// read only non changing copy of current state
+			_configuration = config.getImmutableClone();
+			// do not set up the event dispatcher yet
+			
+			format = _configuration.textFlowInitialFormat;
+			
+			// initialize the flowComposer
+			if (_configuration.flowComposerClass)
+				flowComposer = new _configuration.flowComposerClass();
+			
+			_generation = _nextGeneration++;
+			_interactiveObjectCount = 0;
+			_graphicObjectCount = 0;
+		}
+		
+		/** @private */
+		public override function shallowCopy(startPos:int = 0, endPos:int = -1):IFlowElement
+		{		
+			var retFlow:TextFlow = super.shallowCopy(startPos, endPos) as TextFlow;
+			retFlow._configuration = _configuration;
+			retFlow._generation = _nextGeneration++;
+			if (formatResolver)
+				retFlow.formatResolver = formatResolver.getResolverForNewFlow(this,retFlow);
+			// TODO: preserve the hostFormat??
+			// preserve the swfContext
+			if (retFlow.flowComposer && flowComposer)
+				retFlow.flowComposer.swfContext = flowComposer.swfContext;
+			return retFlow;						
+		}
+		
+		/** @private - count of interactive objects */
+		public function get interactiveObjectCount():int
+		{ return _interactiveObjectCount; }
+		
+		/** @private - increment the count */
+		public function incInteractiveObjectCount():void
+		{ _interactiveObjectCount++; } 
+		
+		/** @private - decrement the count */
+		public function decInteractiveObjectCount():void
+		{ _interactiveObjectCount--; }
+		
+		/** @private - count of interactive objects */
+		public function get graphicObjectCount():int
+		{ return _graphicObjectCount; }
+		
+		/** @private - increment the count */
+		public function incGraphicObjectCount():void
+		{ _graphicObjectCount++; } 
+		
+		/** @private - decrement the count */
+		public function decGraphicObjectCount():void
+		{ _graphicObjectCount--; }
+		
+		/** 
+		* The Configuration object for this TextFlow object. The Configuration object specifies the initial character 
+		* and paragraph formats, the initial container format, and attributes for selection highlighting, 
+		* links, focus, and scrolling.
+		*
+		* <p>If you do not specify a Configuration object, Text Layout Framework uses a default Configuration object, which
+		* is referenced by the <code>defaultConfiguration</code> property.</p>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+	 	* @see Configuration
+	 	* @see #defaultConfiguration
+	 	*/
+		public function get configuration():IConfiguration
+		{ return _configuration; }
+
+		/**
+		 * The InteractionManager associated with this TextFlow object.
+		 * <p>Controls all selection and editing on the text. If the TextFlow is not selectable, 
+		 * the interactionManager is null. To make the TextFlow editable, assign a interactionManager
+		 * that is both an ISelectionManager and an IEditManager. To make a TextFlow that is read-only
+		 * and allows selection, assign a interactionManager that is an ISelectionManager only. </p>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+		 * @see org.apache.flex.textLayout.edit.ISelectionManager ISelectionManager
+		 * @see org.apache.flex.textLayout.edit.IEditManager IEditManager
+		 */
+		public function get interactionManager():ISelectionManager
+		{
+			return _interactionManager;
+		}
+		public function set interactionManager(newInteractionManager:ISelectionManager):void
+		{
+			// detatch old interactionManager
+			if (_interactionManager != newInteractionManager)
+			{
+				if (_interactionManager)
+					_interactionManager.textFlow = null;
+				_interactionManager = newInteractionManager;
+				if (_interactionManager)
+				{
+					_interactionManager.textFlow = this;
+					normalize();
+				}
+				if (flowComposer)
+					flowComposer.interactionManagerChanged(newInteractionManager);
+			}
+		}
+		
+		/** Manages the containers for this element.
+		 * 
+		 * <p>The TextLines that are created from the element appear as children of the container.
+		 * The flowComposer manages the containers, and as the text is edited it adds lines to and removes lines
+		 * from the containers. The flowComposer also keeps track of some critical attributes, such as the
+		 * width and height to compose to, whether scrolling is on, and so on.</p>
+		 * 
+		 * <p>The container and <code>flowComposer</code> are closely related. If you reset <code>flowComposer</code>, 
+		 * the container is reset to the new flowComposer's container. Likewise if the container is reset, 
+		 * <code>flowComposer</code> is reset to the container's new flowComposer.</p>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see org.apache.flex.textLayout.compose.IFlowComposer FlowComposer
+		 */
+		public override function get flowComposer():IFlowComposer
+		{ 
+			return _flowComposer; 
+		}
+		
+		public function set flowComposer(composer:IFlowComposer):void
+		{
+			changeFlowComposer(composer,true);
+		}
+		
+		/** @private use this function directly if you want to clear the flowcomposer but not unload the graphics.  */
+		public function changeFlowComposer(newComposer:IFlowComposer,okToUnloadGraphics:Boolean):void
+		{
+			var origComposer:IFlowComposer = _flowComposer;
+			if (_flowComposer != newComposer)
+			{
+				var oldSWFContext:ISWFContext = ContextUtil.computeBaseSWFContext(_flowComposer ? _flowComposer.swfContext : null);
+				var newSWFContext:ISWFContext = ContextUtil.computeBaseSWFContext(newComposer ? newComposer.swfContext : null);					
+				
+				// Clear out old settings
+				if (_flowComposer)
+				{
+					//hideSelection is no longer on IFlowComposer, so do it manually
+					var containerIter:int = 0;
+					while(containerIter < _flowComposer.numControllers)
+						_flowComposer.getControllerAt(containerIter++).clearSelectionShapes();
+					
+					_flowComposer.setRootElement(null); 	// clear event listeners
+				}
+
+				_flowComposer = newComposer;
+	
+				if (_flowComposer)
+					_flowComposer.setRootElement(this);
+					
+				// Mark flow as damaged
+				if (textLength)
+					damage(getAbsoluteStart(), textLength, "invalid", false);
+				
+				if (oldSWFContext != newSWFContext)
+					invalidateAllFormats();
+	
+				// containers *may* have changed requiring reinherit of columnDirection/blockProgression
+				// but that's only in the case when we have ContainerFormattedElements that can have containers -- if then
+				// this call is really expensive for long flows and needs to be optimized for cases when nothing changes
+				// containerFormatChanged(false);
+
+				// no longer visible shut down all the InlineGraphicElements
+				if (_flowComposer == null)
+				{
+					if (okToUnloadGraphics)
+						unloadGraphics();
+				}
+				else if (origComposer == null)
+					prepareGraphicsForLoad();
+			}
+		}
+		
+		/** @private - use to unload ILGs.  Generally TLF manage this for you but TLF errs on the side of letting the graphics run once they are started.  There may
+		 * be cases where the client will want to unload the graphics. */
+		public function unloadGraphics():void
+		{
+//TODO we probably do not need graphic unloading
+//			if (_graphicObjectCount)
+//				applyFunctionToElements(function (elem:FlowElement):Boolean{ if (elem is InlineGraphicElement) (elem as InlineGraphicElement).stop(true); return false; });			
+		}
+		
+		/** @private - use to queue ILGs for loading.  Generally TLF manage this for you.  However, this function exists so that clients may initiate a load in edge cases. 
+		 * Graphics aren't loaded until the next updateAllControllers call.  */
+		public function prepareGraphicsForLoad():void
+		{
+			// queue for start/restart any graphics that are not loaded but have a URL or CLASS source
+			if (_graphicObjectCount)
+				appendElementsForDelayedUpdate(this,null);			
+		}
+		
+		/** Returns an element whose <code>id</code> property matches the <code>idName</code> parameter. Provides
+		 * the ability to apply a style based on the <code>id</code>. 
+		 *
+		 * <p>For example, the following line sets the style "color" to 0xFF0000 (red), for the
+		 * element having the <code>id</code> span1.</p>
+		 *
+		 * <listing version="3.0" >
+		 * textFlow.getElementByID("span1").setStyle("color", 0xFF0000);
+		 * </listing>
+		 *
+		 * <p><strong>Note:</strong> In the following code, <code>p.addChild(s)</code> <em>removes</em> <code>s</code> 
+		 * from its original parent and adds it to <code>p</code>, the new parent.</p>
+		 *
+		 * <listing version="3.0" >
+		 * var s:SpanElement = new SpanElement();
+		 * var p:ParagraphElement = new ParagraphElement();
+		 * ...
+		 * s = textFlow.getElementByID("span3") as SpanElement;
+		 * p.addChild(s);
+		 * textFlow.addChild(p);
+		 * </listing>
+		 *
+		 * @param idName The <code>id</code> value of the element to find.
+		 *
+		 * @return The element whose id matches <code>idName</code>.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 *
+		 * @see FlowElement#id 
+		 */
+		
+		public function getElementByID(idName:String):IFlowElement
+		{
+			var rslt:IFlowElement;
+			applyFunctionToElements(function (elem:IFlowElement):Boolean{ if (elem.id == idName) { rslt = elem; return true; } return false; });
+			return rslt;
+		}
+
+		/** Returns all elements that have <code>styleName</code> set to <code>styleNameValue</code>.
+		 *
+		 * @param styleNameValue The name of the style for which to find elements that have it set.
+		 *
+		 * @return An array of the elements whose <code>styleName</code> value matches <code>styleNameValue</code>. For example,
+		 * all elements that have the style name "color".
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 *
+		 * @see FlowElement#styleName 
+		 */
+		public function getElementsByStyleName(styleNameValue:String):Array
+		{
+			var a:Array = new Array;
+			applyFunctionToElements(function (elem:FlowElement):Boolean{ if (elem.styleName == styleNameValue) a.push(elem); return false; });
+			return a;
+		}
+		
+		/** Returns all elements that have <code>typeName</code> set to <code>typeNameValue</code>.
+		 *
+		 * @param styleNameValue The name of the style for which to find elements that have it set.
+		 *
+		 * @return An array of the elements whose <code>typeName</code> value matches <code>typeNameValue</code>. For example,
+		 * all elements that have the type name "foo". A <code>typeName</code> is the TextFlow markup tag (such as the
+		 * <code>&lt;p&gt;</code> tag for ParagraphElements).
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see FlowElement#styleName 
+		 */
+		public function getElementsByTypeName(typeNameValue:String):Array
+		{
+			var a:Array = new Array;
+			applyFunctionToElements(function (elem:IFlowElement):Boolean{ if (elem.typeName == typeNameValue) a.push(elem); return false; });
+			return a;
+		}
+
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "TextFlow"; }
+		
+		/** @private */
+		public override function updateLengths(startIdx:int,len:int,updateLines:Boolean):void
+		{
+			if (normalizeStart != -1)
+			{
+				var newNormalizeStart:int = startIdx < normalizeStart ? startIdx : normalizeStart;
+
+				if (newNormalizeStart < normalizeStart)
+					normalizeLen += (normalizeStart-newNormalizeStart);
+				normalizeLen += len;
+				normalizeStart = newNormalizeStart;
+			}
+			else
+			{
+				normalizeStart = startIdx;
+				normalizeLen   = len;
+			}
+			// never go below zero
+			if (normalizeLen < 0)
+				normalizeLen = 0;
+			
+			// fix the lines
+			if (updateLines && _flowComposer)
+			{
+				_flowComposer.updateLengths(startIdx,len);
+				super.updateLengths(startIdx,len, false);
+			}
+			else
+				super.updateLengths(startIdx,len,updateLines);
+		}
+		
+		[RichTextContent]
+		/** @private NOTE: all FlowElement implementers and overrides of mxmlChildren must specify [RichTextContent] metadata */
+		public override function set mxmlChildren(array:Array):void
+		{
+			super.mxmlChildren = array; 
+			normalize();
+			applyWhiteSpaceCollapse(null);
+		} 
+		
+		/** @private Update any elements that have a delayed updated.  Normally used to stop foreignelements when they 
+		 * are either displayed the first time or removed from the stage
+		 */
+		public function applyUpdateElements(okToUnloadGraphics:Boolean):Boolean
+		{
+			if (_elemsToUpdate)
+			{
+				var hasController:Boolean = flowComposer && flowComposer.numControllers != 0;
+				for (var child:Object in _elemsToUpdate)
+					(child as FlowElement).applyDelayedElementUpdate(this,okToUnloadGraphics,hasController);
+				// if there is a controller then done with this list.  
+				// if no controller have to keep the list around because they may be in the list waiting for load on a future compose 
+				// the scenario that preserving the list fixes is a compose with no controllers followed by a compose with controllers
+				if (hasController)
+				{
+					_elemsToUpdate = null;
+					return true;
+				}
+			}
+			return false;
+		}
+		
+		/** @private */
+		public override function preCompose():void
+		{
+			// normalizes the flow
+			do 
+			{
+				normalize();
+			}	
+				// starts or stops any FEs that have been modified, removed or deleted
+			while (applyUpdateElements(true));
+			
+			// need to call normalize again in case any of the element updates have modified the hierarchy
+			// normalize();
+		}
+	
+		/**
+		 * Mark the a range of text as invalid - needs to be recomposed.
+		 * <p>The text classes are self damaging.  This is only used when modifying the container chain.</p>
+		 * <p>Warning: Plan to evaulate a way to hide this method totally.</p>
+		 * @param start		text index of first character to marked invalid
+		 * @param damageLen	number of characters to mark invalid
+		 * @param needNormalize optional parameter (true is default) - normalize should include this range.
+		 * @private
+		 */
+		public function damage(damageStart:int, damageLen:int, damageType:String, needNormalize:Boolean = true):void
+		{
+			// CONFIG::debug { assert(damageLen > 0,"must have at least 1 char in damageLen"); }
+				
+			if (needNormalize)
+			{
+				if (normalizeStart == -1)
+				{
+					normalizeStart = damageStart;
+					normalizeLen   = damageLen;
+				}
+				else
+				{
+					if (damageStart < normalizeStart)
+					{
+						var newNormalizeLen:uint = normalizeLen;
+						newNormalizeLen = normalizeStart+normalizeLen - damageStart;
+						if (damageLen > newNormalizeLen)
+							newNormalizeLen = damageLen;
+						normalizeStart = damageStart;
+						normalizeLen = newNormalizeLen;
+					}
+					else if ((normalizeStart+normalizeLen) > damageStart)
+					{
+						if (damageStart+damageLen > normalizeStart+normalizeLen)
+							normalizeLen = damageStart+damageLen-normalizeStart;
+					}
+					else
+						normalizeLen = damageStart+damageLen-normalizeStart;
+				}
+				
+				// clamp to textLength
+				CONFIG::debug { assert(normalizeStart <= textLength,"damage bad length"); }
+				if (normalizeStart+normalizeLen > textLength)
+					normalizeLen = textLength-normalizeStart;
+				// trace("damage damageStart:" + damageStart.toString() + " damageLen:" + damageLen.toString() + " textLength:" + this.textLength + " normalizeStart:" + normalizeStart.toString() + " normalizeLen:"  + normalizeLen.toString() );
+			}
+			
+			if (_flowComposer)
+				_flowComposer.damage(damageStart, damageLen, damageType);
+				
+			if (hasEventListener(DamageEvent.DAMAGE))
+				dispatchEvent(new DamageEvent(DamageEvent.DAMAGE,false,false,this,damageStart,damageLen));
+		}
+			
+		/**
+		 * Find the paragraph at the specified absolute position
+		 * @private
+		 */
+		public function findAbsoluteParagraph(pos:int):IParagraphElement
+		{
+			var elem:IFlowElement = findLeaf(pos);
+			return elem ? elem.getParagraph() : null;
+		}
+
+		/**
+		 * Find the IFlowGroupElement at the absolute position,
+		 * could be synonymous with the paragraph OR a subBlockElement
+		 * @private
+		 */
+		 public function findAbsoluteFlowGroupElement(pos:int):IFlowGroupElement
+		 {
+		 	var elem:IFlowElement = findLeaf(pos);
+		 	return elem.parent;
+		 }
+		
+		/** @private */
+		CONFIG::debug public override function debugCheckFlowElement(depth:int = 0, extraData:String = ""):int
+		{
+			// debugging function that asserts if the flow element tree is in an invalid state
+			
+			var rslt:int = super.debugCheckFlowElement(depth,extraData);
+			
+			// describe the lines
+			if (Debugging.verbose && flowComposer)
+			{
+				for ( var lineIdx:int = 0; lineIdx < flowComposer.numLines; lineIdx++)
+				{
+					var workLine:ITextFlowLine = flowComposer.getLineAt(lineIdx);
+					var containerIdx:int = flowComposer.getControllerIndex(workLine.controller);
+					// trace("line:",lineIdx,"controller:",containerIdx,workLine.toString());
+				}
+				
+				for (var idx:int = 0; idx < flowComposer.numControllers; idx++)
+				{
+					var controller:IContainerController = flowComposer.getControllerAt(idx);
+					trace("controller:",idx,Debugging.getIdentity(controller),controller.absoluteStart,controller.textLength,controller.compositionWidth,controller.compositionHeight,controller.getContentBounds());
+				}
+			}
+			
+			rslt += assert(parent == null, "TextFlow should not have a parent");
+			rslt += assert(parentRelativeStart == 0, "TextFlow start not zero");
+
+			return rslt;		
+		}
+		
+		/**
+		 * Check the internal consistency of the flow's FlowElement tree.
+		 * @private
+		 * Asserts if the data structures in the flow are invalid.
+		 */
+		CONFIG::debug public function debugCheckTextFlow(validateControllers:Boolean=true):int
+		{
+			if (!Debugging.debugCheckTextFlow)
+				return 0;
+			
+			var rslt:int = debugCheckFlowElement();
+			
+			if (_flowComposer && validateControllers)
+			{
+				var idx:int;
+				var endPrevController:int = 0;
+				for (idx = 0; idx < flowComposer.numControllers; idx++)
+				{
+					var controller:IContainerController = flowComposer.getControllerAt(idx);
+					if (Debugging.verbose)
+					{
+						trace("controller:",idx,"absoluteStart:",controller.absoluteStart,"textLength:",controller.textLength);
+					}
+					
+					rslt += assert(controller.absoluteStart == endPrevController, "controller has bad start");
+					rslt += assert(controller.textLength >= 0, "controller has bad textLength");
+					endPrevController = controller.absoluteStart+controller.textLength;
+					rslt += assert(endPrevController <= textLength, "textLength may not extend past end of root element!");
+				}
+			}
+			
+			rslt += flowComposer.debugCheckTextFlowLines(validateControllers);
+			return rslt;
+		}
+		
+		/**
+		 * Called after an import to validate that the entire flow textLength needs normalize.
+		 * @private
+		 */
+		 CONFIG::debug public function debugCheckNormalizeAll():void
+		{
+			assert(normalizeStart == 0,"normalizeStart: bad normailzeStart");
+			assert(normalizeLen == textLength,"debugCheckNormalizeAll: bad normalizeLen");
+		}
+		
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#addEventListener()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+ 		 */
+ 		 
+		public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false): void
+		{
+			if (!_eventDispatcher)
+				_eventDispatcher = new EventDispatcher();
+//TODO is the target necessary?
+//				_eventDispatcher = new EventDispatcher(this);
+			_eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
+		}
+
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#dispatchEvent()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+ 		 */
+ 		 
+		public function dispatchEvent(event:Event):Boolean
+		{
+			if (!_eventDispatcher)
+				return true;
+			return _eventDispatcher.dispatchEvent(event);
+		}
+
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#hasEventListener()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+ 		 */
+ 		 
+		public function hasEventListener(type:String):Boolean
+		{
+			if (!_eventDispatcher)
+				return false;
+			return _eventDispatcher.hasEventListener(type);
+		}
+		
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#removeEventListener().
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+ 		 */						
+		public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false): void
+		{
+			if (!_eventDispatcher)
+				return;
+			
+			_eventDispatcher.removeEventListener(type, listener, useCapture);
+		}
+
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#willTrigger()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+ 		 */								
+		public function willTrigger(type:String):Boolean
+		{
+			if (!_eventDispatcher)
+				return false;
+			return _eventDispatcher.willTrigger(type);
+		}
+		
+		// elements which are images or blocks that *may* have children requiring activation or deactivation
+		private var _elemsToUpdate:ObjectMap;
+		
+		/** @private */
+		public function appendOneElementForUpdate(elem:IFlowElement):void
+		{
+			if (_elemsToUpdate == null)
+				_elemsToUpdate = new ObjectMap();
+			_elemsToUpdate[elem] = null;
+		}
+		
+		/** @private */
+		public function mustUseComposer():Boolean
+		{ 
+			if (_interactiveObjectCount != 0)
+				return true;
+
+			if (_elemsToUpdate == null)
+				return false; 
+
+			normalize();
+			
+			// anything that doesn't normalize completely forces use of the compser
+			var rslt:Boolean = false;
+			for (var elem:Object in _elemsToUpdate)
+			{
+				if ((elem as FlowElement).updateForMustUseComposer(this))
+					rslt = true;
+			}
+			
+			return rslt;
+		}
+		
+		/** @private */
+		public function processModelChanged(changeType:String, elem:Object, changeStart:int, changeLen:int, needNormalize:Boolean, bumpGeneration:Boolean):void
+		{
+			// track elements that may need an update before the next compose
+			if (elem is IFlowElement)
+				(elem as FlowElement).appendElementsForDelayedUpdate(this,changeType);
+			
+			if (bumpGeneration)
+				_generation = _nextGeneration++;
+			
+			if (changeLen > 0 || changeType == ModelChange.ELEMENT_ADDED)
+				damage(changeStart, changeLen, "invalid", needNormalize);
+			
+			if (formatResolver)
+			{
+				switch(changeType)
+				{
+					case ModelChange.ELEMENT_REMOVAL:
+					case ModelChange.ELEMENT_ADDED:
+					case ModelChange.STYLE_SELECTOR_CHANGED:
+						formatResolver.invalidate(elem);
+						elem.formatChanged(false);
+						break;
+				}
+			}
+		}
+		
+		/** 
+		* The generation number for this TextFlow object. The undo and redo operations use the generation number to validate that 
+		* it's legal to undo or redo an operation. The generation numbers must match. 
+		* 
+		* <p>Each model change increments <code>generation</code> so if the generation number changes, you know the 
+		* TextFlow model has changed.</p>
+		* 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*/
+	 	
+		public function get generation():uint
+		{
+			return _generation;
+		}
+		
+		/** used to reset the number backwards after an undo or redo. @private */
+		public function setGeneration(num:uint):void
+		{
+			_generation = num;
+		}
+		
+		/** @private */
+		public function processAutoSizeImageLoaded(elem:InlineGraphicElement):void
+		{
+			if (flowComposer)
+				elem.appendElementsForDelayedUpdate(this,null);
+		}
+		
+		/**
+		 * Examine the damaged textLength of the TextFlow and put it in a normal form.  This includes adding spans to empty paragraph and
+		 * merging sibling spans that have the same attributes.
+		 * @private 
+		 */
+		public function normalize():void
+		{
+			//trace("NORMALIZE");
+			
+			if (normalizeStart != -1)
+			{
+				var normalizeEnd:int = normalizeStart + (normalizeLen==0?1:normalizeLen);
+				normalizeRange(normalizeStart==0?normalizeStart:normalizeStart-1,normalizeEnd);
+
+				normalizeStart = -1;
+				normalizeLen = 0;				
+			}
+			CONFIG::debug { debugCheckTextFlow(false); }
+		}
+		
+		private var _hostFormatHelper:HostFormatHelper;
+		
+		/** The TextLayoutFormat object for this TextFlow object. This enables several optimizations for reusing 
+		* host formats. For example;
+		*
+		* <listing>
+		* textFlowA.hostFormat = textFlowB.hostFormat
+		* </listing>
+		* 
+		* You must set format values before assigning the TextLayoutFormat object to <code>hostFormat</code>.
+		* For example, the following lines do <em>not</em> set the font size to 24 because
+		* the font size is set <em>after</em> the TextLayoutFormat object has been assigned to <code>hostFormat</code>.
+		*
+		* <listing>
+		* format = new TextLayoutFormat()
+		* textFlow.hostFormat = format
+		* format.fontSize = 24;
+		* </listing>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+	 	* @see org.apache.flex.textLayout.formats.ITextLayoutFormat ITextLayoutFormat
+	 	*/
+	 	
+		public function get hostFormat():ITextLayoutFormat
+		{ return _hostFormatHelper ? _hostFormatHelper.format : null; }
+		public function set hostFormat(value:ITextLayoutFormat):void
+		{
+			if (value == null)
+				_hostFormatHelper = null;
+			else
+			{
+				if (_hostFormatHelper == null)
+					_hostFormatHelper = new HostFormatHelper();
+				_hostFormatHelper.format = value;
+			}
+			formatChanged();
+		}
+		
+		/** @private */
+		public override function doComputeTextLayoutFormat():TextLayoutFormat
+		{
+			var parentPrototype:TextLayoutFormat = _hostFormatHelper ? _hostFormatHelper.getComputedPrototypeFormat() : null;
+			return CreateTLFUtil.createTLF(formatForCascade,parentPrototype);
+		}
+		
+		
+		/** Use the formatResolver to get the character "before style" of an Object.
+		 * @param elem is either a FlowElement or a ContainerController(doesn't happen for characterformat)
+		 * @return any styled CharacterFormat for that element
+		 * @private
+		 */
+		public function getTextLayoutFormatStyle(elem:Object):TextLayoutFormat
+		{
+			if (_formatResolver == null)
+				return null;
+			var rslt:ITextLayoutFormat = _formatResolver.resolveFormat(elem);
+			if (rslt == null)
+				return null;
+			// optimization!
+			var tlfvh:TextLayoutFormat = rslt as TextLayoutFormat;
+			return tlfvh ? tlfvh : new TextLayoutFormat(rslt);
+		}
+		
+		/** Use the formatResolver to get the character "after style" of an Object.
+		 * @param elem is either a FlowElement or a ContainerController(doesn't happen for characterformat)
+		 * @return any styled CharacterFormat for that element
+		 * @private
+		 */
+		public function getExplicitStyle(elem:Object):TextLayoutFormat
+		{
+			if (_formatResolver == null)
+				return null;
+			if(_formatResolver is IExplicitFormatResolver)
+			{
+				var rslt:ITextLayoutFormat = (_formatResolver as IExplicitFormatResolver).resolveExplicitFormat(elem);
+				if (rslt == null)
+					return null;
+				
+				var tlfvh:TextLayoutFormat = rslt as TextLayoutFormat;
+				return tlfvh ? tlfvh : new TextLayoutFormat(rslt);
+			}
+			return null;
+		}
+		
+		/** @private This API peeks at the background manager.  Use when removing data as things go out of view or are recomposed.  */
+		public function get backgroundManager():IBackgroundManager
+		{ return _backgroundManager; }
+		
+		/** @private */
+		public function clearBackgroundManager():void
+		{
+			//store cache for being deleted IBackgroundManager
+			if(_backgroundManager)
+			{
+				if(!BackgroundHelper.BACKGROUND_MANAGER_CACHE)
+					BackgroundHelper.BACKGROUND_MANAGER_CACHE = new ObjectMap();
+				BackgroundHelper.BACKGROUND_MANAGER_CACHE[this] = _backgroundManager.getShapeRectArray().concat();
+			}
+			//end
+			_backgroundManager = null; 
+		}
+		
+		/** @private.  Returns the existing backgroundManager - creating it if it doesn't exist.  Use when adding backgrounds to draw.  */
+		public function getBackgroundManager():IBackgroundManager
+		{
+			if (!_backgroundManager)
+				_backgroundManager = flowComposer.createBackgroundManager();
+			return _backgroundManager;
+		}
+				
+		/** A callback function for resolving element styles. You can use this to provide styling using CSS or 
+		 * named styles, for example. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see IFormatResolver
+		 */
+		 
+		public function get formatResolver(): IFormatResolver
+		{ 
+			return _formatResolver; 
+		}
+		public function set formatResolver(val:IFormatResolver):void
+		{
+			if (_formatResolver != val)
+			{
+				if (_formatResolver)
+					_formatResolver.invalidateAll(this);
+				_formatResolver = val;
+				if (_formatResolver)
+					_formatResolver.invalidateAll(this);
+					
+				formatChanged(true);
+			}
+		}
+		
+		/** Invalidates all formatting information for the TextFlow, forcing it to be recomputed.
+		 * Call this method when styles have changed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+	 	 * @see IFormatResolver#invalidateAll()
+		 */
+		 
+		public function invalidateAllFormats():void
+		{
+			if (_formatResolver)
+				_formatResolver.invalidateAll(this);
+			formatChanged(true);
+		}
+
+		/** The parent element is the element that the TextFlow is nested inside (such as a TableCellElement).
+		 * This property is for support of nested TextFlows to handle things like selection and editing.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 */		
+		public function get parentElement():IFlowGroupElement
+		{
+			return _parentElement;
+		}
+
+		public function set parentElement(value:IFlowGroupElement):void
+		{
+			_parentElement = value;
+		}
+		
+		public function nestedInTable():Boolean{
+			return parentElement && parentElement is ITableCellElement;
+		}
+
+
+	} // end TextFlow class
+}
+
+import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+import org.apache.flex.textLayout.formats.TextLayoutFormat;
+import org.apache.flex.textLayout.utils.CreateTLFUtil;
+
+
+
+
+/** @private.  Expected usage is that all values are set. */
+class HostFormatHelper
+{
+	private var _format:ITextLayoutFormat;
+	private var _computedPrototypeFormat:TextLayoutFormat;
+	
+	public function get format():ITextLayoutFormat
+	{ return _format; }
+	public function set format(value:ITextLayoutFormat):void
+	{ _format = value;  _computedPrototypeFormat = null; }
+
+	public function getComputedPrototypeFormat():TextLayoutFormat
+	{
+		if (_computedPrototypeFormat == null)
+		{
+			var useFormat:ITextLayoutFormat;
+			if (_format is TextLayoutFormat || _format is TextLayoutFormat)
+				useFormat = _format;
+			else
+				useFormat = new TextLayoutFormat(_format);
+			_computedPrototypeFormat = CreateTLFUtil.createTLF(useFormat,null);
+		}
+		return _computedPrototypeFormat;
+	}		
+		
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextRange.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextRange.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextRange.as
new file mode 100644
index 0000000..e354116
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextRange.as
@@ -0,0 +1,171 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+
+	
+
+
+	/**
+	 * A read only class that describes a range of contiguous text. Such a range occurs when you select a
+	 * section of text. The range consists of the anchor point of the selection, <code>anchorPosition</code>,
+	 * and the point that is to be modified by actions, <code>activePosition</code>.  As block selections are 
+	 * modified and extended <code>anchorPosition</code> remains fixed and <code>activePosition</code> is modified.  
+	 * The anchor position may be placed in the text before or after the active position.
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 *
+	 * @see org.apache.flex.textLayout.elements.TextFlow TextFlow
+	 * @see org.apache.flex.textLayout.edit.SelectionState SelectionState
+	 */
+	public class TextRange
+	{
+		/** The TextFlow of the selection.
+ 	 	 */
+		private var _textFlow:ITextFlow;
+		
+		// current range of selection
+		/** Anchor point of the current selection, as an absolute position in the TextFlow. */
+		private var _anchorPosition:int;
+		/** Active end of the current selection, as an absolute position in the TextFlow. */
+		private var _activePosition:int;
+		
+		private function clampToRange(index:int):int
+		{
+			if (index < 0)
+				return 0;
+			if (index > _textFlow.textLength)
+				return _textFlow.textLength;
+			return index;
+		}
+		
+		/** Constructor - creates a new TextRange instance.  A TextRange can be (-1,-1), indicating no range, or a pair of 
+		* values from 0 to <code>TextFlow.textLength</code>.
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 * @param	root	the TextFlow associated with the selection.
+		 * @param anchorIndex	the index position of the anchor in the selection. The first position in the text is position 0.
+		 * @param activeIndex	the index position of the active location in the selection. The first position in the text is position 0. 
+		 *
+		 * @see FlowElement#textLength
+		 */		
+		public function TextRange(root:ITextFlow,anchorIndex:int,activeIndex:int)
+		{
+			_textFlow = root;
+			
+			if (anchorIndex != -1 || activeIndex != -1)
+			{
+				anchorIndex = clampToRange(anchorIndex);
+				activeIndex = clampToRange(activeIndex);
+			}
+			
+			_anchorPosition = anchorIndex;
+			_activePosition = activeIndex;
+		}
+		
+		/** Update the range with new anchor or active position values.
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 *  @param newAnchorPosition	the anchor index of the selection.
+		 *  @param newActivePosition	the active index of the selection.
+		 *  @return true if selection is changed.
+		 */
+		public function updateRange(newAnchorPosition:int,newActivePosition:int):Boolean
+		{
+			if (newAnchorPosition != -1 || newActivePosition != -1)
+			{
+				newAnchorPosition = clampToRange(newAnchorPosition);
+				newActivePosition = clampToRange(newActivePosition);
+			}
+			
+			if (_anchorPosition != newAnchorPosition || _activePosition != newActivePosition)
+			{
+				_anchorPosition = newAnchorPosition;
+				_activePosition = newActivePosition;
+				return true;
+			}
+			return false;
+		}
+		
+		/** Returns the TextFlow associated with the selection.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */						
+		public function get textFlow():ITextFlow
+		{ return _textFlow; }
+		public function set textFlow(value:ITextFlow):void
+		{ _textFlow = value; }
+		
+		/** Anchor position of the selection, as an absolute position in the TextFlow.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */								
+		public function get anchorPosition():int
+		{ return _anchorPosition; }
+		public function set anchorPosition(value:int):void
+		{ _anchorPosition = value; }
+		
+		/** Active position of the selection, as an absolute position in the TextFlow.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */										
+		public function get activePosition():int
+		{ return _activePosition; }
+		public function set activePosition(value:int):void
+		{ _activePosition = value; }
+		
+		/** Start of the selection, as an absolute position in the TextFlow.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */										
+		public function get absoluteStart():int
+		{ return _activePosition < _anchorPosition ? _activePosition : _anchorPosition; }
+		public function set absoluteStart(value:int):void
+		{
+			if (_activePosition < _anchorPosition)
+				_activePosition = value;
+			else
+				_anchorPosition = value;
+		}
+		
+		/** End of the selection, as an absolute position in the TextFlow.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */								
+		public function get absoluteEnd():int
+		{ return _activePosition > _anchorPosition ? _activePosition : _anchorPosition; }
+		public function set absoluteEnd(value:int):void
+		{
+			if (_activePosition > _anchorPosition)
+				_activePosition = value;
+			else
+				_anchorPosition = value;
+		}		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/BackgroundHelper.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/BackgroundHelper.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/BackgroundHelper.as
new file mode 100644
index 0000000..aa51fbe
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/BackgroundHelper.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements.utils
+{
+	import org.apache.flex.utils.ObjectMap;
+	public class BackgroundHelper
+	{
+		public static var BACKGROUND_MANAGER_CACHE:ObjectMap = null;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/GeometricElementUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/GeometricElementUtils.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/GeometricElementUtils.as
new file mode 100644
index 0000000..b31a6c0
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/GeometricElementUtils.as
@@ -0,0 +1,287 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements.utils
+{
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.ElementFormat;
+	import org.apache.flex.text.engine.FontDescription;
+	import org.apache.flex.text.engine.FontMetrics;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.text.engine.TextBaseline;
+	import org.apache.flex.text.engine.TextRotation;
+	import org.apache.flex.text.engine.TypographicCase;
+	import org.apache.flex.textLayout.compose.ISWFContext;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.formats.BaselineShift;
+	import org.apache.flex.textLayout.formats.ColorName;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TLFTypographicCase;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.utils.LocaleUtil;
+	public class GeometricElementUtils
+	{
+		/** @private */
+		public static function resolveDomBaseline(computedFormat:ITextLayoutFormat, para:IParagraphElement):String
+		{
+			CONFIG::debug { assert(computedFormat != null,"bad call to resolveDomBaseline"); }
+			
+			var domBase:String = computedFormat.dominantBaseline;
+			if(domBase == FormatValue.AUTO)
+			{
+				if(computedFormat.textRotation == TextRotation.ROTATE_270 /*|| 
+					this.computedFormat.blockProgression == BlockProgression.RL*/)
+					domBase = TextBaseline.IDEOGRAPHIC_CENTER;
+				else
+				{
+					//otherwise, avoid using the locale of the element and use the paragraph's locale
+					if(para != null)
+						domBase = para.getEffectiveDominantBaseline();
+					else
+						domBase = LocaleUtil.dominantBaseline(computedFormat.locale);
+				}
+			}
+			
+			return domBase;
+		}
+		/** @private 
+		 * Get the "inline box" for an element with the specified computed format as defined by the CSS visual formatting model (http://www.w3.org/TR/CSS2/visuren.html)
+		 * For a span, leading is applied equally above and below the em-box such that the box's height equals lineHeight. 
+		 * Alignment relative to the baseline (using baselineShift, dominantBaseline, alignmentBaseline) is taken into account.
+		 * @param	textLine		The containing text line
+		 * @param	para			The containing para. Only used for resolving AUTO dominantBaseline value. 
+		 * 							May be null, in which case the AUTO dominantBaseline value is resolved based on other attributes (such as the element's computed locale). 	
+		 * @return 	A rectangle representing the inline box. Top and Bottom are relative to the line's Roman baseline. Left and Right are ignored.
+		 */
+		static public function getCSSInlineBoxHelper(computedFormat:ITextLayoutFormat, metrics:FontMetrics, textLine:ITextLine, para:IParagraphElement=null):Rectangle
+		{
+			var emBox:Rectangle 	= metrics.emBox;
+			
+			var ascent:Number 		= -emBox.top;
+			var descent:Number 		= emBox.bottom;
+			var textHeight:Number	= emBox.height;
+			
+			var fontSize:Number 	= computedFormat.fontSize;
+			var lineHeight:Number 	= TextLayoutFormat.lineHeightProperty.computeActualPropertyValue(computedFormat.lineHeight, fontSize);
+			var halfLeading:Number	= (lineHeight - textHeight) / 2;
+			
+			// Apply half leading equally above and below the em box
+			emBox.top -= halfLeading;
+			emBox.bottom += halfLeading;
+			
+			// Account for the effect of dominantBaseline
+			var computedDominantBaseline:String = resolveDomBaseline(computedFormat, para);
+			switch (computedDominantBaseline)
+			{
+				case TextBaseline.ASCENT:
+				case TextBaseline.IDEOGRAPHIC_TOP:
+					emBox.offset(0, ascent); 
+					break;
+				
+				case TextBaseline.IDEOGRAPHIC_CENTER:
+					emBox.offset(0, ascent - textHeight/2);
+					break;
+				
+				case TextBaseline.ROMAN:
+					break;
+				
+				case TextBaseline.DESCENT:
+				case TextBaseline.IDEOGRAPHIC_BOTTOM:
+					emBox.offset(0, -descent);
+			}
+			
+			// Account for the effect of alignmentBaseline
+			var computedAlignmentBaseline:String = (computedFormat.alignmentBaseline == TextBaseline.USE_DOMINANT_BASELINE ? computedDominantBaseline : computedFormat.alignmentBaseline);
+			emBox.offset(0, textLine.getBaselinePosition(computedAlignmentBaseline));
+			
+			// Account for the effect of baselineShift
+			var baselineShift:Number;
+			if (computedFormat.baselineShift == BaselineShift.SUPERSCRIPT)
+				baselineShift = metrics.superscriptOffset * fontSize;
+			else if (computedFormat.baselineShift == BaselineShift.SUBSCRIPT)
+				baselineShift = metrics.subscriptOffset * fontSize;
+			else
+				baselineShift = -computedFormat.baselineShift;
+			
+			emBox.offset(0, baselineShift);
+			
+			return emBox;
+		}
+				/** @private */
+		static public function computeElementFormatHelper(computedFormat:ITextLayoutFormat, para:IParagraphElement, swfContext:ISWFContext):ElementFormat
+		{
+			// compute the cascaded elementFormat
+			var format:ElementFormat = new ElementFormat();
+			CONFIG::debug { Debugging.traceFTECall(format,null,"new ElementFormat()"); }
+			
+			format.alignmentBaseline	= computedFormat.alignmentBaseline;
+			format.alpha				= Number(computedFormat.textAlpha);
+			format.breakOpportunity		= computedFormat.breakOpportunity;
+			format.color				= (computedFormat.color is String) ? translateColor(computedFormat.color) : uint(computedFormat.color);
+			format.dominantBaseline		= GeometricElementUtils.resolveDomBaseline(computedFormat, para);
+			
+			format.digitCase			= computedFormat.digitCase;
+			format.digitWidth			= computedFormat.digitWidth;
+			format.ligatureLevel		= computedFormat.ligatureLevel;
+			format.fontSize				= Number(computedFormat.fontSize);
+			format.kerning				= computedFormat.kerning;
+			format.locale				= computedFormat.locale;
+			format.trackingLeft			= TextLayoutFormat.trackingLeftProperty.computeActualPropertyValue(computedFormat.trackingLeft,format.fontSize);
+			format.trackingRight		= TextLayoutFormat.trackingRightProperty.computeActualPropertyValue(computedFormat.trackingRight,format.fontSize);
+			format.textRotation			= computedFormat.textRotation;
+			format.baselineShift 		= -(TextLayoutFormat.baselineShiftProperty.computeActualPropertyValue(computedFormat.baselineShift, format.fontSize));
+			switch (computedFormat.typographicCase)
+			{
+				case TLFTypographicCase.LOWERCASE_TO_SMALL_CAPS:
+					format.typographicCase = TypographicCase.CAPS_AND_SMALL_CAPS;
+					break;
+				case TLFTypographicCase.CAPS_TO_SMALL_CAPS:
+					format.typographicCase = TypographicCase.SMALL_CAPS;
+					break;
+				/* Others map directly so handle it in the default case */
+				default:
+					format.typographicCase = computedFormat.typographicCase;
+					break;
+			}
+			
+			CONFIG::debug { Debugging.traceFTEAssign(format,"alignmentBaseline",format.alignmentBaseline); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"alpha",format.alpha); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"breakOpportunity",format.breakOpportunity); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"color",format.color); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"dominantBaseline",format.dominantBaseline); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"digitCase",format.digitCase); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"digitWidth",format.digitWidth); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"ligatureLevel",format.ligatureLevel); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"fontSize",format.fontSize); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"kerning",format.kerning); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"locale",format.locale); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"trackingLeft",format.trackingLeft); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"trackingRight",format.trackingRight); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"typographicCase",format.typographicCase); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"textRotation",format.textRotation); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"baselineShift",format.baselineShift);	 }	
+			
+			// set the fontDesription in the cascadedFormat
+			var fd:FontDescription = new FontDescription();
+			fd.fontStyle = computedFormat.fontStyle;
+			fd.fontName = computedFormat.fontFamily;
+//			fd.renderingMode = computedFormat.renderingMode;
+//			fd.cffHinting = computedFormat.cffHinting;
+			
+			// the fontLookup may be override by the resolveFontLookupFunction
+//			if (GlobalSettings.resolveFontLookupFunction == null)
+//				fd.fontLookup = computedFormat.fontLookup;
+//			else
+//			{
+//				fd.fontLookup = GlobalSettings.resolveFontLookupFunction(swfContext ? FlowComposerBase.computeBaseSWFContext(swfContext) : null, computedFormat);
+//			}
+			// and now give the fontMapper a shot at rewriting the FontDescription
+//			var fontMapper:Function = GlobalSettings.fontMapperFunction;
+//			if (fontMapper != null)
+//				fontMapper(fd);
+			CONFIG::debug { Debugging.traceFTECall(fd,null,"new FontDescription()"); }
+//			CONFIG::debug { Debugging.traceFTEAssign(fd,"fontWeight",fd.fontWeight);	 }
+			CONFIG::debug { Debugging.traceFTEAssign(fd,"fontStyle",fd.fontStyle);	 }
+			CONFIG::debug { Debugging.traceFTEAssign(fd,"fontName",fd.fontName);	 }
+//			CONFIG::debug { Debugging.traceFTEAssign(fd,"renderingMode",fd.renderingMode);	 }
+//			CONFIG::debug { Debugging.traceFTEAssign(fd,"cffHinting",fd.cffHinting);	 }
+//			CONFIG::debug { Debugging.traceFTEAssign(fd,"fontLookup",fd.fontLookup);	 }
+			
+			format.fontDescription = fd;
+			CONFIG::debug { Debugging.traceFTEAssign(format,"fontDescription",fd); }
+			
+			//Moved code here because original code tried to access fontMetrics prior to setting the elementFormat.
+			//Since getFontMetrics returns the value of blockElement.elementFormat.getFontMetrics(), we cannot call this
+			//until after the element has been set. Watson 1820571 - gak 06.11.08
+			// Adjust format for superscript/subscript
+			if (computedFormat.baselineShift == BaselineShift.SUPERSCRIPT || 
+				computedFormat.baselineShift == BaselineShift.SUBSCRIPT)
+			{
+				var fontMetrics:FontMetrics;
+				if (swfContext)
+					fontMetrics = swfContext.callInContext(format.getFontMetrics,format,null,true);
+				else	
+					fontMetrics = format.getFontMetrics();	
+				if (computedFormat.baselineShift == BaselineShift.SUPERSCRIPT)
+				{
+					format.baselineShift = (fontMetrics.superscriptOffset * format.fontSize);
+					format.fontSize = fontMetrics.superscriptScale * format.fontSize;
+				}
+				else // it's subscript
+				{
+					format.baselineShift = (fontMetrics.subscriptOffset * format.fontSize);
+					format.fontSize = fontMetrics.subscriptScale * format.fontSize;
+				}
+				CONFIG::debug { Debugging.traceFTEAssign(format,"baselineShift",format.baselineShift); }
+				CONFIG::debug { Debugging.traceFTEAssign(format,"fontSize",format.fontSize); }
+			}			
+			return format;
+		}
+				// mjzhang : fix for bug# 2758977 <s:p color="red"/> throws out of range error - can you do color lookup like Flex SDK
+		/** @private */
+		static private function translateColor(color:String):Number
+		{
+			var ret:Number = NaN;
+			switch ( color.toLowerCase() )
+			{
+				case ColorName.BLACK:
+					ret = 0x000000; break;
+				case ColorName.BLUE:
+					ret = 0x0000FF; break;
+				case ColorName.GREEN:
+					ret = 0x008000; break;
+				case ColorName.GRAY: 
+					ret = 0x808080; break;
+				case ColorName.SILVER: 
+					ret = 0xC0C0C0; break;
+				case ColorName.LIME: 
+					ret = 0x00FF00; break;
+				case ColorName.OLIVE: 
+					ret = 0x808000; break;
+				case ColorName.WHITE: 
+					ret = 0xFFFFFF; break;
+				case ColorName.YELLOW: 
+					ret = 0xFFFF00; break;
+				case ColorName.MAROON: 
+					ret = 0x800000; break;
+				case ColorName.NAVY: 
+					ret = 0x000080; break;
+				case ColorName.RED: 
+					ret = 0xFF0000; break;
+				case ColorName.PURPLE: 
+					ret = 0x800080; break;
+				case ColorName.TEAL: 
+					ret = 0x008080; break;
+				case ColorName.FUCHSIA: 
+					ret = 0xFF00FF; break;
+				case ColorName.AQUA: 
+					ret = 0x00FFFF; break;
+				case ColorName.MAGENTA: 
+					ret = 0xFF00FF; break;
+				case ColorName.CYAN: 
+					ret = 0x00FFFF; break;
+				default : break;
+			}
+			
+			return ret;
+		}		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/ParagraphHelper.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/ParagraphHelper.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/ParagraphHelper.as
new file mode 100644
index 0000000..14e33fd
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/ParagraphHelper.as
@@ -0,0 +1,30 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements.utils
+{
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ParagraphElement;
+	public class ParagraphHelper
+	{
+				public static function getParagraph():IParagraphElement
+		{
+			return new ParagraphElement();
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ActivateEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ActivateEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ActivateEvent.as
new file mode 100644
index 0000000..e1bdca4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ActivateEvent.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events {
+	public class ActivateEvent {
+
+		public static const ACTIVATE:String = "activate";
+		public static const DEACTIVATE:String = "deactivate";
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/CompositionCompleteEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/CompositionCompleteEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/CompositionCompleteEvent.as
new file mode 100644
index 0000000..fdc776a
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/CompositionCompleteEvent.as
@@ -0,0 +1,126 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+	import org.apache.flex.events.IFlexJSEvent;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	
+	/** 
+	 * A ITextFlow instance dispatches this event after a compose operation completes. 
+	 * Each text container has two states: composition and display. This event notifies
+	 * you when the composition phase has ended. This provides an opportunity to make any
+	 * necessary and appropriate changes to the container before you display the text. 
+	 * For example, you can use this event to add highlighting of certain words or
+	 * characters in the text flow before the text is displayed.
+	 * 
+	 * <p>The three main methods that dispatch this event are <code>compose()</code>, 
+	 * <code>updateToController()</code>, and <code>updateAllControllers()</code>.
+	 * All three of these methods are in the StandardFlowComposer class.</p>
+	 *
+	 * <p><strong>Note: </strong>If the event is dispatched by the
+	 * <code>updateAllControllers()</code> method, do not call 
+	 * <code>updateAllControllers()</code> again in your event handler function.
+	 * Such a call would be a recursive call because the <code>updateAllControllers()</code> 
+	 * method executes both the composition and display steps. The <code>updateAllControllers()</code>
+	 * dispatches this event after composition completes, but before the display step executes.
+	 * The same reasoning applies to the <code>updateToController()</code> method.
+	 * </p>
+	 *
+	 * @see org.apache.flex.textLayout.elements.ITextFlow 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class CompositionCompleteEvent extends Event
+	{
+	    /** 
+	     * Defines the value of the <code>type</code> property of a <code>compositionComplete</code> event object 
+	     * @playerversion Flash 10
+	     * @playerversion AIR 1.5
+	     * @langversion 3.0 
+	     */
+	    public static const COMPOSITION_COMPLETE:String = "compositionComplete";
+		
+		
+		//temporary removal of params until Flex removes references to old CompositionCompletionEvent
+		private var _compositionStart:int;
+		private var _compositionLength:int;
+		private var _textFlow:ITextFlow;	
+		
+		/** Constructor
+		 * @param type event type - use the static property COMPOSITION_COMPLETE.
+		 * @param bubbles Indicates whether an event is a bubbling event. This event does not bubble.
+		 * @param cancelable Indicates whether the behavior associated with the event can be prevented.
+		 * This event cannot be cancelled.
+		 * @param textFlow The ITextFlow which was composed
+		 * @param compositionStart start of composition, in terms of an index into the text flow.
+		 * @param compositionLength length number of characters composed
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 **/
+		public function CompositionCompleteEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, textFlow:ITextFlow =  null, compositionStart:int=0, compositionLength:int=0)
+		{
+			_compositionStart = compositionStart;
+			_compositionLength = compositionLength;
+			_textFlow = textFlow;
+			super(type, bubbles, cancelable);
+		}
+		
+      	/** @private */
+		override public function cloneEvent():IFlexJSEvent
+		{
+			return new CompositionCompleteEvent(type, bubbles, cancelable, textFlow, compositionStart, compositionLength);
+		}
+		
+		/** 
+		 * The start location of the text range affected by the composition, expressed as an index into the text flow.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 		 
+		 */
+		public function get compositionStart():int
+		{ return _compositionStart; }		
+		public function set compositionStart(value:int):void
+		{ _compositionStart = value; }		
+		
+		/** 
+		 * The number of characters composed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get compositionLength():int
+		{ return _compositionLength; }
+		public function set compositionLength(value:int):void
+		{ _compositionLength = value; }
+		
+		/**
+		 * ITextFlow on which composition has been completed. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get textFlow():ITextFlow
+		{ return _textFlow; }
+		public function set textFlow(value:ITextFlow):void
+		{ _textFlow = value; }
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ContextMenuEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ContextMenuEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ContextMenuEvent.as
new file mode 100644
index 0000000..c2505b4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ContextMenuEvent.as
@@ -0,0 +1,31 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events {
+	import org.apache.flex.events.Event;
+
+	public class ContextMenuEvent extends Event {
+		
+		public static const MENU_ITEM_SELECT:String = "menuItemSelect";
+		public static const MENU_SELECT:String = "menuSelect";
+
+		public function ContextMenuEvent(type : String, bubbles : Boolean = false, cancelable : Boolean = false) {
+			super(type, bubbles, cancelable);
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/DamageEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/DamageEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/DamageEvent.as
new file mode 100644
index 0000000..06b6e97
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/DamageEvent.as
@@ -0,0 +1,93 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events {
+	import org.apache.flex.events.IFlexJSEvent;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.textLayout.elements.TextFlow;
+	
+	/** 
+	 * A TextFlow instance dispatches this each time it is marked as damaged.  Damage can be caused by changes to the model or changes to the layout.
+	 * 
+	 * @see org.apache.flex.textLayout.elements.TextFlow 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class DamageEvent extends Event
+	{
+		/** Event type for DamageEvent */
+	    public static const DAMAGE:String = "damage";
+
+		private var _textFlow:TextFlow;
+		private var _damageAbsoluteStart:int;
+		private var _damageLength:int;	
+		
+		/** Constructor
+		 * @param damageAbsoluteStart text index of the start of the damage
+		 * @param damageLength length of text that was damaged
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function DamageEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, textFlow:TextFlow =  null, damageAbsoluteStart:int = 0, damageLength:int = 0)
+		{
+			_textFlow = textFlow;
+			_damageAbsoluteStart = damageAbsoluteStart;
+			_damageLength = damageLength;
+			super(type, bubbles, cancelable);
+		}
+		
+      	/** @private */
+		override public function cloneEvent():IFlexJSEvent
+		{
+			return new DamageEvent(type, bubbles, cancelable, _textFlow, _damageAbsoluteStart, _damageLength);
+		}
+		
+		/**
+		 * TextFlow owning the damage 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+
+		public function get textFlow():TextFlow
+		{ return _textFlow; }
+		
+		/**
+		 * Absolute start of the damage 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+
+		public function get damageAbsoluteStart():int
+		{ return _damageAbsoluteStart; }
+		
+		/**
+		 * Length of the damage 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+
+		public function get damageLength():int
+		{ return _damageLength; }
+	}
+}
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/EditEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/EditEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/EditEvent.as
new file mode 100644
index 0000000..a75fca1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/EditEvent.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events {
+	public class EditEvent {
+		public static const CLEAR:String = "clear";
+		public static const COPY:String = "copy";
+		public static const CUT:String = "cut";
+		public static const PASTE:String = "paste";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementEventDispatcher.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementEventDispatcher.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementEventDispatcher.as
new file mode 100644
index 0000000..b298750
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementEventDispatcher.as
@@ -0,0 +1,93 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+	import org.apache.flex.events.EventDispatcher;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	
+	// [ExcludeClass]
+	/** The ElementEventDispatcher class adds a simple tracking counter for event listeners
+	 * to the core EventDispatcher class. This variable is tlf_internal, so internal code
+	 * can check quickly if an EventDispatcher has any listeners attached at all.
+	 */
+	
+	public class FlowElementEventDispatcher extends EventDispatcher
+	{
+		/** @private
+		 * Internal code can check this counter to quickly determine if there are any
+		 * listeners attached to this dispatcher at all.
+		 */
+		public var _listenerCount:int = 0;
+		
+		/** @private
+		 * The element used by this dispatcher
+		 */
+		public var _element:IFlowElement;
+		
+		/** @private 
+		 * The constructor is the same as the supeclass constructor.
+		 */
+		public function FlowElementEventDispatcher(element:IFlowElement)
+		{
+			_element = element;
+			super(null);
+		}
+		
+		/** @private 
+		 * The addEventListener() method increments a counter.
+		 */
+		public override function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
+		{
+			super.addEventListener(type, listener, useCapture, priority, useWeakReference);
+			_listenerCount++;
+			if (_listenerCount == 1)
+			{
+				var tf:ITextFlow = _element.getTextFlow();
+				if (tf)
+					tf.incInteractiveObjectCount();
+				
+				var pg:IParagraphElement = _element.getParagraph() ;
+				if (pg)
+					pg.incInteractiveChildrenCount() ;
+			}
+			_element.modelChanged(ModelChange.ELEMENT_MODIFIED,_element,0,_element.textLength);
+		}
+		
+		/** @private 
+		 * The removeEventListener() method decrements a counter.
+		 */
+		public override function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
+		{
+			super.removeEventListener(type, listener, useCapture);
+			_listenerCount--;			
+			if (_listenerCount == 0)
+			{
+				var tf:ITextFlow = _element.getTextFlow();
+				if (tf)
+					tf.decInteractiveObjectCount();
+				var pg:IParagraphElement = _element.getParagraph() ;
+				if (pg)
+					pg.decInteractiveChildrenCount() ;
+			}
+			_element.modelChanged(ModelChange.ELEMENT_MODIFIED,_element,0,_element.textLength);
+		}
+	}
+}


Mime
View raw message