From 633cec167efbf0b8a4516f00ad495917bde1b8b7 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 22 Oct 2024 19:21:40 +0200 Subject: [PATCH] fix: crash when generating shortcut text for super accelerator (#44346) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: deepak1556 Co-authored-by: Shelley Vohr --- patches/chromium/.patches | 1 + ..._depend_on_packed_resource_integrity.patch | 2 +- ...rtcut_text_for_vkey_command_on_linux.patch | 50 +++++++++++++++++++ spec/api-menu-spec.ts | 14 ++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 patches/chromium/ui_add_missing_shortcut_text_for_vkey_command_on_linux.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index b76c37f09b54..a910f16e6c18 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -132,4 +132,5 @@ build_expose_webplugininfo_interface_to_electron.patch osr_shared_texture_remove_keyed_mutex_on_win_dxgi.patch feat_allow_usage_of_sccontentsharingpicker_on_supported_platforms.patch chore_partial_revert_of.patch +ui_add_missing_shortcut_text_for_vkey_command_on_linux.patch fix_software_compositing_infinite_loop.patch diff --git a/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch b/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch index 044d01966790..ea61b5d0c89b 100644 --- a/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch +++ b/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch @@ -46,7 +46,7 @@ index 246010af5d09afcdd46188c70f74e24fc093a4b6..7b154ad07b3740e6e5f48bc8b5eafec0 # than here in :chrome_dll. deps += [ "//chrome:packed_resources_integrity_header" ] diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn -index f577f0e77c26b246718ad3c792332472ecd04792..93fb0b75912ae1bd862a2f3afb07014d157e0ec2 100644 +index 29029bfcb44f6f6b34ea37b80a611000c3bf3d28..c3c472d62a9d9c3b4b3edd43f6f270fe8b0720b8 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn @@ -6753,9 +6753,12 @@ test("unit_tests") { diff --git a/patches/chromium/ui_add_missing_shortcut_text_for_vkey_command_on_linux.patch b/patches/chromium/ui_add_missing_shortcut_text_for_vkey_command_on_linux.patch new file mode 100644 index 000000000000..6643e78ca56e --- /dev/null +++ b/patches/chromium/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 +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 32a3fc0843656eaa87b85dd63ac1ade6d83b6e5b..ed1ff076b1db6b77d0684bae1931714bf575ebe8 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(); + #endif +diff --git a/ui/base/accelerators/accelerator_unittest.cc b/ui/base/accelerators/accelerator_unittest.cc +index 3b29229c02b0dac7197d3e4bf6014733e0f9669a..cfd9396184e16237cbf49c693af0bd80f8a2ee16 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 bf64f8fbc6d8f6700b40aa0d798dadc67ecc5db6..9307df9b60bcc7bd2a44bb98bc0720901cd8f4a0 100644 +--- a/ui/strings/ui_strings.grd ++++ b/ui/strings/ui_strings.grd +@@ -767,6 +767,11 @@ need to be translated for each locale.--> + Win + + ++ ++ ++ Super ++ ++ + + + Meta diff --git a/spec/api-menu-spec.ts b/spec/api-menu-spec.ts index cc0d1ef35849..e3343e8cf107 100644 --- a/spec/api-menu-spec.ts +++ b/spec/api-menu-spec.ts @@ -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', () => {