[webkit-changes] [WebKit/WebKit] 5d29c2: Stop using -_contextMenuInteraction:styleForMenuWi...

Wenson Hsieh noreply at github.com
Fri Sep 29 10:28:34 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5d29c2a7ed7792a2af1fdd9270eb9c86aa89d725
      https://github.com/WebKit/WebKit/commit/5d29c2a7ed7792a2af1fdd9270eb9c86aa89d725
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-09-29 (Fri, 29 Sep 2023)

  Changed paths:
    M Source/WebKit/SourcesCocoa.txt
    A Source/WebKit/UIProcess/ios/CompactContextMenuPresenter.h
    A Source/WebKit/UIProcess/ios/CompactContextMenuPresenter.mm
    M Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm
    M Source/WebKit/UIProcess/mac/WKTextFinderClient.mm
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj

  Log Message:
  -----------
  Stop using -_contextMenuInteraction:styleForMenuWithConfiguration: in WKFileUploadPanel
https://bugs.webkit.org/show_bug.cgi?id=262354

Reviewed by Richard Robinson.

Introduce the `CompactContextMenuPresenter` helper class, which is used to present or dismiss a
UIContextMenu using compact layout; additionally, deploy this helper class in `WKFileUploadPanel` to
eliminate uses of both `-_contextMenuInteraction:styleForMenuWithConfiguration:` and
`_UIContextMenuLayoutCompactMenu`. See below for more details.

* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/ios/CompactContextMenuPresenter.h: Added.
* Source/WebKit/UIProcess/ios/CompactContextMenuPresenter.mm: Added.

Implement a new helper class that encapsulates a hidden and non-interactable `UIButton`, as well as
its corresponding `UIContextMenuInteraction`. This helper class is constructed with a context menu
interaction delegate, to which the helper class forwards delegate method calls; this allows the
delegate to influence the hidden button's compact context menu as if it were its own, but defers the
compact layout to the button itself.

This allows a `CompactContextMenuPresenter` to (functionally) act as a drop-in replacement for an
actual `UIContextMenuInteraction`.

(-[WKCompactContextMenuPresenterButton contextMenuInteraction:configurationForMenuAtLocation:]):
(-[WKCompactContextMenuPresenterButton contextMenuInteraction:configuration:highlightPreviewForItemWithIdentifier:]):
(-[WKCompactContextMenuPresenterButton contextMenuInteraction:willDisplayMenuForConfiguration:animator:]):
(-[WKCompactContextMenuPresenterButton contextMenuInteraction:willEndForConfiguration:animator:]):

Forward delegate calls to the given external context menu delegate if applicable (see
`WKFileUploadPanel` below).

(WebKit::CompactContextMenuPresenter::CompactContextMenuPresenter):
(WebKit::CompactContextMenuPresenter::~CompactContextMenuPresenter):
(WebKit::CompactContextMenuPresenter::present):
(WebKit::CompactContextMenuPresenter::interaction const):
(WebKit::CompactContextMenuPresenter::dismiss):
* Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm:
(-[WKFileUploadPanel dealloc]):

Replace the existing `UIContextMenuInteraction`, `_documentContextMenuInteraction`, with a
`CompactContextMenuPresenter` instead.

* Source/WebKit/UIProcess/mac/WKTextFinderClient.mm:

Unrelated unified source build fix.

* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

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




More information about the webkit-changes mailing list