| Index: webkit/glue/webframe_impl.cc
|
| ===================================================================
|
| --- webkit/glue/webframe_impl.cc (revision 13484)
|
| +++ webkit/glue/webframe_impl.cc (working copy)
|
| @@ -970,18 +970,26 @@
|
|
|
| if (!options.findNext)
|
| frame()->page()->unmarkAllTextMatches();
|
| + else
|
| + SetMarkerActive(active_match_.get(), false); // Active match is changing.
|
|
|
| // Starts the search from the current selection.
|
| bool start_in_selection = true;
|
|
|
| + // If the user has selected something since the last Find operation we want
|
| + // to start from there. Otherwise, we start searching from where the last Find
|
| + // operation left off (either a Find or a FindNext operation).
|
| + VisibleSelection selection(frame()->selection()->selection());
|
| + if (selection.isNone() && active_match_) {
|
| + selection = VisibleSelection(active_match_.get());
|
| + frame()->selection()->setSelection(selection);
|
| + }
|
| +
|
| DCHECK(frame() && frame()->view());
|
| bool found = frame()->findString(webcore_string, options.forward,
|
| options.matchCase, wrap_within_frame,
|
| start_in_selection);
|
| if (found) {
|
| -#if defined(OS_WIN)
|
| - WebCore::RenderThemeChromiumWin::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_;
|
| @@ -1003,6 +1011,8 @@
|
| } else {
|
| active_match_ = new_selection.toNormalizedRange();
|
| curr_selection_rect = active_match_->boundingBox();
|
| + SetMarkerActive(active_match_.get(), true); // Active.
|
| + ClearSelection(); // WebKit draws the highlighting for all matches.
|
| }
|
|
|
| if (!options.findNext) {
|
| @@ -1113,7 +1123,7 @@
|
| }
|
| }
|
|
|
| -void WebFrameImpl::AddMarker(WebCore::Range* range) {
|
| +void WebFrameImpl::AddMarker(WebCore::Range* range, bool active_match) {
|
| // Use a TextIterator to visit the potentially multiple nodes the range
|
| // covers.
|
| TextIterator markedText(range);
|
| @@ -1125,7 +1135,8 @@
|
| WebCore::DocumentMarker::TextMatch,
|
| textPiece->startOffset(exception),
|
| textPiece->endOffset(exception),
|
| - "" };
|
| + "",
|
| + active_match };
|
|
|
| if (marker.endOffset > marker.startOffset) {
|
| // Find the node to add a marker to and add it.
|
| @@ -1146,6 +1157,13 @@
|
| }
|
| }
|
|
|
| +void WebFrameImpl::SetMarkerActive(WebCore::Range* range, bool active) {
|
| + if (!range)
|
| + return;
|
| +
|
| + frame()->document()->setMarkersActive(range, active);
|
| +}
|
| +
|
| void WebFrameImpl::ScopeStringMatches(int request_id,
|
| const string16& search_text,
|
| const WebFindOptions& options,
|
| @@ -1242,8 +1260,6 @@
|
| if (frame()->editor()->insideVisibleArea(result_range.get())) {
|
| ++match_count;
|
|
|
| - AddMarker(result_range.get());
|
| -
|
| setStart(search_range.get(), new_start);
|
| Node* shadow_tree_root = search_range->shadowTreeRootNode();
|
| if (search_range->collapsed(ec) && shadow_tree_root)
|
| @@ -1264,9 +1280,11 @@
|
| // match was found in active_selection_rect_ on the current frame. If we
|
| // find this rect during scoping it means we have found the active
|
| // tickmark.
|
| + bool found_active_match = false;
|
| if (locating_active_rect_ && (active_selection_rect == result_bounds)) {
|
| // We have found the active tickmark frame.
|
| main_frame_impl->active_match_frame_ = this;
|
| + found_active_match = true;
|
| // We also know which tickmark is active now.
|
| active_match_index_ = match_count - 1;
|
| // To stop looking for the active tickmark, we set this flag.
|
| @@ -1284,6 +1302,8 @@
|
| request_id);
|
| #endif
|
| }
|
| +
|
| + AddMarker(result_range.get(), found_active_match);
|
| }
|
|
|
| resume_scoping_from_range_ = result_range;
|
| @@ -1389,10 +1409,6 @@
|
| SetFindEndstateFocusAndSelection();
|
| CancelPendingScopingEffort();
|
|
|
| -#if defined(OS_WIN)
|
| - WebCore::RenderThemeChromiumWin::setFindInPageMode(false);
|
| -#endif
|
| -
|
| // Remove all markers for matches found and turn off the highlighting.
|
| if (this == static_cast<WebFrameImpl*>(GetView()->GetMainFrame()))
|
| frame()->document()->removeMarkers(WebCore::DocumentMarker::TextMatch);
|
|
|