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

Unified Diff: chrome/renderer/render_view.cc

Issue 335012: Update the find result index "(m of n)" whenever there is an active selection... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: simplify test Created 11 years, 1 month 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: chrome/renderer/render_view.cc
===================================================================
--- chrome/renderer/render_view.cc (revision 31004)
+++ chrome/renderer/render_view.cc (working copy)
@@ -74,6 +74,7 @@
#include "webkit/api/public/WebHistoryItem.h"
#include "webkit/api/public/WebNode.h"
#include "webkit/api/public/WebPoint.h"
+#include "webkit/api/public/WebRange.h"
#include "webkit/api/public/WebRect.h"
#include "webkit/api/public/WebScriptSource.h"
#include "webkit/api/public/WebSearchableFormData.h"
@@ -2780,6 +2781,10 @@
WebRect selection_rect;
bool result = false;
+ // If something is selected when we start searching it means we cannot just
+ // increment the current match ordinal; we need to re-generate it.
+ WebRange current_selection = focused_frame->selectionRange();
+
do {
result = search_frame->find(
request_id, search_text, options, wrap_within_frame, &selection_rect);
@@ -2816,7 +2821,7 @@
webview()->setFocusedFrame(search_frame);
} while (!result && search_frame != focused_frame);
- if (options.findNext) {
+ if (options.findNext && current_selection.isNull()) {
// Force the main_frame to report the actual count.
main_frame->increaseMatchCount(0, request_id);
} else {
« no previous file with comments | « chrome/browser/views/find_bar_host_browsertest.cc ('k') | chrome/test/data/find_in_page/select_changes_ordinal.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698