Fix FLEX-33428. Proposed fix (adding clearFlag) doesn't actually fix the root problem, it only works because it causes the component to use plain text rendering and the test case has plain text to render. This fix addresses a rather strange behavior in TextContainerManager (TCM). It assumes that existing TextLines belong to the same textflow. There is code in TCM's textFlow setter that attempts to remove existing TextLines when the textFlow is changed, but this bug scenario bypasses that and leaves a TextLine created at initialization by the plain text composer when the text hasn't been set yet. The fix remembers whether plain text or html text composition was last used and if switching, removes existing textfields. All tests in gumbo/components/FTETextField pass
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/67ae8ae4 Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/67ae8ae4 Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/67ae8ae4 Branch: refs/heads/release4.11.0 Commit: 67ae8ae4290c28cd1e96f6acb4194e0e5718f276 Parents: 90aa204 Author: Alex Harui <[email protected]> Authored: Thu Oct 10 21:38:05 2013 -0700 Committer: Alex Harui <[email protected]> Committed: Thu Oct 10 23:18:41 2013 -0700 ---------------------------------------------------------------------- .../projects/spark/src/mx/core/FTETextField.as | 31 ++++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/67ae8ae4/frameworks/projects/spark/src/mx/core/FTETextField.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/spark/src/mx/core/FTETextField.as b/frameworks/projects/spark/src/mx/core/FTETextField.as index 89b0dc0..dcfbaee 100644 --- a/frameworks/projects/spark/src/mx/core/FTETextField.as +++ b/frameworks/projects/spark/src/mx/core/FTETextField.as @@ -48,6 +48,11 @@ package mx.core import flash.text.engine.TextLineValidity; import flash.utils.Dictionary; + import mx.managers.SystemManager; + import mx.managers.SystemManagerGlobals; + + import spark.utils.TextUtil; + import flashx.textLayout.compose.ISWFContext; import flashx.textLayout.compose.TextLineRecycler; import flashx.textLayout.formats.ITextLayoutFormat; @@ -56,11 +61,6 @@ package mx.core import flashx.textLayout.formats.TextDecoration; import flashx.textLayout.formats.TextLayoutFormat; - import mx.managers.SystemManager; - import mx.managers.SystemManagerGlobals; - - import spark.utils.TextUtil; - use namespace mx_internal; /** @@ -386,6 +386,8 @@ package mx.core // //-------------------------------------------------------------------------- + private var lastComposeWasText:Boolean; + /** * @private * Apps are likely to create thousands of instances of FTETextField, @@ -2526,13 +2528,30 @@ package mx.core if (testFlag(FLAG_HTML_TEXT_SET)) { - if (!_htmlHelper.hostFormat) + // if switching composers, remove all existing textlines. + // the html composer assumes existing textlines belonged + // to the flow + if (lastComposeWasText) + { + nextLineIndex = 0; + removeExcessTextLines(); + } + lastComposeWasText = false; + + if (!_htmlHelper.hostFormat) createHostFormat(); _htmlHelper.composeHTMLText(compositionWidth, compositionHeight); } else { + if (!lastComposeWasText) + { + nextLineIndex = 0; + removeExcessTextLines(); + } + + lastComposeWasText = true; if (!elementFormat) createElementFormat();
