Fixed a range error when accessing TextBlocks in paragraphs with tables.
diff --git a/automation_tests/src/UnitTest/Tests/KeyboardGestureTest.as b/automation_tests/src/UnitTest/Tests/KeyboardGestureTest.as
index 79a4334..2861a1a 100644
--- a/automation_tests/src/UnitTest/Tests/KeyboardGestureTest.as
+++ b/automation_tests/src/UnitTest/Tests/KeyboardGestureTest.as
@@ -2808,13 +2808,13 @@
SelManager.selectRange(6067, 6067);
sendKeyboardGesture(PG_UP);
- assertTrue("PgUp failed to select 7/8 page up",
+ assertTrue("PgUp failed to select 7/8 page up. Expected 3332,3332 but got " + SelManager.activePosition + "," + SelManager.anchorPosition + " instead.",
SelManager.activePosition == 3332 &&
SelManager.anchorPosition == 3332);
SelManager.selectRange(1314, 1314);
sendKeyboardGesture(PG_UP);
- assertTrue("PgUp failed to select to top line",
+ assertTrue("PgUp failed to select to top line Expected 72,72 but got " + SelManager.activePosition + "," + SelManager.anchorPosition + " instead.",
SelManager.activePosition == 72 &&
SelManager.anchorPosition == 72);
}
@@ -2844,7 +2844,7 @@
SelManager.selectRange(608, 608);
sendKeyboardGesture(PG_UP);
- assertTrue("PageUp failed to move up from image sandwich",
+ assertTrue("PageUp failed to move up from image sandwich. Expected 460,460 but got " + SelManager.activePosition + "," + SelManager.anchorPosition + " instead.",
SelManager.activePosition == 460 &&
SelManager.anchorPosition == 460);
@@ -2897,7 +2897,7 @@
SelManager.selectRange(261, 261);
sendKeyboardGesture(PG_UP);
- assertTrue("PageUp changed movement behavior within right to left text",
+ assertTrue("PageUp changed movement behavior within right to left text. Expected 12,12 but got " + SelManager.activePosition + "," + SelManager.anchorPosition + " instead.",
SelManager.activePosition == 12 &&
SelManager.anchorPosition == 12);
@@ -2937,7 +2937,7 @@
SelManager.selectRange(6067, 6067);
sendKeyboardGesture(SHIFT_PG_UP);
- assertTrue("Shift-PageUp failed to select 7/8 page up",
+ assertTrue("Shift-PageUp failed to select 7/8 page up. Expected 3332,6067 but got " + SelManager.activePosition + "," + SelManager.anchorPosition + " instead.",
SelManager.activePosition == 3332 &&
SelManager.anchorPosition == 6067);
@@ -2973,7 +2973,7 @@
SelManager.selectRange(608, 608);
sendKeyboardGesture(SHIFT_PG_UP);
- assertTrue("Shift-PageUp failed to move up from image sandwich",
+ assertTrue("Shift-PageUp failed to move up from image sandwich. Expected 460,608 but got " + SelManager.activePosition + "," + SelManager.anchorPosition + " instead.",
SelManager.activePosition == 460 &&
SelManager.anchorPosition == 608);
@@ -3026,7 +3026,7 @@
SelManager.selectRange(261, 261);
sendKeyboardGesture(SHIFT_PG_UP);
- assertTrue("Shift-PageUp changed movement behavior within right to left text",
+ assertTrue("Shift-PageUp changed movement behavior within right to left text. Expected 12,261 but got " + SelManager.activePosition + "," + SelManager.anchorPosition + " instead.",
SelManager.activePosition == 12 &&
SelManager.anchorPosition == 261);
diff --git a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
index dbb01b8..ab92d83 100644
--- a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
+++ b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
@@ -81,7 +81,6 @@
public final class ParagraphElement extends ParagraphFormattedElement
{
//private var _textBlock:TextBlock;
- private var _textBlockChildren:Dictionary;
private var _terminatorSpan:SpanElement;
private var _interactiveChildrenCount:int;
@@ -97,7 +96,6 @@
super();
_terminatorSpan = null;
_interactiveChildrenCount = 0 ;
- _textBlockChildren = new Dictionary();
}
tlf_internal function get interactiveChildrenCount():int
{
@@ -142,7 +140,7 @@
updateTextBlock(tb);
}
}
- private function updateTextBlockDict():void
+ private function updateTextBlockRefs():void
{
var tbs:Vector.<TextBlock> = getTextBlocks();
if(tbs.length == 0)
@@ -156,14 +154,22 @@
child = getChildAt(i);
if(child is TableElement)
{
- _textBlockChildren[tb] = items;
- tb = tbs[++tbIdx];
+ tb.userData = items;
+ if(++tbIdx == tbs.length)
+ return;
+ tb = tbs[tbIdx];
+ tb.userData = null;
+
+ //Advance to the next one.
+ if(++tbIdx == tbs.length)
+ return;
+ tb = tbs[tbIdx];
items = [];
continue;
}
items.push(child);
}
- _textBlockChildren[tb] = items;
+ tb.userData = items;
}
private function removeTextBlock(tb:TextBlock):void
{
@@ -174,7 +180,6 @@
if(idx > -1)
{
tbs.splice(idx,1);
- delete _textBlockChildren[tb];
}
}
}
@@ -201,21 +206,24 @@
CONFIG::debug { Debugging.traceFTECall(null,tb,"releaseLines",tb.firstLine, tb.lastLine); }
tb.releaseLines(tb.firstLine, tb.lastLine);
}
- var items:Array = _textBlockChildren[tb];
- var len:int = items.length;
- for (var i:int = 0; i < len; i++)
+ var items:Array = tb.userData;
+ if(items)
{
- var child:FlowElement = items[i];
- child.releaseContentElement();
+ var len:int = items.length;
+ for (var i:int = 0; i < len; i++)
+ {
+ var child:FlowElement = items[i];
+ child.releaseContentElement();
+ }
+ items.length = 0;
}
- items.length = 0;
tb.content = null;
removeTextBlock(tb);
}
/** @private */
tlf_internal function releaseTextBlock(tb:TextBlock=null):void
{
- updateTextBlockDict();
+ updateTextBlockRefs();
if(tb)
{
releaseTextBlockInternal(tb);