summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-02 21:39:07 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-02 21:39:07 +0000
commit406c913ffa55edfe40c707760ae4b64c4f37fe65 (patch)
tree68d4459f1de5c8794d05656f90c7b3349df1a331 /chrome/browser/tab_contents
parent1e1f5b25219fba0e0531fd1c118b0acb4ddf4e8f (diff)
downloadchromium_src-406c913ffa55edfe40c707760ae4b64c4f37fe65.zip
chromium_src-406c913ffa55edfe40c707760ae4b64c4f37fe65.tar.gz
chromium_src-406c913ffa55edfe40c707760ae4b64c4f37fe65.tar.bz2
Enable focus-change via tabbing on Linux.
Review URL: http://codereview.chromium.org/28248 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10725 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/web_contents_view_gtk.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/chrome/browser/tab_contents/web_contents_view_gtk.cc b/chrome/browser/tab_contents/web_contents_view_gtk.cc
index e82b128..5b14c08 100644
--- a/chrome/browser/tab_contents/web_contents_view_gtk.cc
+++ b/chrome/browser/tab_contents/web_contents_view_gtk.cc
@@ -10,10 +10,27 @@
#include "base/gfx/rect.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
+#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/browser/tab_contents/web_contents.h"
namespace {
+// Called when the content view gtk widget is tabbed to. We always return true
+// and grab focus if we don't have it. The call to SetInitialFocus() forwards
+// the tab to webkit. We leave focus via TakeFocus().
+// We cast the WebContents to a TabContents because SetInitialFocus is public
+// in TabContents and protected in WebContents.
+gboolean OnFocus(GtkWidget* widget, GtkDirectionType focus,
+ TabContents* tab_contents) {
+ if (GTK_WIDGET_HAS_FOCUS(widget))
+ return TRUE;
+
+ gtk_widget_grab_focus(widget);
+ bool reverse = focus == GTK_DIR_TAB_BACKWARD;
+ tab_contents->SetInitialFocus(reverse);
+ return TRUE;
+}
+
// Callback used in WebContentsViewGtk::CreateViewForWidget().
void RemoveWidget(GtkWidget* widget, void* container) {
gtk_container_remove(GTK_CONTAINER(container), widget);
@@ -50,6 +67,8 @@ RenderWidgetHostView* WebContentsViewGtk::CreateViewForWidget(
RenderWidgetHostViewGtk* view =
new RenderWidgetHostViewGtk(render_widget_host);
gtk_widget_show(view->native_view());
+ g_signal_connect(view->native_view(), "focus",
+ G_CALLBACK(OnFocus), web_contents_);
gtk_container_foreach(GTK_CONTAINER(vbox_), RemoveWidget, vbox_);
gtk_box_pack_start(GTK_BOX(vbox_), view->native_view(), TRUE, TRUE, 0);
return view;
@@ -121,8 +140,10 @@ void WebContentsViewGtk::UpdateDragCursor(bool is_drop_target) {
NOTIMPLEMENTED();
}
+// This is called when we the renderer asks us to take focus back (i.e., it has
+// iterated past the last focusable element on the page).
void WebContentsViewGtk::TakeFocus(bool reverse) {
- NOTIMPLEMENTED();
+ web_contents_->delegate()->SetFocusToLocationBar();
}
void WebContentsViewGtk::HandleKeyboardEvent(const WebKeyboardEvent& event) {