Chromium Code Reviews| Index: ui/base/ime/input_method_win.cc |
| diff --git a/ui/base/ime/input_method_win.cc b/ui/base/ime/input_method_win.cc |
| index 7db88b6298a3aba4b56d8eff5902250e1a2f00de..ff5848a669f0362d354f95c57ac5c0fb9a9268c4 100644 |
| --- a/ui/base/ime/input_method_win.cc |
| +++ b/ui/base/ime/input_method_win.cc |
| @@ -32,8 +32,7 @@ InputMethodWin::InputMethodWin(internal::InputMethodDelegate* delegate, |
| accept_carriage_return_(false), |
| enabled_(false), |
| is_candidate_popup_open_(false), |
| - composing_window_handle_(NULL), |
| - suppress_next_char_(false) { |
| + composing_window_handle_(NULL) { |
| SetDelegate(delegate); |
| } |
| @@ -104,9 +103,30 @@ void InputMethodWin::DispatchKeyEvent(ui::KeyEvent* event) { |
| return; |
| } |
| + std::vector<MSG> char_msgs; |
| const base::NativeEvent& native_key_event = event->native_event(); |
| + // Peek & remove the following messages in the message queue. |
|
robliao
2015/08/14 16:42:34
This comment isn't particularly necessary because
Shu Chen
2015/08/17 04:09:21
Done.
robliao
2015/08/17 16:42:35
Add these comments to this comment and remove the
Shu Chen
2015/08/18 08:49:41
Done.
|
| + // - WM_CHAR (0x0102) |
| + // - WM_DEADCHAR (0x0103) |
| + // - WM_SYSCHAR (0x0106) |
| + // - WM_SYSDEADCHAR (0x0107) |
| + // And only process WM_CHAR & WM_SYSCHAR message in browser. |
| + // This is to combine the WM_KEY* and WM_CHAR messages in the event |
| + // processing flow. |
| + MSG msg; |
| + while (::PeekMessage(&msg, native_key_event.hwnd, WM_CHAR, WM_DEADCHAR, |
| + PM_REMOVE)) { |
| + if (msg.message == WM_CHAR) |
| + char_msgs.push_back(msg); |
| + } |
| + while (::PeekMessage(&msg, native_key_event.hwnd, WM_SYSCHAR, WM_SYSDEADCHAR, |
| + PM_REMOVE)) { |
| + if (msg.message == WM_SYSCHAR) |
| + char_msgs.push_back(msg); |
| + } |
| + |
| + BOOL handled = FALSE; |
| if (native_key_event.message == WM_CHAR) { |
| - BOOL handled; |
| OnChar(native_key_event.hwnd, native_key_event.message, |
| native_key_event.wParam, native_key_event.lParam, &handled); |
| if (handled) |
| @@ -137,8 +157,15 @@ void InputMethodWin::DispatchKeyEvent(ui::KeyEvent* event) { |
| } |
| ui::EventDispatchDetails details = DispatchKeyEventPostIME(event); |
| - if (!details.dispatcher_destroyed) |
| - suppress_next_char_ = event->stopped_propagation(); |
| + if (details.dispatcher_destroyed || details.target_destroyed || |
| + event->stopped_propagation()) { |
| + return; |
| + } |
| + |
| + for (size_t i = 0; i < char_msgs.size(); ++i) { |
| + msg = char_msgs[i]; |
| + OnChar(msg.hwnd, msg.message, msg.wParam, msg.lParam, &handled); |
| + } |
| } |
| void InputMethodWin::OnTextInputTypeChanged(const TextInputClient* client) { |
| @@ -224,11 +251,6 @@ LRESULT InputMethodWin::OnChar(HWND window_handle, |
| *handled = TRUE; |
| - if (suppress_next_char_) { |
| - suppress_next_char_ = false; |
| - return 0; |
| - } |
| - |
| // We need to send character events to the focused text input client event if |
| // its text input type is ui::TEXT_INPUT_TYPE_NONE. |
| if (GetTextInputClient()) { |
| @@ -587,10 +609,6 @@ bool InputMethodWin::IsWindowFocused(const TextInputClient* client) const { |
| void InputMethodWin::DispatchFabricatedKeyEvent(ui::KeyEvent* event) { |
| if (event->is_char()) { |
| - if (suppress_next_char_) { |
| - suppress_next_char_ = false; |
| - return; |
| - } |
| if (GetTextInputClient()) { |
| GetTextInputClient()->InsertChar( |
| static_cast<base::char16>(event->key_code()), |