summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRoozbeh Pournader <roozbeh@google.com>2015-10-16 02:27:03 -0700
committerRoozbeh Pournader <roozbeh@google.com>2015-10-16 02:49:13 -0700
commit431e506b53e59b21a7d18bf46476b8c1528fabf1 (patch)
treeed058413ee825ea3909e29b33c12a93d0f016c43 /core
parentae5a53d78cac72b73574b874a4d12ae9de708101 (diff)
downloadframeworks_base-431e506b53e59b21a7d18bf46476b8c1528fabf1.zip
frameworks_base-431e506b53e59b21a7d18bf46476b8c1528fabf1.tar.gz
frameworks_base-431e506b53e59b21a7d18bf46476b8c1528fabf1.tar.bz2
Fix line height problem with inline images in StaticLayout.
Previously, paragraphs with ImageSpans in their middle would continue to carry the height of the image into the line height of next lines. This was a regression from L. The bug was due to StaticLayout's out() method almost always modifying the value of its parameter "fm", although that was only intended when there were LineHeightSpans in the text. The method generate() was assuming that it can restore fmTop etc to metrics of the current span by setting them from "fm" after out() was run, while "fm" was modified by out() and its original values was lost! The fix makes sure to set chooseHt back to null if there were no LineHeightSpans, so out() would not modify "fm" unless necessary. AOSP bug: https://code.google.com/p/android/issues/detail?id=188042 Bug: 24548073 Change-Id: I0d00af384c35a9d863377972318da9db7668118f
Diffstat (limited to 'core')
-rw-r--r--core/java/android/text/StaticLayout.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index b0b08db..fdc6cb1 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -627,7 +627,9 @@ public class StaticLayout extends Layout {
chooseHt = getParagraphSpans(spanned, paraStart, paraEnd, LineHeightSpan.class);
- if (chooseHt.length != 0) {
+ if (chooseHt.length == 0) {
+ chooseHt = null; // So that out() would not assume it has any contents
+ } else {
if (chooseHtv == null ||
chooseHtv.length < chooseHt.length) {
chooseHtv = ArrayUtils.newUnpaddedIntArray(chooseHt.length);
@@ -810,7 +812,7 @@ public class StaticLayout extends Layout {
v = out(source, here, endPos,
fmAscent, fmDescent, fmTop, fmBottom,
- v, spacingmult, spacingadd, chooseHt,chooseHtv, fm, flags[breakIndex],
+ v, spacingmult, spacingadd, chooseHt, chooseHtv, fm, flags[breakIndex],
needMultiply, chdirs, dir, easy, bufEnd, includepad, trackpad,
chs, widths, paraStart, ellipsize, ellipsizedWidth,
lineWidths[breakIndex], paint, moreChars);