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 #include "ui/base/ime/input_method_win.h" | 5 #include "ui/base/ime/input_method_win.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "ui/base/ime/text_input_client.h" | 8 #include "ui/base/ime/text_input_client.h" |
9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
10 #include "ui/events/event_constants.h" | 10 #include "ui/events/event_constants.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 LRESULT InputMethodWin::OnChar(HWND window_handle, | 127 LRESULT InputMethodWin::OnChar(HWND window_handle, |
128 UINT message, | 128 UINT message, |
129 WPARAM wparam, | 129 WPARAM wparam, |
130 LPARAM lparam, | 130 LPARAM lparam, |
131 BOOL* handled) { | 131 BOOL* handled) { |
132 *handled = TRUE; | 132 *handled = TRUE; |
133 | 133 |
134 // We need to send character events to the focused text input client event if | 134 // We need to send character events to the focused text input client event if |
135 // its text input type is ui::TEXT_INPUT_TYPE_NONE. | 135 // its text input type is ui::TEXT_INPUT_TYPE_NONE. |
136 if (GetTextInputClient()) { | 136 if (GetTextInputClient()) { |
137 const char16 kCarriageReturn = L'\r'; | 137 const base::char16 kCarriageReturn = L'\r'; |
138 const char16 ch = static_cast<char16>(wparam); | 138 const base::char16 ch = static_cast<base::char16>(wparam); |
139 // A mask to determine the previous key state from |lparam|. The value is 1 | 139 // A mask to determine the previous key state from |lparam|. The value is 1 |
140 // if the key is down before the message is sent, or it is 0 if the key is | 140 // if the key is down before the message is sent, or it is 0 if the key is |
141 // up. | 141 // up. |
142 const uint32 kPrevKeyDownBit = 0x40000000; | 142 const uint32 kPrevKeyDownBit = 0x40000000; |
143 if (ch == kCarriageReturn && !(lparam & kPrevKeyDownBit)) | 143 if (ch == kCarriageReturn && !(lparam & kPrevKeyDownBit)) |
144 accept_carriage_return_ = true; | 144 accept_carriage_return_ = true; |
145 // Conditionally ignore '\r' events to work around crbug.com/319100. | 145 // Conditionally ignore '\r' events to work around crbug.com/319100. |
146 // TODO(yukawa, IME): Figure out long-term solution. | 146 // TODO(yukawa, IME): Figure out long-term solution. |
147 if (ch != kCarriageReturn || accept_carriage_return_) | 147 if (ch != kCarriageReturn || accept_carriage_return_) |
148 GetTextInputClient()->InsertChar(ch, ui::GetModifiersFromKeyState()); | 148 GetTextInputClient()->InsertChar(ch, ui::GetModifiersFromKeyState()); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 if (GetTextInputClient()) { | 355 if (GetTextInputClient()) { |
356 GetTextInputClient()->InsertChar(event.key_code(), | 356 GetTextInputClient()->InsertChar(event.key_code(), |
357 ui::GetModifiersFromKeyState()); | 357 ui::GetModifiersFromKeyState()); |
358 return true; | 358 return true; |
359 } | 359 } |
360 } | 360 } |
361 return DispatchKeyEventPostIME(event); | 361 return DispatchKeyEventPostIME(event); |
362 } | 362 } |
363 | 363 |
364 } // namespace ui | 364 } // namespace ui |
OLD | NEW |