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 #include "ui/views/ime/mock_input_method.h" | 5 #include "ui/views/ime/mock_input_method.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "ui/base/event.h" |
9 #include "ui/base/ime/text_input_client.h" | 10 #include "ui/base/ime/text_input_client.h" |
10 #include "ui/base/keycodes/keyboard_codes.h" | 11 #include "ui/base/keycodes/keyboard_codes.h" |
11 #include "ui/views/events/event.h" | 12 #include "ui/views/events/event.h" |
12 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
13 | 14 |
14 namespace views { | 15 namespace views { |
15 | 16 |
16 MockInputMethod::MockInputMethod() | 17 MockInputMethod::MockInputMethod() |
17 : composition_changed_(false), | 18 : composition_changed_(false), |
18 focus_changed_(false), | 19 focus_changed_(false), |
(...skipping 17 matching lines...) Expand all Loading... |
36 set_delegate(delegate); | 37 set_delegate(delegate); |
37 } | 38 } |
38 | 39 |
39 MockInputMethod::~MockInputMethod() { | 40 MockInputMethod::~MockInputMethod() { |
40 } | 41 } |
41 | 42 |
42 void MockInputMethod::Init(Widget* widget) { | 43 void MockInputMethod::Init(Widget* widget) { |
43 InputMethodBase::Init(widget); | 44 InputMethodBase::Init(widget); |
44 } | 45 } |
45 | 46 |
46 void MockInputMethod::DispatchKeyEvent(const KeyEvent& key) { | 47 void MockInputMethod::DispatchKeyEvent(const ui::KeyEvent& key) { |
47 bool handled = (composition_changed_ || result_text_.length()) && | 48 bool handled = (composition_changed_ || result_text_.length()) && |
48 !IsTextInputTypeNone(); | 49 !IsTextInputTypeNone(); |
49 | 50 |
50 ClearStates(); | 51 ClearStates(); |
51 if (handled) { | 52 if (handled) { |
52 KeyEvent mock_key(ui::ET_KEY_PRESSED, ui::VKEY_PROCESSKEY, key.flags()); | 53 ui::KeyEvent mock_key(ui::ET_KEY_PRESSED, ui::VKEY_PROCESSKEY, key.flags()); |
53 DispatchKeyEventPostIME(mock_key); | 54 DispatchKeyEventPostIME(mock_key); |
54 } else { | 55 } else { |
55 DispatchKeyEventPostIME(key); | 56 DispatchKeyEventPostIME(key); |
56 } | 57 } |
57 | 58 |
58 if (focus_changed_) | 59 if (focus_changed_) |
59 return; | 60 return; |
60 | 61 |
61 ui::TextInputClient* client = GetTextInputClient(); | 62 ui::TextInputClient* client = GetTextInputClient(); |
62 if (client) { | 63 if (client) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 cancel_composition_called_ = false; | 165 cancel_composition_called_ = false; |
165 } | 166 } |
166 | 167 |
167 void MockInputMethod::ClearResult() { | 168 void MockInputMethod::ClearResult() { |
168 composition_.Clear(); | 169 composition_.Clear(); |
169 composition_changed_ = false; | 170 composition_changed_ = false; |
170 result_text_.clear(); | 171 result_text_.clear(); |
171 } | 172 } |
172 | 173 |
173 } // namespace views | 174 } // namespace views |
OLD | NEW |