flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject git commit: [flex-sdk] [refs/heads/develop] - TLF might add a shape and mess up baseline calculations when there is a backgroundColor
Date Mon, 27 May 2013 06:07:14 GMT
Updated Branches:
  refs/heads/develop da7c375d5 -> 7f42c4586


TLF might add a shape and mess up baseline calculations when there is a backgroundColor


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/7f42c458
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/7f42c458
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/7f42c458

Branch: refs/heads/develop
Commit: 7f42c4586597d1d7387163515a0543ca5a695383
Parents: da7c375
Author: Alex Harui <aharui@apache.org>
Authored: Sun May 26 23:05:26 2013 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Sun May 26 23:07:06 2013 -0700

----------------------------------------------------------------------
 .../spark/components/supportClasses/TextBase.as    |   20 ++++++++++++---
 1 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/7f42c458/frameworks/projects/spark/src/spark/components/supportClasses/TextBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/supportClasses/TextBase.as b/frameworks/projects/spark/src/spark/components/supportClasses/TextBase.as
index ff096cb..bcf8b2e 100644
--- a/frameworks/projects/spark/src/spark/components/supportClasses/TextBase.as
+++ b/frameworks/projects/spark/src/spark/components/supportClasses/TextBase.as
@@ -29,8 +29,6 @@ import flash.text.engine.FontLookup;
 import flash.text.engine.TextLine;
 import flash.text.engine.TextLineValidity;
 
-import flashx.textLayout.compose.TextLineRecycler;
-
 import mx.core.IFlexModuleFactory;
 import mx.core.UIComponent;
 import mx.core.mx_internal;
@@ -41,6 +39,8 @@ import mx.resources.ResourceManager;
 import spark.core.IDisplayText;
 import spark.utils.TextUtil;
 
+import flashx.textLayout.compose.TextLineRecycler;
+
 use namespace mx_internal;
 
 //--------------------------------------
@@ -275,11 +275,23 @@ public class TextBase extends UIComponent implements IDisplayText
         // text is vertically aligned then need the composeHeight so the 
         // baseline remains consistent when the width is so narrow there
         // are no textLines.
-        if (textLines.length == 0)
+        if (textLines.length == 0 ||
+            (textLines.length == 1 && textLines[0] is Shape))
             createEmptyTextLine(_composeHeight);
         
         // Return the baseline of the first line of composed text.
-        return textLines.length > 0 ? textLines[0].y : 0;
+        return textLines.length > 0 ? getBaselineFromFirstTextLine() : 0;
+    }
+    
+    private function getBaselineFromFirstTextLine():Number
+    {
+        // you may find a Shape in here when background colors are on
+        for each (var tl:DisplayObject in textLines)
+        {
+            if (tl is TextLine)
+                return tl.y;
+        }
+        return 0;
     }
 
     //----------------------------------


Mime
View raw message