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