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

Side by Side Diff: ui/base/accelerators/accelerator.cc

Issue 954943003: [KeyboardEvent] Use DOM |code| rather than Windows-based key code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « content/renderer/render_view_browsertest.cc ('k') | ui/events/BUILD.gn » ('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) 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/accelerators/accelerator.h" 5 #include "ui/base/accelerators/accelerator.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // an unshifted mode (e.g. French AZERY layout has 'a with grave 190 // an unshifted mode (e.g. French AZERY layout has 'a with grave
191 // accent' for '0'). For display in the menu (e.g. Ctrl-0 for the 191 // accent' for '0'). For display in the menu (e.g. Ctrl-0 for the
192 // default zoom level), we leave VK_[0-9] alone without translation. 192 // default zoom level), we leave VK_[0-9] alone without translation.
193 wchar_t key; 193 wchar_t key;
194 if (key_code_ >= '0' && key_code_ <= '9') 194 if (key_code_ >= '0' && key_code_ <= '9')
195 key = static_cast<wchar_t>(key_code_); 195 key = static_cast<wchar_t>(key_code_);
196 else 196 else
197 key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR)); 197 key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR));
198 shortcut += key; 198 shortcut += key;
199 #elif defined(USE_AURA) || defined(OS_MACOSX) 199 #elif defined(USE_AURA) || defined(OS_MACOSX)
200 const uint16 c = GetCharacterFromKeyCode(key_code_, false); 200 DomCode code = KeyboardCodeToDomCode(key_code_);
201 const uint16 c = DomCodeToCharacter(code, false);
201 if (c != 0) 202 if (c != 0)
202 shortcut += 203 shortcut +=
203 static_cast<base::string16::value_type>(base::ToUpperASCII(c)); 204 static_cast<base::string16::value_type>(base::ToUpperASCII(c));
204 #endif 205 #endif
205 } else { 206 } else {
206 shortcut = l10n_util::GetStringUTF16(string_id); 207 shortcut = l10n_util::GetStringUTF16(string_id);
207 } 208 }
208 209
209 // Checking whether the character used for the accelerator is alphanumeric. 210 // Checking whether the character used for the accelerator is alphanumeric.
210 // If it is not, then we need to adjust the string later on if the locale is 211 // If it is not, then we need to adjust the string later on if the locale is
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 267
267 // Subtracting the size of the shortcut key and 1 for the '+' sign. 268 // Subtracting the size of the shortcut key and 1 for the '+' sign.
268 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1); 269 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1);
269 shortcut.swap(shortcut_rtl); 270 shortcut.swap(shortcut_rtl);
270 } 271 }
271 272
272 return shortcut; 273 return shortcut;
273 } 274 }
274 275
275 } // namespace ui 276 } // namespace ui
OLDNEW
« no previous file with comments | « content/renderer/render_view_browsertest.cc ('k') | ui/events/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698