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

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

Issue 1878083002: Implement IsAsciiUpper and IsAsciiLower in base/strings/string_util.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git sync 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
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 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 base::string16 shortcut; 207 base::string16 shortcut;
208 if (!string_id) { 208 if (!string_id) {
209 #if defined(OS_WIN) 209 #if defined(OS_WIN)
210 // Our fallback is to try translate the key code to a regular character 210 // Our fallback is to try translate the key code to a regular character
211 // unless it is one of digits (VK_0 to VK_9). Some keyboard 211 // unless it is one of digits (VK_0 to VK_9). Some keyboard
212 // layouts have characters other than digits assigned in 212 // layouts have characters other than digits assigned in
213 // an unshifted mode (e.g. French AZERY layout has 'a with grave 213 // an unshifted mode (e.g. French AZERY layout has 'a with grave
214 // accent' for '0'). For display in the menu (e.g. Ctrl-0 for the 214 // accent' for '0'). For display in the menu (e.g. Ctrl-0 for the
215 // default zoom level), we leave VK_[0-9] alone without translation. 215 // default zoom level), we leave VK_[0-9] alone without translation.
216 wchar_t key; 216 wchar_t key;
217 if (key_code_ >= '0' && key_code_ <= '9') 217 if (base::IsAsciiDigit(key_code_))
218 key = static_cast<wchar_t>(key_code_); 218 key = static_cast<wchar_t>(key_code_);
219 else 219 else
220 key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR)); 220 key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR));
221 shortcut += key; 221 shortcut += key;
222 #elif defined(USE_AURA) || defined(OS_MACOSX) 222 #elif defined(USE_AURA) || defined(OS_MACOSX)
223 const uint16_t c = DomCodeToUsLayoutCharacter( 223 const uint16_t c = DomCodeToUsLayoutCharacter(
224 UsLayoutKeyboardCodeToDomCode(key_code_), false); 224 UsLayoutKeyboardCodeToDomCode(key_code_), false);
225 if (c != 0) 225 if (c != 0)
226 shortcut += 226 shortcut +=
227 static_cast<base::string16::value_type>(base::ToUpperASCII(c)); 227 static_cast<base::string16::value_type>(base::ToUpperASCII(c));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 290
291 // Subtracting the size of the shortcut key and 1 for the '+' sign. 291 // Subtracting the size of the shortcut key and 1 for the '+' sign.
292 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1); 292 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1);
293 shortcut.swap(shortcut_rtl); 293 shortcut.swap(shortcut_rtl);
294 } 294 }
295 295
296 return shortcut; 296 return shortcut;
297 } 297 }
298 298
299 } // namespace ui 299 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698