WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-219524-20201203200211.patch (text/plain), 8.67 KB, created by
Devin Rousso
on 2020-12-03 19:02:11 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2020-12-03 19:02:11 PST
Size:
8.67 KB
patch
obsolete
>diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 386118857e6e263fca3bea1079655998e6146f67..d3958ece43f7cc79897626785b41318c8abb4497 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,28 @@ >+2020-12-03 Devin Rousso <drousso@apple.com> >+ >+ [iOS] Provide a context menu action to perform accessibility image extraction >+ https://bugs.webkit.org/show_bug.cgi?id=219524 >+ <rdar://problem/69969613> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * UIProcess/API/Cocoa/_WKElementAction.h: >+ * UIProcess/API/Cocoa/_WKElementAction.mm: >+ (+[_WKElementAction _elementActionWithType:customTitle:assistant:]): >+ (+[_WKElementAction imageForElementActionType:]): >+ (elementActionTypeToUIActionIdentifier): >+ (uiActionIdentifierToElementActionType): >+ Add a new `_WKElementActionTypeImageExtraction` enum type with a default icon and title. >+ >+ * UIProcess/ios/WKActionSheetAssistant.h: >+ * UIProcess/ios/WKActionSheetAssistant.mm: >+ (-[WKActionSheetAssistant defaultActionsForLinkSheet:]): >+ (-[WKActionSheetAssistant defaultActionsForImageSheet:]): >+ (-[WKActionSheetAssistant handleElementActionWithType:element:needsInteraction:]): >+ If the `WKActionSheetAssistantDelegate` allows it, add a `_WKElementActionTypeImageExtraction` >+ action for images (including those inside links). Call out to the `WKActionSheetAssistantDelegate` >+ when handling the action. >+ > 2020-12-02 Wenson Hsieh <wenson_hsieh@apple.com> > > Unreviewed, fix the iOS build after r270362 >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.h b/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.h >index 38af8decedf69f921ac760710960ec903a80df8f..d17b3dda623849f005d86abe8afcb914f9c81927 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.h >@@ -54,6 +54,7 @@ typedef NS_ENUM(NSInteger, _WKElementActionType) { > _WKElementActionTypeOpenInNewWindow WK_API_AVAILABLE(macos(10.15), ios(13.0)), > _WKElementActionTypeDownload WK_API_AVAILABLE(macos(10.15), ios(13.0)), > _WKElementActionToggleShowLinkPreviews WK_API_AVAILABLE(macos(10.15), ios(13.0)), >+ _WKElementActionTypeImageExtraction WK_API_AVAILABLE(ios(WK_IOS_TBA)), > } WK_API_AVAILABLE(macos(10.10), ios(8.0)); > > WK_CLASS_AVAILABLE(macos(10.10), ios(8.0)) >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm >index b44e7a0d73d9d14315f7f1c4dba97d44fd5b9a30..1966222c2402812751c27ba9322cc9cf180c7f9d 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm >@@ -61,6 +61,7 @@ static UIActionIdentifier const WKElementActionTypeOpenInNewTabIdentifier = @"WK > static UIActionIdentifier const WKElementActionTypeOpenInNewWindowIdentifier = @"WKElementActionTypeOpenInNewWindow"; > static UIActionIdentifier const WKElementActionTypeDownloadIdentifier = @"WKElementActionTypeDownload"; > UIActionIdentifier const WKElementActionTypeToggleShowLinkPreviewsIdentifier = @"WKElementActionTypeToggleShowLinkPreviews"; >+static UIActionIdentifier const WKElementActionTypeImageExtractionIdentifier = @"WKElementActionTypeImageExtraction"; > > static NSString * const webkitShowLinkPreviewsPreferenceKey = @"WebKitShowLinkPreviews"; > static NSString * const webkitShowLinkPreviewsPreferenceChangedNotification = @"WebKitShowLinkPreviewsPreferenceChanged"; >@@ -159,6 +160,14 @@ + (instancetype)_elementActionWithType:(_WKElementActionType)type customTitle:(N > case _WKElementActionToggleShowLinkPreviews: > // This action must still exist for compatibility, but doesn't do anything. > break; >+ case _WKElementActionTypeImageExtraction: >+#if ENABLE(IMAGE_EXTRACTION) >+ title = WebCore::localizedNSString(@"Get Info"); >+ handler = ^(WKActionSheetAssistant *assistant, _WKActivatedElementInfo *actionInfo) { >+ [assistant handleElementActionWithType:type element:actionInfo needsInteraction:YES]; >+ }; >+#endif >+ break; > default: > [NSException raise:NSInvalidArgumentException format:@"There is no standard web element action of type %ld.", (long)type]; > return nil; >@@ -225,6 +234,8 @@ + (UIImage *)imageForElementActionType:(_WKElementActionType)actionType > return [UIImage systemImageNamed:@"arrow.down.circle"]; > case _WKElementActionToggleShowLinkPreviews: > return nil; // Intentionally empty. >+ case _WKElementActionTypeImageExtraction: >+ return [UIImage systemImageNamed:@"info.circle"]; > } > } > >@@ -255,6 +266,8 @@ static UIActionIdentifier elementActionTypeToUIActionIdentifier(_WKElementAction > return WKElementActionTypeDownloadIdentifier; > case _WKElementActionToggleShowLinkPreviews: > return WKElementActionTypeToggleShowLinkPreviewsIdentifier; >+ case _WKElementActionTypeImageExtraction: >+ return WKElementActionTypeImageExtractionIdentifier; > } > } > >@@ -284,7 +297,8 @@ static _WKElementActionType uiActionIdentifierToElementActionType(UIActionIdenti > return _WKElementActionTypeDownload; > if ([identifier isEqualToString:WKElementActionTypeToggleShowLinkPreviewsIdentifier]) > return _WKElementActionToggleShowLinkPreviews; >- >+ if ([identifier isEqualToString:WKElementActionTypeImageExtractionIdentifier]) >+ return _WKElementActionTypeImageExtraction; > return _WKElementActionTypeCustom; > } > >diff --git a/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h b/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h >index 848b60f57e9c9f2bb918cffd3d8e72c32586deb8..29ccac7775aeda90952844e84c281fb7cc5cf6bd 100644 >--- a/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h >+++ b/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h >@@ -71,6 +71,10 @@ typedef NS_ENUM(NSInteger, _WKElementActionType); > - (void)removeContextMenuViewIfPossibleForActionSheetAssistant:(WKActionSheetAssistant *)assistant; > #endif > - (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant shareElementWithImage:(UIImage *)image rect:(CGRect)boundingRect; >+#if ENABLE(IMAGE_EXTRACTION) >+- (BOOL)actionSheetAssistant:(WKActionSheetAssistant *)assistant shouldIncludeImageExtractionActionForElement:(_WKActivatedElementInfo *)element; >+- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant imageExtraction:(UIImage *)image; >+#endif > > @end > >diff --git a/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm b/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm >index 397d9cc59f30e387d63e470a3f910e536a687015..f22b8faa7a4d95870e7f37d14e0cf77ba8a7d197 100644 >--- a/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm >+++ b/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm >@@ -563,6 +563,13 @@ - (RetainPtr<NSArray<_WKElementAction *>>)defaultActionsForLinkSheet:(_WKActivat > [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeShare assistant:self]]; > } > >+#if ENABLE(IMAGE_EXTRACTION) >+ if (elementInfo.type == _WKActivatedElementTypeImage || [elementInfo image]) { >+ if ([_delegate respondsToSelector:@selector(actionSheetAssistant:shouldIncludeImageExtractionActionForElement:)] && [_delegate actionSheetAssistant:self shouldIncludeImageExtractionActionForElement:elementInfo]) >+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeImageExtraction assistant:self]]; >+ } >+#endif >+ > return defaultActions; > } > >@@ -586,6 +593,11 @@ - (RetainPtr<NSArray<_WKElementAction *>>)defaultActionsForImageSheet:(_WKActiva > if (!targetURL.scheme.length || [targetURL.scheme caseInsensitiveCompare:@"javascript"] != NSOrderedSame) > [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeCopy assistant:self]]; > >+#if ENABLE(IMAGE_EXTRACTION) >+ if ([_delegate respondsToSelector:@selector(actionSheetAssistant:shouldIncludeImageExtractionActionForElement:)] && [_delegate actionSheetAssistant:self shouldIncludeImageExtractionActionForElement:elementInfo]) >+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeImageExtraction assistant:self]]; >+#endif >+ > return defaultActions; > } > >@@ -835,6 +847,11 @@ - (void)handleElementActionWithType:(_WKElementActionType)type element:(_WKActiv > else > [delegate actionSheetAssistant:self shareElementWithURL:element.URL ?: element.imageURL rect:element.boundingRect]; > break; >+ case _WKElementActionTypeImageExtraction: >+#if ENABLE(IMAGE_EXTRACTION) >+ [delegate actionSheetAssistant:self imageExtraction:element.image]; >+#endif >+ break; > default: > ASSERT_NOT_REACHED(); > break;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 219524
:
415375
|
415426