Title: [198496] trunk/Source/WebKit2
Revision
198496
Author
enr...@apple.com
Date
2016-03-21 12:28:53 -0700 (Mon, 21 Mar 2016)

Log Message

Enable preview of images as attachments.
https://bugs.webkit.org/show_bug.cgi?id=155674
rdar://problem/25242656

Reviewed by Darin Adler.

If the client cannot handle image preview, but can handle attachments,
let them handle images as attachments.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _dataForPreviewItemController:atPosition:type:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (198495 => 198496)


--- trunk/Source/WebKit2/ChangeLog	2016-03-21 19:22:42 UTC (rev 198495)
+++ trunk/Source/WebKit2/ChangeLog	2016-03-21 19:28:53 UTC (rev 198496)
@@ -1,3 +1,17 @@
+2016-03-18  Enrica Casucci  <enr...@apple.com>
+
+        Enable preview of images as attachments.
+        https://bugs.webkit.org/show_bug.cgi?id=155674
+        rdar://problem/25242656
+
+        Reviewed by Darin Adler.
+
+        If the client cannot handle image preview, but can handle attachments,
+        let them handle images as attachments.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _dataForPreviewItemController:atPosition:type:]):
+
 2016-03-20  Dan Bernstein  <m...@apple.com>
 
         [Mac] Determine TARGET_MAC_OS_X_VERSION_MAJOR from MACOSX_DEPLOYMENT_TARGET rather than from MAC_OS_X_VERSION_MAJOR

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (198495 => 198496)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-03-21 19:22:42 UTC (rev 198495)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-03-21 19:28:53 UTC (rev 198496)
@@ -3827,7 +3827,7 @@
     BOOL canShowLinkPreview = _positionInformation.isLink || canShowImagePreview;
     BOOL useImageURLForLink = NO;
     BOOL supportsAttachmentPreview = [uiDelegate respondsToSelector:@selector(_attachmentListForWebView:)] && [uiDelegate respondsToSelector:@selector(_webView:indexIntoAttachmentListForElement:)];
-    BOOL canShowAttachmentPreview = _positionInformation.isAttachment && supportsAttachmentPreview;
+    BOOL canShowAttachmentPreview = (_positionInformation.isAttachment || _positionInformation.isImage) && supportsAttachmentPreview;
 
     if (canShowImagePreview && _positionInformation.isAnimatedImage) {
         canShowImagePreview = NO;
@@ -3886,8 +3886,11 @@
         enum { WKUIPreviewItemTypeAttachment = 5 };
         *type = static_cast<UIPreviewItemType>(WKUIPreviewItemTypeAttachment);
         const auto& element = [[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeAttachment URL:[NSURL _web_URLWithWTFString:_positionInformation.url] location:_positionInformation.point title:_positionInformation.title ID:_positionInformation.idAttribute rect:_positionInformation.bounds image:nil];
-        dataForPreview[@"UIPreviewDataAttachmentList"] = [uiDelegate _attachmentListForWebView:_webView];
-        dataForPreview[@"UIPreviewDataAttachmentIndex"] = [NSNumber numberWithUnsignedInteger:[uiDelegate _webView:_webView indexIntoAttachmentListForElement:element]];
+        NSUInteger index = [uiDelegate _webView:_webView indexIntoAttachmentListForElement:element];
+        if (index != NSNotFound) {
+            dataForPreview[@"UIPreviewDataAttachmentList"] = [uiDelegate _attachmentListForWebView:_webView];
+            dataForPreview[@"UIPreviewDataAttachmentIndex"] = [NSNumber numberWithUnsignedInteger:index];
+        }
     }
     
     return dataForPreview;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to