Repository: flex-tlf Updated Branches: refs/heads/develop cb2794edb -> 7fe228452
Fixed a range error when accessing TextBlocks in paragraphs with tables. Project: http://git-wip-us.apache.org/repos/asf/flex-tlf/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-tlf/commit/7fe22845 Tree: http://git-wip-us.apache.org/repos/asf/flex-tlf/tree/7fe22845 Diff: http://git-wip-us.apache.org/repos/asf/flex-tlf/diff/7fe22845 Branch: refs/heads/develop Commit: 7fe228452bf7aff8bd670dbdc7cb4e6858628bab Parents: cb2794e Author: Harbs <[email protected]> Authored: Thu Aug 18 13:30:57 2016 +0300 Committer: Harbs <[email protected]> Committed: Thu Aug 18 13:30:57 2016 +0300 ---------------------------------------------------------------------- .../src/UnitTest/Tests/KeyboardGestureTest.as | 14 ++++---- .../textLayout/elements/ParagraphElement.as | 36 ++++++++++++-------- 2 files changed, 29 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/7fe22845/automation_tests/src/UnitTest/Tests/KeyboardGestureTest.as ---------------------------------------------------------------------- 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 @@ package UnitTest.Tests 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 @@ package UnitTest.Tests 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 @@ package UnitTest.Tests 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 @@ package UnitTest.Tests 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 @@ package UnitTest.Tests 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 @@ package UnitTest.Tests 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); http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/7fe22845/textLayout/src/flashx/textLayout/elements/ParagraphElement.as ---------------------------------------------------------------------- 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 @@ package flashx.textLayout.elements 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 @@ package flashx.textLayout.elements super(); _terminatorSpan = null; _interactiveChildrenCount = 0 ; - _textBlockChildren = new Dictionary(); } tlf_internal function get interactiveChildrenCount():int { @@ -142,7 +140,7 @@ package flashx.textLayout.elements updateTextBlock(tb); } } - private function updateTextBlockDict():void + private function updateTextBlockRefs():void { var tbs:Vector.<TextBlock> = getTextBlocks(); if(tbs.length == 0) @@ -156,14 +154,22 @@ package flashx.textLayout.elements 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 @@ package flashx.textLayout.elements if(idx > -1) { tbs.splice(idx,1); - delete _textBlockChildren[tb]; } } } @@ -201,21 +206,24 @@ package flashx.textLayout.elements 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);
