fix: crash when generating shortcut text for super accelerator (32-x-y) (#44623)

* fix: crash when generating shortcut text for super accelerator (#44341)

* chore: update patch

---------

Co-authored-by: Robo <hop2deep@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
Basit 2024-11-15 20:11:29 +01:00 коммит произвёл GitHub
Родитель a85c2d1c1e
Коммит a6a0c4cb6d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 65 добавлений и 0 удалений

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

@ -140,3 +140,4 @@ editcontext_use_empty_control_and_selection_bounds_as_fallbacks.patch
editcontext_return_physical_pixels_from_firstrectforcharacterrange.patch
cherry-pick-923797bac925.patch
cherry-pick-e699ac35ac6c.patch
ui_add_missing_shortcut_text_for_vkey_command_on_linux.patch

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

@ -0,0 +1,50 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Tue, 22 Oct 2024 00:27:27 +0900
Subject: Add missing shortcut text for VKEY_COMMAND on linux
Backports https://chromium-review.googlesource.com/c/chromium/src/+/5947724
diff --git a/ui/base/accelerators/accelerator.cc b/ui/base/accelerators/accelerator.cc
index d9445b90dba8f5d7372cd49ae92c2d28f719f288..1109829fed37d60405dae63d1461d44fffdc87f4 100644
--- a/ui/base/accelerators/accelerator.cc
+++ b/ui/base/accelerators/accelerator.cc
@@ -419,6 +419,8 @@ std::u16string Accelerator::ApplyLongFormModifiers(
result = ApplyModifierToAcceleratorString(result, IDS_APP_SEARCH_KEY);
#elif BUILDFLAG(IS_WIN)
result = ApplyModifierToAcceleratorString(result, IDS_APP_WINDOWS_KEY);
+#elif BUILDFLAG(IS_LINUX)
+ result = ApplyModifierToAcceleratorString(result, IDS_APP_SUPER_KEY);
#else
NOTREACHED_IN_MIGRATION();
#endif
diff --git a/ui/base/accelerators/accelerator_unittest.cc b/ui/base/accelerators/accelerator_unittest.cc
index 246cfe906786c1586e15acbae063a77cb5cc84e7..7627da94c48473870b127b57edad2a2845d76d4c 100644
--- a/ui/base/accelerators/accelerator_unittest.cc
+++ b/ui/base/accelerators/accelerator_unittest.cc
@@ -58,6 +58,9 @@ TEST(AcceleratorTest, MAYBE_GetShortcutText) {
{VKEY_OEM_COMMA, EF_CONTROL_DOWN, u"Ctrl+Comma", u"⌃,"},
#if BUILDFLAG(IS_MAC)
{VKEY_T, EF_COMMAND_DOWN | EF_CONTROL_DOWN, nullptr, u"⌃⌘T"},
+#endif
+#if BUILDFLAG(IS_LINUX)
+ {VKEY_T, EF_COMMAND_DOWN | EF_CONTROL_DOWN, u"Super+Ctrl+T", nullptr},
#endif
};
diff --git a/ui/strings/ui_strings.grd b/ui/strings/ui_strings.grd
index 5e1689755ac4976998a2c36bef04b522811d4b30..33a6f39d23b7a095f422a0e4e01f36a447a9a851 100644
--- a/ui/strings/ui_strings.grd
+++ b/ui/strings/ui_strings.grd
@@ -764,6 +764,11 @@ need to be translated for each locale.-->
Win
</message>
</if>
+ <if expr="is_linux">
+ <message name="IDS_APP_SUPER_KEY" desc="Windows key on Windows keyboards, and Command key on Mac keyboards.">
+ Super
+ </message>
+ </if>
<if expr="chromeos_ash">
<message name="IDS_APP_META_KEY" desc="External Meta key (Search key on ChromeOS keyboards, Windows key on Windows keyboards, and Command key on Mac keyboards)">
Meta

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

@ -926,6 +926,20 @@ describe('Menu module', function () {
});
w.show();
});
it('does not crash when rendering menu item with Super or meta accelerator', async () => {
const menu = Menu.buildFromTemplate([{
label: 'Test Super',
accelerator: 'Super+Ctrl+T'
}, {
label: 'Test Meta',
accelerator: 'Meta+Ctrl+T'
}]);
const menuWillClose = once(menu, 'menu-will-close');
menu.popup({ window: w });
menu.closePopup();
await menuWillClose;
});
});
describe('Menu.setApplicationMenu', () => {