Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: ui/views/mus/input_method_mus.cc

Issue 1402213002: Moves mandoline/ui/aura to ui/views/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disable presubmit Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/mus/input_method_mus.h ('k') | ui/views/mus/native_widget_view_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 "mandoline/ui/aura/input_method_mandoline.h" 5 #include "ui/views/mus/input_method_mus.h"
6 6
7 #include "components/mus/public/cpp/view.h" 7 #include "components/mus/public/cpp/view.h"
8 #include "mojo/converters/ime/ime_type_converters.h" 8 #include "mojo/converters/ime/ime_type_converters.h"
9 #include "ui/base/ime/text_input_client.h" 9 #include "ui/base/ime/text_input_client.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
11 #include "ui/mojo/ime/text_input_state.mojom.h" 11 #include "ui/mojo/ime/text_input_state.mojom.h"
12 12
13 namespace mandoline { 13 namespace views {
14 14
15 //////////////////////////////////////////////////////////////////////////////// 15 ////////////////////////////////////////////////////////////////////////////////
16 // InputMethodMandoline, public: 16 // InputMethodMUS, public:
17 17
18 InputMethodMandoline::InputMethodMandoline( 18 InputMethodMUS::InputMethodMUS(ui::internal::InputMethodDelegate* delegate,
19 ui::internal::InputMethodDelegate* delegate, 19 mus::View* view)
20 mus::View* view)
21 : view_(view) { 20 : view_(view) {
22 SetDelegate(delegate); 21 SetDelegate(delegate);
23 } 22 }
24 23
25 InputMethodMandoline::~InputMethodMandoline() {} 24 InputMethodMUS::~InputMethodMUS() {}
26 25
27 //////////////////////////////////////////////////////////////////////////////// 26 ////////////////////////////////////////////////////////////////////////////////
28 // InputMethodMandoline, ui::InputMethod implementation: 27 // InputMethodMUS, ui::InputMethod implementation:
29 28
30 void InputMethodMandoline::OnFocus() { 29 void InputMethodMUS::OnFocus() {
31 InputMethodBase::OnFocus(); 30 InputMethodBase::OnFocus();
32 UpdateTextInputType(); 31 UpdateTextInputType();
33 } 32 }
34 33
35 void InputMethodMandoline::OnBlur() { 34 void InputMethodMUS::OnBlur() {
36 InputMethodBase::OnBlur(); 35 InputMethodBase::OnBlur();
37 UpdateTextInputType(); 36 UpdateTextInputType();
38 } 37 }
39 38
40 bool InputMethodMandoline::OnUntranslatedIMEMessage( 39 bool InputMethodMUS::OnUntranslatedIMEMessage(const base::NativeEvent& event,
41 const base::NativeEvent& event, 40 NativeEventResult* result) {
42 NativeEventResult* result) {
43 return false; 41 return false;
44 } 42 }
45 43
46 void InputMethodMandoline::DispatchKeyEvent(ui::KeyEvent* event) { 44 void InputMethodMUS::DispatchKeyEvent(ui::KeyEvent* event) {
47 DCHECK(event->type() == ui::ET_KEY_PRESSED || 45 DCHECK(event->type() == ui::ET_KEY_PRESSED ||
48 event->type() == ui::ET_KEY_RELEASED); 46 event->type() == ui::ET_KEY_RELEASED);
49 47
50 // If no text input client, do nothing. 48 // If no text input client, do nothing.
51 if (!GetTextInputClient()) { 49 if (!GetTextInputClient()) {
52 ignore_result(DispatchKeyEventPostIME(event)); 50 ignore_result(DispatchKeyEventPostIME(event));
53 return; 51 return;
54 } 52 }
55 53
56 // Here is where we change the differ from our base class's logic. Instead of 54 // Here is where we change the differ from our base class's logic. Instead of
57 // always dispatching a key down event, and then sending a synthesized 55 // always dispatching a key down event, and then sending a synthesized
58 // character event, we instead check to see if this is a character event and 56 // character event, we instead check to see if this is a character event and
59 // send out the key if it is. (We fallback to normal dispatch if it isn't.) 57 // send out the key if it is. (We fallback to normal dispatch if it isn't.)
60 if (event->is_char()) { 58 if (event->is_char()) {
61 GetTextInputClient()->InsertChar(event->GetCharacter(), event->flags()); 59 GetTextInputClient()->InsertChar(event->GetCharacter(), event->flags());
62 event->StopPropagation(); 60 event->StopPropagation();
63 return; 61 return;
64 } 62 }
65 63
66 ignore_result(DispatchKeyEventPostIME(event)); 64 ignore_result(DispatchKeyEventPostIME(event));
67 } 65 }
68 66
69 void InputMethodMandoline::OnTextInputTypeChanged( 67 void InputMethodMUS::OnTextInputTypeChanged(const ui::TextInputClient* client) {
70 const ui::TextInputClient* client) {
71 if (IsTextInputClientFocused(client)) 68 if (IsTextInputClientFocused(client))
72 UpdateTextInputType(); 69 UpdateTextInputType();
73 InputMethodBase::OnTextInputTypeChanged(client); 70 InputMethodBase::OnTextInputTypeChanged(client);
74 } 71 }
75 72
76 void InputMethodMandoline::OnCaretBoundsChanged( 73 void InputMethodMUS::OnCaretBoundsChanged(const ui::TextInputClient* client) {}
77 const ui::TextInputClient* client) {
78 }
79 74
80 void InputMethodMandoline::CancelComposition( 75 void InputMethodMUS::CancelComposition(const ui::TextInputClient* client) {}
81 const ui::TextInputClient* client) {
82 }
83 76
84 void InputMethodMandoline::OnInputLocaleChanged() { 77 void InputMethodMUS::OnInputLocaleChanged() {}
85 }
86 78
87 std::string InputMethodMandoline::GetInputLocale() { 79 std::string InputMethodMUS::GetInputLocale() {
88 return ""; 80 return "";
89 } 81 }
90 82
91 bool InputMethodMandoline::IsCandidatePopupOpen() const { 83 bool InputMethodMUS::IsCandidatePopupOpen() const {
92 return false; 84 return false;
93 } 85 }
94 86
95 void InputMethodMandoline::OnDidChangeFocusedClient( 87 void InputMethodMUS::OnDidChangeFocusedClient(
96 ui::TextInputClient* focused_before, 88 ui::TextInputClient* focused_before,
97 ui::TextInputClient* focused) { 89 ui::TextInputClient* focused) {
98 InputMethodBase::OnDidChangeFocusedClient(focused_before, focused); 90 InputMethodBase::OnDidChangeFocusedClient(focused_before, focused);
99 UpdateTextInputType(); 91 UpdateTextInputType();
100 } 92 }
101 93
102 void InputMethodMandoline::UpdateTextInputType() { 94 void InputMethodMUS::UpdateTextInputType() {
103 ui::TextInputType type = GetTextInputType(); 95 ui::TextInputType type = GetTextInputType();
104 mojo::TextInputStatePtr state = mojo::TextInputState::New(); 96 mojo::TextInputStatePtr state = mojo::TextInputState::New();
105 state->type = mojo::ConvertTo<mojo::TextInputType>(type); 97 state->type = mojo::ConvertTo<mojo::TextInputType>(type);
106 if (type != ui::TEXT_INPUT_TYPE_NONE) 98 if (type != ui::TEXT_INPUT_TYPE_NONE)
107 view_->SetImeVisibility(true, state.Pass()); 99 view_->SetImeVisibility(true, state.Pass());
108 else 100 else
109 view_->SetTextInputState(state.Pass()); 101 view_->SetTextInputState(state.Pass());
110 } 102 }
111 103
112 } // namespace mandoline 104 } // namespace mandoline
OLDNEW
« no previous file with comments | « ui/views/mus/input_method_mus.h ('k') | ui/views/mus/native_widget_view_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698