int TextFinder::selectNearestFindMatch(const WebFloatPoint& point, WebRect* selectionRect) { TextFinder* bestFinder = nullptr; int indexInBestFrame = -1; float distanceInBestFrame = FLT_MAX; for (WebLocalFrameImpl* frame = &ownerFrame(); frame; frame = toWebLocalFrameImpl(frame->traverseNextLocal(false))) { float distanceInFrame; TextFinder& finder = frame->ensureTextFinder(); int indexInFrame = finder.nearestFindMatch(point, distanceInFrame); if (distanceInFrame < distanceInBestFrame) { bestFinder = &finder; indexInBestFrame = indexInFrame; distanceInBestFrame = distanceInFrame; } } if (indexInBestFrame != -1) return bestFinder->selectFindMatch(static_cast<unsigned>(indexInBestFrame), selectionRect); return -1; }
int TextFinder::ordinalOfFirstMatchForFrame(WebLocalFrameImpl* frame) const { int ordinal = 0; WebLocalFrameImpl* mainFrameImpl = ownerFrame().viewImpl()->mainFrameImpl(); // Iterate from the main frame up to (but not including) |frame| and // add up the number of matches found so far. for (WebLocalFrameImpl* it = mainFrameImpl; it != frame; it = toWebLocalFrameImpl(it->traverseNextLocal(true))) { TextFinder& finder = it->ensureTextFinder(); if (finder.m_lastMatchCount > 0) ordinal += finder.m_lastMatchCount; } return ordinal; }
void TextFinder::findMatchRects(WebVector<WebFloatRect>& outputRects) { Vector<WebFloatRect> matchRects; for (WebLocalFrameImpl* frame = &ownerFrame(); frame; frame = toWebLocalFrameImpl(frame->traverseNextLocal(false))) frame->ensureTextFinder().appendFindMatchRects(matchRects); outputRects = matchRects; }