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

Unified Diff: webkit/glue/webframe_impl.cc

Issue 13130: Fix issue 5079: Incorrect "Active match ordinal" count during Find-in-page... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years 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
« chrome/test/automation/tab_proxy.h ('K') | « webkit/glue/webframe_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webframe_impl.cc
===================================================================
--- webkit/glue/webframe_impl.cc (revision 6273)
+++ webkit/glue/webframe_impl.cc (working copy)
@@ -353,7 +353,7 @@
decodeURLEscapeSequences(kurl.string().substring(sizeof("javascript:")-1));
WebCore::ScriptValue result = frame_->loader()->executeScript(script, true);
String scriptResult;
- if (result.getString(scriptResult) &&
+ if (result.getString(scriptResult) &&
!frame_->loader()->isScheduledLocationChangePending()) {
// TODO(darin): We need to figure out how to represent this in session
// history. Hint: don't re-eval script when the user or script navigates
@@ -764,6 +764,9 @@
}
void WebFrameImpl::IncreaseMatchCount(int count, int request_id) {
+ // This function should only be called on the mainframe.
+ DCHECK(this == static_cast<WebFrameImpl*>(GetView()->GetMainFrame()));
+
total_matchcount_ += count;
// Update the UI with the latest findings.
@@ -816,6 +819,9 @@
#if defined(OS_WIN)
WebCore::RenderThemeWin::setFindInPageMode(true);
#endif
+ // Store which frame was active. This will come in handy later when we
+ // change the active match ordinal below.
+ WebFrameImpl* old_active_frame = main_frame_impl->active_match_frame_;
// Set this frame as the active frame (the one with the active highlight).
main_frame_impl->active_match_frame_ = this;
@@ -841,13 +847,23 @@
// to find the active rect for us so we can update the ordinal (n of m).
locating_active_rect_ = true;
} else {
- // This is FindNext so we need to increment (or decrement) the count and
- // wrap if needed.
- request.forward ? ++active_match_index_ : --active_match_index_;
- if (active_match_index_ + 1 > last_match_count_)
- active_match_index_ = 0;
- if (active_match_index_ + 1 == 0)
- active_match_index_ = last_match_count_ - 1;
+ if (old_active_frame != this) {
+ // If the active frame has changed it means that we have a multi-frame
+ // page and we just switch to searching in a new frame. Then we just
+ // want to reset the index.
+ if (request.forward)
+ active_match_index_ = 0;
+ else
+ active_match_index_ = last_match_count_ - 1;
+ } else {
+ // We are still the active frame, so increment (or decrement) the
+ // |active_match_index|, wrapping if needed (on single frame pages).
+ request.forward ? ++active_match_index_ : --active_match_index_;
+ if (active_match_index_ + 1 > last_match_count_)
+ active_match_index_ = 0;
+ if (active_match_index_ + 1 == 0)
+ active_match_index_ = last_match_count_ - 1;
+ }
}
#if defined(OS_WIN)
@@ -885,7 +901,8 @@
it != frame;
it = static_cast<WebFrameImpl*>(
webview_impl_->GetNextFrameAfter(it, true))) {
- ordinal += it->last_match_count_;
+ if (it->last_match_count_ > 0)
+ ordinal += it->last_match_count_;
}
return ordinal;
@@ -1539,7 +1556,7 @@
const GURL& script_url) {
WebCore::ScriptSourceCode source_code(
webkit_glue::StdStringToString(js_code),
- webkit_glue::GURLToKURL(script_url),
+ webkit_glue::GURLToKURL(script_url),
1); // base line number (for errors)
frame_->loader()->executeScript(source_code);
}
@@ -1828,4 +1845,3 @@
}
password_listeners_.clear();
}
-
« chrome/test/automation/tab_proxy.h ('K') | « webkit/glue/webframe_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698