Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: third_party/WebKit/Source/web/TextFinder.cpp

Issue 1605863002: Restart search in page when new text is found. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/TextFinder.cpp
diff --git a/third_party/WebKit/Source/web/TextFinder.cpp b/third_party/WebKit/Source/web/TextFinder.cpp
index 27d8ab2ff72fb62eb478a1b8f20a9bb976c8402a..8d03a36427ec1925dfa50b78817b552cee01e056 100644
--- a/third_party/WebKit/Source/web/TextFinder.cpp
+++ b/third_party/WebKit/Source/web/TextFinder.cpp
@@ -112,7 +112,7 @@ private:
const bool m_reset;
};
-bool TextFinder::find(int identifier, const WebString& searchText, const WebFindOptions& options, bool wrapWithinFrame, WebRect* selectionRect)
+bool TextFinder::find(int identifier, const WebString& searchText, const WebFindOptions& options, bool wrapWithinFrame, WebRect* selectionRect, bool* activeNow)
{
if (!ownerFrame().frame() || !ownerFrame().frame()->page())
return false;
@@ -163,17 +163,22 @@ bool TextFinder::find(int identifier, const WebString& searchText, const WebFind
ownerFrame().viewImpl()->zoomToFindInPageRect(ownerFrame().frameView()->contentsToRootFrame(enclosingIntRect(LayoutObject::absoluteBoundingBoxRectForRange(m_activeMatch.get()))));
}
- setMarkerActive(m_activeMatch.get(), true);
+ bool isActive = setMarkerActive(m_activeMatch.get(), true);
paulmeyer 2016/02/12 13:58:49 nit: Please move this block down to right above th
dvadym 2016/02/12 16:46:06 Done.
+ if (activeNow)
+ *activeNow = isActive;
+
WebLocalFrameImpl* oldActiveFrame = mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame;
mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame = &ownerFrame();
// Make sure no node is focused. See http://crbug.com/38700.
ownerFrame().frame()->document()->clearFocusedElement();
- if (!options.findNext || activeSelection) {
- // This is either a Find operation or a Find-next from a new start point
- // due to a selection, so we set the flag to ask the scoping effort
- // to find the active rect for us and report it back to the UI.
+ if (!options.findNext || activeSelection || !isActive) {
+ // This is either a Find operation, a Find-next from a new start point
+ // due to a selection, or new matches were found during Find-next due
+ // to DOM alteration (that couldn't be set as active), so we set the
+ // flag to ask the scoping effort to find the active rect for us and
+ // report it back to the UI.
m_locatingActiveRect = true;
} else {
if (oldActiveFrame != &ownerFrame()) {
@@ -687,11 +692,11 @@ void TextFinder::addMarker(Range* range, bool activeMatch)
ownerFrame().frame()->document()->markers().addTextMatchMarker(range, activeMatch);
}
-void TextFinder::setMarkerActive(Range* range, bool active)
+bool TextFinder::setMarkerActive(Range* range, bool active)
{
if (!range || range->collapsed())
- return;
- ownerFrame().frame()->document()->markers().setMarkersActive(range, active);
+ return false;
+ return ownerFrame().frame()->document()->markers().setMarkersActive(range, active);
}
void TextFinder::unmarkAllTextMatches()

Powered by Google App Engine
This is Rietveld 408576698