Title: [203809] trunk/Source/WebKit2
- Revision
- 203809
- Author
- [email protected]
- Date
- 2016-07-27 18:59:13 -0700 (Wed, 27 Jul 2016)
Log Message
[iOS] Add WKUIDelegate SPI for specifying that an attachment list is from a managed source
https://bugs.webkit.org/show_bug.cgi?id=160280
<rdar://problem/27471815>
Reviewed by Dan Bernstein.
* Platform/spi/ios/UIKitSPI.h: Declared
UIPreviewItemTypeAttachment, UIPreviewDataAttachmentList, and UIPreviewDataAttachmentIndex.
* UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Declared -_attachmentListForWebView:sourceIsManaged:.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _dataForPreviewItemController:atPosition:type:]): Used UIPreviewItemTypeAttachment,
UIPreviewDataAttachmentList, and UIPreviewDataAttachmentIndex. If uiDelegate responds to
-_attachmentListForWebView:sourceIsManaged:, called it instead of -_attachmentListForWebView:.
Set sourceIsManaged as the value for the UIPreviewDataAttachmentListSourceIsManaged key in dataForPreview.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (203808 => 203809)
--- trunk/Source/WebKit2/ChangeLog 2016-07-28 01:36:44 UTC (rev 203808)
+++ trunk/Source/WebKit2/ChangeLog 2016-07-28 01:59:13 UTC (rev 203809)
@@ -1,3 +1,20 @@
+2016-07-27 Andy Estes <[email protected]>
+
+ [iOS] Add WKUIDelegate SPI for specifying that an attachment list is from a managed source
+ https://bugs.webkit.org/show_bug.cgi?id=160280
+ <rdar://problem/27471815>
+
+ Reviewed by Dan Bernstein.
+
+ * Platform/spi/ios/UIKitSPI.h: Declared
+ UIPreviewItemTypeAttachment, UIPreviewDataAttachmentList, and UIPreviewDataAttachmentIndex.
+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Declared -_attachmentListForWebView:sourceIsManaged:.
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _dataForPreviewItemController:atPosition:type:]): Used UIPreviewItemTypeAttachment,
+ UIPreviewDataAttachmentList, and UIPreviewDataAttachmentIndex. If uiDelegate responds to
+ -_attachmentListForWebView:sourceIsManaged:, called it instead of -_attachmentListForWebView:.
+ Set sourceIsManaged as the value for the UIPreviewDataAttachmentListSourceIsManaged key in dataForPreview.
+
2016-07-27 Chelsea Pugh <[email protected]>
[iOS] Remove unused textContentType SPI from _WKFormInputSession
Modified: trunk/Source/WebKit2/Platform/spi/ios/UIKitSPI.h (203808 => 203809)
--- trunk/Source/WebKit2/Platform/spi/ios/UIKitSPI.h 2016-07-28 01:36:44 UTC (rev 203808)
+++ trunk/Source/WebKit2/Platform/spi/ios/UIKitSPI.h 2016-07-28 01:59:13 UTC (rev 203809)
@@ -88,6 +88,7 @@
UIPreviewItemTypeLink,
UIPreviewItemTypeImage,
UIPreviewItemTypeText,
+ UIPreviewItemTypeAttachment,
};
@class UIPreviewItemController;
@@ -853,4 +854,9 @@
extern const NSString *UIPreviewDataDDResult;
extern const NSString *UIPreviewDataDDContext;
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
+extern const NSString *UIPreviewDataAttachmentList;
+extern const NSString *UIPreviewDataAttachmentIndex;
+#endif
+
WTF_EXTERN_C_END
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (203808 => 203809)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2016-07-28 01:36:44 UTC (rev 203808)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2016-07-28 01:59:13 UTC (rev 203809)
@@ -72,6 +72,7 @@
- (BOOL)_webView:(WKWebView *)webView showCustomSheetForElement:(_WKActivatedElementInfo *)element WK_API_AVAILABLE(ios(WK_IOS_TBA));
- (void)_webView:(WKWebView *)webView alternateActionForURL:(NSURL *)url WK_API_AVAILABLE(ios(WK_IOS_TBA));
- (NSArray *)_attachmentListForWebView:(WKWebView *)webView WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (NSArray *)_attachmentListForWebView:(WKWebView *)webView sourceIsManaged:(BOOL*)sourceIsManaged WK_API_AVAILABLE(ios(WK_IOS_TBA));
- (NSUInteger)_webView:(WKWebView *)webView indexIntoAttachmentListForElement:(_WKActivatedElementInfo *)element WK_API_AVAILABLE(ios(WK_IOS_TBA));
- (UIEdgeInsets)_webView:(WKWebView *)webView finalObscuredInsetsForScrollView:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset WK_API_AVAILABLE(ios(9_0));
- (UIViewController *)_webView:(WKWebView *)webView previewViewControllerForURL:(NSURL *)url defaultActions:(NSArray<_WKElementAction *> *)actions elementInfo:(_WKActivatedElementInfo *)elementInfo WK_API_AVAILABLE(ios(9_0));
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (203808 => 203809)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2016-07-28 01:36:44 UTC (rev 203808)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2016-07-28 01:59:13 UTC (rev 203809)
@@ -3858,7 +3858,9 @@
BOOL canShowImagePreview = _positionInformation.isImage && supportsImagePreview;
BOOL canShowLinkPreview = _positionInformation.isLink || canShowImagePreview;
BOOL useImageURLForLink = NO;
- BOOL supportsAttachmentPreview = [uiDelegate respondsToSelector:@selector(_attachmentListForWebView:)] && [uiDelegate respondsToSelector:@selector(_webView:indexIntoAttachmentListForElement:)];
+ BOOL respondsToAttachmentListForWebViewSourceIsManaged = [uiDelegate respondsToSelector:@selector(_attachmentListForWebView:sourceIsManaged:)];
+ BOOL supportsAttachmentPreview = ([uiDelegate respondsToSelector:@selector(_attachmentListForWebView:)] || respondsToAttachmentListForWebViewSourceIsManaged)
+ && [uiDelegate respondsToSelector:@selector(_webView:indexIntoAttachmentListForElement:)];
BOOL canShowAttachmentPreview = (_positionInformation.isAttachment || _positionInformation.isImage) && supportsAttachmentPreview;
if (canShowImagePreview && _positionInformation.isAnimatedImage) {
@@ -3914,15 +3916,22 @@
*type = UIPreviewItemTypeImage;
dataForPreview[UIPreviewDataLink] = [NSURL _web_URLWithWTFString:_positionInformation.imageURL];
} else if (canShowAttachmentPreview) {
- // FIXME: Should use UIKit constants.
- enum { WKUIPreviewItemTypeAttachment = 5 };
- *type = static_cast<UIPreviewItemType>(WKUIPreviewItemTypeAttachment);
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
+ *type = UIPreviewItemTypeAttachment;
auto element = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeAttachment URL:[NSURL _web_URLWithWTFString:_positionInformation.url] location:_positionInformation.point title:_positionInformation.title ID:_positionInformation.idAttribute rect:_positionInformation.bounds image:nil]);
NSUInteger index = [uiDelegate _webView:_webView indexIntoAttachmentListForElement:element.get()];
if (index != NSNotFound) {
- dataForPreview[@"UIPreviewDataAttachmentList"] = [uiDelegate _attachmentListForWebView:_webView];
- dataForPreview[@"UIPreviewDataAttachmentIndex"] = [NSNumber numberWithUnsignedInteger:index];
+ BOOL sourceIsManaged = NO;
+ if (respondsToAttachmentListForWebViewSourceIsManaged)
+ dataForPreview[UIPreviewDataAttachmentList] = [uiDelegate _attachmentListForWebView:_webView sourceIsManaged:&sourceIsManaged];
+ else
+ dataForPreview[UIPreviewDataAttachmentList] = [uiDelegate _attachmentListForWebView:_webView];
+ dataForPreview[UIPreviewDataAttachmentIndex] = [NSNumber numberWithUnsignedInteger:index];
+
+ // FIXME: Replace the following NSString literal with a UIKit NSString constant.
+ dataForPreview[@"UIPreviewDataAttachmentListSourceIsManaged"] = [NSNumber numberWithBool:sourceIsManaged];
}
+#endif
}
return dataForPreview;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes