Update common/chromium/accelerator.patch

This commit is contained in:
Aleksei Kuzmin 2018-07-17 16:55:45 +02:00
Родитель 64043596ae
Коммит 926dad610c
1 изменённых файлов: 40 добавлений и 23 удалений

Просмотреть файл

@ -1,16 +1,16 @@
diff --git a/ui/base/accelerators/accelerator.cc b/ui/base/accelerators/accelerator.cc
index dd756238a056..878b468311eb 100644
index a6756c2..5352958 100644
--- a/ui/base/accelerators/accelerator.cc
+++ b/ui/base/accelerators/accelerator.cc
@@ -9,6 +9,7 @@
#include "base/i18n/rtl.h"
@@ -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"
@@ -19,9 +20,7 @@
@@ -21,9 +22,7 @@
#include <windows.h>
#endif
@ -20,24 +20,25 @@ index dd756238a056..878b468311eb 100644
namespace ui {
@@ -210,7 +209,16 @@ base::string16 Accelerator::GetShortcutText() const {
}
@@ -145,7 +144,17 @@ base::string16 Accelerator::GetShortcutText() const {
shortcut = KeyCodeToName(key_code_);
#endif
base::string16 shortcut;
+ unsigned int flags = 0;
if (!string_id) {
if (shortcut.empty()) {
+ if (IsShiftDown())
+ flags = ui::EF_SHIFT_DOWN;
+ flags = ui::EF_SHIFT_DOWN;
+ const uint16_t c = DomCodeToUsLayoutCharacter(
+ UsLayoutKeyboardCodeToDomCode(key_code_), flags);
+ if (c != 0)
+ shortcut +=
+ 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
@@ -219,20 +227,18 @@ base::string16 Accelerator::GetShortcutText() const {
@@ -154,17 +163,20 @@ 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;
@ -55,21 +56,23 @@ index dd756238a056..878b468311eb 100644
- static_cast<base::string16::value_type>(base::ToUpperASCII(c));
+ shortcut = key;
+ }
#endif
+#endif
+ if (key_code_ > VKEY_F1 && key_code_ <= VKEY_F24)
+ shortcut += base::UTF8ToUTF16(
+ shortcut = base::UTF8ToUTF16(
+ base::StringPrintf("F%d", key_code_ - VKEY_F1 + 1));
} else {
shortcut = l10n_util::GetStringUTF16(string_id);
+ if (IsShiftDown())
+ shortcut = l10n_util::GetStringFUTF16(IDS_APP_SHIFT_MODIFIER, shortcut);
+ } else if (IsShiftDown()) {
+#if defined(OS_MACOSX)
+ const base::char16 kShiftSymbol[] = {0x21e7, 0};
+ shortcut = kShiftSymbol;
+#else
+ shortcut = l10n_util::GetStringFUTF16(IDS_APP_SHIFT_MODIFIER, shortcut);
#endif
}
// Checking whether the character used for the accelerator is alphanumeric.
@@ -247,15 +253,13 @@ base::string16 Accelerator::GetShortcutText() const {
shortcut_rtl.assign(shortcut);
}
@@ -221,15 +233,12 @@ base::string16 Accelerator::GetShortcutText() const {
base::string16 Accelerator::ApplyLongFormModifiers(
base::string16 shortcut) const {
- if (IsShiftDown())
- shortcut = l10n_util::GetStringFUTF16(IDS_APP_SHIFT_MODIFIER, shortcut);
-
@ -79,8 +82,22 @@ index dd756238a056..878b468311eb 100644
if (IsCtrlDown())
shortcut = l10n_util::GetStringFUTF16(IDS_APP_CONTROL_MODIFIER, shortcut);
- else if (IsAltDown())
+
+ if (IsAltDown())
shortcut = l10n_util::GetStringFUTF16(IDS_APP_ALT_MODIFIER, shortcut);
if (IsCmdDown()) {
@@ -249,14 +258,12 @@ base::string16 Accelerator::ApplyShortFormModifiers(
base::string16 shortcut) const {
const base::char16 kCommandSymbol[] = {0x2318, 0};
const base::char16 kCtrlSymbol[] = {0x2303, 0};
- const base::char16 kShiftSymbol[] = {0x21e7, 0};
const base::char16 kOptionSymbol[] = {0x2325, 0};
const base::char16 kNoSymbol[] = {0};
std::vector<base::string16> parts;
parts.push_back(base::string16(IsCtrlDown() ? kCtrlSymbol : kNoSymbol));
parts.push_back(base::string16(IsAltDown() ? kOptionSymbol : kNoSymbol));
- parts.push_back(base::string16(IsShiftDown() ? kShiftSymbol : kNoSymbol));
parts.push_back(base::string16(IsCmdDown() ? kCommandSymbol : kNoSymbol));
parts.push_back(shortcut);
return base::StrCat(parts);