From 4cf435df2e485e405f085982ac8fd9c82fb57d47 Mon Sep 17 00:00:00 2001 From: Gilles Debunne Date: Tue, 4 Jan 2011 15:35:29 -0800 Subject: Revert "Fix for ellipsized text that has two lines at maximum." This reverts commit 32ea4ffdca0f4706e447d0a275f259fe121b9e6a. This change introduces an ANR in AutoComplete text view. There is an infinite loop when the suggestion TextView is measured. Reverted to fix the ANR, opening a new bug for the ellipsize. Bug 3315813, 3320375, 3318059 Change-Id: I1872116ca1f39324ed4500d338bafac7e0d195ec --- core/java/android/text/StaticLayout.java | 182 +++++++++++++++---------------- 1 file changed, 90 insertions(+), 92 deletions(-) (limited to 'core/java/android/text/StaticLayout.java') diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java index d8d632062107..3dd1ecd34ad8 100644 --- a/core/java/android/text/StaticLayout.java +++ b/core/java/android/text/StaticLayout.java @@ -361,103 +361,101 @@ public class StaticLayout extends Layout if (fitbottom > okbottom) okbottom = fitbottom; } - } else { - if (breakOnlyAtSpaces) { - if (ok != here) { - // Log.e("text", "output ok " + here + " to " +ok); - - while (ok < spanEnd && chs[ok - paraStart] == ' ') { - ok++; - } + } else if (breakOnlyAtSpaces) { + if (ok != here) { + // Log.e("text", "output ok " + here + " to " +ok); - v = out(source, - here, ok, - okascent, okdescent, oktop, okbottom, - v, - spacingmult, spacingadd, chooseht, - choosehtv, fm, hasTabOrEmoji, - needMultiply, paraStart, chdirs, dir, easy, - ok == bufend, includepad, trackpad, - chs, widths, here - paraStart, - where, ellipsizedWidth, okwidth, - paint); - - here = ok; - } else { - // Act like it fit even though it didn't. - - fitwidth = w; - fit = j + 1; - - if (fmtop < fittop) - fittop = fmtop; - if (fmascent < fitascent) - fitascent = fmascent; - if (fmdescent > fitdescent) - fitdescent = fmdescent; - if (fmbottom > fitbottom) - fitbottom = fmbottom; + while (ok < spanEnd && chs[ok - paraStart] == ' ') { + ok++; } - } else { - if (ok != here) { - // Log.e("text", "output ok " + here + " to " +ok); - while (ok < spanEnd && chs[ok - paraStart] == ' ') { - ok++; - } + v = out(source, + here, ok, + okascent, okdescent, oktop, okbottom, + v, + spacingmult, spacingadd, chooseht, + choosehtv, fm, hasTabOrEmoji, + needMultiply, paraStart, chdirs, dir, easy, + ok == bufend, includepad, trackpad, + chs, widths, here - paraStart, + where, ellipsizedWidth, okwidth, + paint); + + here = ok; + } else { + // Act like it fit even though it didn't. + + fitwidth = w; + fit = j + 1; + + if (fmtop < fittop) + fittop = fmtop; + if (fmascent < fitascent) + fitascent = fmascent; + if (fmdescent > fitdescent) + fitdescent = fmdescent; + if (fmbottom > fitbottom) + fitbottom = fmbottom; + } + } else { + if (ok != here) { + // Log.e("text", "output ok " + here + " to " +ok); - v = out(source, - here, ok, - okascent, okdescent, oktop, okbottom, - v, - spacingmult, spacingadd, chooseht, - choosehtv, fm, hasTabOrEmoji, - needMultiply, paraStart, chdirs, dir, easy, - ok == bufend, includepad, trackpad, - chs, widths, here - paraStart, - where, ellipsizedWidth, okwidth, - paint); - - here = ok; - } else if (fit != here) { - // Log.e("text", "output fit " + here + " to " +fit); - v = out(source, - here, fit, - fitascent, fitdescent, - fittop, fitbottom, - v, - spacingmult, spacingadd, chooseht, - choosehtv, fm, hasTabOrEmoji, - needMultiply, paraStart, chdirs, dir, easy, - fit == bufend, includepad, trackpad, - chs, widths, here - paraStart, - where, ellipsizedWidth, fitwidth, - paint); - - here = fit; - } else { - // Log.e("text", "output one " + here + " to " +(here + 1)); - // XXX not sure why the existing fm wasn't ok. - // measureText(paint, mWorkPaint, - // source, here, here + 1, fm, tab, - // null); - - v = out(source, - here, here+1, - fm.ascent, fm.descent, - fm.top, fm.bottom, - v, - spacingmult, spacingadd, chooseht, - choosehtv, fm, hasTabOrEmoji, - needMultiply, paraStart, chdirs, dir, easy, - here + 1 == bufend, includepad, - trackpad, - chs, widths, here - paraStart, - where, ellipsizedWidth, - widths[here - paraStart], paint); - - here = here + 1; + while (ok < spanEnd && chs[ok - paraStart] == ' ') { + ok++; } + + v = out(source, + here, ok, + okascent, okdescent, oktop, okbottom, + v, + spacingmult, spacingadd, chooseht, + choosehtv, fm, hasTabOrEmoji, + needMultiply, paraStart, chdirs, dir, easy, + ok == bufend, includepad, trackpad, + chs, widths, here - paraStart, + where, ellipsizedWidth, okwidth, + paint); + + here = ok; + } else if (fit != here) { + // Log.e("text", "output fit " + here + " to " +fit); + v = out(source, + here, fit, + fitascent, fitdescent, + fittop, fitbottom, + v, + spacingmult, spacingadd, chooseht, + choosehtv, fm, hasTabOrEmoji, + needMultiply, paraStart, chdirs, dir, easy, + fit == bufend, includepad, trackpad, + chs, widths, here - paraStart, + where, ellipsizedWidth, fitwidth, + paint); + + here = fit; + } else { + // Log.e("text", "output one " + here + " to " +(here + 1)); + // XXX not sure why the existing fm wasn't ok. + // measureText(paint, mWorkPaint, + // source, here, here + 1, fm, tab, + // null); + + v = out(source, + here, here+1, + fm.ascent, fm.descent, + fm.top, fm.bottom, + v, + spacingmult, spacingadd, chooseht, + choosehtv, fm, hasTabOrEmoji, + needMultiply, paraStart, chdirs, dir, easy, + here + 1 == bufend, includepad, + trackpad, + chs, widths, here - paraStart, + where, ellipsizedWidth, + widths[here - paraStart], paint); + + here = here + 1; } if (here < spanStart) { -- cgit v1.2.3