Changeset 206683 in webkit


Ignore:
Timestamp:
Sep 30, 2016, 3:30:20 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

The dragged image should be the current frame only of the animated image
https://bugs.webkit.org/show_bug.cgi?id=162109

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2016-09-30
Reviewed by Tim Horton.

Source/WebCore:

Instead of creating an NSImage with all the frames for the dragImage,
create an NSImage with the current frame only.

  • dom/DataTransferMac.mm:

(WebCore::DataTransfer::createDragImage): Call currentFrameNSImage() to create the dragImage.

  • editing/cocoa/HTMLConverter.mm:

(fileWrapperForElement): Call the Image function with its new name.

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

(WebCore::Image::nsImage): Rename getNSImage() to nsImage().
(WebCore::Image::currentFrameNSImage): Returns the NSImage of the current frame.
(WebCore::Image::tiffRepresentation): Rename getTIFFRepresentation() to tiffRepresentation().
(WebCore::Image::getNSImage): Deleted.
(WebCore::Image::getTIFFRepresentation): Deleted.

  • platform/graphics/mac/ImageMac.mm:

(WebCore::BitmapImage::tiffRepresentation): Rename getTIFFRepresentation() to tiffRepresentation().
(WebCore::BitmapImage::nsImage): Rename getNSImage() to nsImage().
(WebCore::BitmapImage::currentFrameNSImage): Returns the NSImage of the current frame.
(WebCore::BitmapImage::getTIFFRepresentation): Deleted.
(WebCore::BitmapImage::getNSImage): Deleted.

  • platform/mac/CursorMac.mm:

(WebCore::createCustomCursor): Call currentFrameNSImage() since the cursor does not animate anyway.

  • platform/mac/DragImageMac.mm:

(WebCore::createDragImageFromImage): Use currentFrameNSImage() for the dragImage.

  • platform/mac/PasteboardMac.mm:

(WebCore::Pasteboard::write): Call the Image function with its new name.

Source/WebKit/mac:

  • DOM/DOM.mm:

(-[DOMElement image]): Call the Image function with its new name.
(-[DOMElement _imageTIFFRepresentation]): Ditto.

  • Misc/WebElementDictionary.mm:

(-[WebElementDictionary _image]): Call the Image function with its new name.

  • Misc/WebIconDatabase.mm:

(-[WebIconDatabase defaultIconWithSize:]): Call currentFrameNSImage() to create the icon image.
(webGetNSImage): Call the Image function with its new name.

  • WebCoreSupport/WebContextMenuClient.mm:

(WebContextMenuClient::imageForCurrentSharingServicePickerItem): Call currentFrameNSImage() instead of nsImage()..
(WebContextMenuClient::contextMenuForEvent): Ditto.

  • WebView/WebHTMLView.mm:

(-[WebHTMLView pasteboard:provideDataForType:]): Call the Image function with its new name.

Source/WebKit2:

  • UIProcess/Cocoa/WebViewImpl.mm:

(WebKit::WebViewImpl::provideDataForPasteboard): Call the Image function with its new name.

Location:
trunk/Source
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r206681 r206683  
     12016-09-30  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        The dragged image should be the current frame only of the animated image
     4        https://bugs.webkit.org/show_bug.cgi?id=162109
     5
     6        Reviewed by Tim Horton.
     7
     8        Instead of creating an NSImage with all the frames for the dragImage,
     9        create an NSImage with the current frame only.
     10
     11        * dom/DataTransferMac.mm:
     12        (WebCore::DataTransfer::createDragImage): Call currentFrameNSImage() to create the dragImage.
     13        * editing/cocoa/HTMLConverter.mm:
     14        (fileWrapperForElement):  Call the Image function with its new name.
     15        * platform/graphics/BitmapImage.h:
     16        * platform/graphics/Image.h:
     17        (WebCore::Image::nsImage): Rename getNSImage() to nsImage().
     18        (WebCore::Image::currentFrameNSImage): Returns the NSImage of the current frame.
     19        (WebCore::Image::tiffRepresentation): Rename getTIFFRepresentation() to tiffRepresentation().
     20        (WebCore::Image::getNSImage): Deleted.
     21        (WebCore::Image::getTIFFRepresentation): Deleted.
     22        * platform/graphics/mac/ImageMac.mm:
     23        (WebCore::BitmapImage::tiffRepresentation): Rename getTIFFRepresentation() to tiffRepresentation().
     24        (WebCore::BitmapImage::nsImage): Rename getNSImage() to nsImage().
     25        (WebCore::BitmapImage::currentFrameNSImage): Returns the NSImage of the current frame.
     26        (WebCore::BitmapImage::getTIFFRepresentation): Deleted.
     27        (WebCore::BitmapImage::getNSImage): Deleted.
     28        * platform/mac/CursorMac.mm:
     29        (WebCore::createCustomCursor): Call currentFrameNSImage() since the cursor does not animate anyway.
     30        * platform/mac/DragImageMac.mm:
     31        (WebCore::createDragImageFromImage): Use currentFrameNSImage() for the dragImage.
     32        * platform/mac/PasteboardMac.mm:
     33        (WebCore::Pasteboard::write): Call the Image function with its new name.
     34
    1352016-09-30  Chris Dumez  <cdumez@apple.com>
    236
  • trunk/Source/WebCore/dom/DataTransferMac.mm

    r166965 r206683  
    5050        }
    5151    } else if (m_dragImage) {
    52         result = m_dragImage->image()->getNSImage();
     52        result = m_dragImage->image()->currentFrameNSImage();
    5353       
    5454        location = m_dragLocation;
  • trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm

    r202863 r206683  
    24652465        auto* image = downcast<RenderImage>(*renderer).cachedImage();
    24662466        if (image && !image->errorOccurred()) {
    2467             RetainPtr<NSFileWrapper> wrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:(NSData *)image->imageForRenderer(renderer)->getTIFFRepresentation()]);
     2467            RetainPtr<NSFileWrapper> wrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:(NSData *)image->imageForRenderer(renderer)->tiffRepresentation()]);
    24682468            [wrapper setPreferredFilename:@"image.tiff"];
    24692469            return wrapper;
  • trunk/Source/WebCore/platform/graphics/BitmapImage.h

    r206631 r206683  
    9797    // Accessors for native image formats.
    9898#if USE(APPKIT)
    99     NSImage* getNSImage() override;
     99    NSImage *nsImage() override;
     100    RetainPtr<NSImage> currentFrameNSImage() override;
    100101#endif
    101102
    102103#if PLATFORM(COCOA)
    103     CFDataRef getTIFFRepresentation() override;
     104    CFDataRef tiffRepresentation() override;
    104105#endif
    105106
     
    192193
    193194#if USE(APPKIT)
    194     mutable RetainPtr<NSImage> m_nsImage; // A cached NSImage of frame 0. Only built lazily if someone actually queries for one.
     195    mutable RetainPtr<NSImage> m_nsImage; // A cached NSImage of all the frames. Only built lazily if someone actually queries for one.
    195196#endif
    196197#if USE(CG)
    197     mutable RetainPtr<CFDataRef> m_tiffRep; // Cached TIFF rep for frame 0. Only built lazily if someone queries for one.
     198    mutable RetainPtr<CFDataRef> m_tiffRep; // Cached TIFF rep for all the frames. Only built lazily if someone queries for one.
    198199#endif
    199200    RefPtr<Image> m_cachedImage;
  • trunk/Source/WebCore/platform/graphics/Image.h

    r206631 r206683  
    147147
    148148#if USE(APPKIT)
    149     virtual NSImage* getNSImage() { return nullptr; }
     149    virtual NSImage *nsImage() { return nullptr; }
     150    virtual RetainPtr<NSImage> currentFrameNSImage() { return nullptr; }
    150151#endif
    151152
    152153#if PLATFORM(COCOA)
    153     virtual CFDataRef getTIFFRepresentation() { return nullptr; }
     154    virtual CFDataRef tiffRepresentation() { return nullptr; }
    154155#endif
    155156
  • trunk/Source/WebCore/platform/graphics/mac/ImageMac.mm

    r206481 r206683  
    7575}
    7676
    77 CFDataRef BitmapImage::getTIFFRepresentation()
     77CFDataRef BitmapImage::tiffRepresentation()
    7878{
    7979    if (m_tiffRep)
    8080        return m_tiffRep.get();
    8181
    82     auto nativeImages = this->framesNativeImages();
     82    auto nativeImages = framesNativeImages();
    8383
    84     // If framesImages.size() is zero, we know for certain this image doesn't have valid data
     84    // If nativeImages.size() is zero, we know for certain this image doesn't have valid data
    8585    // Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully,
    8686    // in certain circumstances that call will spam the console with an error message
     
    104104
    105105#if USE(APPKIT)
    106 NSImage* BitmapImage::getNSImage()
     106NSImage* BitmapImage::nsImage()
    107107{
    108108    if (m_nsImage)
    109109        return m_nsImage.get();
    110110
    111     CFDataRef data = getTIFFRepresentation();
     111    CFDataRef data = tiffRepresentation();
    112112    if (!data)
    113         return 0;
     113        return nullptr;
    114114   
    115115    m_nsImage = adoptNS([[NSImage alloc] initWithData:(NSData*)data]);
    116116    return m_nsImage.get();
    117117}
     118
     119RetainPtr<NSImage> BitmapImage::currentFrameNSImage()
     120{
     121    auto nativeImage = this->nativeImageForCurrentFrame();
     122    if (!nativeImage)
     123        return nullptr;
     124
     125    return adoptNS([[NSImage alloc] initWithCGImage:nativeImage.get() size:NSZeroSize]);
     126}
    118127#endif
    119128
  • trunk/Source/WebCore/platform/mac/CursorMac.mm

    r201038 r206683  
    4949{
    5050    // FIXME: The cursor won't animate.  Not sure if that's a big deal.
    51     NSImage* nsImage = image->getNSImage();
     51    auto nsImage = image->currentFrameNSImage();
    5252    if (!nsImage)
    53         return 0;
     53        return nullptr;
    5454    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    5555
     
    7979#endif
    8080
    81     return adoptNS([[NSCursor alloc] initWithImage:nsImage hotSpot:hotSpot]);
     81    return adoptNS([[NSCursor alloc] initWithImage:nsImage.get() hotSpot:hotSpot]);
    8282    END_BLOCK_OBJC_EXCEPTIONS;
    8383    return nullptr;
  • trunk/Source/WebCore/platform/mac/DragImageMac.mm

    r200070 r206683  
    122122#pragma clang diagnostic push
    123123#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    124             [image->getNSImage() drawInRect:destRect fromRect:NSMakeRect(0, 0, size.width(), size.height()) operation:NSCompositeSourceOver fraction:1.0];
     124            [image->currentFrameNSImage() drawInRect:destRect fromRect:NSMakeRect(0, 0, size.width(), size.height()) operation:NSCompositeSourceOver fraction:1.0];
    125125#pragma clang diagnostic pop
    126126            [rotatedDragImage.get() unlockFocus];
     
    130130    }
    131131
    132     RetainPtr<NSImage> dragImage = adoptNS([image->getNSImage() copy]);
     132    auto dragImage = image->currentFrameNSImage();
    133133    [dragImage.get() setSize:(NSSize)size];
    134134    return dragImage;
  • trunk/Source/WebCore/platform/mac/PasteboardMac.mm

    r203109 r206683  
    256256void Pasteboard::write(const PasteboardImage& pasteboardImage)
    257257{
    258     CFDataRef imageData = pasteboardImage.image->getTIFFRepresentation();
     258    CFDataRef imageData = pasteboardImage.image->tiffRepresentation();
    259259    if (!imageData)
    260260        return;
  • trunk/Source/WebKit/mac/ChangeLog

    r206440 r206683  
     12016-09-30  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        The dragged image should be the current frame only of the animated image
     4        https://bugs.webkit.org/show_bug.cgi?id=162109
     5
     6        Reviewed by Tim Horton.
     7
     8        * DOM/DOM.mm:
     9        (-[DOMElement image]): Call the Image function with its new name.
     10        (-[DOMElement _imageTIFFRepresentation]): Ditto.
     11        * Misc/WebElementDictionary.mm:
     12        (-[WebElementDictionary _image]): Call the Image function with its new name.
     13        * Misc/WebIconDatabase.mm:
     14        (-[WebIconDatabase defaultIconWithSize:]): Call currentFrameNSImage() to create the icon image.
     15        (webGetNSImage): Call the Image function with its new name.
     16        * WebCoreSupport/WebContextMenuClient.mm:
     17        (WebContextMenuClient::imageForCurrentSharingServicePickerItem): Call currentFrameNSImage() instead of nsImage()..
     18        (WebContextMenuClient::contextMenuForEvent): Ditto.
     19        * WebView/WebHTMLView.mm:
     20        (-[WebHTMLView pasteboard:provideDataForType:]): Call the Image function with its new name.
     21
    1222016-09-27  Jer Noble  <jer.noble@apple.com>
    223
  • trunk/Source/WebKit/mac/DOM/DOM.mm

    r205682 r206683  
    671671    if (!cachedImage || cachedImage->errorOccurred())
    672672        return nil;
    673     return cachedImage->imageForRenderer(renderer)->getNSImage();
     673    return cachedImage->imageForRenderer(renderer)->nsImage();
    674674}
    675675
     
    699699    if (!cachedImage || cachedImage->errorOccurred())
    700700        return nil;
    701     return (NSData *)cachedImage->imageForRenderer(renderer)->getTIFFRepresentation();
     701    return (NSData *)cachedImage->imageForRenderer(renderer)->tiffRepresentation();
    702702}
    703703
  • trunk/Source/WebKit/mac/Misc/WebElementDictionary.mm

    r193378 r206683  
    205205{
    206206    Image* image = _result->image();
    207     return image ? image->getNSImage() : nil;
     207    return image ? image->nsImage() : nil;
    208208}
    209209
  • trunk/Source/WebKit/mac/Misc/WebIconDatabase.mm

    r184853 r206683  
    164164   
    165165    Image* image = iconDatabase().defaultIcon(IntSize(size));
    166     return image ? image->getNSImage() : nil;
     166    return image ? image->currentFrameNSImage().autorelease() : nil;
    167167}
    168168
     
    471471    if (!image)
    472472        return nil;
    473     NSImage* nsImage = image->getNSImage();
     473    NSImage* nsImage = image->nsImage();
    474474    if (!nsImage)
    475475        return nil;
  • trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm

    r199692 r206683  
    227227        return nil;
    228228
    229     return [[image->getNSImage() retain] autorelease];
     229    return image->currentFrameNSImage();
    230230}
    231231#endif
     
    243243        ASSERT(page->contextMenuController().context().hitTestResult().innerNode());
    244244
    245         RetainPtr<NSItemProvider> itemProvider = adoptNS([[NSItemProvider alloc] initWithItem:image->getNSImage() typeIdentifier:@"public.image"]);
     245        RetainPtr<NSItemProvider> itemProvider = adoptNS([[NSItemProvider alloc] initWithItem:image->currentFrameNSImage().autorelease() typeIdentifier:@"public.image"]);
    246246
    247247        bool isContentEditable = page->contextMenuController().context().hitTestResult().innerNode()->isContentEditable();
  • trunk/Source/WebKit/mac/WebView/WebHTMLView.mm

    r206361 r206683  
    22112211    } else if ([type isEqual:NSTIFFPboardType] && [self promisedDragTIFFDataSource]) {
    22122212        if (Image* image = [self promisedDragTIFFDataSource]->image())
    2213             [pasteboard setData:(NSData *)image->getTIFFRepresentation() forType:NSTIFFPboardType];
     2213            [pasteboard setData:(NSData *)image->tiffRepresentation() forType:NSTIFFPboardType];
    22142214        [self setPromisedDragTIFFDataSource:0];
    22152215    }
  • trunk/Source/WebKit2/ChangeLog

    r206675 r206683  
     12016-09-30  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        The dragged image should be the current frame only of the animated image
     4        https://bugs.webkit.org/show_bug.cgi?id=162109
     5
     6        Reviewed by Tim Horton.
     7
     8        * UIProcess/Cocoa/WebViewImpl.mm:
     9        (WebKit::WebViewImpl::provideDataForPasteboard): Call the Image function with its new name.
     10
    1112016-09-30  Anders Carlsson  <andersca@apple.com>
    212
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm

    r206033 r206683  
    30393039
    30403040    if ([type isEqual:NSTIFFPboardType] && m_promisedImage) {
    3041         [pasteboard setData:(NSData *)m_promisedImage->getTIFFRepresentation() forType:NSTIFFPboardType];
     3041        [pasteboard setData:(NSData *)m_promisedImage->tiffRepresentation() forType:NSTIFFPboardType];
    30423042        m_promisedImage = nullptr;
    30433043    }
Note: See TracChangeset for help on using the changeset viewer.