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

Changeset 187173 in webkit


Ignore:
Timestamp:
Jul 22, 2015, 12:15:06 PM (11 years ago)
Author:
Beth Dakin
Message:

Animated images should animate in previews
https://bugs.webkit.org/show_bug.cgi?id=147173
-and corresponding-
rdar://problem/21637698

Reviewed by Dan Bernstein.

Source/WebCore:

New virtual function to indicate whether or not the image is animated.

  • platform/graphics/BitmapImage.h:
  • platform/graphics/Image.h:

(WebCore::Image::isAnimated):

Source/WebKit2:

InteractionInformationAtPosition needs to know if it’s an animated image.

  • Shared/InteractionInformationAtPosition.cpp:

(WebKit::InteractionInformationAtPosition::encode):
(WebKit::InteractionInformationAtPosition::decode):

  • Shared/InteractionInformationAtPosition.h:

New delegate method to create a link preview view controller for animated
images.

  • UIProcess/API/Cocoa/WKUIDelegatePrivate.h:

Treat animated images more like link previews.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView previewViewControllerForPosition:inSourceView:]):

Set info.isAnimatedImage

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::getPositionInformation):

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r187171 r187173  
     12015-07-22  Beth Dakin  <bdakin@apple.com>
     2
     3        Animated images should animate in previews
     4        https://bugs.webkit.org/show_bug.cgi?id=147173
     5        -and corresponding-
     6        rdar://problem/21637698
     7
     8        Reviewed by Dan Bernstein.
     9
     10        New virtual function to indicate whether or not the image is animated.
     11        * platform/graphics/BitmapImage.h:
     12        * platform/graphics/Image.h:
     13        (WebCore::Image::isAnimated):
     14
    1152015-07-22  Jinyoung Hur  <hur.ims@navercorp.com>
    216
  • trunk/Source/WebCore/platform/graphics/BitmapImage.h

    r184793 r187173  
    179179
    180180    virtual bool currentFrameKnownToBeOpaque() override;
     181
     182    virtual bool isAnimated() override { return m_frameCount > 1; }
    181183   
    182184    bool canAnimate();
  • trunk/Source/WebCore/platform/graphics/Image.h

    r183716 r187173  
    8686    virtual bool currentFrameKnownToBeOpaque() = 0;
    8787
     88    virtual bool isAnimated() { return false; }
     89
    8890    // Derived classes should override this if they can assure that
    8991    // the image contains only resources from its own security origin.
  • trunk/Source/WebKit2/ChangeLog

    r187159 r187173  
     12015-07-22  Beth Dakin  <bdakin@apple.com>
     2
     3        Animated images should animate in previews
     4        https://bugs.webkit.org/show_bug.cgi?id=147173
     5        -and corresponding-
     6        rdar://problem/21637698
     7
     8        Reviewed by Dan Bernstein.
     9
     10        InteractionInformationAtPosition needs to know if it’s an animated image.
     11        * Shared/InteractionInformationAtPosition.cpp:
     12        (WebKit::InteractionInformationAtPosition::encode):
     13        (WebKit::InteractionInformationAtPosition::decode):
     14        * Shared/InteractionInformationAtPosition.h:
     15
     16        New delegate method to create a link preview view controller for animated
     17        images.
     18        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
     19
     20        Treat animated images more like link previews.
     21        * UIProcess/ios/WKContentViewInteraction.mm:
     22        (-[WKContentView previewViewControllerForPosition:inSourceView:]):
     23
     24        Set info.isAnimatedImage
     25        * WebProcess/WebPage/ios/WebPageIOS.mm:
     26        (WebKit::WebPage::getPositionInformation):
     27
    1282015-07-22  Michael Catanzaro  <mcatanzaro@igalia.com>
    229
  • trunk/Source/WebKit2/Shared/InteractionInformationAtPosition.cpp

    r186916 r187173  
    4040    encoder << isNearMarkedText;
    4141    encoder << touchCalloutEnabled;
     42    encoder << isAnimatedImage;
    4243    encoder << clickableElementName;
    4344    encoder << url;
     
    6869
    6970    if (!decoder.decode(result.touchCalloutEnabled))
     71        return false;
     72
     73    if (!decoder.decode(result.isAnimatedImage))
    7074        return false;
    7175   
  • trunk/Source/WebKit2/Shared/InteractionInformationAtPosition.h

    r186916 r187173  
    4444    bool isNearMarkedText { false };
    4545    bool touchCalloutEnabled { true };
     46    bool isAnimatedImage { false };
    4647    String clickableElementName;
    4748    String url;
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h

    r186719 r187173  
    3434@class UIViewController;
    3535@class _WKActivatedElementInfo;
     36@class _WKElementAction;
    3637@class _WKFrameHandle;
    3738
     
    5758#if TARGET_OS_IPHONE
    5859- (BOOL)_webView:(WKWebView *)webView shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element WK_AVAILABLE(NA, WK_IOS_TBA);
    59 - (NSArray *)_webView:(WKWebView *)webView actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(NSArray *)defaultActions;
     60- (NSArray *)_webView:(WKWebView *)webView actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(WK_ARRAY(_WKElementAction *) *)defaultActions;
    6061- (void)_webView:(WKWebView *)webView didNotHandleTapAsClickAtPoint:(CGPoint)point;
    6162- (BOOL)_webView:(WKWebView *)webView shouldRequestGeolocationAuthorizationForURL:(NSURL *)url isMainFrame:(BOOL)isMainFrame mainFrameURL:(NSURL *)mainFrameURL;
     
    6667- (void)_webView:(WKWebView *)webView didDismissPreviewViewController:(UIViewController *)previewedViewController;
    6768- (UIEdgeInsets)_webView:(WKWebView *)webView finalObscuredInsetsForScrollView:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset;
    68 - (UIViewController *)_webView:(WKWebView *)webView previewViewControllerForURL:(NSURL *)url defaultActions:(NSArray *)actions elementInfo:(_WKActivatedElementInfo *)elementInfo WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
     69- (UIViewController *)_webView:(WKWebView *)webView previewViewControllerForURL:(NSURL *)url defaultActions:(WK_ARRAY(_WKElementAction *) *)actions elementInfo:(_WKActivatedElementInfo *)elementInfo WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
     70- (UIViewController *)_webView:(WKWebView *)webView previewViewControllerForAnimatedImageAtURL:(NSURL *)url defaultActions:(WK_ARRAY(_WKElementAction *) *)actions elementInfo:(_WKActivatedElementInfo *)elementInfo imageSize:(CGSize)imageSize WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
    6971#endif
    7072
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r187117 r187173  
    32783278        if (absoluteImageURL.isEmpty() || !(WebCore::protocolIsInHTTPFamily(absoluteImageURL) || WebCore::protocolIs(absoluteImageURL, "data")))
    32793279            return nil;
     3280
     3281        NSURL *targetURL = [NSURL _web_URLWithWTFString:_positionInformation.imageURL];
     3282        RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage URL:targetURL location:_positionInformation.point title:_positionInformation.title rect:_positionInformation.bounds image:_positionInformation.image.get()]);
     3283        _page->startInteractionWithElementAtPosition(_positionInformation.point);
     3284
     3285        // Treat animated images like a link preview
     3286        if (_positionInformation.isAnimatedImage) {
     3287            if ([uiDelegate respondsToSelector:@selector(_webView:previewViewControllerForAnimatedImageAtURL:defaultActions:elementInfo:imageSize:)]) {
     3288                _previewType = PreviewElementType::Link;
     3289                RetainPtr<NSArray> actions = [_actionSheetAssistant defaultActionsForImageSheet:elementInfo.get()];
     3290                _highlightLongPressCanClick = NO;
     3291                return [uiDelegate _webView:_webView previewViewControllerForAnimatedImageAtURL:targetURL defaultActions:actions.get() elementInfo:elementInfo.get() imageSize:_positionInformation.image->size()];
     3292            }
     3293        }
     3294
    32803295        _previewType = PreviewElementType::Image;
    3281         NSURL *targetURL = [NSURL _web_URLWithWTFString:_positionInformation.imageURL];
    32823296        if ([uiDelegate respondsToSelector:@selector(_webView:willPreviewImageWithURL:)])
    32833297            [uiDelegate _webView:_webView willPreviewImageWithURL:targetURL];
    3284         RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage URL:targetURL location:_positionInformation.point title:_positionInformation.title rect:_positionInformation.bounds image:_positionInformation.image.get()]);
    3285         _page->startInteractionWithElementAtPosition(_positionInformation.point);
    32863298        return [[[WKImagePreviewViewController alloc] initWithCGImage:_positionInformation.image->makeCGImageCopy() defaultActions:[_actionSheetAssistant defaultActionsForImageSheet:elementInfo.get()] elementInfo:elementInfo] autorelease];
    32873299    }
  • trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

    r187117 r187173  
    22242224                        info.imageURL = [(NSURL *)element->document().completeURL(renderImage.cachedImage()->url()) absoluteString];
    22252225                        if (Image* image = renderImage.cachedImage()->imageForRenderer(&renderImage)) {
     2226                            info.isAnimatedImage = image->isAnimated();
    22262227                            FloatSize screenSizeInPixels = screenSize();
    22272228                            screenSizeInPixels.scale(corePage()->deviceScaleFactor());
Note: See TracChangeset for help on using the changeset viewer.