- Revision
- 290746
- Author
- [email protected]
- Date
- 2022-03-02 12:18:43 -0800 (Wed, 02 Mar 2022)
Log Message
[iOS] Copy context menu action should be titled "Copy Link" when long pressing a non-image link
https://bugs.webkit.org/show_bug.cgi?id=237367
rdar://77397886
Reviewed by Devin Rousso.
Source/WebCore:
Add a localizable string for "Copy Link". See WebKit/ChangeLog for more details.
* en.lproj/Localizable.strings:
Source/WebKit:
Change the current title of the "Copy" context menu action to "Copy Link", when showing the context menu for a
non-image link. See below for more details.
Tests: fast/events/touch/ios/long-press-on-link.html
fast/events/touch/ios/long-press-on-image.html
* UIProcess/API/Cocoa/_WKActivatedElementInfo.mm:
(-[_WKActivatedElementInfo _initWithInteractionInformationAtPosition:userInfo:]):
(-[_WKActivatedElementInfo _isImage]):
Add a helper method to return whether or not the activated element represents an image. Crucially, this will
return YES in the case of image links, even though the activated element type is _WKActivatedElementTypeLink.
We consult this below to still show "Copy" in the case of image links, instead of "Copy Link".
* UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h:
* UIProcess/API/Cocoa/_WKElementAction.mm:
(+[_WKElementAction _elementActionWithType:customTitle:assistant:]):
(+[_WKElementAction _elementActionWithType:info:assistant:]):
Add a `_WKActivatedElementInfo` argument to `-_elementActionWithType:assistant:`, and use this to set a custom
title for the menu action in the case of the Copy action for non-image links.
(+[_WKElementAction _elementActionWithType:assistant:]): Deleted.
* UIProcess/API/Cocoa/_WKElementActionInternal.h:
* UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant _appendOpenActionsForURL:actions:elementInfo:]):
(-[WKActionSheetAssistant defaultActionsForLinkSheet:]):
(-[WKActionSheetAssistant defaultActionsForImageSheet:]):
Additionally use `-_isImage` instead of `-image` here when supplying several default Visual Look Up-related
items; `-image` is misleading here, since it returns a non-null result even in the case of non-image elements,
if a node snapshot was requested by the client. It's also a bit wasteful, since it means we currently create an
image from the bitmap data while performing this check, when we really only need to know whether the hit-tested
element was an image element.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _simulateElementAction:atLocation:]):
(-[WKContentView _contentsOfUserInterfaceItem:]):
(-[WKContentView _contextMenuInteraction:configurationForMenuAtLocation:completion:]):
Include the titles of all visible menu items as an additional argument in the "contents of user interface item"
dictionary, in the case of context menus. To do this, we take advantage of the `-updateVisibleMenuWithBlock:`
API, which passes the currently visible `UIMenu`, to collect the titles of each visible menu item, and then
simply return the visible menu as-is.
See adjusted layout tests for more information.
(-[WKContentView contextMenuInteraction:willDisplayMenuForConfiguration:animator:]):
Move the call to `-_didShowContextMenu` to the animation completion block, such that we invoke the testing
completion handler for `didShowContextMenuCallback` after the menu is actually visible. Importantly, this allows
us to query the list of visible menu item titles above, by calling `-updateVisibleMenuWithBlock:`.
* UIProcess/mac/DisplayCaptureSessionManager.mm:
(WebKit::alertForWindowSelection):
Drive-by fix: add quotes around the description argument to the UI string macro to fix an error when running
the `update-webkit-localizable-strings` script.
LayoutTests:
Adjust a couple of layout tests to check for items labeled "Copy" (in the case of an image) and "Copy Link" (in
the case of a link).
* fast/events/touch/ios/long-press-on-image-expected.txt:
* fast/events/touch/ios/long-press-on-image.html:
* fast/events/touch/ios/long-press-on-link-expected.txt:
* fast/events/touch/ios/long-press-on-link.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (290745 => 290746)
--- trunk/LayoutTests/ChangeLog 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/LayoutTests/ChangeLog 2022-03-02 20:18:43 UTC (rev 290746)
@@ -1,3 +1,19 @@
+2022-03-02 Wenson Hsieh <[email protected]>
+
+ [iOS] Copy context menu action should be titled "Copy Link" when long pressing a non-image link
+ https://bugs.webkit.org/show_bug.cgi?id=237367
+ rdar://77397886
+
+ Reviewed by Devin Rousso.
+
+ Adjust a couple of layout tests to check for items labeled "Copy" (in the case of an image) and "Copy Link" (in
+ the case of a link).
+
+ * fast/events/touch/ios/long-press-on-image-expected.txt:
+ * fast/events/touch/ios/long-press-on-image.html:
+ * fast/events/touch/ios/long-press-on-link-expected.txt:
+ * fast/events/touch/ios/long-press-on-link.html:
+
2022-03-02 Myles C. Maxfield <[email protected]>
[Cocoa] The behavior of navigator-language-ru changed in Monterey / iOS 15
Modified: trunk/LayoutTests/fast/events/touch/ios/long-press-on-image-expected.txt (290745 => 290746)
--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-image-expected.txt 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-image-expected.txt 2022-03-02 20:18:43 UTC (rev 290746)
@@ -4,6 +4,7 @@
PASS context menu triggered on image
+PASS results.items.includes('Copy') is true
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/events/touch/ios/long-press-on-image.html (290745 => 290746)
--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-image.html 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-image.html 2022-03-02 20:18:43 UTC (rev 290746)
@@ -25,12 +25,14 @@
const targetRect = document.getElementById("target").getBoundingClientRect();
const pressPointX = targetRect.x + targetRect.width / 2;
const pressPointY = targetRect.y + targetRect.height / 2;
- const results = (await UIHelper.longPressAndGetContextMenuContentAt(pressPointX, pressPointY)).contextMenu;
+ results = (await UIHelper.longPressAndGetContextMenuContentAt(pressPointX, pressPointY)).contextMenu;
if (results.imageURL.includes("dice.png") && results.isImage && !results.isLink)
testPassed("context menu triggered on image");
else
testFailed("context menu was not triggered on image");
+ shouldBeTrue("results.items.includes('Copy')");
+
await liftUpAtPoint(pressPointX, pressPointY);
await UIHelper.activateAt(0, 0);
finishJSTest();
Modified: trunk/LayoutTests/fast/events/touch/ios/long-press-on-link-expected.txt (290745 => 290746)
--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-link-expected.txt 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-link-expected.txt 2022-03-02 20:18:43 UTC (rev 290746)
@@ -4,6 +4,7 @@
PASS correct page loaded in preview
+PASS results.items.includes('Copy Link') is true
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/events/touch/ios/long-press-on-link.html (290745 => 290746)
--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-link.html 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-link.html 2022-03-02 20:18:43 UTC (rev 290746)
@@ -25,12 +25,14 @@
const targetRect = document.getElementById("targetRect").getBoundingClientRect();
const pressPointX = targetRect.x + targetRect.width / 2;
const pressPointY = targetRect.y + targetRect.height / 2;
- const results = (await UIHelper.longPressAndGetContextMenuContentAt(pressPointX, pressPointY)).contextMenu;
+ results = (await UIHelper.longPressAndGetContextMenuContentAt(pressPointX, pressPointY)).contextMenu;
if (results.url == "http://localhost:54321/" && results.isLink)
testPassed("correct page loaded in preview");
else
testFailed("did not load correct page");
+ shouldBeTrue("results.items.includes('Copy Link')");
+
await liftUpAtPoint(pressPointX, pressPointY);
await UIHelper.activateAt(0, 0);
finishJSTest();
Modified: trunk/Source/WebCore/ChangeLog (290745 => 290746)
--- trunk/Source/WebCore/ChangeLog 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/Source/WebCore/ChangeLog 2022-03-02 20:18:43 UTC (rev 290746)
@@ -1,3 +1,15 @@
+2022-03-02 Wenson Hsieh <[email protected]>
+
+ [iOS] Copy context menu action should be titled "Copy Link" when long pressing a non-image link
+ https://bugs.webkit.org/show_bug.cgi?id=237367
+ rdar://77397886
+
+ Reviewed by Devin Rousso.
+
+ Add a localizable string for "Copy Link". See WebKit/ChangeLog for more details.
+
+ * en.lproj/Localizable.strings:
+
2022-03-02 Antoine Quint <[email protected]>
[web-animations] setting the composite property on a keyframe effect should invalidate the target style
Modified: trunk/Source/WebCore/en.lproj/Localizable.strings (290745 => 290746)
--- trunk/Source/WebCore/en.lproj/Localizable.strings 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/Source/WebCore/en.lproj/Localizable.strings 2022-03-02 20:18:43 UTC (rev 290746)
@@ -346,6 +346,9 @@
/* Copy Link context menu item */
"Copy Link" = "Copy Link";
+/* Title for Copy Link button */
+"Copy Link (ActionSheet)" = "Copy Link";
+
/* Copy Video Address Location context menu item */
"Copy Video Address" = "Copy Video Address";
Modified: trunk/Source/WebKit/ChangeLog (290745 => 290746)
--- trunk/Source/WebKit/ChangeLog 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/Source/WebKit/ChangeLog 2022-03-02 20:18:43 UTC (rev 290746)
@@ -1,3 +1,70 @@
+2022-03-02 Wenson Hsieh <[email protected]>
+
+ [iOS] Copy context menu action should be titled "Copy Link" when long pressing a non-image link
+ https://bugs.webkit.org/show_bug.cgi?id=237367
+ rdar://77397886
+
+ Reviewed by Devin Rousso.
+
+ Change the current title of the "Copy" context menu action to "Copy Link", when showing the context menu for a
+ non-image link. See below for more details.
+
+ Tests: fast/events/touch/ios/long-press-on-link.html
+ fast/events/touch/ios/long-press-on-image.html
+
+ * UIProcess/API/Cocoa/_WKActivatedElementInfo.mm:
+ (-[_WKActivatedElementInfo _initWithInteractionInformationAtPosition:userInfo:]):
+ (-[_WKActivatedElementInfo _isImage]):
+
+ Add a helper method to return whether or not the activated element represents an image. Crucially, this will
+ return YES in the case of image links, even though the activated element type is _WKActivatedElementTypeLink.
+ We consult this below to still show "Copy" in the case of image links, instead of "Copy Link".
+
+ * UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h:
+ * UIProcess/API/Cocoa/_WKElementAction.mm:
+ (+[_WKElementAction _elementActionWithType:customTitle:assistant:]):
+ (+[_WKElementAction _elementActionWithType:info:assistant:]):
+
+ Add a `_WKActivatedElementInfo` argument to `-_elementActionWithType:assistant:`, and use this to set a custom
+ title for the menu action in the case of the Copy action for non-image links.
+
+ (+[_WKElementAction _elementActionWithType:assistant:]): Deleted.
+ * UIProcess/API/Cocoa/_WKElementActionInternal.h:
+ * UIProcess/ios/WKActionSheetAssistant.mm:
+ (-[WKActionSheetAssistant _appendOpenActionsForURL:actions:elementInfo:]):
+ (-[WKActionSheetAssistant defaultActionsForLinkSheet:]):
+ (-[WKActionSheetAssistant defaultActionsForImageSheet:]):
+
+ Additionally use `-_isImage` instead of `-image` here when supplying several default Visual Look Up-related
+ items; `-image` is misleading here, since it returns a non-null result even in the case of non-image elements,
+ if a node snapshot was requested by the client. It's also a bit wasteful, since it means we currently create an
+ image from the bitmap data while performing this check, when we really only need to know whether the hit-tested
+ element was an image element.
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _simulateElementAction:atLocation:]):
+ (-[WKContentView _contentsOfUserInterfaceItem:]):
+ (-[WKContentView _contextMenuInteraction:configurationForMenuAtLocation:completion:]):
+
+ Include the titles of all visible menu items as an additional argument in the "contents of user interface item"
+ dictionary, in the case of context menus. To do this, we take advantage of the `-updateVisibleMenuWithBlock:`
+ API, which passes the currently visible `UIMenu`, to collect the titles of each visible menu item, and then
+ simply return the visible menu as-is.
+
+ See adjusted layout tests for more information.
+
+ (-[WKContentView contextMenuInteraction:willDisplayMenuForConfiguration:animator:]):
+
+ Move the call to `-_didShowContextMenu` to the animation completion block, such that we invoke the testing
+ completion handler for `didShowContextMenuCallback` after the menu is actually visible. Importantly, this allows
+ us to query the list of visible menu item titles above, by calling `-updateVisibleMenuWithBlock:`.
+
+ * UIProcess/mac/DisplayCaptureSessionManager.mm:
+ (WebKit::alertForWindowSelection):
+
+ Drive-by fix: add quotes around the description argument to the UI string macro to fix an error when running
+ the `update-webkit-localizable-strings` script.
+
2022-03-02 J Pascoe <[email protected]>
[WebAuthn] Ensure presenter gets dismissed on iOS
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKActivatedElementInfo.mm (290745 => 290746)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKActivatedElementInfo.mm 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKActivatedElementInfo.mm 2022-03-02 20:18:43 UTC (rev 290746)
@@ -49,6 +49,7 @@
RetainPtr<NSDictionary> _userInfo;
#endif
BOOL _animatedImage;
+ BOOL _isImage;
}
#if PLATFORM(IOS_FAMILY)
@@ -81,7 +82,7 @@
_image = information.image;
_ID = information.idAttribute;
_animatedImage = information.isAnimatedImage;
-
+ _isImage = information.isImage;
_userInfo = userInfo;
return self;
@@ -156,6 +157,11 @@
}
#endif
+- (BOOL)_isImage
+{
+ return _isImage;
+}
+
- (CocoaImage *)image
{
if (_cocoaImage)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h (290745 => 290746)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h 2022-03-02 20:18:43 UTC (rev 290746)
@@ -45,5 +45,6 @@
@property (nonatomic, readonly) NSString *imageMIMEType;
@property (nonatomic, readonly) WebCore::IntPoint _interactionLocation;
+@property (nonatomic, readonly) BOOL _isImage;
@end
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm (290745 => 290746)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm 2022-03-02 20:18:43 UTC (rev 290746)
@@ -128,7 +128,7 @@
WKElementActionHandlerInternal handler = nil;
switch (type) {
case _WKElementActionTypeCopy:
- title = WEB_UI_STRING_KEY("Copy", "Copy (ActionSheet)", "Title for Copy Link or Image action button");
+ title = WEB_UI_STRING_KEY("Copy", "Copy (ActionSheet)", "Title for Copy Link and Image or Copy Image action button");
handler = ^(WKActionSheetAssistant *assistant, _WKActivatedElementInfo *actionInfo) {
[assistant handleElementActionWithType:type element:actionInfo needsInteraction:YES];
};
@@ -194,9 +194,12 @@
return adoptNS([[self alloc] _initWithTitle:(customTitle ? customTitle : title) actionHandler:handler type:type assistant:assistant]).autorelease();
}
-+ (instancetype)_elementActionWithType:(_WKElementActionType)type assistant:(WKActionSheetAssistant *)assistant
++ (instancetype)_elementActionWithType:(_WKElementActionType)type info:(_WKActivatedElementInfo *)info assistant:(WKActionSheetAssistant *)assistant
{
- return [self _elementActionWithType:type customTitle:nil assistant:assistant];
+ NSString *customTitle = nil;
+ if (type == _WKElementActionTypeCopy && info.type == _WKActivatedElementTypeLink && !info._isImage)
+ customTitle = WEB_UI_STRING_KEY("Copy Link", "Copy Link (ActionSheet)", "Title for Copy Link button");
+ return [self _elementActionWithType:type customTitle:customTitle assistant:assistant];
}
+ (instancetype)elementActionWithType:(_WKElementActionType)type customTitle:(NSString *)customTitle
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementActionInternal.h (290745 => 290746)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementActionInternal.h 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementActionInternal.h 2022-03-02 20:18:43 UTC (rev 290746)
@@ -32,7 +32,7 @@
@interface _WKElementAction ()
-+ (instancetype)_elementActionWithType:(_WKElementActionType)type assistant:(WKActionSheetAssistant *)assistant;
++ (instancetype)_elementActionWithType:(_WKElementActionType)type info:(_WKActivatedElementInfo *)info assistant:(WKActionSheetAssistant *)assistant;
+ (instancetype)_elementActionWithType:(_WKElementActionType)type title:(NSString *)title actionHandler:(WKElementActionHandler)actionHandler;
- (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info forActionSheetAssistant:(WKActionSheetAssistant *)assistant;
Modified: trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm (290745 => 290746)
--- trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm 2022-03-02 20:18:43 UTC (rev 290746)
@@ -525,7 +525,7 @@
return;
#endif
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeOpen assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeOpen info:elementInfo assistant:self]];
}
- (RetainPtr<NSArray<_WKElementAction *>>)defaultActionsForLinkSheet:(_WKActivatedElementInfo *)elementInfo
@@ -539,31 +539,31 @@
#if HAVE(SAFARI_SERVICES_FRAMEWORK)
if ([getSSReadingListClass() supportsURL:targetURL])
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeAddToReadingList assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeAddToReadingList info:elementInfo assistant:self]];
#endif
if ([elementInfo imageURL]) {
if (TCCAccessPreflight(WebKit::get_TCC_kTCCServicePhotos(), NULL) != kTCCAccessPreflightDenied)
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeSaveImage assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeSaveImage info:elementInfo assistant:self]];
}
if (!isJavaScriptURL(targetURL)) {
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeCopy assistant:self]];
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeShare assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeCopy info:elementInfo assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeShare info:elementInfo assistant:self]];
}
- if (elementInfo.type == _WKActivatedElementTypeImage || [elementInfo image]) {
+ if (elementInfo.type == _WKActivatedElementTypeImage || elementInfo._isImage) {
#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
if ([_delegate respondsToSelector:@selector(actionSheetAssistantShouldIncludeCopyCroppedImageAction:)] && [_delegate actionSheetAssistantShouldIncludeCopyCroppedImageAction:self]) {
// FIXME (rdar://88834304): This should be additionally gated on the relevant VisionKit SPI.
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeCopyCroppedImage assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeCopyCroppedImage info:elementInfo assistant:self]];
}
#endif
#if ENABLE(IMAGE_ANALYSIS)
if ([_delegate respondsToSelector:@selector(actionSheetAssistant:shouldIncludeShowTextActionForElement:)] && [_delegate actionSheetAssistant:self shouldIncludeShowTextActionForElement:elementInfo])
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeImageExtraction assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeImageExtraction info:elementInfo assistant:self]];
if ([_delegate respondsToSelector:@selector(actionSheetAssistant:shouldIncludeLookUpImageActionForElement:)] && [_delegate actionSheetAssistant:self shouldIncludeLookUpImageActionForElement:elementInfo])
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeRevealImage assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeRevealImage info:elementInfo assistant:self]];
#endif
}
@@ -577,30 +577,30 @@
auto defaultActions = adoptNS([[NSMutableArray alloc] init]);
if (targetURL) {
[self _appendOpenActionsForURL:targetURL actions:defaultActions.get() elementInfo:elementInfo];
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeShare assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeShare info:elementInfo assistant:self]];
} else if ([elementInfo imageURL])
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeShare assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeShare info:elementInfo assistant:self]];
#if HAVE(SAFARI_SERVICES_FRAMEWORK)
if ([getSSReadingListClass() supportsURL:targetURL])
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeAddToReadingList assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeAddToReadingList info:elementInfo assistant:self]];
#endif
if (TCCAccessPreflight(WebKit::get_TCC_kTCCServicePhotos(), NULL) != kTCCAccessPreflightDenied)
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeSaveImage assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeSaveImage info:elementInfo assistant:self]];
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeCopy assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeCopy info:elementInfo assistant:self]];
#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
if ([_delegate respondsToSelector:@selector(actionSheetAssistantShouldIncludeCopyCroppedImageAction:)] && [_delegate actionSheetAssistantShouldIncludeCopyCroppedImageAction:self]) {
// FIXME (rdar://88834304): This should be additionally gated on the relevant VisionKit SPI.
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeCopyCroppedImage assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeCopyCroppedImage info:elementInfo assistant:self]];
}
#endif
#if ENABLE(IMAGE_ANALYSIS)
if ([_delegate respondsToSelector:@selector(actionSheetAssistant:shouldIncludeShowTextActionForElement:)] && [_delegate actionSheetAssistant:self shouldIncludeShowTextActionForElement:elementInfo])
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeImageExtraction assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeImageExtraction info:elementInfo assistant:self]];
if ([_delegate respondsToSelector:@selector(actionSheetAssistant:shouldIncludeLookUpImageActionForElement:)] && [_delegate actionSheetAssistant:self shouldIncludeLookUpImageActionForElement:elementInfo])
- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeRevealImage assistant:self]];
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeRevealImage info:elementInfo assistant:self]];
#endif
return defaultActions;
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (290745 => 290746)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-03-02 20:18:43 UTC (rev 290746)
@@ -11004,8 +11004,8 @@
{
_layerTreeTransactionIdAtLastInteractionStart = downcast<WebKit::RemoteLayerTreeDrawingAreaProxy>(*_page->drawingArea()).lastCommittedLayerTreeTransactionID();
[self doAfterPositionInformationUpdate:[actionType, self, protectedSelf = retainPtr(self)] (WebKit::InteractionInformationAtPosition info) {
- _WKElementAction *action = "" _elementActionWithType:actionType assistant:_actionSheetAssistant.get()];
_WKActivatedElementInfo *elementInfo = [_WKActivatedElementInfo activatedElementInfoWithInteractionInformationAtPosition:info userInfo:nil];
+ _WKElementAction *action = "" _elementActionWithType:actionType info:elementInfo assistant:_actionSheetAssistant.get()];
[action runActionWithElementInfo:elementInfo];
} forRequest:WebKit::InteractionInformationRequest(WebCore::roundedIntPoint(location))];
}
@@ -11111,12 +11111,19 @@
#if HAVE(LINK_PREVIEW)
if ([userInterfaceItem isEqualToString:@"contextMenu"]) {
+ auto itemTitles = adoptNS([NSMutableArray<NSString *> new]);
+ [_contextMenuInteraction updateVisibleMenuWithBlock:[&itemTitles](UIMenu *menu) -> UIMenu * {
+ for (UIMenuElement *child in menu.children)
+ [itemTitles addObject:child.title];
+ return menu;
+ }];
if (self._shouldUseContextMenus) {
return @{ userInterfaceItem: @{
@"url": _positionInformation.url.isValid() ? WTF::userVisibleString(_positionInformation.url) : @"",
@"isLink": [NSNumber numberWithBool:_positionInformation.isLink],
@"isImage": [NSNumber numberWithBool:_positionInformation.isImage],
- @"imageURL": _positionInformation.imageURL.isValid() ? WTF::userVisibleString(_positionInformation.imageURL) : @""
+ @"imageURL": _positionInformation.imageURL.isValid() ? WTF::userVisibleString(_positionInformation.imageURL) : @"",
+ @"items": itemTitles.get()
} };
}
NSString *url = "" previewData][UIPreviewDataLink];
@@ -11124,7 +11131,8 @@
@"url": url,
@"isLink": [NSNumber numberWithBool:_positionInformation.isLink],
@"isImage": [NSNumber numberWithBool:_positionInformation.isImage],
- @"imageURL": _positionInformation.imageURL.isValid() ? WTF::userVisibleString(_positionInformation.imageURL) : @""
+ @"imageURL": _positionInformation.imageURL.isValid() ? WTF::userVisibleString(_positionInformation.imageURL) : @"",
+ @"items": itemTitles.get()
} };
}
#endif
@@ -11452,8 +11460,6 @@
return;
}
- [strongSelf->_webView _didShowContextMenu];
-
strongSelf->_showLinkPreviews = true;
if (NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:webkitShowLinkPreviewsPreferenceKey])
strongSelf->_showLinkPreviews = value.boolValue;
@@ -11723,6 +11729,7 @@
if (auto strongSelf = weakSelf.get()) {
ASSERT_IMPLIES(strongSelf->_isDisplayingContextMenuWithAnimation, [strongSelf->_contextMenuHintContainerView window]);
strongSelf->_isDisplayingContextMenuWithAnimation = NO;
+ [strongSelf->_webView _didShowContextMenu];
}
}];
Modified: trunk/Source/WebKit/UIProcess/mac/DisplayCaptureSessionManager.mm (290745 => 290746)
--- trunk/Source/WebKit/UIProcess/mac/DisplayCaptureSessionManager.mm 2022-03-02 19:58:26 UTC (rev 290745)
+++ trunk/Source/WebKit/UIProcess/mac/DisplayCaptureSessionManager.mm 2022-03-02 20:18:43 UTC (rev 290746)
@@ -74,7 +74,7 @@
});
auto alert = adoptNS([[NSAlert alloc] init]);
- [alert setMessageText:WEB_UI_NSSTRING(@"Choose a window to share", Message for window sharing prompt)];
+ [alert setMessageText:WEB_UI_NSSTRING(@"Choose a window to share", "Message for window sharing prompt")];
auto popupButton = adoptNS([[NSPopUpButton alloc] initWithFrame:NSMakeRect(10, 0, 290, 36) pullsDown:NO]);
auto menu = [popupButton menu];