[webkit-changes] [WebKit/WebKit] fdb385: Need a method to take a UIKeyCommand and return wh...

eddydas noreply at github.com
Fri May 10 11:54:07 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: fdb3855c7cd3ac3bba2c68998b92948e4fb3be9d
      https://github.com/WebKit/WebKit/commit/fdb3855c7cd3ac3bba2c68998b92948e4fb3be9d
  Author: Eddy Wong <eddy_wong at apple.com>
  Date:   2024-05-10 (Fri, 10 May 2024)

  Changed paths:
    M Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionContext.h
    M Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionContext.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCommandCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtensionCommand.h
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h

  Log Message:
  -----------
  Need a method to take a UIKeyCommand and return whether any Web Extension command matches
https://bugs.webkit.org/show_bug.cgi?id=273920
rdar://127787491 (Need a method to take a UIKeyCommand and return whether any Web Extension command matches (273920))

Reviewed by Brian Weinstein.

Introduces a couple of convenience methods that triggers the applicable
WebExtensionCommand based on a given UIKeyCommand.

This pattern is done for AppKit already, but lacks the UIKit counterpart.

This is needed because the existing _WKWebExtensionKeyCommand.handler is
never called because _WKWebExtensionKeyCommand itself will never be in the
responder chain. Therefore the app needs to pass the received UIKeyCommand
object back to the extensions stack for handling. The new methods in this patch
enables such handling.

* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionContext.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionContext.mm:
(-[_WKWebExtensionContext performCommandForKeyCommand:]):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCommandCocoa.mm:
(+[_WKWebExtensionKeyCommand commandWithTitle:image:input:modifierFlags:identifier:]):
(-[_WKWebExtensionKeyCommand performWebExtensionCommandForKeyCommand:]):
(WebKit::WebExtensionCommand::keyCommand const):

(WebKit::WebExtensionCommand::matchesKeyCommand const):
Ideally WebExtensionCommand should have a globally unique identity that can
be propagated into UIKeyCommand.propertyList. But there isn't such identity
right now. Let's just check for the input, modifierKeys, and the dev-provided command identifier for now.

(+[_WKWebExtensionKeyCommand commandWithTitle:image:input:modifierFlags:handler:]): Deleted.
UIKeyCommand isn't really meant to be subclassed. This subclass exists today
just to attach a _handler to the UIKeyCommand object. But when the key is
pressed, the UIKeyCommand object we will receive is actually another object
created by the system. So this _handler is actually never called.
So, let's vend the base class UIKeyCommand instead.
_WKWebExtensionKeyCommand still exists after this patch just to provide a
namespace for the designated selector -performWebExtensionCommandForKeyCommand:
to live somewhere reasonable.

(-[_WKWebExtensionKeyCommand copyWithZone:]): Deleted.
(-[_WKWebExtensionKeyCommand performWithSender:target:]): Deleted.
(-[_WKWebExtensionKeyCommand _resolvedTargetFromFirstTarget:sender:]): Deleted.
(-[_WKWebExtensionKeyCommand _performWithTarget:]): Deleted.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::command):
(WebKit::WebExtensionContext::performCommand):
* Source/WebKit/UIProcess/Extensions/WebExtensionCommand.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list