Change add{StyleRun, ReplacementRun} to append{StyleRun, ReplacementRun}

Giving any range to the Builder is too much freedum and hard to tell
errors. Changes to accept length instead of ranges. By this change, we
can prevent and tell errors about
- The gap in the text that no Paint is assigned.
- The given range is overlapped.
- The given range exceeds the text length.

Bug: 112327179
Test: TreeHugger

Change-Id: Iefc078b1f7be2d006a65b46e0b4ea1018ecb29e7
This commit is contained in:
Seigo Nonaka
2018-10-16 18:02:32 -07:00
parent 916bdd7d4d
commit 7b86fe573c
4 changed files with 72 additions and 20 deletions

View File

@@ -505,7 +505,7 @@ public class MeasuredParagraph {
}
mWholeWidth += width;
} else {
builder.addReplacementRun(mCachedPaint, start, end, width);
builder.appendReplacementRun(mCachedPaint, end - start, width);
}
}
@@ -520,7 +520,7 @@ public class MeasuredParagraph {
mCopiedBuffer, start, end - start, start, end - start, false /* isRtl */,
mWidths.getRawArray(), start);
} else {
builder.addStyleRun(mCachedPaint, start, end, false /* isRtl */);
builder.appendStyleRun(mCachedPaint, end - start, false /* isRtl */);
}
} else {
// If there is multiple bidi levels, split into individual bidi level and apply style.
@@ -536,7 +536,7 @@ public class MeasuredParagraph {
mCopiedBuffer, levelStart, levelLength, levelStart, levelLength,
isRtl, mWidths.getRawArray(), levelStart);
} else {
builder.addStyleRun(mCachedPaint, levelStart, levelEnd, isRtl);
builder.appendStyleRun(mCachedPaint, levelEnd - levelStart, isRtl);
}
if (levelEnd == end) {
break;