OSDN Git Service

Reset StaticLayout.mEllipsized during generate()
authorSiyamed Sinir <siyamed@google.com>
Fri, 4 Aug 2017 05:01:56 +0000 (22:01 -0700)
committerSiyamed Sinir <siyamed@google.com>
Tue, 22 Aug 2017 02:20:50 +0000 (19:20 -0700)
StaticLayout.mEllipsized and mMaxLineHeight was set for proper
calculation of static ellipsized text height. However, since
DynamicLayout uses a static instance of StaticLayout, and nobody reset
the mEllipsized, this caused configuration discrepancies for different
DynamicLayout instances.

Test: bit -t CtsTextTestCases:android.text.cts.DynamicLayoutTest
Test: bit -t CtsTextTestCases:android.text.cts.StaticLayoutTest
Bug: 64372088
Change-Id: I8ea6697d29da2ccbb433b64f17b4d1d6f254e8e1
Merged-In: a19cd51d2c511777201c09e258a4e8286249fd9a
(cherry picked from commit a19cd51d2c511777201c09e258a4e8286249fd9a)

core/java/android/text/StaticLayout.java

index a8c6aa6..16f40ba 100644 (file)
@@ -608,6 +608,8 @@ public class StaticLayout extends Layout {
         b.setLocales(paint.getTextLocales());
 
         mLineCount = 0;
+        mEllipsized = false;
+        mMaxLineHeight = DEFAULT_MAX_LINE_HEIGHT;
 
         int v = 0;
         boolean needMultiply = (spacingmult != 1 || spacingadd != 0);
@@ -1366,7 +1368,7 @@ public class StaticLayout extends Layout {
      * The value is the same as getLineTop(maxLines) for ellipsized version where structurally no
      * more than maxLines is contained.
      */
-    private int mMaxLineHeight = -1;
+    private int mMaxLineHeight = DEFAULT_MAX_LINE_HEIGHT;
 
     private static final int COLUMNS_NORMAL = 4;
     private static final int COLUMNS_ELLIPSIZE = 6;
@@ -1394,6 +1396,8 @@ public class StaticLayout extends Layout {
 
     private static final double EXTRA_ROUNDING = 0.5;
 
+    private static final int DEFAULT_MAX_LINE_HEIGHT = -1;
+
     // This is used to return three arrays from a single JNI call when
     // performing line breaking
     /*package*/ static class LineBreaks {