Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_GTK_KEY_BINDINGS_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_GTK_KEY_BINDINGS_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_GTK_KEY_BINDINGS_HANDLER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_GTK_KEY_BINDINGS_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "content/common/edit_command.h" | 13 #include "content/common/edit_command.h" |
| 14 #include "content/common/content_export.h" | |
|
jam
2011/10/04 16:48:32
nit: ordering
| |
| 14 #include "ui/base/gtk/owned_widget_gtk.h" | 15 #include "ui/base/gtk/owned_widget_gtk.h" |
| 15 | 16 |
| 16 struct NativeWebKeyboardEvent; | 17 struct NativeWebKeyboardEvent; |
| 17 | 18 |
| 18 // This class is a convenience class for handling editor key bindings defined | 19 // This class is a convenience class for handling editor key bindings defined |
| 19 // in gtk keyboard theme. | 20 // in gtk keyboard theme. |
| 20 // In gtk, only GtkEntry and GtkTextView support customizing editor key bindings | 21 // In gtk, only GtkEntry and GtkTextView support customizing editor key bindings |
| 21 // through keyboard theme. And in gtk keyboard theme definition file, each key | 22 // through keyboard theme. And in gtk keyboard theme definition file, each key |
| 22 // binding must be bound to a specific class or object. So existing keyboard | 23 // binding must be bound to a specific class or object. So existing keyboard |
| 23 // themes only define editor key bindings exactly for GtkEntry and GtkTextView. | 24 // themes only define editor key bindings exactly for GtkEntry and GtkTextView. |
| 24 // Then, the only way for us to intercept editor key bindings defined in | 25 // Then, the only way for us to intercept editor key bindings defined in |
| 25 // keyboard theme, is to create a GtkEntry or GtkTextView object and call | 26 // keyboard theme, is to create a GtkEntry or GtkTextView object and call |
| 26 // gtk_bindings_activate_event() against it for the key events. If a key event | 27 // gtk_bindings_activate_event() against it for the key events. If a key event |
| 27 // matches a predefined key binding, corresponding signal will be emitted. | 28 // matches a predefined key binding, corresponding signal will be emitted. |
| 28 // GtkTextView is used here because it supports more key bindings than GtkEntry, | 29 // GtkTextView is used here because it supports more key bindings than GtkEntry, |
| 29 // but in order to minimize the side effect of using a GtkTextView object, a new | 30 // but in order to minimize the side effect of using a GtkTextView object, a new |
| 30 // class derived from GtkTextView is used, which overrides all signals related | 31 // class derived from GtkTextView is used, which overrides all signals related |
| 31 // to key bindings, to make sure GtkTextView won't receive them. | 32 // to key bindings, to make sure GtkTextView won't receive them. |
| 32 // | 33 // |
| 33 // See third_party/WebKit/Source/WebCore/editing/EditorCommand.cpp for detailed | 34 // See third_party/WebKit/Source/WebCore/editing/EditorCommand.cpp for detailed |
| 34 // definition of webkit edit commands. | 35 // definition of webkit edit commands. |
| 35 // See webkit/glue/editor_client_impl.cc for key bindings predefined in our | 36 // See webkit/glue/editor_client_impl.cc for key bindings predefined in our |
| 36 // webkit glue. | 37 // webkit glue. |
| 37 class GtkKeyBindingsHandler { | 38 class CONTENT_EXPORT GtkKeyBindingsHandler { |
| 38 public: | 39 public: |
| 39 explicit GtkKeyBindingsHandler(GtkWidget* parent_widget); | 40 explicit GtkKeyBindingsHandler(GtkWidget* parent_widget); |
| 40 ~GtkKeyBindingsHandler(); | 41 ~GtkKeyBindingsHandler(); |
| 41 | 42 |
| 42 // Matches a key event against predefined gtk key bindings, false will be | 43 // Matches a key event against predefined gtk key bindings, false will be |
| 43 // returned if the key event doesn't correspond to a predefined key binding. | 44 // returned if the key event doesn't correspond to a predefined key binding. |
| 44 // Edit commands matched with |wke| will be stored in |edit_commands|. | 45 // Edit commands matched with |wke| will be stored in |edit_commands|. |
| 45 bool Match(const NativeWebKeyboardEvent& wke, EditCommands* edit_commands); | 46 bool Match(const NativeWebKeyboardEvent& wke, EditCommands* edit_commands); |
| 46 | 47 |
| 47 private: | 48 private: |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 // Handler of "move-focus" signal. | 120 // Handler of "move-focus" signal. |
| 120 static void MoveFocus(GtkWidget* widget, GtkDirectionType arg1); | 121 static void MoveFocus(GtkWidget* widget, GtkDirectionType arg1); |
| 121 | 122 |
| 122 ui::OwnedWidgetGtk handler_; | 123 ui::OwnedWidgetGtk handler_; |
| 123 | 124 |
| 124 // Buffer to store the match results. | 125 // Buffer to store the match results. |
| 125 EditCommands edit_commands_; | 126 EditCommands edit_commands_; |
| 126 }; | 127 }; |
| 127 | 128 |
| 128 #endif // CONTENT_BROWSER_RENDERER_HOST_GTK_KEY_BINDINGS_HANDLER_H_ | 129 #endif // CONTENT_BROWSER_RENDERER_HOST_GTK_KEY_BINDINGS_HANDLER_H_ |
| OLD | NEW |