d6c8ff2e70
* chore: bump chromium in DEPS to 119.0.6021.0 * 4727729: Initial ScreenCaptureKit AudioInputStream implementation https://chromium-review.googlesource.com/c/chromium/src/+/4727729 * chore: fixup patch indices * chore: bump chromium in DEPS to 119.0.6023.0 * 4875713: mac: Switch to Xcode 15.0 15A240d with macOS SDK 14.0 23A334 https://chromium-review.googlesource.com/c/chromium/src/+/4875713 * 4831380: [task-attribution] Reland: Move to an implicit GCed task container model https://chromium-review.googlesource.com/c/chromium/src/+/4831380 * 4877868: Remove all gitignore entries for submodules https://chromium-review.googlesource.com/c/chromium/src/+/4877868 * 4824705: Set origin to commit for data: URLs https://chromium-review.googlesource.com/c/chromium/src/+/4824705 * chore: fixup patch indices * 4881382: Expose selection in WebFormControlElement as unsigned https://chromium-review.googlesource.com/c/chromium/src/+/4881382 * 4874216: Portals: Cancel drag-drop in predecessor before activation https://chromium-review.googlesource.com/c/chromium/src/+/4874216 * chore: bump chromium in DEPS to 119.0.6025.0 * chore: bump chromium in DEPS to 119.0.6027.0 * 4884489: Update gitignore to be explicit about directories https://chromium-review.googlesource.com/c/chromium/src/+/4884489 * 4881091: Add debug info about owner document's origin when inheriting https://chromium-review.googlesource.com/c/chromium/src/+/4881091 * chore: fixup patch indices * chore: bump chromium in DEPS to 119.0.6029.0 * chore: update patches * 4881091: Add debug info about owner document's origin when inheriting Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4881091 * 4831380: [task-attribution] Reland: Move to an implicit GCed task container model Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4831380 * 4866732: Extract document.title for installable checks Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4866732 * chore: link to crbug in message port test --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>
85 lines
3.3 KiB
Diff
85 lines
3.3 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: fix: improve shortcut text of Accelerator
|
|
|
|
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-= and Ctrl-Plus show up as such
|
|
|
|
diff --git a/ui/base/accelerators/accelerator.cc b/ui/base/accelerators/accelerator.cc
|
|
index c33829d85745e595e3da8d9913f6e75b05e6c4a9..fa6fe3626b7c5f2b8e8ba9302780650952ecfa47 100644
|
|
--- a/ui/base/accelerators/accelerator.cc
|
|
+++ b/ui/base/accelerators/accelerator.cc
|
|
@@ -11,6 +11,7 @@
|
|
#include "base/i18n/rtl.h"
|
|
#include "base/notreached.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 "build/chromeos_buildflags.h"
|
|
@@ -175,6 +176,11 @@ std::u16string Accelerator::GetShortcutText() const {
|
|
#endif
|
|
|
|
if (shortcut.empty()) {
|
|
+ // When a shifted char is explicitly specified, for example Ctrl+Plus,
|
|
+ // use the shifted char directly.
|
|
+ if (shifted_char) {
|
|
+ shortcut += *shifted_char;
|
|
+ } else {
|
|
#if BUILDFLAG(IS_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
|
|
@@ -198,6 +204,10 @@ std::u16string Accelerator::GetShortcutText() const {
|
|
shortcut +=
|
|
static_cast<std::u16string::value_type>(base::ToUpperASCII(c));
|
|
#endif
|
|
+ }
|
|
+ if (key_code_ > VKEY_F1 && key_code_ <= VKEY_F24)
|
|
+ shortcut = base::UTF8ToUTF16(
|
|
+ base::StringPrintf("F%d", key_code_ - VKEY_F1 + 1));
|
|
}
|
|
|
|
#if BUILDFLAG(IS_MAC)
|
|
@@ -382,7 +392,7 @@ std::u16string Accelerator::ApplyLongFormModifiers(
|
|
const std::u16string& shortcut) const {
|
|
std::u16string result = shortcut;
|
|
|
|
- if (IsShiftDown())
|
|
+ if (!shifted_char && IsShiftDown())
|
|
result = ApplyModifierToAcceleratorString(result, IDS_APP_SHIFT_KEY);
|
|
|
|
// Note that we use 'else-if' in order to avoid using Ctrl+Alt as a shortcut.
|
|
@@ -390,7 +400,7 @@ std::u16string Accelerator::ApplyLongFormModifiers(
|
|
// more information.
|
|
if (IsCtrlDown())
|
|
result = ApplyModifierToAcceleratorString(result, IDS_APP_CTRL_KEY);
|
|
- else if (IsAltDown())
|
|
+ if (IsAltDown())
|
|
result = ApplyModifierToAcceleratorString(result, IDS_APP_ALT_KEY);
|
|
|
|
if (IsCmdDown()) {
|
|
diff --git a/ui/base/accelerators/accelerator.h b/ui/base/accelerators/accelerator.h
|
|
index d5fe7062b4d7932782a0b46371f316f8bf9b499d..adfc3b796379c65bd3406374a44b169560ca8795 100644
|
|
--- a/ui/base/accelerators/accelerator.h
|
|
+++ b/ui/base/accelerators/accelerator.h
|
|
@@ -16,6 +16,7 @@
|
|
#include <utility>
|
|
|
|
#include "base/component_export.h"
|
|
+#include "third_party/abseil-cpp/absl/types/optional.h"
|
|
#include "base/time/time.h"
|
|
#include "build/build_config.h"
|
|
#include "ui/events/event_constants.h"
|
|
@@ -130,6 +131,8 @@ class COMPONENT_EXPORT(UI_BASE) Accelerator {
|
|
return interrupted_by_mouse_event_;
|
|
}
|
|
|
|
+ absl::optional<char16_t> shifted_char;
|
|
+
|
|
private:
|
|
friend class AcceleratorTestMac;
|
|
std::u16string ApplyLongFormModifiers(const std::u16string& shortcut) const;
|