diff options
| author | Raph Levien <raph@google.com> | 2012-10-22 15:01:17 -0700 |
|---|---|---|
| committer | Raph Levien <raph@google.com> | 2012-10-22 15:01:17 -0700 |
| commit | 42ef515d185d4fc038d602172789cc264f1d9960 (patch) | |
| tree | 9f9f497e5cef80745124126af24c9ae20165dad3 | |
| parent | cc0106cd99831ce7d3715e3c85e5b3e6c5c6ca78 (diff) | |
| download | frameworks_base-42ef515d185d4fc038d602172789cc264f1d9960.zip frameworks_base-42ef515d185d4fc038d602172789cc264f1d9960.tar.gz frameworks_base-42ef515d185d4fc038d602172789cc264f1d9960.tar.bz2 | |
Fix for bug: Gmail (and other places): cursor placed on top of letter
This patch fixes bug 7346656. In this particular case, the text line in
the EditText was split into multiple spans, with the boundary between
the "r" and "," in "r,". These were being drawn as two separate runs,
but measured as a single run, leading to inconsistent measurements
because this is a kern pair in Roboto.
The fix is to eliminate the special-case code for measuring. This will
actually improve efficiency, as the value computed in one pass is now
more likely to be reused in another.
Change-Id: I04142a0ec98f280fc1027c7cbdbf903e3096f8e4
| -rw-r--r-- | core/java/android/text/TextLine.java | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java index 0d2835a..1fecf81 100644 --- a/core/java/android/text/TextLine.java +++ b/core/java/android/text/TextLine.java @@ -939,27 +939,22 @@ class TextLine { continue; } - if (c == null) { - x += handleText(wp, i, mlimit, i, inext, runIsRtl, c, x, top, - y, bottom, fmi, needWidth || mlimit < measureLimit); - } else { - for (int j = i, jnext; j < mlimit; j = jnext) { - jnext = mCharacterStyleSpanSet.getNextTransition(mStart + j, mStart + mlimit) - - mStart; - - wp.set(mPaint); - for (int k = 0; k < mCharacterStyleSpanSet.numberOfSpans; k++) { - // Intentionally using >= and <= as explained above - if ((mCharacterStyleSpanSet.spanStarts[k] >= mStart + jnext) || - (mCharacterStyleSpanSet.spanEnds[k] <= mStart + j)) continue; - - CharacterStyle span = mCharacterStyleSpanSet.spans[k]; - span.updateDrawState(wp); - } + for (int j = i, jnext; j < mlimit; j = jnext) { + jnext = mCharacterStyleSpanSet.getNextTransition(mStart + j, mStart + mlimit) - + mStart; + + wp.set(mPaint); + for (int k = 0; k < mCharacterStyleSpanSet.numberOfSpans; k++) { + // Intentionally using >= and <= as explained above + if ((mCharacterStyleSpanSet.spanStarts[k] >= mStart + jnext) || + (mCharacterStyleSpanSet.spanEnds[k] <= mStart + j)) continue; - x += handleText(wp, j, jnext, i, inext, runIsRtl, c, x, - top, y, bottom, fmi, needWidth || jnext < measureLimit); + CharacterStyle span = mCharacterStyleSpanSet.spans[k]; + span.updateDrawState(wp); } + + x += handleText(wp, j, jnext, i, inext, runIsRtl, c, x, + top, y, bottom, fmi, needWidth || jnext < measureLimit); } } |
