Skip to content

Commit

Permalink
Cherry-pick 6196748. rdar://123455683
Browse files Browse the repository at this point in the history
    Add more fallback logic for the name of a browser action keyboard shortcut
    https://bugs.webkit.org/show_bug.cgi?id=269997
    rdar://123455683

    Reviewed by Timothy Hatcher.

    This change:
    1) Makes it so we don't crash if a command has an empty name or description
    2) Falls back to the display name for _execute_browser_action if no action title is specified

    * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm:
    (WebKit::WebExtension::populateCommandsIfNeeded):
    * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCommandCocoa.mm:
    (+[_WKWebExtensionKeyCommand commandWithTitle:image:input:modifierFlags:handler:]):

    Canonical link: https://commits.webkit.org/275248@main

Identifier: 273664.1314@safari-7619.1.5-branch
  • Loading branch information
b-weinstein authored and MyahCobbs committed Feb 26, 2024
1 parent 6339c0d commit 3ce8b56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1615,8 +1615,11 @@ static bool parseCommandShortcut(const String& shortcut, OptionSet<ModifierFlags
continue;
}

if (isActionCommand && !description.length)
if (isActionCommand && !description.length) {
description = displayActionLabel();
if (!description.length)
description = displayShortName();
}

commandData.description = description;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ @implementation _WKWebExtensionKeyCommand

+ (instancetype)commandWithTitle:(NSString *)title image:(UIImage *)image input:(NSString *)input modifierFlags:(UIKeyModifierFlags)modifierFlags handler:(WebExtensionKeyCommandHandlerBlock)handler
{
RELEASE_ASSERT(title.length);
RELEASE_ASSERT(input.length);
RELEASE_ASSERT(title);
RELEASE_ASSERT(input);
RELEASE_ASSERT(handler);

auto *propertyList = @{
Expand Down

0 comments on commit 3ce8b56

Please sign in to comment.