You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2013/10/12 01:11:52 UTC
[1/3] git commit: [flex-tlf] [refs/heads/master] - FLEX-33409:
workaround player bugs involving discretionary hyphens
Updated Branches:
refs/heads/master 15ceae3d2 -> 3b7adac46
FLEX-33409: workaround player bugs involving discretionary hyphens
Project: http://git-wip-us.apache.org/repos/asf/flex-tlf/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-tlf/commit/f4545d2a
Tree: http://git-wip-us.apache.org/repos/asf/flex-tlf/tree/f4545d2a
Diff: http://git-wip-us.apache.org/repos/asf/flex-tlf/diff/f4545d2a
Branch: refs/heads/master
Commit: f4545d2abb2312ef43e2b2b2d2bbb0dd02b929ca
Parents: 15ceae3
Author: Alex Harui <ah...@apache.org>
Authored: Sat Aug 31 21:45:26 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Sat Aug 31 21:47:30 2013 -0700
----------------------------------------------------------------------
FLEX33409.patch | 150 +++++++++++++++++++
diff.txt | 150 +++++++++++++++++++
.../flashx/textLayout/compose/BaseCompose.as | 2 +-
.../flashx/textLayout/compose/ComposeState.as | 5 +
.../textLayout/compose/FlowComposerBase.as | 10 ++
.../textLayout/container/ContainerController.as | 2 +
.../textLayout/elements/FlowLeafElement.as | 2 +-
.../textLayout/elements/ParagraphElement.as | 41 ++++-
8 files changed, 359 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/f4545d2a/FLEX33409.patch
----------------------------------------------------------------------
diff --git a/FLEX33409.patch b/FLEX33409.patch
new file mode 100644
index 0000000..d301049
--- /dev/null
+++ b/FLEX33409.patch
@@ -0,0 +1,150 @@
+diff --git a/textLayout/src/flashx/textLayout/compose/BaseCompose.as b/textLayout/src/flashx/textLayout/compose/BaseCompose.as
+index e8ddb7b..2ad0506 100644
+--- a/textLayout/src/flashx/textLayout/compose/BaseCompose.as
++++ b/textLayout/src/flashx/textLayout/compose/BaseCompose.as
+@@ -1435,7 +1435,7 @@ package flashx.textLayout.compose
+
+ // advance to the next element, using the rootElement of the container as a limitNode
+ // to prevent going past the content bound to this container
+- _curElementOffset += _curLine.textLength;
++ _curElementOffset = _curLine.absoluteStart + _curLine.textLength - _curElementStart;
+ if (_curElementOffset >= _curElement.textLength)
+ {
+ // We may have composed ahead over several spans; skip until we match up
+diff --git a/textLayout/src/flashx/textLayout/compose/ComposeState.as b/textLayout/src/flashx/textLayout/compose/ComposeState.as
+index bdddf85..ce7bddc 100644
+--- a/textLayout/src/flashx/textLayout/compose/ComposeState.as
++++ b/textLayout/src/flashx/textLayout/compose/ComposeState.as
+@@ -340,6 +340,11 @@ package flashx.textLayout.compose
+ var line:TextFlowLine = _curLineIndex < _flowComposer.numLines ? (_flowComposer as StandardFlowComposer).lines[_curLineIndex] : null;
+
+ var useExistingLine:Boolean = line && (!line.isDamaged() || line.validity == FlowDamageType.GEOMETRY);
++ // if the line ends with a hyphen, don't use existing line because the player seems to mis-handle
++ // starting the next line.
++ if (useExistingLine && line.textLength > 0 &&
++ line.paragraph.getCharCodeAtPosition(line.absoluteStart + line.textLength - 1) == 0xAD)
++ useExistingLine = false;
+ var numberLine:TextLine;
+
+ // create numberLine if in a listElement
+diff --git a/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as b/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as
+index 04bc2a3..b03592a 100644
+--- a/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as
++++ b/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as
+@@ -296,6 +296,16 @@ package flashx.textLayout.compose
+ */
+ public function damage(startPosition:int, damageLength:int, damageType:String):void
+ {
++ if (ContainerController.tlf_internal::usesDiscretionaryHyphens)
++ {
++ // damage everything from the beginning.
++ // The player tends to screw up if you start
++ // composition in the middle and there are lines above broken on
++ // hyphens.
++ damageLength += startPosition;
++ startPosition = 0;
++ }
++
+ // find the line at damageStart
+ if (_lines.length == 0 || textFlow.textLength == 0)
+ return;
+diff --git a/textLayout/src/flashx/textLayout/container/ContainerController.as b/textLayout/src/flashx/textLayout/container/ContainerController.as
+index 50161ee..528c26d 100644
+--- a/textLayout/src/flashx/textLayout/container/ContainerController.as
++++ b/textLayout/src/flashx/textLayout/container/ContainerController.as
+@@ -111,6 +111,8 @@ package flashx.textLayout.container
+ */
+ public class ContainerController implements IInteractionEventHandler, ITextLayoutFormat, ISandboxSupport
+ {
++ static tlf_internal var usesDiscretionaryHyphens:Boolean = true;
++
+ private var _textFlowCache:TextFlow;
+ private var _rootElement:ContainerFormattedElement;
+
+diff --git a/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as b/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as
+index 8571ca8..22bfe40 100644
+--- a/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as
++++ b/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as
+@@ -574,7 +574,7 @@ package flashx.textLayout.elements
+ if (blockProgression == BlockProgression.RL && (parent is TCYElement))
+ return 0;
+ CONFIG::debug { assert(_computedFormat != null,"Missing _computedFormat in FlowLeafElement.getEffectiveLineHeight"); }
+- return TextLayoutFormat.lineHeightProperty.computeActualPropertyValue(_computedFormat.lineHeight, getEffectiveFontSize());
++ return TextLayoutFormat.lineHeightProperty.computeActualPropertyValue(computedFormat.lineHeight, getEffectiveFontSize());
+ }
+
+ /** @private
+diff --git a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
+index f58e1d4..13590a5 100644
+--- a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
++++ b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
+@@ -33,7 +33,9 @@ package flashx.textLayout.elements
+ import flash.text.engine.TextRotation;
+ import flash.utils.getQualifiedClassName;
+
++ import flashx.textLayout.tlf_internal;
+ import flashx.textLayout.compose.TextFlowLine;
++ import flashx.textLayout.container.ContainerController;
+ import flashx.textLayout.debug.Debugging;
+ import flashx.textLayout.debug.assert;
+ import flashx.textLayout.formats.BlockProgression;
+@@ -48,7 +50,6 @@ package flashx.textLayout.elements
+ import flashx.textLayout.formats.TextJustify;
+ import flashx.textLayout.formats.TextLayoutFormat;
+ import flashx.textLayout.property.Property;
+- import flashx.textLayout.tlf_internal;
+ import flashx.textLayout.utils.CharacterUtil;
+ import flashx.textLayout.utils.LocaleUtil;
+
+@@ -477,6 +478,25 @@ package flashx.textLayout.elements
+
+ public function findPreviousAtomBoundary(relativePosition:int):int
+ {
++ if (ContainerController.tlf_internal::usesDiscretionaryHyphens)
++ {
++ var textBlock:TextBlock = getTextBlock();
++ var tl:TextLine = textBlock.getTextLineAtCharIndex(relativePosition);
++ var currentAtomIndex = tl.getAtomIndexAtCharIndex(relativePosition);
++ if (currentAtomIndex == 0)
++ {
++ tl = tl.previousLine;
++ if (!tl)
++ return -1;
++ return tl.textBlockBeginIndex + tl.rawTextLength;
++ }
++ while (--relativePosition)
++ {
++ if (tl.getAtomIndexAtCharIndex(relativePosition) < currentAtomIndex)
++ break;
++ }
++ return relativePosition;
++ }
+ return getTextBlock().findPreviousAtomBoundary(relativePosition);
+ }
+
+@@ -500,6 +520,25 @@ package flashx.textLayout.elements
+
+ public function findNextAtomBoundary(relativePosition:int):int
+ {
++ if (ContainerController.tlf_internal::usesDiscretionaryHyphens)
++ {
++ var textBlock:TextBlock = getTextBlock();
++ var tl:TextLine = textBlock.getTextLineAtCharIndex(relativePosition);
++ var currentAtomIndex = tl.getAtomIndexAtCharIndex(relativePosition);
++ if (currentAtomIndex == tl.atomCount - 1)
++ {
++ tl = tl.nextLine;
++ if (!tl)
++ return -1;
++ return tl.textBlockBeginIndex;
++ }
++ while (++relativePosition)
++ {
++ if (tl.getAtomIndexAtCharIndex(relativePosition) > currentAtomIndex)
++ break;
++ }
++ return relativePosition;
++ }
+ return getTextBlock().findNextAtomBoundary(relativePosition);
+ }
+
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/f4545d2a/diff.txt
----------------------------------------------------------------------
diff --git a/diff.txt b/diff.txt
new file mode 100644
index 0000000..d301049
--- /dev/null
+++ b/diff.txt
@@ -0,0 +1,150 @@
+diff --git a/textLayout/src/flashx/textLayout/compose/BaseCompose.as b/textLayout/src/flashx/textLayout/compose/BaseCompose.as
+index e8ddb7b..2ad0506 100644
+--- a/textLayout/src/flashx/textLayout/compose/BaseCompose.as
++++ b/textLayout/src/flashx/textLayout/compose/BaseCompose.as
+@@ -1435,7 +1435,7 @@ package flashx.textLayout.compose
+
+ // advance to the next element, using the rootElement of the container as a limitNode
+ // to prevent going past the content bound to this container
+- _curElementOffset += _curLine.textLength;
++ _curElementOffset = _curLine.absoluteStart + _curLine.textLength - _curElementStart;
+ if (_curElementOffset >= _curElement.textLength)
+ {
+ // We may have composed ahead over several spans; skip until we match up
+diff --git a/textLayout/src/flashx/textLayout/compose/ComposeState.as b/textLayout/src/flashx/textLayout/compose/ComposeState.as
+index bdddf85..ce7bddc 100644
+--- a/textLayout/src/flashx/textLayout/compose/ComposeState.as
++++ b/textLayout/src/flashx/textLayout/compose/ComposeState.as
+@@ -340,6 +340,11 @@ package flashx.textLayout.compose
+ var line:TextFlowLine = _curLineIndex < _flowComposer.numLines ? (_flowComposer as StandardFlowComposer).lines[_curLineIndex] : null;
+
+ var useExistingLine:Boolean = line && (!line.isDamaged() || line.validity == FlowDamageType.GEOMETRY);
++ // if the line ends with a hyphen, don't use existing line because the player seems to mis-handle
++ // starting the next line.
++ if (useExistingLine && line.textLength > 0 &&
++ line.paragraph.getCharCodeAtPosition(line.absoluteStart + line.textLength - 1) == 0xAD)
++ useExistingLine = false;
+ var numberLine:TextLine;
+
+ // create numberLine if in a listElement
+diff --git a/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as b/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as
+index 04bc2a3..b03592a 100644
+--- a/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as
++++ b/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as
+@@ -296,6 +296,16 @@ package flashx.textLayout.compose
+ */
+ public function damage(startPosition:int, damageLength:int, damageType:String):void
+ {
++ if (ContainerController.tlf_internal::usesDiscretionaryHyphens)
++ {
++ // damage everything from the beginning.
++ // The player tends to screw up if you start
++ // composition in the middle and there are lines above broken on
++ // hyphens.
++ damageLength += startPosition;
++ startPosition = 0;
++ }
++
+ // find the line at damageStart
+ if (_lines.length == 0 || textFlow.textLength == 0)
+ return;
+diff --git a/textLayout/src/flashx/textLayout/container/ContainerController.as b/textLayout/src/flashx/textLayout/container/ContainerController.as
+index 50161ee..528c26d 100644
+--- a/textLayout/src/flashx/textLayout/container/ContainerController.as
++++ b/textLayout/src/flashx/textLayout/container/ContainerController.as
+@@ -111,6 +111,8 @@ package flashx.textLayout.container
+ */
+ public class ContainerController implements IInteractionEventHandler, ITextLayoutFormat, ISandboxSupport
+ {
++ static tlf_internal var usesDiscretionaryHyphens:Boolean = true;
++
+ private var _textFlowCache:TextFlow;
+ private var _rootElement:ContainerFormattedElement;
+
+diff --git a/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as b/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as
+index 8571ca8..22bfe40 100644
+--- a/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as
++++ b/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as
+@@ -574,7 +574,7 @@ package flashx.textLayout.elements
+ if (blockProgression == BlockProgression.RL && (parent is TCYElement))
+ return 0;
+ CONFIG::debug { assert(_computedFormat != null,"Missing _computedFormat in FlowLeafElement.getEffectiveLineHeight"); }
+- return TextLayoutFormat.lineHeightProperty.computeActualPropertyValue(_computedFormat.lineHeight, getEffectiveFontSize());
++ return TextLayoutFormat.lineHeightProperty.computeActualPropertyValue(computedFormat.lineHeight, getEffectiveFontSize());
+ }
+
+ /** @private
+diff --git a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
+index f58e1d4..13590a5 100644
+--- a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
++++ b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
+@@ -33,7 +33,9 @@ package flashx.textLayout.elements
+ import flash.text.engine.TextRotation;
+ import flash.utils.getQualifiedClassName;
+
++ import flashx.textLayout.tlf_internal;
+ import flashx.textLayout.compose.TextFlowLine;
++ import flashx.textLayout.container.ContainerController;
+ import flashx.textLayout.debug.Debugging;
+ import flashx.textLayout.debug.assert;
+ import flashx.textLayout.formats.BlockProgression;
+@@ -48,7 +50,6 @@ package flashx.textLayout.elements
+ import flashx.textLayout.formats.TextJustify;
+ import flashx.textLayout.formats.TextLayoutFormat;
+ import flashx.textLayout.property.Property;
+- import flashx.textLayout.tlf_internal;
+ import flashx.textLayout.utils.CharacterUtil;
+ import flashx.textLayout.utils.LocaleUtil;
+
+@@ -477,6 +478,25 @@ package flashx.textLayout.elements
+
+ public function findPreviousAtomBoundary(relativePosition:int):int
+ {
++ if (ContainerController.tlf_internal::usesDiscretionaryHyphens)
++ {
++ var textBlock:TextBlock = getTextBlock();
++ var tl:TextLine = textBlock.getTextLineAtCharIndex(relativePosition);
++ var currentAtomIndex = tl.getAtomIndexAtCharIndex(relativePosition);
++ if (currentAtomIndex == 0)
++ {
++ tl = tl.previousLine;
++ if (!tl)
++ return -1;
++ return tl.textBlockBeginIndex + tl.rawTextLength;
++ }
++ while (--relativePosition)
++ {
++ if (tl.getAtomIndexAtCharIndex(relativePosition) < currentAtomIndex)
++ break;
++ }
++ return relativePosition;
++ }
+ return getTextBlock().findPreviousAtomBoundary(relativePosition);
+ }
+
+@@ -500,6 +520,25 @@ package flashx.textLayout.elements
+
+ public function findNextAtomBoundary(relativePosition:int):int
+ {
++ if (ContainerController.tlf_internal::usesDiscretionaryHyphens)
++ {
++ var textBlock:TextBlock = getTextBlock();
++ var tl:TextLine = textBlock.getTextLineAtCharIndex(relativePosition);
++ var currentAtomIndex = tl.getAtomIndexAtCharIndex(relativePosition);
++ if (currentAtomIndex == tl.atomCount - 1)
++ {
++ tl = tl.nextLine;
++ if (!tl)
++ return -1;
++ return tl.textBlockBeginIndex;
++ }
++ while (++relativePosition)
++ {
++ if (tl.getAtomIndexAtCharIndex(relativePosition) > currentAtomIndex)
++ break;
++ }
++ return relativePosition;
++ }
+ return getTextBlock().findNextAtomBoundary(relativePosition);
+ }
+
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/f4545d2a/textLayout/src/flashx/textLayout/compose/BaseCompose.as
----------------------------------------------------------------------
diff --git a/textLayout/src/flashx/textLayout/compose/BaseCompose.as b/textLayout/src/flashx/textLayout/compose/BaseCompose.as
index e8ddb7b..2ad0506 100644
--- a/textLayout/src/flashx/textLayout/compose/BaseCompose.as
+++ b/textLayout/src/flashx/textLayout/compose/BaseCompose.as
@@ -1435,7 +1435,7 @@ package flashx.textLayout.compose
// advance to the next element, using the rootElement of the container as a limitNode
// to prevent going past the content bound to this container
- _curElementOffset += _curLine.textLength;
+ _curElementOffset = _curLine.absoluteStart + _curLine.textLength - _curElementStart;
if (_curElementOffset >= _curElement.textLength)
{
// We may have composed ahead over several spans; skip until we match up
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/f4545d2a/textLayout/src/flashx/textLayout/compose/ComposeState.as
----------------------------------------------------------------------
diff --git a/textLayout/src/flashx/textLayout/compose/ComposeState.as b/textLayout/src/flashx/textLayout/compose/ComposeState.as
index bdddf85..ce7bddc 100644
--- a/textLayout/src/flashx/textLayout/compose/ComposeState.as
+++ b/textLayout/src/flashx/textLayout/compose/ComposeState.as
@@ -340,6 +340,11 @@ package flashx.textLayout.compose
var line:TextFlowLine = _curLineIndex < _flowComposer.numLines ? (_flowComposer as StandardFlowComposer).lines[_curLineIndex] : null;
var useExistingLine:Boolean = line && (!line.isDamaged() || line.validity == FlowDamageType.GEOMETRY);
+ // if the line ends with a hyphen, don't use existing line because the player seems to mis-handle
+ // starting the next line.
+ if (useExistingLine && line.textLength > 0 &&
+ line.paragraph.getCharCodeAtPosition(line.absoluteStart + line.textLength - 1) == 0xAD)
+ useExistingLine = false;
var numberLine:TextLine;
// create numberLine if in a listElement
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/f4545d2a/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as
----------------------------------------------------------------------
diff --git a/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as b/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as
index 04bc2a3..b03592a 100644
--- a/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as
+++ b/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as
@@ -296,6 +296,16 @@ package flashx.textLayout.compose
*/
public function damage(startPosition:int, damageLength:int, damageType:String):void
{
+ if (ContainerController.tlf_internal::usesDiscretionaryHyphens)
+ {
+ // damage everything from the beginning.
+ // The player tends to screw up if you start
+ // composition in the middle and there are lines above broken on
+ // hyphens.
+ damageLength += startPosition;
+ startPosition = 0;
+ }
+
// find the line at damageStart
if (_lines.length == 0 || textFlow.textLength == 0)
return;
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/f4545d2a/textLayout/src/flashx/textLayout/container/ContainerController.as
----------------------------------------------------------------------
diff --git a/textLayout/src/flashx/textLayout/container/ContainerController.as b/textLayout/src/flashx/textLayout/container/ContainerController.as
index 50161ee..528c26d 100644
--- a/textLayout/src/flashx/textLayout/container/ContainerController.as
+++ b/textLayout/src/flashx/textLayout/container/ContainerController.as
@@ -111,6 +111,8 @@ package flashx.textLayout.container
*/
public class ContainerController implements IInteractionEventHandler, ITextLayoutFormat, ISandboxSupport
{
+ static tlf_internal var usesDiscretionaryHyphens:Boolean = true;
+
private var _textFlowCache:TextFlow;
private var _rootElement:ContainerFormattedElement;
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/f4545d2a/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as
----------------------------------------------------------------------
diff --git a/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as b/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as
index 8571ca8..22bfe40 100644
--- a/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as
+++ b/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as
@@ -574,7 +574,7 @@ package flashx.textLayout.elements
if (blockProgression == BlockProgression.RL && (parent is TCYElement))
return 0;
CONFIG::debug { assert(_computedFormat != null,"Missing _computedFormat in FlowLeafElement.getEffectiveLineHeight"); }
- return TextLayoutFormat.lineHeightProperty.computeActualPropertyValue(_computedFormat.lineHeight, getEffectiveFontSize());
+ return TextLayoutFormat.lineHeightProperty.computeActualPropertyValue(computedFormat.lineHeight, getEffectiveFontSize());
}
/** @private
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/f4545d2a/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 f58e1d4..13590a5 100644
--- a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
+++ b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
@@ -33,7 +33,9 @@ package flashx.textLayout.elements
import flash.text.engine.TextRotation;
import flash.utils.getQualifiedClassName;
+ import flashx.textLayout.tlf_internal;
import flashx.textLayout.compose.TextFlowLine;
+ import flashx.textLayout.container.ContainerController;
import flashx.textLayout.debug.Debugging;
import flashx.textLayout.debug.assert;
import flashx.textLayout.formats.BlockProgression;
@@ -48,7 +50,6 @@ package flashx.textLayout.elements
import flashx.textLayout.formats.TextJustify;
import flashx.textLayout.formats.TextLayoutFormat;
import flashx.textLayout.property.Property;
- import flashx.textLayout.tlf_internal;
import flashx.textLayout.utils.CharacterUtil;
import flashx.textLayout.utils.LocaleUtil;
@@ -477,6 +478,25 @@ package flashx.textLayout.elements
public function findPreviousAtomBoundary(relativePosition:int):int
{
+ if (ContainerController.tlf_internal::usesDiscretionaryHyphens)
+ {
+ var textBlock:TextBlock = getTextBlock();
+ var tl:TextLine = textBlock.getTextLineAtCharIndex(relativePosition);
+ var currentAtomIndex = tl.getAtomIndexAtCharIndex(relativePosition);
+ if (currentAtomIndex == 0)
+ {
+ tl = tl.previousLine;
+ if (!tl)
+ return -1;
+ return tl.textBlockBeginIndex + tl.rawTextLength;
+ }
+ while (--relativePosition)
+ {
+ if (tl.getAtomIndexAtCharIndex(relativePosition) < currentAtomIndex)
+ break;
+ }
+ return relativePosition;
+ }
return getTextBlock().findPreviousAtomBoundary(relativePosition);
}
@@ -500,6 +520,25 @@ package flashx.textLayout.elements
public function findNextAtomBoundary(relativePosition:int):int
{
+ if (ContainerController.tlf_internal::usesDiscretionaryHyphens)
+ {
+ var textBlock:TextBlock = getTextBlock();
+ var tl:TextLine = textBlock.getTextLineAtCharIndex(relativePosition);
+ var currentAtomIndex = tl.getAtomIndexAtCharIndex(relativePosition);
+ if (currentAtomIndex == tl.atomCount - 1)
+ {
+ tl = tl.nextLine;
+ if (!tl)
+ return -1;
+ return tl.textBlockBeginIndex;
+ }
+ while (++relativePosition)
+ {
+ if (tl.getAtomIndexAtCharIndex(relativePosition) > currentAtomIndex)
+ break;
+ }
+ return relativePosition;
+ }
return getTextBlock().findNextAtomBoundary(relativePosition);
}
[2/3] git commit: [flex-tlf] [refs/heads/master] - FLEX-33698 Added
support for shift-return with three levels: 0 Always hard return 1 hard
return in lists 2 always soft return (deault)
Posted by jm...@apache.org.
FLEX-33698 Added support for shift-return with three levels:
0 Always hard return
1 hard return in lists
2 always soft return (deault)
Project: http://git-wip-us.apache.org/repos/asf/flex-tlf/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-tlf/commit/258787a7
Tree: http://git-wip-us.apache.org/repos/asf/flex-tlf/tree/258787a7
Diff: http://git-wip-us.apache.org/repos/asf/flex-tlf/diff/258787a7
Branch: refs/heads/master
Commit: 258787a70bf31eaeca81b5fe98f2fe7b9559e4eb
Parents: f4545d2
Author: Harbs <ha...@in-tools.com>
Authored: Tue Sep 3 15:05:56 2013 +0300
Committer: Harbs <ha...@in-tools.com>
Committed: Tue Sep 3 15:05:56 2013 +0300
----------------------------------------------------------------------
.../src/flashx/textLayout/edit/EditManager.as | 20 ++++++++++++++++---
.../flashx/textLayout/elements/Configuration.as | 21 +++++++++++++++++++-
.../textLayout/elements/IConfiguration.as | 14 +++++++++++++
.../textLayout/elements/ParagraphElement.as | 4 ++--
4 files changed, 53 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/258787a7/textLayout/src/flashx/textLayout/edit/EditManager.as
----------------------------------------------------------------------
diff --git a/textLayout/src/flashx/textLayout/edit/EditManager.as b/textLayout/src/flashx/textLayout/edit/EditManager.as
index 645e79e..2b46e72 100644
--- a/textLayout/src/flashx/textLayout/edit/EditManager.as
+++ b/textLayout/src/flashx/textLayout/edit/EditManager.as
@@ -138,6 +138,7 @@ package flashx.textLayout.edit
*/
public class EditManager extends SelectionManager implements IEditManager
{
+ static tlf_internal var handleShiftAsSoftReturn:Boolean = true;
/**
* To minimize expensive recompositions during fast typing, inserts
* don't necessarily take place immediately. An insert operation that
@@ -306,8 +307,14 @@ package flashx.textLayout.edit
/* pre-Argo and on the mac then ignoreNextTextEvent */
if (!Configuration.versionIsAtLeast(10,1) && (Capabilities.os.search("Mac OS") > -1))
ignoreNextTextEvent = true;
- undo();
- event.preventDefault();
+ if(event.shiftKey){
+ redo();
+ event.preventDefault();
+
+ } else {
+ undo();
+ event.preventDefault();
+ }
break;
case 121: // small y
ignoreNextTextEvent = true;
@@ -383,7 +390,7 @@ package flashx.textLayout.edit
if (listItem && firstLeaf.getParentByType(ListElement) != listItem.getParentByType(ListElement))
listItem = null;
- // inside a list shift-enter splits a paragraph and shift splits the listitem
+ // inside a list shift-enter splits a paragraph and enter splits the listitem
if (listItem && !event.shiftKey)
{
// if on last item of list and it's empty, remove it and put cursor on a new para immediatly following the list (new para should be wrapped in a new list item if parent of list is another list).
@@ -403,6 +410,13 @@ package flashx.textLayout.edit
refreshSelection();
}
}
+ else if(event.shiftKey &&
+ ((!listItem && textFlow.configuration.shiftEnterLevel > 0) ||
+ textFlow.configuration.shiftEnterLevel > 1)
+ )
+ {
+ overwriteMode ? overwriteText("\u2028") : insertText("\u2028");
+ }
else
splitParagraph();
event.preventDefault();
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/258787a7/textLayout/src/flashx/textLayout/elements/Configuration.as
----------------------------------------------------------------------
diff --git a/textLayout/src/flashx/textLayout/elements/Configuration.as b/textLayout/src/flashx/textLayout/elements/Configuration.as
index 64af033..c9c3cf4 100644
--- a/textLayout/src/flashx/textLayout/elements/Configuration.as
+++ b/textLayout/src/flashx/textLayout/elements/Configuration.as
@@ -71,10 +71,18 @@ package flashx.textLayout.elements
static tlf_internal const playerEnablesSpicyFeatures:Boolean = versionIsAtLeast(10,2) && (new Sprite).hasOwnProperty("needsSoftKeyboard");
static tlf_internal const hasTouchScreen:Boolean = playerEnablesArgoFeatures && Capabilities["touchScreenType"] != "none";
+ static public const SHIFT_RETURN_AS_HARD:int = 0;
+ static public const SHIFT_RETURN_AS_HARD_IN_LIST:int = 1;
+ static public const SHIFT_RETURN_AS_SOFT:int = 2;
+
+ static tlf_internal var defaultShiftEnterLevel:int = SHIFT_RETURN_AS_SOFT;
+
/** If manageTabKey and manageEnterKey are false, the client must handle those keys on their own. */
private var _manageTabKey:Boolean;
private var _manageEnterKey:Boolean;
+ private var _shiftEnterLevel:int = defaultShiftEnterLevel;
+
private var _overflowPolicy:String;
private var _enableAccessibility:Boolean;
@@ -250,7 +258,18 @@ package flashx.textLayout.elements
public function set manageEnterKey(value:Boolean):void
{ _manageEnterKey = value; _immutableClone = null; }
-
+ /**
+ * @copy IConfiguration#shiftEnterLevel
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+
+ public function get shiftEnterLevel():int
+ { return _shiftEnterLevel; }
+ public function set shiftEnterLevel(value:int):void
+ { _shiftEnterLevel = value; }
/**
* @copy IConfiguration#overflowPolicy
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/258787a7/textLayout/src/flashx/textLayout/elements/IConfiguration.as
----------------------------------------------------------------------
diff --git a/textLayout/src/flashx/textLayout/elements/IConfiguration.as b/textLayout/src/flashx/textLayout/elements/IConfiguration.as
index 721e6ce..6a06016 100644
--- a/textLayout/src/flashx/textLayout/elements/IConfiguration.as
+++ b/textLayout/src/flashx/textLayout/elements/IConfiguration.as
@@ -66,6 +66,20 @@ package flashx.textLayout.elements
function get manageEnterKey():Boolean
/**
+ * Determines how shift-enter is treated. Shift-enter can be treated as a soft return or hard return.
+ * There are three possible levels. Level 0 means all shift-returns will be hard returns.
+ * Level 1 means shift-returns inside lists will be treated as hard returns. Otherwise they will be treated as hard returns.
+ * Level 2 means all shift-returns will be treated as soft returns.
+ *
+ * <p>Default value is <code>2</code>.</p>
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+
+ function get shiftEnterLevel():int;
+ /**
* Policy used for deciding whether the last line of a container fits in the container, or whether it overflows.
* Use the constants of the OverflowPolicy class to set this property.
*
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/258787a7/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 13590a5..f8fea72 100644
--- a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
+++ b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
@@ -482,7 +482,7 @@ package flashx.textLayout.elements
{
var textBlock:TextBlock = getTextBlock();
var tl:TextLine = textBlock.getTextLineAtCharIndex(relativePosition);
- var currentAtomIndex = tl.getAtomIndexAtCharIndex(relativePosition);
+ var currentAtomIndex:int = tl.getAtomIndexAtCharIndex(relativePosition);
if (currentAtomIndex == 0)
{
tl = tl.previousLine;
@@ -524,7 +524,7 @@ package flashx.textLayout.elements
{
var textBlock:TextBlock = getTextBlock();
var tl:TextLine = textBlock.getTextLineAtCharIndex(relativePosition);
- var currentAtomIndex = tl.getAtomIndexAtCharIndex(relativePosition);
+ var currentAtomIndex:int = tl.getAtomIndexAtCharIndex(relativePosition);
if (currentAtomIndex == tl.atomCount - 1)
{
tl = tl.nextLine;
[3/3] git commit: [flex-tlf] [refs/heads/master] - Fixed some
"Warning: variable definition duplicates function parameter" issues that
popped up when compiling TLF with Falcon.
Posted by jm...@apache.org.
Fixed some "Warning: variable definition duplicates function parameter" issues that popped up when compiling TLF with Falcon.
Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>
Project: http://git-wip-us.apache.org/repos/asf/flex-tlf/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-tlf/commit/3b7adac4
Tree: http://git-wip-us.apache.org/repos/asf/flex-tlf/tree/3b7adac4
Diff: http://git-wip-us.apache.org/repos/asf/flex-tlf/diff/3b7adac4
Branch: refs/heads/master
Commit: 3b7adac460ba80e397f4edc8279678305a39ed8e
Parents: 258787a
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Fri Sep 13 11:26:55 2013 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Fri Sep 13 11:26:55 2013 +0200
----------------------------------------------------------------------
.../flashx/textLayout/compose/TextFlowLine.as | 1 -
.../src/flashx/textLayout/edit/ParaEdit.as | 32 ++++++++++----------
.../textLayout/elements/FlowGroupElement.as | 8 ++---
.../textLayout/factory/StringTextLineFactory.as | 10 +++---
.../flashx/textLayout/property/ArrayProperty.as | 6 ++--
5 files changed, 28 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/3b7adac4/textLayout/src/flashx/textLayout/compose/TextFlowLine.as
----------------------------------------------------------------------
diff --git a/textLayout/src/flashx/textLayout/compose/TextFlowLine.as b/textLayout/src/flashx/textLayout/compose/TextFlowLine.as
index 0fe938c..11b8511 100644
--- a/textLayout/src/flashx/textLayout/compose/TextFlowLine.as
+++ b/textLayout/src/flashx/textLayout/compose/TextFlowLine.as
@@ -1924,7 +1924,6 @@ package flashx.textLayout.compose
{
var blockRect:Rectangle = new Rectangle();
var globalStart:Point = new Point(0,0);
- var heightAndAdj:Array;
if(begAtomIndex > endAtomIndex)
{
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/3b7adac4/textLayout/src/flashx/textLayout/edit/ParaEdit.as
----------------------------------------------------------------------
diff --git a/textLayout/src/flashx/textLayout/edit/ParaEdit.as b/textLayout/src/flashx/textLayout/edit/ParaEdit.as
index e4972f1..974eba2 100644
--- a/textLayout/src/flashx/textLayout/edit/ParaEdit.as
+++ b/textLayout/src/flashx/textLayout/edit/ParaEdit.as
@@ -600,21 +600,21 @@ package flashx.textLayout.edit
CONFIG::debug { assert(begIdx <= endIdx,"bad indexeds passed to ParaEdit.cacheContainerStyleInformation"); }
if (flowRoot.flowComposer)
{
- var startIdx:int = flowRoot.flowComposer.findControllerIndexAtPosition(begIdx,false);
- if (startIdx == -1)
+ var ctrlrBegIdx:int = flowRoot.flowComposer.findControllerIndexAtPosition(begIdx,false);
+ if (ctrlrBegIdx == -1)
return;
- var endIdx:int = flowRoot.flowComposer.findControllerIndexAtPosition(endIdx,true);
- if (endIdx == -1)
- endIdx = flowRoot.flowComposer.numControllers-1;
- while (startIdx <= endIdx)
+ var ctrlrEndIdx:int = flowRoot.flowComposer.findControllerIndexAtPosition(endIdx,true);
+ if (ctrlrEndIdx == -1)
+ ctrlrEndIdx = flowRoot.flowComposer.numControllers-1;
+ while (ctrlrBegIdx <= ctrlrEndIdx)
{
- var controller:ContainerController = flowRoot.flowComposer.getControllerAt(startIdx);
+ var controller:ContainerController = flowRoot.flowComposer.getControllerAt(ctrlrBegIdx);
var obj:Object = new Object();
obj.container = controller;
// save just the styles
obj.attributes = new TextLayoutFormat(controller.format);
undoArray.push(obj);
- startIdx++;
+ ctrlrBegIdx++;
}
}
}
@@ -624,22 +624,22 @@ package flashx.textLayout.edit
CONFIG::debug { assert(begIdx <= endIdx,"bad indexes passed to ParaEdit.cacheContainerStyleInformation"); }
if (flowRoot.flowComposer)
{
- var startIdx:int = flowRoot.flowComposer.findControllerIndexAtPosition(begIdx,false);
- if (startIdx == -1)
+ var ctrlrBegIdx:int = flowRoot.flowComposer.findControllerIndexAtPosition(begIdx,false);
+ if (ctrlrBegIdx == -1)
return;
- var endIdx:int = flowRoot.flowComposer.findControllerIndexAtPosition(endIdx,true);
- if (endIdx == -1)
- endIdx = flowRoot.flowComposer.numControllers-1;
+ var ctrlrEndIdx:int = flowRoot.flowComposer.findControllerIndexAtPosition(endIdx,true);
+ if (ctrlrEndIdx == -1)
+ ctrlrEndIdx = flowRoot.flowComposer.numControllers-1;
var controllerIndex:int = flowRoot.flowComposer.findControllerIndexAtPosition(begIdx,false);
- while (startIdx <= endIdx)
+ while (ctrlrBegIdx <= ctrlrEndIdx)
{
- var controller:ContainerController = flowRoot.flowComposer.getControllerAt(startIdx);
+ var controller:ContainerController = flowRoot.flowComposer.getControllerAt(ctrlrBegIdx);
var newFormat:TextLayoutFormat = new TextLayoutFormat(controller.format);
if (applyFormat)
newFormat.apply(applyFormat);
undefineDefinedFormats(newFormat,undefineFormat);
controller.format = newFormat;
- startIdx++;
+ ctrlrBegIdx++;
}
}
}
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/3b7adac4/textLayout/src/flashx/textLayout/elements/FlowGroupElement.as
----------------------------------------------------------------------
diff --git a/textLayout/src/flashx/textLayout/elements/FlowGroupElement.as b/textLayout/src/flashx/textLayout/elements/FlowGroupElement.as
index 1682720..b02a22d 100644
--- a/textLayout/src/flashx/textLayout/elements/FlowGroupElement.as
+++ b/textLayout/src/flashx/textLayout/elements/FlowGroupElement.as
@@ -355,8 +355,8 @@ package flashx.textLayout.elements
return parent.getNextLeafHelper(limitElement,this);
}
- var child:FlowElement = getChildAt(idx+1);
- return (child is FlowLeafElement) ? FlowLeafElement(child) : FlowGroupElement(child).getFirstLeaf();
+ var childFlowElement:FlowElement = getChildAt(idx+1);
+ return (childFlowElement is FlowLeafElement) ? FlowLeafElement(childFlowElement) : FlowGroupElement(childFlowElement).getFirstLeaf();
}
/** @private */
@@ -374,8 +374,8 @@ package flashx.textLayout.elements
return parent.getPreviousLeafHelper(limitElement,this);
}
- var child:FlowElement = getChildAt(idx-1);
- return (child is FlowLeafElement) ? FlowLeafElement(child) : FlowGroupElement(child).getLastLeaf();
+ var childFlowElement:FlowElement = getChildAt(idx-1);
+ return (childFlowElement is FlowLeafElement) ? FlowLeafElement(childFlowElement) : FlowGroupElement(childFlowElement).getLastLeaf();
}
/**
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/3b7adac4/textLayout/src/flashx/textLayout/factory/StringTextLineFactory.as
----------------------------------------------------------------------
diff --git a/textLayout/src/flashx/textLayout/factory/StringTextLineFactory.as b/textLayout/src/flashx/textLayout/factory/StringTextLineFactory.as
index c8731a3..355e6c5 100644
--- a/textLayout/src/flashx/textLayout/factory/StringTextLineFactory.as
+++ b/textLayout/src/flashx/textLayout/factory/StringTextLineFactory.as
@@ -310,8 +310,8 @@ package flashx.textLayout.factory
/** @private */
tlf_internal function doTruncation(bp:String, measureWidth:Boolean, measureHeight:Boolean):void
{
- var bp:String = _tf.computedFormat.blockProgression;
- if (!doesComposedTextFit(truncationOptions.lineCountLimit, _tf.textLength, bp))
+ var bpString:String = _tf.computedFormat.blockProgression;
+ if (!doesComposedTextFit(truncationOptions.lineCountLimit, _tf.textLength, bpString))
{
_isTruncated = true;
var somethingFit:Boolean = false; // were we able to fit something?
@@ -331,7 +331,7 @@ package flashx.textLayout.factory
{
var truncateAtCharPosition:int;
- if (_tf.computedFormat.lineBreak == LineBreak.EXPLICIT || (bp == BlockProgression.TB ? measureWidth : measureHeight))
+ if (_tf.computedFormat.lineBreak == LineBreak.EXPLICIT || (bpString == BlockProgression.TB ? measureWidth : measureHeight))
{
// 3., 4. Initial truncation position: end of the last allowed line
var line:TextLine = _factoryComposer._lines[_truncationLineIndex] as TextLine;
@@ -340,7 +340,7 @@ package flashx.textLayout.factory
else
{
// 3. Calculate allowed width (width left over from the last line of the truncation indicator)
- var targetWidth:Number = (bp == BlockProgression.TB ? compositionBounds.width : compositionBounds.height);
+ var targetWidth:Number = (bpString == BlockProgression.TB ? compositionBounds.width : compositionBounds.height);
if (paragraphFormat)
{
targetWidth -= (Number(paragraphFormat.paragraphSpaceAfter) + Number(paragraphFormat.paragraphSpaceBefore));
@@ -375,7 +375,7 @@ package flashx.textLayout.factory
{
_tf.flowComposer.compose();
- if (doesComposedTextFit(truncationOptions.lineCountLimit, _tf.textLength, bp))
+ if (doesComposedTextFit(truncationOptions.lineCountLimit, _tf.textLength, bpString))
{
somethingFit = true;
break;
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/3b7adac4/textLayout/src/flashx/textLayout/property/ArrayProperty.as
----------------------------------------------------------------------
diff --git a/textLayout/src/flashx/textLayout/property/ArrayProperty.as b/textLayout/src/flashx/textLayout/property/ArrayProperty.as
index 090e892..b754074 100644
--- a/textLayout/src/flashx/textLayout/property/ArrayProperty.as
+++ b/textLayout/src/flashx/textLayout/property/ArrayProperty.as
@@ -145,12 +145,12 @@ package flashx.textLayout.property
var addComma:Boolean = false;
for each (var prop:Property in desc)
{
- var val:Object = member[prop.name];
- if (val != null)
+ var memberVal:Object = member[prop.name];
+ if (memberVal != null)
{
if (addComma)
rslt += ", ";
- rslt += prop.name + ":" + prop.toXMLString(val);
+ rslt += prop.name + ":" + prop.toXMLString(memberVal);
addComma = true;
}
}