You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ha...@apache.org on 2017/03/16 16:23:45 UTC

[4/6] git commit: [flex-asjs] [refs/heads/tlf] - Cleaned up imports

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as
index fb0dd74..72bf132 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as
@@ -16,11 +16,8 @@
 //  limitations under the License.
 //
 ////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.textLayout.edit {
-	import org.apache.flex.textLayout.container.IContainerController;
-	import org.apache.flex.textLayout.compose.ITextFlowTableBlock;
-	import org.apache.flex.textLayout.elements.ITableColElement;
-	import org.apache.flex.textLayout.dummy.Clipboard;
+package org.apache.flex.textLayout.edit
+{
 	import org.apache.flex.core.IApplicationView;
 	import org.apache.flex.core.IParentIUIBase;
 	import org.apache.flex.events.Event;
@@ -38,6 +35,7 @@ package org.apache.flex.textLayout.edit {
 	import org.apache.flex.text.events.TextEvent;
 	import org.apache.flex.textLayout.compose.IFlowComposer;
 	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.compose.ITextFlowTableBlock;
 	import org.apache.flex.textLayout.compose.TextFlowTableBlock;
 	import org.apache.flex.textLayout.container.ColumnState;
 	import org.apache.flex.textLayout.container.IContainerController;
@@ -45,6 +43,7 @@ package org.apache.flex.textLayout.edit {
 	import org.apache.flex.textLayout.debug.assert;
 	import org.apache.flex.textLayout.dummy.BitmapData;
 	import org.apache.flex.textLayout.dummy.BoundsUtil;
+	import org.apache.flex.textLayout.dummy.Clipboard;
 	import org.apache.flex.textLayout.dummy.ContextMenu;
 	import org.apache.flex.textLayout.dummy.IBitmapDrawable;
 	import org.apache.flex.textLayout.dummy.Mouse;
@@ -57,10 +56,11 @@ package org.apache.flex.textLayout.edit {
 	import org.apache.flex.textLayout.elements.GlobalSettings;
 	import org.apache.flex.textLayout.elements.IParagraphElement;
 	import org.apache.flex.textLayout.elements.ITableCellElement;
-	import org.apache.flex.textLayout.elements.TableColElement;
+	import org.apache.flex.textLayout.elements.ITableColElement;
 	import org.apache.flex.textLayout.elements.ITableElement;
 	import org.apache.flex.textLayout.elements.ITableRowElement;
 	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.TableColElement;
 	import org.apache.flex.textLayout.elements.TextRange;
 	import org.apache.flex.textLayout.events.ContextMenuEvent;
 	import org.apache.flex.textLayout.events.EditEvent;
@@ -72,320 +72,326 @@ package org.apache.flex.textLayout.edit {
 	import org.apache.flex.textLayout.formats.TextLayoutFormat;
 	import org.apache.flex.textLayout.operations.CopyOperation;
 	import org.apache.flex.textLayout.operations.FlowOperation;
-
 	import org.apache.flex.textLayout.utils.NavigationUtil;
 	import org.apache.flex.utils.PointUtils;
-    
-
-    
-    /** 
-     * The SelectionManager class manages text selection in a text flow.
-     * 
-     * <p>The selection manager keeps track of the selected text range, manages its formatting, 
-     * and can handle events affecting the selection. To allow a user to make selections in
-     * a text flow, assign a SelectionManager object to the <code>interactionManager</code>
-     * property of the flow. (To allow editing, assign an instance of the EditManager class,
-     * which extends SelectionManager.)</p>
-     *
-     * <p>The following table describes how the SelectionManager class handles keyboard shortcuts:</p>
-     *
-     * <table class="innertable" width="100%">
-     * <thead>
-     * <tr><th></th><th></th><th align = "center">TB,LTR</th><th align = "right"></th><th></th><th align = "center">TB,RTL</th><th></th><th></th><th align = "center">TL,LTR</th><th></th><th></th><th align = "center">RL,RTL</th><th></th></tr>
-     * <tr><th></th><th>none</th><th>ctrl</th><th>alt|ctrl+alt</th><th>none</th><th>ctrl</th><th>alt|ctrl+alt</th><th>none</th><th>ctrl</th><th>alt|ctrl+alt</th><th>none</th><th>ctrl</th><th>alt|ctrl+alt</th></tr>
-     * </thead>
-     * <tr><td>leftarrow</td><td>previousCharacter</td><td>previousWord</td><td>previousWord</td><td>nextCharacter</td><td>nextWord</td><td>nextWord</td><td>nextLine</td><td>endOfDocument</td><td>endOfParagraph</td><td>nextLine</td><td>endOfDocument</td><td>endOfParagraph</td></tr>
-     * <tr><td>uparrow</td><td>previousLine</td><td>startOfDocument</td><td>startOfParagraph</td><td>previousLine</td><td>startOfDocument</td><td>startOfParagraph</td><td>previousCharacter</td><td>previousWord</td><td>previousWord</td><td>nextCharacter</td><td>nextWord</td><td>nextWord</td></tr>
-     * <tr><td>rightarrow</td><td>nextCharacter</td><td>nextWord</td><td>nextWord</td><td>previousCharacter</td><td>previousWord</td><td>previousWord</td><td>previousLine</td><td>startOfDocument</td><td>startOfParagraph</td><td>previousLine</td><td>startOfDocument</td><td>startOfParagraph</td></tr>
-     * <tr><td>downarrow</td><td>nextLine</td><td>endOfDocument</td><td>endOfParagraph</td><td>nextLine</td><td>endOfDocument</td><td>endOfParagraph</td><td>nextCharacter</td><td>nextWord</td><td>nextWord</td><td>previousCharacter</td><td>previousWord</td><td>previousWord</td></tr>
-     * <tr><td>home</td><td>startOfLine</td><td>startOfDocument</td><td>startOfLine</td><td>startOfLine</td><td>startOfDocument</td><td>startOfLine</td><td>startOfLine</td><td>startOfDocument</td><td>startOfLine</td><td>startOfLine</td><td>startOfDocument</td><td>startOfLine</td></tr>
-     * <tr><td>end</td><td>endOfLine</td><td>endOfDocument</td><td>endOfLine</td><td>endOfLine</td><td>endOfDocument</td><td>endOfLine</td><td>endOfLine</td><td>endOfDocument</td><td>endOfLine</td><td>endOfLine</td><td>endOfDocument</td><td>endOfLine</td></tr>
-     * <tr><td>pagedown</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td></tr>
-     * <tr><td>pageup</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td></tr>
-     * </table>
-     *
-     * <p><strong>Key:</strong>
-     * <ul>
-     *  <li>none = no modifier</li>
-     *  <li>ctrl, shift, alt = modifiers</li>
-     *  <li>alt-key and ctrl+alt-key are the same on all platforms (on some platforms alt-key does not get to the Text Layout Framework (TLF)</li>
-     *  <li>shift key modifes to extend the active end of the selection in the specified manner</li>            
-     *  <li>TB (top-to-bottom),RL (right-to-left) are textFlow level <code>blockProgression</code> settings</li>                        
-     *  <li>LTR (left-to-right),RTL (right-to-left) are textFlow level <code>direction</code> settings</li>                 
-     *  <li>next and prev in logical order in the textFlow - the effect in RTL text is that the selection moves in the physical direction</li>
-     * </ul></p>
-     * 
-     * @see EditManager
-     * @see flashx.elements.ITextFlow
-     * 
-     * @playerversion Flash 10
-     * @playerversion AIR 1.5
-     * @langversion 3.0
-     */
-    public class SelectionManager implements ISelectionManager
-    {
+
+	/** 
+	 * The SelectionManager class manages text selection in a text flow.
+	 * 
+	 * <p>The selection manager keeps track of the selected text range, manages its formatting, 
+	 * and can handle events affecting the selection. To allow a user to make selections in
+	 * a text flow, assign a SelectionManager object to the <code>interactionManager</code>
+	 * property of the flow. (To allow editing, assign an instance of the EditManager class,
+	 * which extends SelectionManager.)</p>
+	 *
+	 * <p>The following table describes how the SelectionManager class handles keyboard shortcuts:</p>
+	 *
+	 * <table class="innertable" width="100%">
+	 * <thead>
+	 * <tr><th></th><th></th><th align = "center">TB,LTR</th><th align = "right"></th><th></th><th align = "center">TB,RTL</th><th></th><th></th><th align = "center">TL,LTR</th><th></th><th></th><th align = "center">RL,RTL</th><th></th></tr>
+	 * <tr><th></th><th>none</th><th>ctrl</th><th>alt|ctrl+alt</th><th>none</th><th>ctrl</th><th>alt|ctrl+alt</th><th>none</th><th>ctrl</th><th>alt|ctrl+alt</th><th>none</th><th>ctrl</th><th>alt|ctrl+alt</th></tr>
+	 * </thead>
+	 * <tr><td>leftarrow</td><td>previousCharacter</td><td>previousWord</td><td>previousWord</td><td>nextCharacter</td><td>nextWord</td><td>nextWord</td><td>nextLine</td><td>endOfDocument</td><td>endOfParagraph</td><td>nextLine</td><td>endOfDocument</td><td>endOfParagraph</td></tr>
+	 * <tr><td>uparrow</td><td>previousLine</td><td>startOfDocument</td><td>startOfParagraph</td><td>previousLine</td><td>startOfDocument</td><td>startOfParagraph</td><td>previousCharacter</td><td>previousWord</td><td>previousWord</td><td>nextCharacter</td><td>nextWord</td><td>nextWord</td></tr>
+	 * <tr><td>rightarrow</td><td>nextCharacter</td><td>nextWord</td><td>nextWord</td><td>previousCharacter</td><td>previousWord</td><td>previousWord</td><td>previousLine</td><td>startOfDocument</td><td>startOfParagraph</td><td>previousLine</td><td>startOfDocument</td><td>startOfParagraph</td></tr>
+	 * <tr><td>downarrow</td><td>nextLine</td><td>endOfDocument</td><td>endOfParagraph</td><td>nextLine</td><td>endOfDocument</td><td>endOfParagraph</td><td>nextCharacter</td><td>nextWord</td><td>nextWord</td><td>previousCharacter</td><td>previousWord</td><td>previousWord</td></tr>
+	 * <tr><td>home</td><td>startOfLine</td><td>startOfDocument</td><td>startOfLine</td><td>startOfLine</td><td>startOfDocument</td><td>startOfLine</td><td>startOfLine</td><td>startOfDocument</td><td>startOfLine</td><td>startOfLine</td><td>startOfDocument</td><td>startOfLine</td></tr>
+	 * <tr><td>end</td><td>endOfLine</td><td>endOfDocument</td><td>endOfLine</td><td>endOfLine</td><td>endOfDocument</td><td>endOfLine</td><td>endOfLine</td><td>endOfDocument</td><td>endOfLine</td><td>endOfLine</td><td>endOfDocument</td><td>endOfLine</td></tr>
+	 * <tr><td>pagedown</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td></tr>
+	 * <tr><td>pageup</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td></tr>
+	 * </table>
+	 *
+	 * <p><strong>Key:</strong>
+	 * <ul>
+	 *  <li>none = no modifier</li>
+	 *  <li>ctrl, shift, alt = modifiers</li>
+	 *  <li>alt-key and ctrl+alt-key are the same on all platforms (on some platforms alt-key does not get to the Text Layout Framework (TLF)</li>
+	 *  <li>shift key modifes to extend the active end of the selection in the specified manner</li>            
+	 *  <li>TB (top-to-bottom),RL (right-to-left) are textFlow level <code>blockProgression</code> settings</li>                        
+	 *  <li>LTR (left-to-right),RTL (right-to-left) are textFlow level <code>direction</code> settings</li>                 
+	 *  <li>next and prev in logical order in the textFlow - the effect in RTL text is that the selection moves in the physical direction</li>
+	 * </ul></p>
+	 * 
+	 * @see EditManager
+	 * @see flashx.elements.ITextFlow
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public class SelectionManager implements ISelectionManager
+	{
 		static public var useTableSelectionCursors:Boolean = false;
 		/**
 		 * Cursor for selection of table
 		 **/
 		public static var SelectTable:String = "selectTable";
-		
 		/**
 		 * Cursor for selection of table row
 		 **/
 		public static var SelectTableRow:String = "selectTableRow";
-		
 		/**
 		 * Cursor for selection of table column
 		 **/
 		public static var SelectTableColumn:String = "selectTableColumn";
-		
-        private var _focusedSelectionFormat:SelectionFormat;
-        private var _unfocusedSelectionFormat:SelectionFormat;
-        private var _inactiveSelectionFormat:SelectionFormat;
+		private var _focusedSelectionFormat:SelectionFormat;
+		private var _unfocusedSelectionFormat:SelectionFormat;
+		private var _inactiveSelectionFormat:SelectionFormat;
 		private var _focusedCellSelectionFormat:SelectionFormat;
 		private var _unfocusedCellSelectionFormat:SelectionFormat;
 		private var _inactiveCellSelectionFormat:SelectionFormat;
-        private var _selFormatState:String = SelectionFormatState.UNFOCUSED;
-        private var _isActive:Boolean;
-        
-        /** The ITextFlow of the selection. */
-        private var _textFlow:ITextFlow;
-		
+		private var _selFormatState:String = SelectionFormatState.UNFOCUSED;
+		private var _isActive:Boolean;
+		/** The ITextFlow of the selection. */
+		private var _textFlow:ITextFlow;
 		protected var _subManager:ISelectionManager;
 		protected var _superManager:ISelectionManager;
-		
 		private var _currentTable:ITableElement;
-		
 		// this should probably be produced dynamically rather than keep a reference.
 		private var _cellRange:CellRange;
-		
-		//TODO the following functions need proper comments and should be moved to a logical location within the class.
-		
+
+		// TODO the following functions need proper comments and should be moved to a logical location within the class.
 		public function get currentTable():ITableElement
 		{
 			return _currentTable;
 		}
+
 		public function set currentTable(table:ITableElement):void
 		{
 			_currentTable = table;
 		}
-		
+
 		public function hasCellRangeSelection():Boolean
 		{
-			if (!_currentTable) {
+			if (!_currentTable)
+			{
 				return false;
 			}
-			
-			//we should really check the anchorCellPosition and activeCellPosition instead
-			if (!_cellRange) {
+
+			// we should really check the anchorCellPosition and activeCellPosition instead
+			if (!_cellRange)
+			{
 				return false;
 			}
-			
+
 			return true;
 		}
-		
+
 		/**
 		 * Select a table cell text flow
 		 **/
-		public function selectCellTextFlow(cell:ITableCellElement):void {
-			
-			if (cell && cell.table) {
+		public function selectCellTextFlow(cell:ITableCellElement):void
+		{
+			if (cell && cell.table)
+			{
 				var selectionManager:SelectionManager = cell.textFlow.interactionManager as SelectionManager;
-				
+
 				clear();
-				
-				if (selectionManager) {
+
+				if (selectionManager)
+				{
 					selectionManager.currentTable = cell.table;
 					selectionManager.selectAll();
-					
+
 					// this seems to be required to work but it should not be
-					selectionManager.setFocus(); 
+					selectionManager.setFocus();
 				}
 			}
 		}
-		
+
 		/**
 		 * Select a table cell. 
 		 **/
-		public function selectCell(cell:ITableCellElement):void {
+		public function selectCell(cell:ITableCellElement):void
+		{
 			var beginCoordinates:CellCoordinates;
 			var endCoordinates:CellCoordinates;
-			
-			if (cell) {
+
+			if (cell)
+			{
 				beginCoordinates = new CellCoordinates(cell.rowIndex, cell.colIndex);
 				endCoordinates = new CellCoordinates(cell.rowIndex, cell.colIndex);
-				
-				if (beginCoordinates.isValid()) {
+
+				if (beginCoordinates.isValid())
+				{
 					selectCellRange(beginCoordinates, endCoordinates);
 				}
 			}
 		}
-		
+
 		/**
 		 * Select table cells at the specified index.
 		 **/
-		public function selectCellAt(table:ITableElement, rowIndex:int, colIndex:int):void {
+		public function selectCellAt(table:ITableElement, rowIndex:int, colIndex:int):void
+		{
 			var cell:ITableCellElement = table.getCellAt(rowIndex, colIndex);
-			
-			if (cell) {
+
+			if (cell)
+			{
 				selectCell(cell);
 			}
 		}
-		
+
 		/**
 		 * Select table cells at the specified index
 		 **/
-		public function selectCells(cells:Vector.<ITableCellElement>):void {
-            var max:int = 2147483647;
-            var min:int = -2147483647;
+		public function selectCells(cells:Vector.<ITableCellElement>):void
+		{
+			var max:int = 2147483647;
+			var min:int = -2147483647;
 			var startX:int = max;
 			var startY:int = max;
 			var endX:int = min;
 			var endY:int = min;
 			var cell:ITableCellElement;
 			var table:ITableElement;
-			for each(cell in cells)
+			for each (cell in cells)
 			{
-				if(cell)
+				if (cell)
 				{
-					if(table == null)
+					if (table == null)
 						table = cell.table;
-					
+
 					var col:int = cell.colIndex;
 					var row:int = cell.rowIndex;
-					if(col < startX)
+					if (col < startX)
 						startX = col;
-					if(col > endX)
+					if (col > endX)
 						endX = col;
-					if(row < startY)
+					if (row < startY)
 						startY = row;
-					if(row > endY)
+					if (row > endY)
 						endY = row;
 				}
 			}
-			if(startX <= endX && startY <= endY)
-				selectCellRange(
-					new CellCoordinates(startY,startX,table),
-					new CellCoordinates(endY,endX,table)
-				);
+			if (startX <= endX && startY <= endY)
+				selectCellRange(new CellCoordinates(startY, startX, table), new CellCoordinates(endY, endX, table));
 		}
-		
+
 		/**
 		 * Select the specified table row. 
 		 **/
-		public function selectRow(row:ITableRowElement):void {
+		public function selectRow(row:ITableRowElement):void
+		{
 			var beginCoordinates:CellCoordinates;
 			var endCoordinates:CellCoordinates;
-			
-			if (row) {
+
+			if (row)
+			{
 				beginCoordinates = new CellCoordinates(row.rowIndex, 0);
 				endCoordinates = new CellCoordinates(row.rowIndex, row.numCells);
-				
-				if (beginCoordinates.isValid() && endCoordinates.isValid()) {
+
+				if (beginCoordinates.isValid() && endCoordinates.isValid())
+				{
 					selectCellRange(beginCoordinates, endCoordinates);
 				}
 			}
 		}
-		
+
 		/**
 		 * Select a table row at the specified index
 		 **/
-		public function selectRowAt(table:ITableElement, index:int):void {
+		public function selectRowAt(table:ITableElement, index:int):void
+		{
 			var row:ITableRowElement = table ? table.getRowAt(index) : null;
-			
-			if (row) {
+
+			if (row)
+			{
 				selectRow(row);
 			}
 		}
-		
+
 		/**
 		 * Selects the table rows provided
 		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableRowElement
 		 **/
-		public function selectRows(rows:Array):void {
+		public function selectRows(rows:Array):void
+		{
 			var cells:Vector.<ITableCellElement> = new Vector.<ITableCellElement>();
-//			var table:ITableElement;
+			// var table:ITableElement;
 			var cell:ITableCellElement;
-			
-			if (rows && rows.length) {
-				
-				for (var i:int;i<rows.length;i++) 
+
+			if (rows && rows.length)
+			{
+				for (var i:int; i < rows.length; i++)
 				{
 					var row:ITableRowElement = rows[i] as ITableRowElement;
-					
+
 					if (row)
 					{
-						for each(cell in row.cells)
-						cells.push(cell);
+						for each (cell in row.cells)
+							cells.push(cell);
 					}
 				}
-				
+
 				selectCells(cells);
 			}
 		}
-		
+
 		/**
 		 * Select a table column. 
 		 **/
-		public function selectColumn(column:ITableColElement):void {
+		public function selectColumn(column:ITableColElement):void
+		{
 			var table:ITableElement = column.table;
-			
-			if (column && table) {
+
+			if (column && table)
+			{
 				selectCells(table.getCellsForColumn(column));
 			}
 		}
-		
+
 		/**
 		 * Select a table column at the specified index 
 		 **/
-		public function selectColumnAt(table:ITableElement, index:int):void {
+		public function selectColumnAt(table:ITableElement, index:int):void
+		{
 			var column:ITableColElement = table.getColumnAt(index);
-			
-			if (column && table) {
+
+			if (column && table)
+			{
 				return selectColumn(column);
 			}
 		}
-		
+
 		/**
 		 * Selects the table columns provided
 		 **/
-		public function selectColumns(columns:Array):void {
+		public function selectColumns(columns:Array):void
+		{
 			var cells:Vector.<ITableCellElement> = new Vector.<ITableCellElement>();
 			var cell:ITableCellElement;
-			
-			if (columns && columns.length) {
-				
-				for (var i:int;i<columns.length;i++) 
+
+			if (columns && columns.length)
+			{
+				for (var i:int; i < columns.length; i++)
 				{
 					var column:ITableColElement = columns[i] as TableColElement;
-					
+
 					if (column)
 					{
-						for each(cell in column.cells)
+						for each (cell in column.cells)
 							cells.push(cell);
 					}
-					
 				}
-				
+
 				selectCells(cells);
 			}
 		}
-		
+
 		/**
 		 * Select all cells in a table. 
 		 **/
-		public function selectTable(table:ITableElement):void {
-			
+		public function selectTable(table:ITableElement):void
+		{
 			if (table)
 			{
-				var startCoords:CellCoordinates = new CellCoordinates(0,0,table);
-				var endCoords:CellCoordinates = new CellCoordinates(table.numRows-1,table.numColumns-1,table);
-				selectCellRange(startCoords,endCoords);
+				var startCoords:CellCoordinates = new CellCoordinates(0, 0, table);
+				var endCoords:CellCoordinates = new CellCoordinates(table.numRows - 1, table.numColumns - 1, table);
+				selectCellRange(startCoords, endCoords);
 			}
-			
 		}
-		
+
 		/**
 		 * Select a range of table cells. 
 		 **/
@@ -393,25 +399,28 @@ package org.apache.flex.textLayout.edit {
 		{
 			var blocks:Vector.<ITextFlowTableBlock>;
 			var block:TextFlowTableBlock;
-//			var controller:IContainerController;
-			
-			if (selectionType == SelectionType.TEXT) {
+			// var controller:IContainerController;
+
+			if (selectionType == SelectionType.TEXT)
+			{
 				clear();
 			}
 			clearCellSelections();
-			
-			if (anchorCoords && activeCoords) {
+
+			if (anchorCoords && activeCoords)
+			{
 				_cellRange = new CellRange(_currentTable, anchorCoords, activeCoords);
 				activeCellPosition = activeCoords;
 				blocks = _currentTable.getTableBlocksInRange(anchorCoords, activeCoords);
-				
-				for each(block in blocks) {
+
+				for each (block in blocks)
+				{
 					block.controller.clearSelectionShapes();
 					block.controller.addCellSelectionShapes(currentCellSelectionFormat.rangeColor, block, anchorCoords, activeCoords);
 				}
-				if(subManager)
+				if (subManager)
 				{
-					subManager.selectRange(-1,-1);
+					subManager.selectRange(-1, -1);
 					subManager = null;
 				}
 			}
@@ -423,136 +432,134 @@ package org.apache.flex.textLayout.edit {
 			}
 			selectionChanged();
 		}
-		
+
 		public function getCellRange():CellRange
 		{
 			// not really a good implementation. We'll fix this later
 			return _cellRange;
 		}
+
 		public function setCellRange(range:CellRange):void
 		{
-			selectCellRange(range.anchorCoordinates,range.activeCoordinates);
-			//_cellRange = range;
+			selectCellRange(range.anchorCoordinates, range.activeCoordinates);
+			// _cellRange = range;
 			// do something about actually drawing the selection.
 		}
-        
-        // current range of selection
-        /** Anchor point of the current selection, as an index into the ITextFlow. */
-        private var anchorMark:Mark;
-        /** Active end of the current selection, as an index into the ITextFlow. */
-        private var activeMark:Mark;
-        private var _anchorCellPosition:CellCoordinates;
-		private var _activeCellPosition:CellCoordinates;
 
+		// current range of selection
+		/** Anchor point of the current selection, as an index into the ITextFlow. */
+		private var anchorMark:Mark;
+		/** Active end of the current selection, as an index into the ITextFlow. */
+		private var activeMark:Mark;
+		private var _anchorCellPosition:CellCoordinates;
+		private var _activeCellPosition:CellCoordinates;
 		// used to save pending attributes at a point selection
-        private var _pointFormat:ITextLayoutFormat;
-        /** 
-         * The format that will be applied to inserted text. 
-         * 
-         * TBD: pointFormat needs to be extended to remember user styles and "undefine" of formats from calls to IEditManager.undefineFormat with leafFormat values on a point selection.
-         */
-        protected function get pointFormat():ITextLayoutFormat
-        { return _pointFormat; }
-
-        
-        /** @private
-         * Ignore the next text input event. This is needed because the player may send a text input event
-         * following by a key down event when ctrl+key is entered. 
-         */
-        protected var ignoreNextTextEvent:Boolean = false;
-        
-        /**
-         *  @private
-         *  For usability reasons, operations are sometimes grouped (merged) so they 
-         *  can be undone together. Certain events, such as changing the selection, may make merging 
-         *  inappropriate. This flag is used to keep track of when operation merging
-         *  is appropriate.  This might need to be moved to SelectionManager later. I'm keeping it
-         *  here for now since I'm unsure if other regular selection operations that we add can
-         *  be undone.
-         */
-        protected var allowOperationMerge:Boolean = false;
-        
-        private var _mouseOverSelectionArea:Boolean = false;    
-
-        CONFIG::debug 
-        {
-            protected var id:String;
-            static private var smCount:int = 0;
-        }
-        
-        /** 
-         * 
-         * Creates a SelectionManager object.
-         * 
-         * <p>Assign a SelectionManager object to the <code>interactionManager</code> property of
-         * a text flow to enable text selection.</p>
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         */
-        public function SelectionManager()
-        {
-            _textFlow = null;
-            anchorMark = createMark();
-            activeMark = createMark();
+		private var _pointFormat:ITextLayoutFormat;
+
+		/** 
+		 * The format that will be applied to inserted text. 
+		 * 
+		 * TBD: pointFormat needs to be extended to remember user styles and "undefine" of formats from calls to IEditManager.undefineFormat with leafFormat values on a point selection.
+		 */
+		protected function get pointFormat():ITextLayoutFormat
+		{
+			return _pointFormat;
+		}
+
+		/** @private
+		 * Ignore the next text input event. This is needed because the player may send a text input event
+		 * following by a key down event when ctrl+key is entered. 
+		 */
+		protected var ignoreNextTextEvent:Boolean = false;
+		/**
+		 *  @private
+		 *  For usability reasons, operations are sometimes grouped (merged) so they 
+		 *  can be undone together. Certain events, such as changing the selection, may make merging 
+		 *  inappropriate. This flag is used to keep track of when operation merging
+		 *  is appropriate.  This might need to be moved to SelectionManager later. I'm keeping it
+		 *  here for now since I'm unsure if other regular selection operations that we add can
+		 *  be undone.
+		 */
+		protected var allowOperationMerge:Boolean = false;
+		private var _mouseOverSelectionArea:Boolean = false;
+		CONFIG::debug
+		{
+			protected var id:String;
+			static private var smCount:int = 0;
+		}
+		/** 
+		 * 
+		 * Creates a SelectionManager object.
+		 * 
+		 * <p>Assign a SelectionManager object to the <code>interactionManager</code> property of
+		 * a text flow to enable text selection.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function SelectionManager()
+		{
+			_textFlow = null;
+			anchorMark = createMark();
+			activeMark = createMark();
 			anchorCellPosition = createCellMark();
 			activeCellPosition = createCellMark();
-            _pointFormat = null;
-            _isActive = false;
-            CONFIG::debug 
-            {
-                this.id = smCount.toString();
-                smCount++;
-            }
-			
+			_pointFormat = null;
+			_isActive = false;
+			CONFIG::debug
+			{
+				this.id = smCount.toString();
+				smCount++;
+			}
+
 			Mouse.registerCursor(SelectTable, createSelectTableCursor());
 			Mouse.registerCursor(SelectTableRow, createSelectTableRowCursor());
 			Mouse.registerCursor(SelectTableColumn, createSelectTableColumnCursor());
-        }
-		
-        /**
-         * @copy ISelectionManager#getSelectionState()
-         * 
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         * 
-         * @see org.apache.flex.textLayout.edit.SelectionState
-         */
-        public function getSelectionState():SelectionState
-        {
-			if(subManager)
+		}
+
+		/**
+		 * @copy ISelectionManager#getSelectionState()
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionState
+		 */
+		public function getSelectionState():SelectionState
+		{
+			if (subManager)
 				return subManager.getSelectionState();
-			
-            return new SelectionState(_textFlow, anchorMark.position, activeMark.position, pointFormat, _cellRange);
-        }
-                
-        /**
-         * @copy ISelectionManager#setSelectionState()
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         * 
-         * @see org.apache.flex.textLayout.edit.SelectionState
-         */
-        public function setSelectionState(sel:SelectionState):void
-        {
-            internalSetSelection(sel.textFlow, sel.anchorPosition, sel.activePosition, sel.pointFormat);
-        }
-
-        /**
-         *  @copy ISelectionManager#hasSelection()
-         * 
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         */
-        public function hasSelection():Boolean
-        {
+
+			return new SelectionState(_textFlow, anchorMark.position, activeMark.position, pointFormat, _cellRange);
+		}
+
+		/**
+		 * @copy ISelectionManager#setSelectionState()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionState
+		 */
+		public function setSelectionState(sel:SelectionState):void
+		{
+			internalSetSelection(sel.textFlow, sel.anchorPosition, sel.activePosition, sel.pointFormat);
+		}
+
+		/**
+		 *  @copy ISelectionManager#hasSelection()
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function hasSelection():Boolean
+		{
 			return selectionType == SelectionType.TEXT;
 		}
 
@@ -580,2325 +587,2350 @@ package org.apache.flex.textLayout.edit {
 		 * @playerversion AIR 1.5
 		 * @langversion 3.0
 		 */
-		public function get selectionType() : String
+		public function get selectionType():String
 		{
-			if(anchorMark.position != -1)
+			if (anchorMark.position != -1)
 				return SelectionType.TEXT;
-			else if(anchorCellPosition.isValid())
+			else if (anchorCellPosition.isValid())
 				return SelectionType.CELLS;
-			
+
 			return SelectionType.NONE;
 		}
-        /** 
-         *  @copy ISelectionManager#isRangeSelection()
-         * 
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         */             
-        public function isRangeSelection():Boolean
-        { return anchorMark.position != -1 && anchorMark.position != activeMark.position; }
-        
-        /**
-         * The ITextFlow object managed by this selection manager. 
-         * 
-         * <p>A selection manager manages a single text flow. A selection manager can also be
-         * assigned to a text flow by setting the <code>interactionManager</code> property of the
-         * ITextFlow object.</p>
-         * 
-         * @see org.apache.flex.textLayout.elements.ITextFlow#interactionManager
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         */
-        public function get textFlow():ITextFlow
-        {
-            return _textFlow;
-        }
-        public function set textFlow(value:ITextFlow):void
-        {
-            if (_textFlow != value)
-            {
-                if (_textFlow)
-                    flushPendingOperations();
-                
-                clear();
-				clearCellSelections();
-				_cellRange = null;
-                
-                // If we switch into read-only mode, make sure the cursor isn't showing a text selection IBeam
-                if (!value) // see Watson 2637162
-                    setMouseCursor(MouseCursor.AUTO);
-        
-                _textFlow = value;
-                
-                if (_textFlow && _textFlow.interactionManager != this)
-                    _textFlow.interactionManager = this;
-            }
-        }  
-        
-        /**
-         *  @copy ISelectionManager#editingMode
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         * 
-         * @see org.apache.flex.textLayout.edit.EditingMode
-         */
-         public function get editingMode():String
-         {
-            return EditingMode.READ_SELECT;
-         }               
-         
-        /** 
-         *  @copy ISelectionManager#windowActive
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         */
-         public function get windowActive():Boolean
-         {
-            return _selFormatState != SelectionFormatState.INACTIVE;
-         }
-         
-        /** 
-         *  @copy ISelectionManager#focused
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-        */
-         public function get focused():Boolean
-         {
-            return _selFormatState == SelectionFormatState.FOCUSED;
-         }
-         
-        /**
-         *  @copy ISelectionManager#currentSelectionFormat
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         * 
-         * @see org.apache.flex.textLayout.edit.SelectionFormat
-         */
-         public function get currentSelectionFormat():SelectionFormat
-         { 
-            if (_selFormatState == SelectionFormatState.UNFOCUSED)
-            {
-                return unfocusedSelectionFormat;
-            }
-            else if (_selFormatState == SelectionFormatState.INACTIVE)
-            {
-                return inactiveSelectionFormat;
-            }
-            return focusedSelectionFormat;
-         }
-
-		 /**
-		  *  @copy ISelectionManager#currentCellSelectionFormat
-		  * 
-		  * @playerversion Flash 10
-		  * @playerversion AIR 1.5
-		  * @langversion 3.0
-		  * 
-		  * @see org.apache.flex.textLayout.edit.SelectionFormat
-		  */
-		 public function get currentCellSelectionFormat():SelectionFormat
-		 { 
-			 if (_selFormatState == SelectionFormatState.UNFOCUSED)
-			 {
-				 return unfocusedCellSelectionFormat;
-			 }
-			 else if (_selFormatState == SelectionFormatState.INACTIVE)
-			 {
-				 return inactiveCellSelectionFormat;
-			 }
-			 return focusedCellSelectionFormat;
-		 }
-
-        /**
-         *  @copy ISelectionManager#focusedSelectionFormat
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         * 
-         * @see org.apache.flex.textLayout.edit.SelectionFormat
-         */
-         public function set focusedSelectionFormat(val:SelectionFormat):void
-         { 
-            _focusedSelectionFormat = val;
-            if (this._selFormatState == SelectionFormatState.FOCUSED)
-                refreshSelection();
-         }
-         
-        /**
-         * @private - docs on setter
-         */
-         public function get focusedSelectionFormat():SelectionFormat
-         { 
-            return _focusedSelectionFormat ? _focusedSelectionFormat : (_textFlow ? _textFlow.configuration.focusedSelectionFormat : null);
-         }       
-
-        /**
-         *  @copy ISelectionManager#unfocusedSelectionFormat
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         * 
-         * @see org.apache.flex.textLayout.edit.SelectionFormat
-         */
-         public function set unfocusedSelectionFormat(val:SelectionFormat):void
-         { 
-            _unfocusedSelectionFormat = val;
-            if (this._selFormatState == SelectionFormatState.UNFOCUSED)
-                refreshSelection();
-         }          
-         
-        /**
-         *  @private - docs on setter
-         */
-         public function get unfocusedSelectionFormat():SelectionFormat
-         { 
-            return _unfocusedSelectionFormat ? _unfocusedSelectionFormat : (_textFlow ? _textFlow.configuration.unfocusedSelectionFormat : null);
-         }
-         
-        /**
-         *  @copy ISelectionManager#inactiveSelectionFormat
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         * 
-         * @see org.apache.flex.textLayout.edit.SelectionFormat
-         */
-         public function set inactiveSelectionFormat(val:SelectionFormat):void
-         { 
-            _inactiveSelectionFormat = val;
-            if (this._selFormatState == SelectionFormatState.INACTIVE)
-                refreshSelection();
-         }          
-         
-        /**
-         * @private - docs on setter
-         */
-         public function get inactiveSelectionFormat():SelectionFormat
-         { 
-            return _inactiveSelectionFormat ? _inactiveSelectionFormat : (_textFlow ? _textFlow.configuration.inactiveSelectionFormat : null);
-         }       
-
-		 /**
-		  *  @copy ISelectionManager#focusedCellSelectionFormat
-		  * 
-		  * @playerversion Flash 10
-		  * @playerversion AIR 1.5
-		  * @langversion 3.0
-		  * 
-		  * @see org.apache.flex.textLayout.edit.SelectionFormat
-		  */
-		 public function set focusedCellSelectionFormat(val:SelectionFormat):void
-		 { 
-			 _focusedCellSelectionFormat = val;
-			 if (this._selFormatState == SelectionFormatState.FOCUSED)
-				 refreshSelection();
-		 }
-		 
-		 /**
-		  * @private - docs on setter
-		  */
-		 public function get focusedCellSelectionFormat():SelectionFormat
-		 { 
-			 return _focusedCellSelectionFormat ? _focusedCellSelectionFormat : (_textFlow ? _textFlow.configuration.focusedSelectionFormat : null);
-		 }       
-		 
-		 /**
-		  *  @copy ISelectionManager#unfocusedCellSelectionFormat
-		  * 
-		  * @playerversion Flash 10
-		  * @playerversion AIR 1.5
-		  * @langversion 3.0
-		  * 
-		  * @see org.apache.flex.textLayout.edit.SelectionFormat
-		  */
-		 public function set unfocusedCellSelectionFormat(val:SelectionFormat):void
-		 { 
-			 _unfocusedCellSelectionFormat = val;
-			 if (this._selFormatState == SelectionFormatState.UNFOCUSED)
-				 refreshSelection();
-		 }          
-		 
-		 /**
-		  *  @private - docs on setter
-		  */
-		 public function get unfocusedCellSelectionFormat():SelectionFormat
-		 { 
-			 return _unfocusedCellSelectionFormat ? _unfocusedCellSelectionFormat : (_textFlow ? _textFlow.configuration.unfocusedSelectionFormat : null);
-		 }
-		 
-		 /**
-		  *  @copy ISelectionManager#inactiveCellSelectionFormat
-		  * 
-		  * @playerversion Flash 10
-		  * @playerversion AIR 1.5
-		  * @langversion 3.0
-		  * 
-		  * @see org.apache.flex.textLayout.edit.SelectionFormat
-		  */
-		 public function set inactiveCellSelectionFormat(val:SelectionFormat):void
-		 { 
-			 _inactiveCellSelectionFormat = val;
-			 if (this._selFormatState == SelectionFormatState.INACTIVE)
-				 refreshSelection();
-		 }          
-		 
-		 /**
-		  * @private - docs on setter
-		  */
-		 public function get inactiveCellSelectionFormat():SelectionFormat
-		 { 
-			 return _inactiveCellSelectionFormat ? _inactiveCellSelectionFormat : (_textFlow ? _textFlow.configuration.inactiveSelectionFormat : null);
-		 }       
-		 
-         /** @private - returns the selectionFormatState.  @see org.apache.flex.textLayout.edit.SelectionFormatState */
-         public function get selectionFormatState():String
-         { return _selFormatState; }
-         
-         /** @private - sets the SelectionFormatState. @see org.apache.flex.textLayout.edit.SelectionFormatState */
-         public function setSelectionFormatState(selFormatState:String):void
-         {
-            if (selFormatState != _selFormatState)
-            {                   
-            //  trace("changing selection state: was", _selFormatState, "switching to", selFormatState, "on selectionManager", id);
-                var oldSelectionFormat:SelectionFormat = currentSelectionFormat;
-                _selFormatState = selFormatState;
-                var newSelectionFormat:SelectionFormat = currentSelectionFormat;
-                if (!newSelectionFormat.equals(oldSelectionFormat))
-                {
-                    refreshSelection();
-                }
-             }
-         }
-         
-         /** @private */
-         public function cloneSelectionFormatState(oldISelectionManager:ISelectionManager):void
-         {
-            var oldSelectionManager:SelectionManager = oldISelectionManager as SelectionManager;
-            if (oldSelectionManager)
-            {
-                _isActive = oldSelectionManager._isActive;
-                _mouseOverSelectionArea = oldSelectionManager._mouseOverSelectionArea;
-                setSelectionFormatState(oldSelectionManager.selectionFormatState);
-            }
-         }
-         
-        /**
-         * Gets the SelectionState at the specified mouse position.
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         * @see org.apache.flex.textLayout.edit.SelectionState
-         * @param currentTarget     The object that is actively processing the Event object with an event listener.
-         * @param target            The InteractiveObject instance under the pointing device. The target is not always the object in the display list that registered the event listener. Use the currentTarget property to access the object in the display list that is currently processing the event.
-         * @param localX            The horizontal coordinate at which the event occurred relative to the containing sprite.
-         * @param localY            The vertical coordinate at which the event occurred relative to the containing sprite.
-         * @param extendSelection   Indicates that only activeIndex should move
-         * @return the resulting SelectionState
-         */                                                                                                              
-         private function selectionPoint(currentTarget:Object, target:Object, localX:Number, localY:Number, extendSelection:Boolean = false):SelectionState
-         {
-            //trace("selectionPoint");
-            if (!_textFlow) 
-                return null;
-            if (!hasSelection()) 
-                extendSelection = false;
-            
-            var begIdx:int = anchorMark.position;
-            var endIdx:int = activeMark.position;
-            
-            endIdx = computeSelectionIndex(_textFlow, target, currentTarget, localX, localY);
-            if (endIdx == -1)
-                return null;    // ignore
-                        
-            // make sure we aren't selecting after the flow terminating character
-            endIdx = Math.min(endIdx, _textFlow.textLength - 1);
-            
-            if (!extendSelection)
-                begIdx = endIdx;                            
-
-            if (begIdx == endIdx)
-            {
-                begIdx = NavigationUtil.updateStartIfInReadOnlyElement(_textFlow, begIdx);
-                endIdx = NavigationUtil.updateEndIfInReadOnlyElement(_textFlow, endIdx);
-            } else {
-                endIdx = NavigationUtil.updateEndIfInReadOnlyElement(_textFlow, endIdx);
-            }           
-            return new SelectionState(textFlow, begIdx, endIdx);
-         }                       
-         
-        /** 
-         *  @copy ISelectionManager#setFocus()
-         * 
-         * 
-        * @playerversion Flash 10
-        * @playerversion AIR 1.5
-         * @langversion 3.0
-        */
-         public function setFocus():void
-         {
-             if (!_textFlow)
-                 return;
-             
-            //  trace("setFocus sm", id);
-
-            // container with the activePosition gets the key focus
-            if (_textFlow.flowComposer)
-                _textFlow.flowComposer.setFocus(activePosition,false);
-            setSelectionFormatState(SelectionFormatState.FOCUSED);
-         }
-         
-        /** 
-         * Set the Mouse cursor. 
-         * @param cursor    New cursor value, MouseCursor.AUTO if mouse is going off text, MouseCursor.IBEAM if mouse is going into text
-         * 
-         * @playerversion Flash 10.2
-         * @playerversion AIR 2.0
-         * @langversion 3.0
-         */
-        protected function setMouseCursor(cursor:String):void
-        {
-			Mouse.cursor = Configuration.getCursorString(textFlow.configuration, cursor);
-        }
-        
-        /**
-         *  @copy ISelectionManager#anchorPosition
-         */
-        public function get anchorPosition() : int
-        {
-            return anchorMark.position;
-        }
-        /**
-         *  @copy ISelectionManager#activePosition
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         */
-        public function get activePosition() : int
-        {
-            return activeMark.position;         
-        }
-        /**
-         *  @copy ISelectionManager#absoluteStart
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         */
-        public function get absoluteStart() : int
-        {
-            return (anchorMark.position < activeMark.position) ? anchorMark.position : activeMark.position;
-        }
-        /**
-         *  @copy ISelectionManager#absoluteEnd
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         */
-        public function get absoluteEnd() : int
-        {
-            return (anchorMark.position > activeMark.position) ? anchorMark.position : activeMark.position;
-        }
-        
-        /** 
-         *  @copy ISelectionManager#selectAll
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         * 
-         * @see org.apache.flex.textLayout.compose.IFlowComposer
-         */
-        public function selectAll() : void
-        {
-			if(subManager)
-				subManager.selectAll();
-			else
-			{
-				var lastSelectablePos:int = (_textFlow.textLength > 0) ? _textFlow.textLength - 1 : 0;
-				selectRange(0, lastSelectablePos);
-			}
-        }
-        
-        /** 
-         * @copy ISelectionManager#selectRange
-         * 
-         * 
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         * 
-         * @see org.apache.flex.textLayout.compose.IFlowComposer
-         */
-        public function selectRange(anchorPosition:int, activePosition:int) : void
-        {
-            flushPendingOperations();
-			
-			if(subManager && (anchorPosition != -1 || activePosition != -1))
-			{
-				subManager.selectRange(-1,-1);
-				subManager = null;
-			}
-			if(textFlow.nestedInTable())
+
+		/** 
+		 *  @copy ISelectionManager#isRangeSelection()
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function isRangeSelection():Boolean
+		{
+			return anchorMark.position != -1 && anchorMark.position != activeMark.position;
+		}
+
+		/**
+		 * The ITextFlow object managed by this selection manager. 
+		 * 
+		 * <p>A selection manager manages a single text flow. A selection manager can also be
+		 * assigned to a text flow by setting the <code>interactionManager</code> property of the
+		 * ITextFlow object.</p>
+		 * 
+		 * @see org.apache.flex.textLayout.elements.ITextFlow#interactionManager
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get textFlow():ITextFlow
+		{
+			return _textFlow;
+		}
+
+		public function set textFlow(value:ITextFlow):void
+		{
+			if (_textFlow != value)
 			{
-				var cell:ITableCellElement = textFlow.parentElement as ITableCellElement;
-				superManager = cell.getTextFlow().interactionManager;
-				superManager.currentTable = cell.table;
-				superManager.deselect();
-				superManager.anchorCellPosition.column = cell.colIndex;
-				superManager.anchorCellPosition.row = cell.rowIndex;
-				superManager.subManager = this;
-			}
+				if (_textFlow)
+					flushPendingOperations();
 
-            
-            // anchor and active can be in any order
-            // TODO: range check and clamp anchor,active
-            if (anchorPosition != anchorMark.position || activePosition != activeMark.position)
-            {   
-                clearSelectionShapes();
+				clear();
 				clearCellSelections();
 				_cellRange = null;
-                    
-                internalSetSelection(_textFlow, anchorPosition, activePosition, _pointFormat);
-                
-                // selection changed
-                selectionChanged();
-                
-                allowOperationMerge = false;
-            }
-        }
-		
-		/** 
-		 * @copy ISelectionManager#selectFirstPosition
+
+				// If we switch into read-only mode, make sure the cursor isn't showing a text selection IBeam
+				if (!value) // see Watson 2637162
+					setMouseCursor(MouseCursor.AUTO);
+
+				_textFlow = value;
+
+				if (_textFlow && _textFlow.interactionManager != this)
+					_textFlow.interactionManager = this;
+			}
+		}
+
+		/**
+		 *  @copy ISelectionManager#editingMode
 		 * 
 		 * @playerversion Flash 10
 		 * @playerversion AIR 1.5
 		 * @langversion 3.0
 		 * 
-		 * @see org.apache.flex.textLayout.compose.IFlowComposer
+		 * @see org.apache.flex.textLayout.edit.EditingMode
 		 */
-		public function selectFirstPosition():void
+		public function get editingMode():String
 		{
-			selectRange(0, 0);
+			return EditingMode.READ_SELECT;
 		}
-		
+
 		/** 
-		 * @copy ISelectionManager#selectLastPosition
+		 *  @copy ISelectionManager#windowActive
 		 * 
 		 * @playerversion Flash 10
 		 * @playerversion AIR 1.5
 		 * @langversion 3.0
-		 * 
-		 * @see org.apache.flex.textLayout.compose.IFlowComposer
 		 */
-		public function selectLastPosition():void
+		public function get windowActive():Boolean
 		{
-            var max:int = 2147483647;
-			selectRange(max, max);
+			return _selFormatState != SelectionFormatState.INACTIVE;
 		}
 
 		/** 
-		 * @copy ISelectionManager#deselect
+		 *  @copy ISelectionManager#focused
 		 * 
 		 * @playerversion Flash 10
 		 * @playerversion AIR 1.5
 		 * @langversion 3.0
+		 */
+		public function get focused():Boolean
+		{
+			return _selFormatState == SelectionFormatState.FOCUSED;
+		}
+
+		/**
+		 *  @copy ISelectionManager#currentSelectionFormat
 		 * 
-		 * @see org.apache.flex.textLayout.compose.IFlowComposer
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionFormat
 		 */
-		public function deselect():void
+		public function get currentSelectionFormat():SelectionFormat
 		{
-			if (hasAnySelection())
+			if (_selFormatState == SelectionFormatState.UNFOCUSED)
 			{
-				clearSelectionShapes();
-				clearCellSelections();
-				addSelectionShapes();
+				return unfocusedSelectionFormat;
 			}
-			selectRange(-1,-1);
-			_cellRange = null;
+			else if (_selFormatState == SelectionFormatState.INACTIVE)
+			{
+				return inactiveSelectionFormat;
+			}
+			return focusedSelectionFormat;
 		}
 
-        private function internalSetSelection(root:ITextFlow,anchorPosition:int,activePosition:int,format:ITextLayoutFormat = null) : void
-        {
-            _textFlow = root;
-            
-            // clamp anchor/active
-            if (anchorPosition < 0 || activePosition < 0)
-            {
-                anchorPosition = -1;
-                activePosition = -1;
-            }
-			else if(subManager)
+		/**
+		 *  @copy ISelectionManager#currentCellSelectionFormat
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionFormat
+		 */
+		public function get currentCellSelectionFormat():SelectionFormat
+		{
+			if (_selFormatState == SelectionFormatState.UNFOCUSED)
 			{
-				subManager.flushPendingOperations();
-				subManager = null;
+				return unfocusedCellSelectionFormat;
 			}
-            
-            var lastSelectablePos:int = (_textFlow.textLength > 0) ? _textFlow.textLength - 1 : 0;
-            
-            if (anchorPosition != -1 && activePosition != -1)
-            {
-                if (anchorPosition > lastSelectablePos)
-                    anchorPosition = lastSelectablePos;
-                
-                if (activePosition > lastSelectablePos)
-                    activePosition = lastSelectablePos;
-            }
-
-            _pointFormat = format;
-            anchorMark.position = anchorPosition; // NavigationUtil.updateStartIfInReadOnlyElement(root, anchorPosition);
-            activeMark.position = activePosition; // NavigationUtil.updateEndIfInReadOnlyElement(root, activePosition);
-        //  trace("Selection ", anchorMark, "to", activeMark.position);
-        }       
-        
-        /** 
-		 * Clear any active selections.
-         */
-        private function clear(): void
-        {
-            if (hasSelection())
-            {
-                flushPendingOperations();
-                clearSelectionShapes();
-                internalSetSelection(_textFlow, -1, -1);
-                // selection cleared
-                selectionChanged();
-                allowOperationMerge = false;
-            }
-        }
-        /**
-		 * Clear any cell selections
-		 * */
-		private function clearCellSelections():void
-		{
-			var blocks:Vector.<ITextFlowTableBlock>;
-			var block:ITextFlowTableBlock;
-			var controller:IContainerController;
-			
-			if (_cellRange) {
-				blocks = _cellRange.table.getTableBlocksInRange(_cellRange.anchorCoordinates, _cellRange.activeCoordinates);
-				
-				for each (block in blocks) {
-					if (controller != block.controller) {
-						block.controller.clearSelectionShapes();
-					}
-					
-					controller = block.controller;
-				}
-				
+			else if (_selFormatState == SelectionFormatState.INACTIVE)
+			{
+				return inactiveCellSelectionFormat;
 			}
-			if(block)
-				block.controller.clearSelectionShapes();
-			
-			//_cellRange = null;
-		}
-        private function addSelectionShapes():void
-        {
-            if (_textFlow.flowComposer)
-            {
-                // selection may need to be constrained due to model changes that weren't done with the EditManager
-                internalSetSelection(_textFlow, anchorMark.position, activeMark.position, _pointFormat);
-                
-                // zero alpha means nothing is drawn so skip it
-                if (currentSelectionFormat && 
-                    (((absoluteStart == absoluteEnd) &&  (currentSelectionFormat.pointAlpha != 0)) ||
-                     ((absoluteStart != absoluteEnd) && (currentSelectionFormat.rangeAlpha != 0))))
-                {
-                    var containerIter:int = 0;
-                    while(containerIter < _textFlow.flowComposer.numControllers)
-                    {
-                        _textFlow.flowComposer.getControllerAt(containerIter++).addSelectionShapes(currentSelectionFormat, absoluteStart, absoluteEnd);
-                    }
-                }
-            }
-        }
-        
-        private function clearSelectionShapes():void
-        {
-            var flowComposer:IFlowComposer = _textFlow ? _textFlow.flowComposer : null; 
-            if (flowComposer)
-            {
-                var containerIter:int = 0;
-                while(containerIter < flowComposer.numControllers)
-                {
-                    flowComposer.getControllerAt(containerIter++).clearSelectionShapes();
-                }
-            }
-        }
-		
-		/** 
-		 *  @copy ISelectionManager#refreshSelection()
+			return focusedCellSelectionFormat;
+		}
+
+		/**
+		 *  @copy ISelectionManager#focusedSelectionFormat
 		 * 
 		 * @playerversion Flash 10
 		 * @playerversion AIR 1.5
 		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionFormat
 		 */
-		public function refreshSelection(): void
+		public function set focusedSelectionFormat(val:SelectionFormat):void
 		{
-			if (hasAnySelection())
-			{
-				clearSelectionShapes();
-				clearCellSelections();
-				addSelectionShapes();
-			}
+			_focusedSelectionFormat = val;
+			if (this._selFormatState == SelectionFormatState.FOCUSED)
+				refreshSelection();
 		}
-		
-		/** 
-		 *  @copy ISelectionManager#clearSelection()
+
+		/**
+		 * @private - docs on setter
+		 */
+		public function get focusedSelectionFormat():SelectionFormat
+		{
+			return _focusedSelectionFormat ? _focusedSelectionFormat : (_textFlow ? _textFlow.configuration.focusedSelectionFormat : null);
+		}
+
+		/**
+		 *  @copy ISelectionManager#unfocusedSelectionFormat
 		 * 
 		 * @playerversion Flash 10
 		 * @playerversion AIR 1.5
 		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionFormat
 		 */
-		public function clearSelection(): void
+		public function set unfocusedSelectionFormat(val:SelectionFormat):void
 		{
-			if (hasAnySelection())
-			{
-				clearSelectionShapes();
-				clearCellSelections();
-			}
+			_unfocusedSelectionFormat = val;
+			if (this._selFormatState == SelectionFormatState.UNFOCUSED)
+				refreshSelection();
 		}
-        
-        /** Verifies that the selection is in a legal state. @private */
-        CONFIG::debug public function debugCheckSelectionManager():int
-        {
-            var rslt:int = 0;
-            if (hasSelection())
-            {
-                // both points must be within the flow - may not include trailing \n in final paragraph
-                var lastPosition:int = _textFlow.textLength > 0 ? _textFlow.textLength - 1 : 0;
-                rslt += assert(anchorMark.position >= 0 && anchorMark.position <= lastPosition,"SelectionManager:validate selBegIdx is out of range");
-                rslt += assert(activeMark.position >= 0 && activeMark.position <= lastPosition,"SelectionManager:validate selEndIdx is out of range");
-            }
-            return rslt;
-        }
-        
-        // ////////////////////////////////////
-        // internal selection handling methods
-        // ////////////////////////////////////
-        
-        /** @private
-         * Handler function called when the selection has been changed.
-         * @playerversion Flash 10
-         * @playerversion AIR 1.5
-         * @langversion 3.0
-         * @param doDispatchEvent   true if a selection changed event will be sent
-         * @param resetPointFormat  true if the attributes associated with the caret should be discarded
-         */
-        public function selectionChanged(doDispatchEvent:Boolean = true, resetPointFormat:Boolean=true):void
-        {
-            CONFIG::debug { debugCheckSelectionManager(); } // validates the selection
-            
-            // clear any remembered attributes for the next character
-            if (resetPointFormat) 
-                _pointFormat = null;
-            
-            if (doDispatchEvent && _textFlow)
-			{
-				if(textFlow.parentElement && textFlow.parentElement.getTextFlow())
-					textFlow.parentElement.getTextFlow().dispatchEvent(new SelectionEvent(SelectionEvent.SELECTION_CHANGE, false, false, hasSelection() ? getSelectionState() : null));
-				else
-					textFlow.dispatchEvent(new SelectionEvent(SelectionEvent.SELECTION_CHANGE, false, false, hasSelection() ? getSelectionState() : null));
-			}
-        }
 
-        // TODO: this routine could be much more efficient - instead of iterating over all lines in the ITextFlow it should iterate over 
-        // the visible lines in the container.  Todo that move this routine into ContainerController and use the shapeChildren along with the logic in fillShapeChildren
-        static private function computeSelectionIndexInContainer(textFlow:ITextFlow, controller:IContainerController, localX:Number, localY:Number):int
-        {
-			var result:int;
-            //var origX:Number = localX;
-            //var origY:Number = localY;
-            var lineIndex:int = -1;
-            
-            var firstCharVisible:int = controller.absoluteStart;
-            var length:int  = controller.textLength;
-            
-            // try to find a point on the line
-            var bp:String = textFlow.computedFormat.blockProgression;
-            var isTTB:Boolean = (bp == BlockProgression.RL);
-            var isDirectionRTL:Boolean = (textFlow.computedFormat.direction == Direction.RTL);
-            
-            //Establish perpendicular the coordinate for use with TTB or LTR/RTL lines
-            var perpCoor:Number = isTTB ? localX : localY;
-            
-            //get the nearest column so we can ignore lines which aren't in the column we're looking for.
-            //if we don't do this, we won't be able to select across column boundaries.
-            var nearestColIdx:int = locateNearestColumn(controller, localX, localY, textFlow.computedFormat.blockProgression,textFlow.computedFormat.direction);
+		/**
+		 *  @private - docs on setter
+		 */
+		public function get unfocusedSelectionFormat():SelectionFormat
+		{
+			return _unfocusedSelectionFormat ? _unfocusedSelectionFormat : (_textFlow ? _textFlow.configuration.unfocusedSelectionFormat : null);
+		}
 
-			var prevLineBounds:Rectangle = null;
-			var previousLineIndex:int = -1;
+		/**
+		 *  @copy ISelectionManager#inactiveSelectionFormat
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionFormat
+		 */
+		public function set inactiveSelectionFormat(val:SelectionFormat):void
+		{
+			_inactiveSelectionFormat = val;
+			if (this._selFormatState == SelectionFormatState.INACTIVE)
+				refreshSelection();
+		}
 
-			/*
-			//For the table feature, we are trying to make sure if the current point is in the table and which cell it is in
-			var nearestCell:ITableCellElement = locateNearestCell(controller, localX, localY, textFlow.computedFormat.blockProgression,textFlow.computedFormat.direction);
-            
-			
-			if(nearestCell)
-			{
-				//To-Do: Need to update the codes to be a real paragraph search sequence
-				var cellPara:IParagraphElement = nearestCell.getLastLeaf().getParagraph();
-				if(cellPara.getTextFlow() == textFlow)
-				{
-					//textLine = cellPara.getTextBlock().lastLine;
-					
-					//result = computeSelectionIndexInLine(textFlow, textLine, localX, localY);
-					// trace("computeSelectionIndexInContainer:(",origX,origY,")",textFlow.flowComposer.getControllerIndex(controller).toString(),lineIndex.toString(),result.toString());
-					return cellPara.getAbsoluteStart() + cellPara.textLength - 1;
-				}
-			}
-            */
-            var lastLineIndexInColumn:int = -1;
-            
-            // Matching ITextFlowLine and ITextLine - they are not necessarily valid
-            var rtline:ITextFlowLine;
-            var rtTextLine:ITextLine;
-            
-            for (var testIndex:int = textFlow.flowComposer.numLines - 1; testIndex >= 0; testIndex--)
-            {
-                rtline = textFlow.flowComposer.getLineAt(testIndex);
-                if (rtline.controller != controller || rtline.columnIndex != nearestColIdx)
-                {
-                    // use last line in previous column
-                    if (lastLineIndexInColumn != -1)
-                    {
-                        lineIndex = testIndex+1;
-                        break;
-                    }
-                    continue;
-                }
-                    
-                // is this line even displayed?
-                if (rtline.absoluteStart < firstCharVisible || rtline.absoluteStart >= firstCharVisible+length)
-                    continue;
-                rtTextLine = rtline.getTextLine();
-                if (rtTextLine == null || rtTextLine.parent == null)
-                    continue;
-                
-                if (lastLineIndexInColumn == -1)
-                    lastLineIndexInColumn = testIndex;
-                    
-                var bounds:Rectangle = BoundsUtil.getBounds(rtTextLine, controller.container);// rtTextLine.getBounds(DisplayObject(controller.container));
-                // trace(testIndex.toString(),":",bounds.toString());
-                
-                var linePerpCoor:Number = isTTB ? bounds.left : bounds.bottom;
-                var midPerpCoor:Number = -1;//will be a positive value if prevLineBounds is not null
-                
-                //if this is not the first test loop, use the prevLineBounds to find the mid-point between the current
-                //line, which will be logically up from the previous line - we're walking back-to-front
-                if(prevLineBounds)
-                {
-                    //if it's ttb, use the right bounds (ie the top of the line)...
-                    var prevPerpCoor:Number = (isTTB ? prevLineBounds.right : prevLineBounds.top);
-                    //calculate the midpoint
-                    midPerpCoor = (linePerpCoor + prevPerpCoor)/2;
-                }
-                
-                //if the current line is below the click, then this OR the previous line, is the line we're looking for
-                var isLineBelow:Boolean = (isTTB ? linePerpCoor > perpCoor : linePerpCoor < perpCoor);
-                if(isLineBelow || testIndex == 0)
-                {
-                    //if we haven't calculated the midPerpCoor (-1), then this is the first loop and we want to use the 
-                    //current line,. Otherwise, if the click's perpendicular coordinate is below the mid point between the current
-                    //line or below it, then we want to use the line below (ie the previous line, but logically the one after the current)
-                    var inPrevLine:Boolean = midPerpCoor != -1 && (isTTB ? perpCoor < midPerpCoor : perpCoor > midPerpCoor);
-					/*
-					if(rtline.paragraph.isInTable())
-					{
-						//if rtline is the last line of the cell and the isPrevLine is true, find the cell of the column in next row
-						//and try to set the line to be 
-						if ( inPrevLine && testIndex != lastLineIndexInColumn )
-						{
-							var rtPara:IParagraphElement = rtline.paragraph;
-							var rtCell:ITableCellElement = rtPara.getParentCellElement();
-							//get the last element of the cell
-							var lastElement:FlowElement = rtCell.getLastLeaf();
-							var rtLastTbLine:ITextFlowLine = lastElement ? lastElement.getParagraph().getTextBlock().lastLine.userData : null;
-							if( rtline == rtLastTbLine )
-							{
-								//temproray codes, need to be updated when the column apis are ready
-								var rtTable:ITableElement = rtCell.table;
-								var rtRow:ITableRowElement = rtCell.parent as ITableRowElement;
-								var nextRow:ITableRowElement = rtRow.getNextSibling() as ITableRowElement;
-								if ( nextRow && rtCell )
-								{
-									var nextCell:ITableCellElement = nextRow.getChildAt(rtCell.colIndex) as ITableCellElement;
-									lineIndex = textFlow.flowComposer.findLineIndexAtPosition(nextCell.getFirstLeaf().getParagraph().getAbsoluteStart());
-								}
-							}
-							else
-								lineIndex = testIndex + 1;
-						}
-						else
-							lineIndex = testIndex;
-					}
-					else
-					*/
-                    	lineIndex = inPrevLine && testIndex != lastLineIndexInColumn ? testIndex+1 : testIndex;
-					break;
-                }
-                else
-                {
-                    //this line is below the click, so set the prevLineBounds to bounds of the current line and move on...
-                    prevLineBounds = bounds;
-                    previousLineIndex = testIndex;
-                }
-            }
-
-            if (lineIndex == -1)
-            {
-                lineIndex = previousLineIndex;
-                if (lineIndex == -1)
-                    return -1;  // no lines in container
-            }   
-                
-            //Get a valid textLine -- check to make sure line is valid, regenerate if necessary, make sure it has correct container relative coordinates
-            var textFlowLine:ITextFlowLine = textFlow.flowComposer.getLineAt(lineIndex);
-			if(textFlowLine is TextFlowTableBlock)
-			{
-				result = TextFlowTableBlock(textFlowLine).absoluteStart;
-			}
-			else
+		/**
+		 * @private - docs on setter
+		 */
+		public function get inactiveSelectionFormat():SelectionFormat
+		{
+			return _inactiveSelectionFormat ? _inactiveSelectionFormat : (_textFlow ? _textFlow.configuration.inactiveSelectionFormat : null);
+		}
+
+		/**
+		 *  @copy ISelectionManager#focusedCellSelectionFormat
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionFormat
+		 */
+		public function set focusedCellSelectionFormat(val:SelectionFormat):void
+		{
+			_focusedCellSelectionFormat = val;
+			if (this._selFormatState == SelectionFormatState.FOCUSED)
+				refreshSelection();
+		}
+
+		/**
+		 * @private - docs on setter
+		 */
+		public function get focusedCellSelectionFormat():SelectionFormat
+		{
+			return _focusedCellSelectionFormat ? _focusedCellSelectionFormat : (_textFlow ? _textFlow.configuration.focusedSelectionFormat : null);
+		}
+
+		/**
+		 *  @copy ISelectionManager#unfocusedCellSelectionFormat
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionFormat
+		 */
+		public function set unfocusedCellSelectionFormat(val:SelectionFormat):void
+		{
+			_unfocusedCellSelectionFormat = val;
+			if (this._selFormatState == SelectionFormatState.UNFOCUSED)
+				refreshSelection();
+		}
+
+		/**
+		 *  @private - docs on setter
+		 */
+		public function get unfocusedCellSelectionFormat():SelectionFormat
+		{
+			return _unfocusedCellSelectionFormat ? _unfocusedCellSelectionFormat : (_textFlow ? _textFlow.configuration.unfocusedSelectionFormat : null);
+		}
+
+		/**
+		 *  @copy ISelectionManager#inactiveCellSelectionFormat
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionFormat
+		 */
+		public function set inactiveCellSelectionFormat(val:SelectionFormat):void
+		{
+			_inactiveCellSelectionFormat = val;
+			if (this._selFormatState == SelectionFormatState.INACTIVE)
+				refreshSelection();
+		}
+
+		/**
+		 * @private - docs on setter
+		 */
+		public function get inactiveCellSelectionFormat():SelectionFormat
+		{
+			return _inactiveCellSelectionFormat ? _inactiveCellSelectionFormat : (_textFlow ? _textFlow.configuration.inactiveSelectionFormat : null);
+		}
+
+		/** @private - returns the selectionFormatState.  @see org.apache.flex.textLayout.edit.SelectionFormatState */
+		public function get selectionFormatState():String
+		{
+			return _selFormatState;
+		}
+
+		/** @private - sets the SelectionFormatState. @see org.apache.flex.textLayout.edit.SelectionFormatState */
+		public function setSelectionFormatState(selFormatState:String):void
+		{
+			if (selFormatState != _selFormatState)
 			{
-				var textLine:ITextLine = textFlowLine.getTextLine(true);
-				
-				// adjust localX,localY to be relative to the textLine.  
-				// Can't use localToGlobal/globalToLocal because textLine may not be on the display list due to virtualization
-				// we may need to bring this back if textline's can be rotated or placed by any mechanism other than a translation
-				// but then we'll need to provisionally place a virtualized ITextLine in its parent container
-				localX -= textLine.x;
-				localY -= textLine.y;
-				/* var localPoint:Point = DisplayObject(controller.container).localToGlobal(new Point(localX,localY));
-				localPoint = textLine.globalToLocal(localPoint);
-				localX = localPoint.x;
-				localY = localPoint.y; */
-				
-				
-				var startOnNextLineIfNecessary:Boolean = false;
-				
-				var lastAtom:int = -1;
-				if (isDirectionRTL) {
-					lastAtom = textLine.atomCount - 1;
-				} else {
-					if ((textFlowLine.absoluteStart + textFlowLine.textLength) >= textFlowLine.paragraph.getAbsoluteStart() + textFlowLine.paragraph.textLength) {
-						if (textLine.atomCount > 1) lastAtom = textLine.atomCount - 2;
-					} else {
-						var lastLinePosInPar:int = textFlowLine.absoluteStart + textFlowLine.textLength - 1;
-						var lastChar:String = textLine.textBlock.content.rawText.charAt(lastLinePosInPar);
-						if (lastChar == " ") {
-							if (textLine.atomCount > 1) lastAtom = textLine.atomCount - 2;
-						} else {
-							startOnNextLineIfNecessary = true;
-							if (textLine.atomCount > 0) lastAtom = textLine.atomCount - 1;
-						}
-					}
-				}
-				var lastAtomRect:Rectangle = (lastAtom > 0) ? textLine.getAtomBounds(lastAtom) : new Rectangle(0, 0, 0, 0);
-				
-				if (!isTTB)
+				// trace("changing selection state: was", _selFormatState, "switching to", selFormatState, "on selectionManager", id);
+				var oldSelectionFormat:SelectionFormat = currentSelectionFormat;
+				_selFormatState = selFormatState;
+				var newSelectionFormat:SelectionFormat = currentSelectionFormat;
+				if (!newSelectionFormat.equals(oldSelectionFormat))
 				{
-					if (localX < 0)
-						localX = 0;
-					else if (localX > (lastAtomRect.x + lastAtomRect.width))
-					{
-						if (startOnNextLineIfNecessary) 
-							return textFlowLine.absoluteStart + textFlowLine.textLength - 1;
-						if (lastAtomRect.x + lastAtomRect.width > 0)
-							localX = lastAtomRect.x + lastAtomRect.width;
-					}
-				}
-				else
-				{   
-					if (localY < 0) 
-						localY = 0;
-					else if (localY > (lastAtomRect.y + lastAtomRect.height))
-					{
-						if (startOnNextLineIfNecessary) 
-							return textFlowLine.absoluteStart + textFlowLine.textLength - 1;    
-						if (lastAtomRect.y + lastAtomRect.height > 0)
-							localY = lastAtomRect.y + lastAtomRect.height;
-					}
+					refreshSelection();
 				}
-				
-				result = computeSelectionIndexInLine(textFlow, textLine, localX, localY);
 			}
+		}
 
-            // trace("computeSelectionIndexInContainer:(",origX,origY,")",textFlow.flowComposer.getControllerIndex(controller).toString(),lineIndex.toString(),result.toString());
-            return result != -1 ? result : firstCharVisible + length;   
-        }
-		/*
-		static private function locateNearestCell(container:ContainerController, localX:Number, localY:Number, wm:String, direction:String):ITableCellElement
+		/** @private */
+		public function cloneSelectionFormatState(oldISelectionManager:ISelectionManager):void
 		{
-			var cellIdx:int = 0;
-			//if we only have 1 column, no need to perform calculation...
-			var columnState:ColumnState = container.columnState;
-			
-			var isFound:Boolean = false;
-			var curCell:ITableCellElement = null;
-			
-			//we need to compare the current column to the nextColmn
-			while(cellIdx < columnState.cellCount - 1)
+			var oldSelectionManager:SelectionManager = oldISelectionManager as SelectionManager;
+			if (oldSelectionManager)
 			{
-				curCell = columnState.getCellAt(cellIdx);
-				var curRect:Rectangle = new Rectangle(curCell.x, curCell.y, curCell.width, curCell.height);
-				
-				if(curRect.contains(localX, localY)) //in current column
-				{
-					isFound = true;
-					break;
-				}
-				++cellIdx;
-			}
-			return isFound? curCell : null;
-		}
-        */
-        static private function locateNearestColumn(container:IContainerController, localX:Number, localY:Number, wm:String, direction:String):int
-        {
-            var colIdx:int = 0;
-            //if we only have 1 column, no need to perform calculation...
-            var columnState:ColumnState = container.columnState;
-
-            //we need to compare the current column to the nextColmn
-            while(colIdx < columnState.columnCount - 1)
-            {
-                var curCol:Rectangle  = columnState.getColumnAt(colIdx);
-                var nextCol:Rectangle = columnState.getColumnAt(colIdx + 1);
-                
-                if(curCol.contains(localX, localY)) //in current column
-                    break;
-                
-                if(nextCol.contains(localX, localY))//in next column
-                {
-                    ++colIdx;
-                    break;
-                }
-                else
-                {
-                    if(wm == BlockProgression.RL)
-                    {
-                        //if localY is above curCol || between columns, but close to current
-                        if(localY < curCol.top || localY < nextCol.top && Math.abs(curCol.bottom - localY) <= Math.abs(nextCol.top - localY))
-                            break;
-                        
-                        if(localY > nextCol.top)//between but closer to nextCol
-                        {
-                            ++colIdx;
-                            break;
-                        }
-                    }
-                    else
-                    {
-                        if(direction  == Direction.LTR)
-                        {
-                            //if localX is left of curCol || between columns but closer to current, break here
-                            if(localX < curCol.left || localX < nextCol.left && Math.abs(curCol.right - localX) <= Math.abs(nextCol.left - localX)) 
-                                break;
-                            if(localX < nextCol.left) // between, but closer to next column
-                            {
-                                ++colIdx;
-                                break;
-                            }
-                        }
-                        else
-                        {
-                            //if localX is right of curCol || between columns, but closer to current
-                            if(localX > curCol.right || localX > nextCol.right && Math.abs(curCol.left - localX) <= Math.abs(nextCol.right - localX))
-                                break;
-                            
-                            if(localX > nextCol.right) // between, but closer to next column
-                            {
-                                ++colIdx;
-                                break;
-                            }
-                        } 
-                    }
-                }
-                
-                //increment colIdx.  If this is the last pass through, then the conditions above were never met
-                //so we want the last column
-                ++colIdx;
-            }
+				_isActive = oldSelectionManager._isActive;
+				_mouseOverSelectionArea = oldSelectionManager._mouseOverSelectionArea;
+				setSelectionFormatState(oldSelectionManager.selectionFormatState);
+			}
+		}
 
-            
-            return colIdx;
-        }
-        
-        static private function computeSelectionIndexInLine(textFlow:ITextFlow, textLine:ITextLine,localX:Number,localY:Number):int
-        {
-            if (!(textLine.userData is ITextFlowLine))
-                return -1;  // not a TextLayout generated line
-                
-            var rtline:ITextFlowLine = ITextFlowLine(textLine.userData);
-            if (rtline.validity == "invalid")
-                return -1;  // not currently composed 
-            textLine = rtline.getTextLine(true);    // make sure the ITextLine is not released
-            
-                
-            var isTTB:Boolean = textFlow.computedFormat.blockProgression == BlockProgression.RL;
-            var perpCoor:Number = isTTB ? localX : localY;
-            
-            // new code for builds 385 and later
-            var pt:Point = new Point();
-            pt.x = localX;
-            pt.y = localY;
-            
-            // in most cases, we want to "fixup" the coordiates of the x and y coordinates
-            //because we could be getting a positive results for a click in the line, but the
-            //coordinates do not match any particular glyph.  However, there are cases where the 
-            //fix leads to bad results. For example, if there is a TCY run, this code will always cause
-            //a selection to be created in the middle of the run, meaning idividual glyphs cannot be selected.
-            //
-            //As a result, we need to be performing the less common case check prior to adjusting the 
-            //coordinates.
-            pt = PointUtils.localToGlobal(pt, textLine);// textLine.localToGlobal(pt);
-            var elemIdx:int = textLine.getAtomIndexAtPoint(pt.x,pt.y);
-            //trace("global point: " + pt);
-            //trace("elemIdx: " + elemIdx);
-            if(elemIdx == -1)
-            {
-                //reset the pt
-                pt.x = localX;
-                pt.y = localY;
-                
-                //make adjustments
-                if (pt.x < 0 || (isTTB && perpCoor > textLine.ascent))
-                    pt.x = 0;
-                if (pt.y < 0 || (!isTTB && perpCoor > textLine.descent))
-                    pt.y = 0;
-                
-                //get the global again and get try for the element again
-                pt = PointUtils.localToGlobal(pt, textLine);// textLine.localToGlobal(pt);
-                elemIdx = textLine.getAtomIndexAtPoint(pt.x,pt.y);
-                //trace("global point (second): " + pt);
-                //trace("elemIdx (second): " + elemIdx);
-            }
-            
-            //now we REALLY don't have a glyph, so return the head or tail of the line.
-            if (elemIdx == -1)
-            {
-                //we need to use global coordinates here.  reset pt and get conversion...
-                pt.x = localX;
-                pt.y = localY;
-                pt = PointUtils.localToGlobal(pt, textLine);// textLine.localToGlobal(pt);
-                if (textLine.parent)
-                    pt = PointUtils.globalToLocal(pt, textLine.parent);// textLine.parent.globalToLocal(pt);
-                
-                if(!isTTB)
-                    return (pt.x <= textLine.x) ? rtline.absoluteStart : (rtline.absoluteStart + rtline.textLength - 1);
-                else
-                    return (pt.y <= textLine.y) ? rtline.absoluteStart : (rtline.absoluteStart + rtline.textLength - 1);
-            }
-            
-            // get the character box and if check we are past the middle select past this character. 
-            var glyphRect:Rectangle = textLine.getAtomBounds(elemIdx);
-            // trace("idx",elemIdx,"x",glyphRect.x,"y",glyphRect.y,"width",glyphRect.width,"height",glyphRect.height,"localX",localX,"localY",localY,"textLine.x",textLine.x);
-            var leanRight:Boolean = false;
-            if(glyphRect)
-            {   
-                //if this is TTB and NOT TCY determine lean based on Y coordinates...
-                if(isTTB && textLine.getAtomTextRotation(elemIdx) != TextRotation.ROTATE_0)
-                    leanRight = (localY > (glyphRect.y + glyphRect.height/2));
-                else //use X..
-                    leanRight = (localX > (glyphRect.x + glyphRect.width/2));
-            }
-            
-            var paraSelectionIdx:int;
-            if ((textLine.getAtomBidiLevel(elemIdx) % 2) != 0) // Right to left case, right is "start" unicode
-                paraSelectionIdx = leanRight ? textLine.getAtomTextBlockBeginIndex(elemIdx) : textLine.getAtomTextBlockEndIndex(elemIdx);
-            else  // Left to right case, right is "end" unicode
-                paraSelectionIdx = leanRight ? textLine.getAtomTextBlockEndIndex(elemIdx) : textLine.getAtomTextBlockBeginIndex(elemIdx);
-
-			//we again need to do some fixup here.  Unfortunately, we don't have the index into the paragraph until
-            return rtline.paragraph.getTextBlockAbsoluteStart(textLine.textBlock) + paraSelectionIdx;
-        }
-        
 		/**
-		 *  @flexjsignorecoercion org.apache.flex.core.IParentIUIBase
+		 * Gets the SelectionState at the specified mouse position.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.edit.SelectionState
+		 * @param currentTarget     The object that is actively processing the Event object with an event listener.
+		 * @param target            The InteractiveObject instance under the pointing device. The target is not always the object in the display list that registered the event listener. Use the currentTarget property to access the object in the display list that is currently processing the event.
+		 * @param localX            The horizontal coordinate at which the event occurred relative to the containing sprite.
+		 * @param localY            The vertical coordinate at which the event occurred relative to the containing sprite.
+		 * @param extendSelection   Indicates that only activeIndex should move
+		 * @return the resulting SelectionState
 		 */
-        static private function checkForDisplayed(container:IParentIUIBase):Boolean
-        {
-            try
-            {
-                while (container)
-                {
-                    if (!container.visible)
-                        return false;
-                    container = container.parent as IParentIUIBase;
-//TODO is this performant enough? Can we check for null instead?
-                    if (container is IApplicationView)
-                        return true;                    
-                }
-            }
-            catch (e:Error)
-            { return true; }
-            return false;   // not on the stage
-
-        }
-		/** @private - find a controller and adjusts the x and y values of localPoint if necessary */
-		private static function findController(textFlow:ITextFlow, target:Object, currentTarget:Object, localPoint:Point):IContainerController
+		private function selectionPoint(currentTarget:Object, target:Object, localX:Number, localY:Number, extendSelection:Boolean = false):SelectionState
 		{
-			var localX:Number = localPoint.x;
-			var localY:Number = localPoint.y;
-			var controller:IContainerController;
-			var containerPoint:Point; // scratch
-			
-			var globalPoint:Point = PointUtils.localToGlobal(new Point(localX, localY), target);// DisplayObject(target).localToGlobal(new Point(localX, localY));
+			// trace("selectionPoint");
+			if (!_textFlow)
+				return null;
+			if (!hasSelection())
+				extendSelection = false;
 
-			for (var idx:int = 0; idx < textFlow.flowComposer.numControllers; idx++)
+			var begIdx:int = anchorMark.position;
+			var endIdx:int = activeMark.position;
+
+			endIdx = computeSelectionIndex(_textFlow, target, currentTarget, localX, localY);
+			if (endIdx == -1)
+				return null;    // ignore
+
+			// make sure we aren't selecting after the flow terminating character
+			endIdx = Math.min(endIdx, _textFlow.textLength - 1);
+
+			if (!extendSelection)
+				begIdx = endIdx;
+
+			if (begIdx == endIdx)
 			{
-				var testController:IContainerController = textFlow.flowComposer.getControllerAt(idx); 
-				if (testController.container == target || testController.container == currentTarget)
+				begIdx = NavigationUtil.updateStartIfInReadOnlyElement(_textFlow, begIdx);
+				endIdx = NavigationUtil.updateEndIfInReadOnlyElement(_textFlow, endIdx);
+			}
+			else
+			{
+				endIdx = NavigationUtil.updateEndIfInReadOnlyElement(_textFlow, endIdx);
+			}
+			return new SelectionState(textFlow, begIdx, endIdx);
+		}
+
+		/** 
+		 *  @copy ISelectionMan

<TRUNCATED>