summaryrefslogtreecommitdiffstats
path: root/WebKit/android/nav/FindCanvas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android/nav/FindCanvas.cpp')
-rw-r--r--WebKit/android/nav/FindCanvas.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/WebKit/android/nav/FindCanvas.cpp b/WebKit/android/nav/FindCanvas.cpp
index 61bb07e..24b0129 100644
--- a/WebKit/android/nav/FindCanvas.cpp
+++ b/WebKit/android/nav/FindCanvas.cpp
@@ -275,8 +275,15 @@ void FindCanvas::findHelper(const void* text, size_t byteLength,
if (mWorkingIndex) {
SkPoint newY;
getTotalMatrix().mapXY(0, y, &newY);
- SkIRect bounds = mWorkingRegion.getBounds();
- if (bounds.fBottom < SkScalarRound(newY.fY)) {
+ SkIRect workingBounds = mWorkingRegion.getBounds();
+ int newYInt = SkScalarRound(newY.fY);
+ if (workingBounds.fTop > newYInt) {
+ // The new text is above the working region, so we know it's not
+ // a continuation.
+ resetWorkingCanvas();
+ mWorkingIndex = 0;
+ mWorkingRegion.setEmpty();
+ } else if (workingBounds.fBottom < newYInt) {
// Now we know that this line is lower than our partial match.
SkPaint clonePaint(paint);
clonePaint.setTextEncoding(SkPaint::kUTF8_TextEncoding);
@@ -301,6 +308,9 @@ void FindCanvas::findHelper(const void* text, size_t byteLength,
mWorkingRegion.setEmpty();
}
}
+ // If neither one is true, then we are likely continuing on the same
+ // line, but are in a new draw call because the paint has changed. In
+ // this case, we can continue without adding a space.
}
// j is the position in the search text
// Start off with mWorkingIndex in case we are continuing from a prior call
@@ -396,21 +406,20 @@ void FindCanvas::findHelper(const void* text, size_t byteLength,
// call.
// Keep track of a partial match that may start on this line.
if (j > 0) { // if j is greater than 0, we have a partial match
- int partialIndex = index - j + mWorkingIndex;
+ int relativeCount = j - mWorkingIndex; // Number of characters in this
+ // part of the match.
+ int partialIndex = index - relativeCount; // Index that starts our
+ // partial match.
const uint16_t* partialGlyphs = chars + partialIndex;
- SkRect partial = (this->*addMatch)(partialIndex, paint, j,
+ SkRect partial = (this->*addMatch)(partialIndex, paint, relativeCount,
partialGlyphs, positions, y);
partial.inset(mOutset, mOutset);
- getTotalMatrix().mapRect(&partial);
SkIRect dest;
partial.roundOut(&dest);
// Only save a partial if it is in the current clip.
if (getTotalClip().contains(dest)) {
mWorkingRegion.op(dest, SkRegion::kUnion_Op);
mWorkingIndex = j;
- // From one perspective, it seems like we would want to draw here,
- // since we have all the information (paint, matrix, etc)
- // However, we only want to draw if we find the rest
return;
}
}