[webkit-changes] [WebKit/WebKit] 8c025b: REGRESSION (268616 at main): No context menu preview ...

Wenson Hsieh noreply at github.com
Thu Dec 14 16:32:49 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8c025b25b577af2f5489f1af12efa8da92eb5eb7
      https://github.com/WebKit/WebKit/commit/8c025b25b577af2f5489f1af12efa8da92eb5eb7
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-12-14 (Thu, 14 Dec 2023)

  Changed paths:
    A LayoutTests/fast/events/touch/ios/long-press-on-link-in-ephemeral-session-expected.txt
    A LayoutTests/fast/events/touch/ios/long-press-on-link-in-ephemeral-session.html
    M LayoutTests/resources/ui-helper.js
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
    M Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
    M Tools/WebKitTestRunner/TestController.h
    M Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

  Log Message:
  -----------
  REGRESSION (268616 at main): No context menu preview appears for data detected links in Notes
https://bugs.webkit.org/show_bug.cgi?id=266431
rdar://119524150

Reviewed by Megan Gardner.

Make a couple of minor adjustments to fix context menu previews for data detected links in HTML
Notes, after the changes in 268616 at main. See below for more details.

Test: fast/events/touch/ios/long-press-on-link-in-ephemeral-session.html

* LayoutTests/fast/events/touch/ios/long-press-on-link-in-ephemeral-session-expected.txt: Added.
* LayoutTests/fast/events/touch/ios/long-press-on-link-in-ephemeral-session.html: Added.

Add a layout test to cover the changes in 264553 at main, as well as the changes in this bug, by
verifying that in an ephemeral browsing session:

1. The context menu preview for an app store link is not full height (where "full height" is just
   represented by an arbitrary height cutoff of the preview platter view).
2. The context menu preview for a regular HTTP link is full height.

* LayoutTests/resources/ui-helper.js:
(window.UIHelper.contextMenuPreviewRect):
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView dataDetectionContextForPositionInformation:]):

Limit the logic to avoid showing previews in ephemeral browsing (or when advanced privacy is
enabled) to iTunes Store links only. This data detectors codepath is the default way to preview
links for `WKWebView` clients that don't otherwise provide a custom menu configuration (e.g.
Safari). As such, the changes in 268616 at main actually caused links in ephemeral browsing sessions
outside of Safari to lose their previews. This patch restores the iTunes Store check to bring back
shipping behavior.

(-[WKContentView _createTargetedContextMenuHintPreviewIfPossible]):

After we stopped using `UIContextMenuStyle` to show a compact menu for data-detected links, the
preview is now shown with a transparent background in Notes, since Notes makes their web view
transparent, such that the estimated background color is transparent black. This looks really ugly
on iOS in the context of the preview platter's background, since the text in the text indicator is
barely legible in light mode, on top of the backdrop filter.

To mitigate this, fall back to `+[UIColor systemBackgroundColor]` instead of transparent black for
text indicator previews, in the case where the estimated background color for the text indicator is
transparent black.

* Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::contextMenuPreviewRect const):
* Tools/WebKitTestRunner/TestController.h:
* Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(swizzledAppStoreURL):
(WTR::TestController::cocoaPlatformInitialize):

Swizzle out `-[NSURL iTunesStoreURL]` to:
1. Make it work on iOS simulator, in the same way as it does on device (for the link in the new test).
2. Make it work in a consistent manner, to ensure stability when testing.

* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h:
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::contextMenuPreviewRect const):

Add a new testing helper to retrieve the bounds of the context menu preview platter.

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




More information about the webkit-changes mailing list