Revert "Use getRunAdvance to position cursor"
This reverts commit cb5499c85097450c48f66f6c08a35bab2ad5ab12.
Bug: 21549197
diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java
index f7027f9..f176240 100644
--- a/core/java/android/text/Layout.java
+++ b/core/java/android/text/Layout.java
@@ -1121,7 +1121,6 @@
* closest to the specified horizontal position.
*/
public int getOffsetForHorizontal(int line, float horiz) {
- // TODO: use Paint.getOffsetForAdvance to avoid binary search
int max = getLineEnd(line) - 1;
int min = getLineStart(line);
Directions dirs = getLineDirections(line);
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java
index 605b91d..479242c 100644
--- a/core/java/android/text/TextLine.java
+++ b/core/java/android/text/TextLine.java
@@ -739,14 +739,16 @@
float ret = 0;
+ int contextLen = contextEnd - contextStart;
if (needWidth || (c != null && (wp.bgColor != 0 || wp.underlineColor != 0 || runIsRtl))) {
if (mCharsValid) {
- ret = wp.getRunAdvance(mChars, start, contextEnd, contextStart, contextEnd,
- runIsRtl, end);
+ ret = wp.getTextRunAdvances(mChars, start, runLen,
+ contextStart, contextLen, runIsRtl, null, 0);
} else {
int delta = mStart;
- ret = wp.getRunAdvance(mText, delta + start, delta + contextEnd,
- delta + contextStart, delta + contextEnd, runIsRtl, delta + end);
+ ret = wp.getTextRunAdvances(mText, delta + start,
+ delta + end, delta + contextStart, delta + contextEnd,
+ runIsRtl, null, 0);
}
}