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

Side by Side Diff: ui/base/ime/input_method_win.cc

Issue 1875763003: Only overwrite DomKey of keydown event if it's a printable character (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | no next file » | 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) 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <cwctype>
9 10
10 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
11 #include "base/command_line.h" 12 #include "base/command_line.h"
12 #include "ui/base/ime/ime_bridge.h" 13 #include "ui/base/ime/ime_bridge.h"
13 #include "ui/base/ime/ime_engine_handler_interface.h" 14 #include "ui/base/ime/ime_engine_handler_interface.h"
14 #include "ui/base/ime/text_input_client.h" 15 #include "ui/base/ime/text_input_client.h"
15 #include "ui/base/ime/win/tsf_input_scope.h" 16 #include "ui/base/ime/win/tsf_input_scope.h"
16 #include "ui/base/ui_base_switches.h" 17 #include "ui/base/ui_base_switches.h"
17 #include "ui/events/event.h" 18 #include "ui/events/event.h"
18 #include "ui/events/event_constants.h" 19 #include "ui/events/event_constants.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } else if (key.type() == ui::ET_KEY_RELEASED && 160 } else if (key.type() == ui::ET_KEY_RELEASED &&
160 (code == ui::VKEY_SHIFT || code == ui::VKEY_CONTROL) && 161 (code == ui::VKEY_SHIFT || code == ui::VKEY_CONTROL) &&
161 pending_requested_direction_ != base::i18n::UNKNOWN_DIRECTION) { 162 pending_requested_direction_ != base::i18n::UNKNOWN_DIRECTION) {
162 GetTextInputClient()->ChangeTextDirectionAndLayoutAlignment( 163 GetTextInputClient()->ChangeTextDirectionAndLayoutAlignment(
163 pending_requested_direction_); 164 pending_requested_direction_);
164 pending_requested_direction_ = base::i18n::UNKNOWN_DIRECTION; 165 pending_requested_direction_ = base::i18n::UNKNOWN_DIRECTION;
165 } 166 }
166 } 167 }
167 168
168 // If only 1 WM_CHAR per the key event, set it as the character of it. 169 // If only 1 WM_CHAR per the key event, set it as the character of it.
169 if (char_msgs.size() == 1) 170 if (char_msgs.size() == 1 &&
171 !std::iswcntrl(static_cast<wint_t>(char_msgs[0].wParam)))
170 event->set_character(static_cast<base::char16>(char_msgs[0].wParam)); 172 event->set_character(static_cast<base::char16>(char_msgs[0].wParam));
171 173
172 // Dispatches the key events to the Chrome IME extension which is listening to 174 // Dispatches the key events to the Chrome IME extension which is listening to
173 // key events on the following two situations: 175 // key events on the following two situations:
174 // 1) |char_msgs| is empty when the event is non-character key. 176 // 1) |char_msgs| is empty when the event is non-character key.
175 // 2) |char_msgs|.size() == 1 when the event is character key and the WM_CHAR 177 // 2) |char_msgs|.size() == 1 when the event is character key and the WM_CHAR
176 // messages have been combined in the event processing flow. 178 // messages have been combined in the event processing flow.
177 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 179 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
178 switches::kDisableMergeKeyCharEvents) && 180 switches::kDisableMergeKeyCharEvents) &&
179 char_msgs.size() <= 1 && GetEngine() && 181 char_msgs.size() <= 1 && GetEngine() &&
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 ui::IMEEngineHandlerInterface* engine = GetEngine(); 700 ui::IMEEngineHandlerInterface* engine = GetEngine();
699 if (engine) { 701 if (engine) {
700 if (old_text_input_type != ui::TEXT_INPUT_TYPE_NONE) 702 if (old_text_input_type != ui::TEXT_INPUT_TYPE_NONE)
701 engine->FocusOut(); 703 engine->FocusOut();
702 if (GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) 704 if (GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE)
703 engine->FocusIn(context); 705 engine->FocusIn(context);
704 } 706 }
705 } 707 }
706 708
707 } // namespace ui 709 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698