⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 197656 in webkit


Ignore:
Timestamp:
Mar 6, 2016, 7:36:53 PM (11 years ago)
Author:
enrica@apple.com
Message:

Support preview on attachment elements.
https://bugs.webkit.org/show_bug.cgi?id=155074
rdar://problem/24806079

Reviewed by Sam Weinig.

Allowing preview to start on attachment elements.
Adding a private UIDelegate method to provide the data for the preview.

  • UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _interactionShouldBeginFromPreviewItemController:forPosition:]):
(-[WKContentView _dataForPreviewItemController:atPosition:type:]):

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r197638 r197656  
     12016-03-05  Enrica Casucci  <enrica@apple.com>
     2
     3        Support preview on attachment elements.
     4        https://bugs.webkit.org/show_bug.cgi?id=155074
     5        rdar://problem/24806079
     6
     7        Reviewed by Sam Weinig.
     8
     9        Allowing preview to start on attachment elements.
     10        Adding a private UIDelegate method to provide the data for the preview.
     11
     12        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
     13        * UIProcess/ios/WKContentViewInteraction.mm:
     14        (-[WKContentView _interactionShouldBeginFromPreviewItemController:forPosition:]):
     15        (-[WKContentView _dataForPreviewItemController:atPosition:type:]):
     16
    1172016-03-06  Andreas Kling  <akling@apple.com>
    218
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h

    r197596 r197656  
    7373- (void)_webView:(WKWebView *)webView didDismissPreviewViewController:(UIViewController *)previewedViewController WK_AVAILABLE(NA, 9_0);
    7474- (BOOL)_webView:(WKWebView *)webView showCustomSheetForElement:(_WKActivatedElementInfo *)element WK_AVAILABLE(NA, WK_IOS_TBA);
     75- (NSArray *)_attachmentListForWebView:(WKWebView *)webView WK_AVAILABLE(NA, WK_IOS_TBA);
     76- (NSUInteger)_webView:(WKWebView *)webView indexIntoAttachmentListForElement:(_WKActivatedElementInfo *)element WK_AVAILABLE(NA, WK_IOS_TBA);
    7577- (UIEdgeInsets)_webView:(WKWebView *)webView finalObscuredInsetsForScrollView:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset WK_AVAILABLE(NA, 9_0);
    7678- (UIViewController *)_webView:(WKWebView *)webView previewViewControllerForURL:(NSURL *)url defaultActions:(WK_ARRAY(_WKElementAction *) *)actions elementInfo:(_WKActivatedElementInfo *)elementInfo WK_AVAILABLE(NA, 9_0);
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r197632 r197656  
    36333633
    36343634    [self ensurePositionInformationIsUpToDate:position];
    3635     if (!_positionInformation.isLink && !_positionInformation.isImage)
     3635    if (!_positionInformation.isLink && !_positionInformation.isImage && !_positionInformation.isAttachment)
    36363636        return NO;
    36373637   
     
    36643664    BOOL canShowLinkPreview = _positionInformation.isLink || canShowImagePreview;
    36653665    BOOL useImageURLForLink = NO;
     3666    BOOL supportsAttachmentPreview = [uiDelegate respondsToSelector:@selector(_attachmentListForWebView:)] && [uiDelegate respondsToSelector:@selector(_webView:indexIntoAttachmentListForElement:)];
     3667    BOOL canShowAttachmentPreview = _positionInformation.isAttachment && supportsAttachmentPreview;
    36663668
    36673669    if (canShowImagePreview && _positionInformation.isAnimatedImage) {
     
    36713673    }
    36723674
    3673     if (!canShowLinkPreview && !canShowImagePreview)
     3675    if (!canShowLinkPreview && !canShowImagePreview && !canShowAttachmentPreview)
    36743676        return nil;
    36753677
     
    36903692        if (_positionInformation.isDataDetectorLink) {
    36913693            NSDictionary *context = nil;
    3692             id <WKUIDelegatePrivate> uiDelegate = static_cast<id <WKUIDelegatePrivate>>([_webView UIDelegate]);
    36933694            if ([uiDelegate respondsToSelector:@selector(_dataDetectionContextForWebView:)])
    36943695                context = [uiDelegate _dataDetectionContextForWebView:_webView];
     
    37073708        *type = UIPreviewItemTypeImage;
    37083709        dataForPreview[UIPreviewDataLink] = [NSURL _web_URLWithWTFString:_positionInformation.imageURL];
     3710    } else if (canShowAttachmentPreview) {
     3711        // FIXME: Should use UIKit constants.
     3712        enum { WKUIPreviewItemTypeAttachment = 5 };
     3713        *type = static_cast<UIPreviewItemType>(WKUIPreviewItemTypeAttachment);
     3714        const auto& element = [[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeAttachment URL:[NSURL _web_URLWithWTFString:_positionInformation.url] location:_positionInformation.point title:_positionInformation.title rect:_positionInformation.bounds image:nil];
     3715        dataForPreview[@"UIPreviewDataAttachmentList"] = [uiDelegate _attachmentListForWebView:_webView];
     3716        dataForPreview[@"UIPreviewDataAttachmentIndex"] = [NSNumber numberWithUnsignedInteger:[uiDelegate _webView:_webView indexIntoAttachmentListForElement:element]];
    37093717    }
    37103718   
Note: See TracChangeset for help on using the changeset viewer.