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

Unified Diff: webkit/glue/webframe_impl.cc

Issue 4283: Fix bug 455: Active match in Find is not selected and links are not focused a... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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
« no previous file with comments | « 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 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.
« no previous file with comments | « webkit/glue/webframe_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698