| Index: webkit/glue/webframe_impl.cc
|
| ===================================================================
|
| --- webkit/glue/webframe_impl.cc (revision 2542)
|
| +++ webkit/glue/webframe_impl.cc (working copy)
|
| @@ -1225,7 +1225,50 @@
|
| active_tickmark_ = WidgetClientWin::kNoTickmark;
|
| }
|
|
|
| -void WebFrameImpl::StopFinding() {
|
| +void WebFrameImpl::SetFindEndstateFocusAndSelection() {
|
| + WebFrameImpl* main_frame_impl =
|
| + static_cast<WebFrameImpl*>(GetView()->GetMainFrame());
|
| +
|
| + if (this == main_frame_impl->active_tickmark_frame() &&
|
| + active_tickmark_ != WidgetClientWin::kNoTickmark) {
|
| + RefPtr<Range> range = tickmarks_[active_tickmark_];
|
| +
|
| + // Set the selection to what the active match is.
|
| + frame()->selectionController()->setSelectedRange(
|
| + range.get(), WebCore::DOWNSTREAM, false);
|
| +
|
| + // We will be setting focus ourselves, so we want the view to forget its
|
| + // stored focus node so that it won't change it after we are done.
|
| + static_cast<WebViewImpl*>(GetView())->ReleaseFocusReferences();
|
| +
|
| + // Try to find the first focusable node up the chain, which will, for
|
| + // example, focus links if we have found text within the link.
|
| + Node* node = range->startNode();
|
| + while (!node->isFocusable() && node != frame()->document())
|
| + node = node->parent();
|
| +
|
| + if (node != frame()->document()) {
|
| + // Found a focusable parent node. Set focus to it.
|
| + frame()->document()->setFocusedNode(node);
|
| + } else {
|
| + // Iterate over all the nodes in the range until we find a focusable node.
|
| + // This, for example, sets focus to the first link if you search for
|
| + // text and text that is within one or more links.
|
| + node = range->startNode();
|
| + while (node != NULL && node != range->pastEndNode()) {
|
| + if (node->isFocusable()) {
|
| + frame()->document()->setFocusedNode(node);
|
| + break;
|
| + }
|
| + node = node->traverseNextNode();
|
| + }
|
| + }
|
| + }
|
| +}
|
| +
|
| +void WebFrameImpl::StopFinding(bool clear_selection) {
|
| + if (!clear_selection)
|
| + SetFindEndstateFocusAndSelection();
|
| CancelPendingScopingEffort();
|
|
|
| // Let the frame know that we don't want tickmarks or highlighting anymore.
|
|
|