summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 23:38:16 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 23:38:16 +0000
commit05d47875219edd6f25490d8a878021ff2d564170 (patch)
tree88fe8a3aaa158da3dd6acbb20258ab604a93ce56 /webkit
parent43101c0334b3297868085e661a2e92f935434a5e (diff)
downloadchromium_src-05d47875219edd6f25490d8a878021ff2d564170.zip
chromium_src-05d47875219edd6f25490d8a878021ff2d564170.tar.gz
chromium_src-05d47875219edd6f25490d8a878021ff2d564170.tar.bz2
When the Find bar has focus it eats keypresses such as PageUp, PageDown and Up and Down arrow keys. It doesn't need to - instead the page should scroll even if focus is on the Find bar.
This patch forwards those selected keypresses to the page for its perusal. Known issues: Just like Firefox, the page doesn't scroll if it has frames. SONG=I like to fixit fixit. I like to fixit fixit. BUG=7079 TEST=Open FindInPage on a webpage that has a vertical scrollbar. Press Down, Up, PageDown and PageUp and the page should scroll accordingly. Make sure no ding is heard while doing so. Also make sure this works if focus is on a textfield/textarea when you press Ctrl+F. Review URL: http://codereview.chromium.org/62129 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13389 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webview.h14
-rw-r--r--webkit/glue/webview_impl.cc33
-rw-r--r--webkit/glue/webview_impl.h1
3 files changed, 43 insertions, 5 deletions
diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h
index 35c7fe8..99ad41e 100644
--- a/webkit/glue/webview.h
+++ b/webkit/glue/webview.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef WEBKIT_GLUE_WEBVIEW_H__
-#define WEBKIT_GLUE_WEBVIEW_H__
+#ifndef WEBKIT_GLUE_WEBVIEW_H_
+#define WEBKIT_GLUE_WEBVIEW_H_
#include <string>
#include <vector>
@@ -129,6 +129,10 @@ class WebView : public WebWidget {
// bug is fixed.
virtual void StoreFocusForFrame(WebFrame* frame) = 0;
+ // Clears the focused node (and selection if a text field is focused) to
+ // ensure that a text field on the page is not eating keystrokes we send it.
+ virtual void ClearFocusedNode() = 0;
+
// Requests the webview to download an image. When done, the delegate is
// notified by way of DidDownloadImage. Returns true if the request was
// successfully started, false otherwise. id is used to uniquely identify the
@@ -218,7 +222,7 @@ class WebView : public WebWidget {
virtual WebDevToolsAgent* GetWebDevToolsAgent() = 0;
private:
- DISALLOW_EVIL_CONSTRUCTORS(WebView);
+ DISALLOW_COPY_AND_ASSIGN(WebView);
};
-#endif // WEBKIT_GLUE_WEBVIEW_H__
+#endif // WEBKIT_GLUE_WEBVIEW_H_
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index 408246b..440830f 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -1075,6 +1075,39 @@ void WebViewImpl::SetBackForwardListSize(int size) {
page_->backForwardList()->setCapacity(size);
}
+void WebViewImpl::ClearFocusedNode() {
+ // Get the last focused frame or the mainframe.
+ RefPtr<Frame> frame = last_focused_frame_;
+ if (!frame.get() && page_.get())
+ frame = page_->mainFrame();
+ if (!frame.get())
+ return;
+
+ RefPtr<Document> document = frame->document();
+ if (!document.get())
+ return;
+
+ RefPtr<Node> old_focused_node = document->focusedNode();
+
+ // Clear the focused node.
+ document->setFocusedNode(NULL);
+
+ if (!old_focused_node.get())
+ return;
+
+ // If a text field has focus, we need to make sure the selection controller
+ // knows to remove selection from it. Otherwise, the text field is still
+ // processing keyboard events even though focus has been moved to the page and
+ // keystrokes get eaten as a result.
+ if (old_focused_node->hasTagName(HTMLNames::textareaTag) ||
+ (old_focused_node->hasTagName(HTMLNames::inputTag) &&
+ static_cast<HTMLInputElement*>(old_focused_node.get())->isTextField())) {
+ // Clear the selection.
+ SelectionController* selection = frame->selection();
+ selection->clear();
+ }
+}
+
void WebViewImpl::SetFocus(bool enable) {
if (enable) {
// Getting the focused frame will have the side-effect of setting the main
diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h
index e52a8d2..413445e 100644
--- a/webkit/glue/webview_impl.h
+++ b/webkit/glue/webview_impl.h
@@ -70,6 +70,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
virtual bool HandleInputEvent(const WebKit::WebInputEvent* input_event);
virtual void MouseCaptureLost();
virtual void SetFocus(bool enable);
+ virtual void ClearFocusedNode();
virtual void StoreFocusForFrame(WebFrame* frame);
virtual bool ImeSetComposition(int string_type,
int cursor_position,