6555be2636
* chore: bump chromium to 74.0.3729.5 (master) * Remove ScopedBlockingCall constructor without location https://chromium-review.googlesource.com/c/chromium/src/+/1496560 * Use XCode 9.4.1 for Mac SDK 10.13 * chore: roll chromium 74.0.3729.27
86 lines
3.2 KiB
Diff
86 lines
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Cheng Zhao <zcbenz@gmail.com>
|
|
Date: Thu, 4 Oct 2018 14:57:02 -0700
|
|
Subject: accelerator.patch
|
|
|
|
This patch makes three changes to Accelerator::GetShortcutText to improve shortcut display text in menus:
|
|
|
|
1. Ctrl-Alt-<Key> accelerators show as Ctrl-Alt-<Key> instead of as Ctrl-<Key>
|
|
2. F2-F24 accelerators show up as such
|
|
3. Ctrl-Shift-= should show as Ctrl-+
|
|
|
|
diff --git a/ui/base/accelerators/accelerator.cc b/ui/base/accelerators/accelerator.cc
|
|
index a59d08c79b315ad30dea3ce4fb67b59bba07fae7..7f245b1e8b9b3c5dc6666be4d74b69c86e80a351 100644
|
|
--- a/ui/base/accelerators/accelerator.cc
|
|
+++ b/ui/base/accelerators/accelerator.cc
|
|
@@ -11,6 +11,7 @@
|
|
#include "base/logging.h"
|
|
#include "base/strings/strcat.h"
|
|
#include "base/strings/string_util.h"
|
|
+#include "base/strings/stringprintf.h"
|
|
#include "base/strings/utf_string_conversions.h"
|
|
#include "build/build_config.h"
|
|
#include "ui/base/l10n/l10n_util.h"
|
|
@@ -22,9 +23,7 @@
|
|
#include <windows.h>
|
|
#endif
|
|
|
|
-#if !defined(OS_WIN) && (defined(USE_AURA) || defined(OS_MACOSX))
|
|
#include "ui/events/keycodes/keyboard_code_conversion.h"
|
|
-#endif
|
|
|
|
namespace ui {
|
|
|
|
@@ -148,7 +147,15 @@ base::string16 Accelerator::GetShortcutText() const {
|
|
shortcut = KeyCodeToName(key_code_);
|
|
#endif
|
|
|
|
+ unsigned int flags = 0;
|
|
if (shortcut.empty()) {
|
|
+ const uint16_t c = DomCodeToUsLayoutCharacter(
|
|
+ UsLayoutKeyboardCodeToDomCode(key_code_), flags);
|
|
+ if (c != 0) {
|
|
+ shortcut =
|
|
+ static_cast<base::string16::value_type>(
|
|
+ base::ToUpperASCII(static_cast<base::char16>(c)));
|
|
+ }
|
|
#if defined(OS_WIN)
|
|
// Our fallback is to try translate the key code to a regular character
|
|
// unless it is one of digits (VK_0 to VK_9). Some keyboard
|
|
@@ -157,21 +164,14 @@ base::string16 Accelerator::GetShortcutText() const {
|
|
// accent' for '0'). For display in the menu (e.g. Ctrl-0 for the
|
|
// default zoom level), we leave VK_[0-9] alone without translation.
|
|
wchar_t key;
|
|
- if (base::IsAsciiDigit(key_code_))
|
|
+ if (base::IsAsciiDigit(key_code_)) {
|
|
key = static_cast<wchar_t>(key_code_);
|
|
- else
|
|
- key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR));
|
|
- // If there is no translation for the given |key_code_| (e.g.
|
|
- // VKEY_UNKNOWN), |::MapVirtualKeyW| returns 0.
|
|
- if (key != 0)
|
|
- shortcut += key;
|
|
-#elif defined(USE_AURA) || defined(OS_MACOSX) || defined(OS_ANDROID)
|
|
- const uint16_t c = DomCodeToUsLayoutCharacter(
|
|
- UsLayoutKeyboardCodeToDomCode(key_code_), false);
|
|
- if (c != 0)
|
|
- shortcut +=
|
|
- static_cast<base::string16::value_type>(base::ToUpperASCII(c));
|
|
+ shortcut = key;
|
|
+ }
|
|
#endif
|
|
+ if (key_code_ > VKEY_F1 && key_code_ <= VKEY_F24)
|
|
+ shortcut = base::UTF8ToUTF16(
|
|
+ base::StringPrintf("F%d", key_code_ - VKEY_F1 + 1));
|
|
}
|
|
|
|
// Checking whether the character used for the accelerator is alphanumeric.
|
|
@@ -235,7 +235,7 @@ base::string16 Accelerator::ApplyLongFormModifiers(
|
|
// more information.
|
|
if (IsCtrlDown())
|
|
shortcut = ApplyModifierToAcceleratorString(shortcut, IDS_APP_CTRL_KEY);
|
|
- else if (IsAltDown())
|
|
+ if (IsAltDown())
|
|
shortcut = ApplyModifierToAcceleratorString(shortcut, IDS_APP_ALT_KEY);
|
|
|
|
if (IsCmdDown()) {
|