| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_IM_CONTEXT_WRAPPER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_GTK_IM_CONTEXT_WRAPPER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_GTK_IM_CONTEXT_WRAPPER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_GTK_IM_CONTEXT_WRAPPER_H_ |
| 7 | 7 |
| 8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
| 9 #include <pango/pango-attributes.h> | 9 #include <pango/pango-attributes.h> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 16 #include "ui/base/ime/composition_text.h" | 16 #include "ui/base/ime/composition_text.h" |
| 17 #include "ui/base/ime/text_input_type.h" | 17 #include "ui/base/ime/text_input_type.h" |
| 18 | 18 |
| 19 class RenderWidgetHostViewGtk; | |
| 20 typedef struct _GtkIMContext GtkIMContext; | 19 typedef struct _GtkIMContext GtkIMContext; |
| 21 typedef struct _GtkWidget GtkWidget; | 20 typedef struct _GtkWidget GtkWidget; |
| 22 | 21 |
| 23 namespace content { | |
| 24 struct NativeWebKeyboardEvent; | |
| 25 } | |
| 26 | |
| 27 namespace gfx { | 22 namespace gfx { |
| 28 class Rect; | 23 class Rect; |
| 29 } | 24 } |
| 30 | 25 |
| 26 namespace content { |
| 27 class RenderWidgetHostViewGtk; |
| 28 struct NativeWebKeyboardEvent; |
| 29 |
| 31 // This class is a convenience wrapper for GtkIMContext. | 30 // This class is a convenience wrapper for GtkIMContext. |
| 32 // It creates and manages two GtkIMContext instances, one is GtkIMMulticontext, | 31 // It creates and manages two GtkIMContext instances, one is GtkIMMulticontext, |
| 33 // for plain text input box, another is GtkIMContextSimple, for password input | 32 // for plain text input box, another is GtkIMContextSimple, for password input |
| 34 // box. | 33 // box. |
| 35 // | 34 // |
| 36 // This class is in charge of dispatching key events to these two GtkIMContext | 35 // This class is in charge of dispatching key events to these two GtkIMContext |
| 37 // instances and handling signals emitted by them. Key events then will be | 36 // instances and handling signals emitted by them. Key events then will be |
| 38 // forwarded to renderer along with input method results via corresponding host | 37 // forwarded to renderer along with input method results via corresponding host |
| 39 // view. | 38 // view. |
| 40 // | 39 // |
| (...skipping 20 matching lines...) Expand all Loading... |
| 61 void ConfirmComposition(); | 60 void ConfirmComposition(); |
| 62 | 61 |
| 63 private: | 62 private: |
| 64 // Check if a text needs commit by forwarding a char event instead of | 63 // Check if a text needs commit by forwarding a char event instead of |
| 65 // by confirming as a composition text. | 64 // by confirming as a composition text. |
| 66 bool NeedCommitByForwardingCharEvent() const; | 65 bool NeedCommitByForwardingCharEvent() const; |
| 67 | 66 |
| 68 // Check if the input method returned any result, eg. preedit and commit text. | 67 // Check if the input method returned any result, eg. preedit and commit text. |
| 69 bool HasInputMethodResult() const; | 68 bool HasInputMethodResult() const; |
| 70 | 69 |
| 71 void ProcessFilteredKeyPressEvent(content::NativeWebKeyboardEvent* wke); | 70 void ProcessFilteredKeyPressEvent(NativeWebKeyboardEvent* wke); |
| 72 void ProcessUnfilteredKeyPressEvent(content::NativeWebKeyboardEvent* wke); | 71 void ProcessUnfilteredKeyPressEvent(NativeWebKeyboardEvent* wke); |
| 73 | 72 |
| 74 // Processes result returned from input method after filtering a key event. | 73 // Processes result returned from input method after filtering a key event. |
| 75 // |filtered| indicates if the key event was filtered by the input method. | 74 // |filtered| indicates if the key event was filtered by the input method. |
| 76 void ProcessInputMethodResult(const GdkEventKey* event, bool filtered); | 75 void ProcessInputMethodResult(const GdkEventKey* event, bool filtered); |
| 77 | 76 |
| 78 // Real code of "commit" signal handler. | 77 // Real code of "commit" signal handler. |
| 79 void HandleCommit(const string16& text); | 78 void HandleCommit(const string16& text); |
| 80 | 79 |
| 81 // Real code of "preedit-start" signal handler. | 80 // Real code of "preedit-start" signal handler. |
| 82 void HandlePreeditStart(); | 81 void HandlePreeditStart(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 189 |
| 191 // Information of the last key event, for working around | 190 // Information of the last key event, for working around |
| 192 // http://crosbug.com/6582 | 191 // http://crosbug.com/6582 |
| 193 int last_key_code_; | 192 int last_key_code_; |
| 194 bool last_key_was_up_; | 193 bool last_key_was_up_; |
| 195 bool last_key_filtered_no_result_; | 194 bool last_key_filtered_no_result_; |
| 196 | 195 |
| 197 DISALLOW_COPY_AND_ASSIGN(GtkIMContextWrapper); | 196 DISALLOW_COPY_AND_ASSIGN(GtkIMContextWrapper); |
| 198 }; | 197 }; |
| 199 | 198 |
| 199 } // namespace content |
| 200 |
| 200 #endif // CONTENT_BROWSER_RENDERER_HOST_GTK_IM_CONTEXT_WRAPPER_H_ | 201 #endif // CONTENT_BROWSER_RENDERER_HOST_GTK_IM_CONTEXT_WRAPPER_H_ |
| OLD | NEW |