Diff
Modified: branches/safari-602-branch/Source/WebCore/ChangeLog (208161 => 208162)
--- branches/safari-602-branch/Source/WebCore/ChangeLog 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog 2016-10-31 18:43:25 UTC (rev 208162)
@@ -1,3 +1,45 @@
+2016-10-31 Matthew Hanson <matthew_han...@apple.com>
+
+ Merge r206802. rdar://problem/28409525
+
+ 2016-10-28 Said Abou-Hallawa <sabouhall...@apple.com>
+
+ The dragged image should be the current frame only of the animated image
+ https://bugs.webkit.org/show_bug.cgi?id=162109
+
+ Instead of creating an NSImage with all the frames for the dragImage,
+ create an NSImage with the current frame only.
+
+ * bindings/objc/DOM.mm:
+ (-[DOMElement image]): Call the Image function with its new name.
+ (-[DOMElement _imageTIFFRepresentation]): Ditto.
+ * dom/DataTransferMac.mm:
+ (WebCore::DataTransfer::createDragImage): Call snapshotNSImage() to create the dragImage.
+ * editing/cocoa/HTMLConverter.mm:
+ (fileWrapperForElement): Call the Image function with its new name.
+ * platform/graphics/BitmapImage.cpp:
+ (WebCore::BitmapImage::framesNativeImages): Added.
+ * platform/graphics/BitmapImage.h:
+ * platform/graphics/Image.h:
+ (WebCore::Image::framesNativeImages): Added.
+ (WebCore::Image::nsImage): Rename getNSImage() to nsImage().
+ (WebCore::Image::snapshotNSImage): 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::snapshotNSImage): Returns the NSImage of the current frame.
+ (WebCore::BitmapImage::getTIFFRepresentation): Deleted.
+ (WebCore::BitmapImage::getNSImage): Deleted.
+ * platform/mac/CursorMac.mm:
+ (WebCore::createCustomCursor): Call snapshotNSImage() since the cursor does not animate anyway.
+ * platform/mac/DragImageMac.mm:
+ (WebCore::createDragImageFromImage): Use snapshotNSImage() for the dragImage.
+ * platform/mac/PasteboardMac.mm:
+ (WebCore::Pasteboard::write): Call the Image function with its new name.
+
2016-10-27 Daniel Bates <daba...@apple.com>
Merge r207848. rdar://problem/28216276
Modified: branches/safari-602-branch/Source/WebCore/bindings/objc/DOM.mm (208161 => 208162)
--- branches/safari-602-branch/Source/WebCore/bindings/objc/DOM.mm 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebCore/bindings/objc/DOM.mm 2016-10-31 18:43:25 UTC (rev 208162)
@@ -713,7 +713,7 @@
auto* cachedImage = downcast<RenderImage>(*renderer).cachedImage();
if (!cachedImage || cachedImage->errorOccurred())
return nil;
- return cachedImage->imageForRenderer(renderer)->getNSImage();
+ return cachedImage->imageForRenderer(renderer)->nsImage();
}
#endif
@@ -739,7 +739,7 @@
WebCore::CachedImage* cachedImage = downcast<RenderImage>(*renderer).cachedImage();
if (!cachedImage || cachedImage->errorOccurred())
return nil;
- return (NSData *)cachedImage->imageForRenderer(renderer)->getTIFFRepresentation();
+ return (NSData *)cachedImage->imageForRenderer(renderer)->tiffRepresentation();
}
#endif
Modified: branches/safari-602-branch/Source/WebCore/dom/DataTransferMac.mm (208161 => 208162)
--- branches/safari-602-branch/Source/WebCore/dom/DataTransferMac.mm 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebCore/dom/DataTransferMac.mm 2016-10-31 18:43:25 UTC (rev 208162)
@@ -49,7 +49,7 @@
location.setY(imageRect.height() - (elementRect.y() - imageRect.y() + m_dragLocation.y()));
}
} else if (m_dragImage) {
- result = m_dragImage->image()->getNSImage();
+ result = m_dragImage->image()->snapshotNSImage();
location = m_dragLocation;
location.setY([result size].height - location.y());
Modified: branches/safari-602-branch/Source/WebCore/editing/cocoa/HTMLConverter.mm (208161 => 208162)
--- branches/safari-602-branch/Source/WebCore/editing/cocoa/HTMLConverter.mm 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebCore/editing/cocoa/HTMLConverter.mm 2016-10-31 18:43:25 UTC (rev 208162)
@@ -2464,7 +2464,7 @@
if (is<RenderImage>(renderer)) {
auto* image = downcast<RenderImage>(*renderer).cachedImage();
if (image && !image->errorOccurred()) {
- RetainPtr<NSFileWrapper> wrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:(NSData *)image->imageForRenderer(renderer)->getTIFFRepresentation()]);
+ RetainPtr<NSFileWrapper> wrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:(NSData *)image->imageForRenderer(renderer)->tiffRepresentation()]);
[wrapper setPreferredFilename:@"image.tiff"];
return wrapper;
}
Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/BitmapImage.cpp (208161 => 208162)
--- branches/safari-602-branch/Source/WebCore/platform/graphics/BitmapImage.cpp 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebCore/platform/graphics/BitmapImage.cpp 2016-10-31 18:43:25 UTC (rev 208162)
@@ -426,6 +426,21 @@
return frameImageAtIndex(currentFrame());
}
+#if USE(CG)
+Vector<NativeImagePtr> BitmapImage::framesNativeImages()
+{
+ Vector<NativeImagePtr> images;
+ size_t count = frameCount();
+
+ for (size_t i = 0; i < count; ++i) {
+ if (auto image = frameImageAtIndex(i))
+ images.append(image);
+ }
+
+ return images;
+}
+#endif
+
bool BitmapImage::frameHasAlphaAtIndex(size_t index)
{
if (!ensureFrameIsCached(index, CacheMetadataOnly))
Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/BitmapImage.h (208161 => 208162)
--- branches/safari-602-branch/Source/WebCore/platform/graphics/BitmapImage.h 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebCore/platform/graphics/BitmapImage.h 2016-10-31 18:43:25 UTC (rev 208162)
@@ -148,11 +148,12 @@
// Accessors for native image formats.
#if USE(APPKIT)
- NSImage* getNSImage() override;
+ NSImage *nsImage() override;
+ RetainPtr<NSImage> snapshotNSImage() override;
#endif
#if PLATFORM(COCOA)
- CFDataRef getTIFFRepresentation() override;
+ CFDataRef tiffRepresentation() override;
#endif
#if USE(CG)
@@ -176,6 +177,9 @@
NativeImagePtr nativeImageForCurrentFrame() override;
ImageOrientation orientationForCurrentFrame() override { return frameOrientationAtIndex(currentFrame()); }
+#if USE(CG)
+ Vector<NativeImagePtr> framesNativeImages() override;
+#endif
bool currentFrameKnownToBeOpaque() override;
@@ -281,6 +285,10 @@
bool notSolidColor() override;
#endif
+#if PLATFORM(COCOA)
+ RetainPtr<CFDataRef> tiffRepresentation(const Vector<NativeImagePtr>&);
+#endif
+
private:
void clearTimer();
void startTimer(double delay);
@@ -301,10 +309,10 @@
double m_desiredFrameStartTime { 0 }; // The system time at which we hope to see the next call to startAnimation().
#if USE(APPKIT)
- mutable RetainPtr<NSImage> m_nsImage; // A cached NSImage of frame 0. Only built lazily if someone actually queries for one.
+ mutable RetainPtr<NSImage> m_nsImage; // A cached NSImage of all the frames. Only built lazily if someone actually queries for one.
#endif
#if USE(CG)
- mutable RetainPtr<CFDataRef> m_tiffRep; // Cached TIFF rep for frame 0. Only built lazily if someone queries for one.
+ mutable RetainPtr<CFDataRef> m_tiffRep; // Cached TIFF rep for all the frames. Only built lazily if someone queries for one.
#endif
// The value of this data member is a missing value if we haven’t analyzed to check for a solid color or not, but an invalid
Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/Image.h (208161 => 208162)
--- branches/safari-602-branch/Source/WebCore/platform/graphics/Image.h 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebCore/platform/graphics/Image.h 2016-10-31 18:43:25 UTC (rev 208162)
@@ -139,15 +139,17 @@
virtual NativeImagePtr nativeImageForCurrentFrame() { return nullptr; }
virtual ImageOrientation orientationForCurrentFrame() { return ImageOrientation(); }
+ virtual Vector<NativeImagePtr> framesNativeImages() { return { }; }
// Accessors for native image formats.
#if USE(APPKIT)
- virtual NSImage* getNSImage() { return nullptr; }
+ virtual NSImage *nsImage() { return nullptr; }
+ virtual RetainPtr<NSImage> snapshotNSImage() { return nullptr; }
#endif
#if PLATFORM(COCOA)
- virtual CFDataRef getTIFFRepresentation() { return nullptr; }
+ virtual CFDataRef tiffRepresentation() { return nullptr; }
#endif
#if USE(CG)
Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/mac/ImageMac.mm (208161 => 208162)
--- branches/safari-602-branch/Source/WebCore/platform/graphics/mac/ImageMac.mm 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebCore/platform/graphics/mac/ImageMac.mm 2016-10-31 18:43:25 UTC (rev 208162)
@@ -80,56 +80,66 @@
return Image::nullImage();
}
-CFDataRef BitmapImage::getTIFFRepresentation()
+RetainPtr<CFDataRef> BitmapImage::tiffRepresentation(const Vector<NativeImagePtr>& nativeImages)
{
- if (m_tiffRep)
- return m_tiffRep.get();
-
- unsigned numFrames = frameCount();
-
- // If numFrames is zero, we know for certain this image doesn't have valid data
+ // If nativeImages.size() is zero, we know for certain this image doesn't have valid data
// Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully,
// in certain circumstances that call will spam the console with an error message
- if (!numFrames)
- return 0;
+ if (!nativeImages.size())
+ return nullptr;
- Vector<CGImageRef> images;
- for (unsigned i = 0; i < numFrames; ++i ) {
- CGImageRef cgImage = frameImageAtIndex(i).get();
- if (cgImage)
- images.append(cgImage);
- }
-
- unsigned numValidFrames = images.size();
-
RetainPtr<CFMutableDataRef> data = "" 0));
- RetainPtr<CGImageDestinationRef> destination = adoptCF(CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, numValidFrames, 0));
+ RetainPtr<CGImageDestinationRef> destination = adoptCF(CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, nativeImages.size(), 0));
if (!destination)
return 0;
- for (unsigned i = 0; i < numValidFrames; ++i)
- CGImageDestinationAddImage(destination.get(), images[i], 0);
+ for (auto nativeImage : nativeImages)
+ CGImageDestinationAddImage(destination.get(), nativeImage.get(), 0);
CGImageDestinationFinalize(destination.get());
+ return data;
+}
+CFDataRef BitmapImage::tiffRepresentation()
+{
+ if (m_tiffRep)
+ return m_tiffRep.get();
+
+ auto data = ""
+ if (!data)
+ return nullptr;
+
m_tiffRep = data;
return m_tiffRep.get();
}
#if USE(APPKIT)
-NSImage* BitmapImage::getNSImage()
+NSImage* BitmapImage::nsImage()
{
if (m_nsImage)
return m_nsImage.get();
- CFDataRef data = ""
+ CFDataRef data = ""
if (!data)
- return 0;
+ return nullptr;
m_nsImage = adoptNS([[NSImage alloc] initWithData:(NSData*)data]);
return m_nsImage.get();
}
+
+RetainPtr<NSImage> BitmapImage::snapshotNSImage()
+{
+ auto nativeImage = this->nativeImageForCurrentFrame();
+ if (!nativeImage)
+ return nullptr;
+
+ auto data = "" nativeImage });
+ if (!data)
+ return nullptr;
+
+ return adoptNS([[NSImage alloc] initWithData:(NSData *)data.get()]);
+}
#endif
}
Modified: branches/safari-602-branch/Source/WebCore/platform/mac/CursorMac.mm (208161 => 208162)
--- branches/safari-602-branch/Source/WebCore/platform/mac/CursorMac.mm 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebCore/platform/mac/CursorMac.mm 2016-10-31 18:43:25 UTC (rev 208162)
@@ -48,9 +48,9 @@
#endif
{
// FIXME: The cursor won't animate. Not sure if that's a big deal.
- NSImage* nsImage = image->getNSImage();
+ auto nsImage = image->snapshotNSImage();
if (!nsImage)
- return 0;
+ return nullptr;
BEGIN_BLOCK_OBJC_EXCEPTIONS;
#if ENABLE(MOUSE_CURSOR_SCALE)
@@ -78,7 +78,7 @@
[[[nsImage representations] objectAtIndex:0] setSize:expandedSize];
#endif
- return adoptNS([[NSCursor alloc] initWithImage:nsImage hotSpot:hotSpot]);
+ return adoptNS([[NSCursor alloc] initWithImage:nsImage.get() hotSpot:hotSpot]);
END_BLOCK_OBJC_EXCEPTIONS;
return nullptr;
}
Modified: branches/safari-602-branch/Source/WebCore/platform/mac/DragImageMac.mm (208161 => 208162)
--- branches/safari-602-branch/Source/WebCore/platform/mac/DragImageMac.mm 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebCore/platform/mac/DragImageMac.mm 2016-10-31 18:43:25 UTC (rev 208162)
@@ -121,7 +121,7 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- [image->getNSImage() drawInRect:destRect fromRect:NSMakeRect(0, 0, size.width(), size.height()) operation:NSCompositeSourceOver fraction:1.0];
+ [image->snapshotNSImage() drawInRect:destRect fromRect:NSMakeRect(0, 0, size.width(), size.height()) operation:NSCompositeSourceOver fraction:1.0];
#pragma clang diagnostic pop
[rotatedDragImage.get() unlockFocus];
@@ -129,7 +129,7 @@
}
}
- RetainPtr<NSImage> dragImage = adoptNS([image->getNSImage() copy]);
+ auto dragImage = image->snapshotNSImage();
[dragImage.get() setSize:(NSSize)size];
return dragImage;
}
Modified: branches/safari-602-branch/Source/WebCore/platform/mac/PasteboardMac.mm (208161 => 208162)
--- branches/safari-602-branch/Source/WebCore/platform/mac/PasteboardMac.mm 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebCore/platform/mac/PasteboardMac.mm 2016-10-31 18:43:25 UTC (rev 208162)
@@ -255,7 +255,7 @@
void Pasteboard::write(const PasteboardImage& pasteboardImage)
{
- CFDataRef imageData = pasteboardImage.image->getTIFFRepresentation();
+ CFDataRef imageData = pasteboardImage.image->tiffRepresentation();
if (!imageData)
return;
Modified: branches/safari-602-branch/Source/WebKit/mac/ChangeLog (208161 => 208162)
--- branches/safari-602-branch/Source/WebKit/mac/ChangeLog 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebKit/mac/ChangeLog 2016-10-31 18:43:25 UTC (rev 208162)
@@ -1,3 +1,23 @@
+2016-10-31 Matthew Hanson <matthew_han...@apple.com>
+
+ Merge r206802. rdar://problem/28409525
+
+ 2016-10-28 Said Abou-Hallawa <sabouhall...@apple.com>
+
+ The dragged image should be the current frame only of the animated image
+ https://bugs.webkit.org/show_bug.cgi?id=162109
+
+ * Misc/WebElementDictionary.mm:
+ (-[WebElementDictionary _image]): Call the Image function with its new name.
+ * Misc/WebIconDatabase.mm:
+ (-[WebIconDatabase defaultIconWithSize:]): Call snapshotNSImage() to create the icon image.
+ (webGetNSImage): Call the Image function with its new name.
+ * WebCoreSupport/WebContextMenuClient.mm:
+ (WebContextMenuClient::imageForCurrentSharingServicePickerItem): Call snapshotNSImage() instead of nsImage()..
+ (WebContextMenuClient::contextMenuForEvent): Ditto.
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView pasteboard:provideDataForType:]): Call the Image function with its new name.
+
2016-10-26 Babak Shafiei <bshaf...@apple.com>
Merge r207171. rdar://problem/28857503
Modified: branches/safari-602-branch/Source/WebKit/mac/Misc/WebElementDictionary.mm (208161 => 208162)
--- branches/safari-602-branch/Source/WebKit/mac/Misc/WebElementDictionary.mm 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebKit/mac/Misc/WebElementDictionary.mm 2016-10-31 18:43:25 UTC (rev 208162)
@@ -204,7 +204,7 @@
- (NSImage *)_image
{
Image* image = _result->image();
- return image ? image->getNSImage() : nil;
+ return image ? image->nsImage() : nil;
}
- (NSValue *)_imageRect
Modified: branches/safari-602-branch/Source/WebKit/mac/Misc/WebIconDatabase.mm (208161 => 208162)
--- branches/safari-602-branch/Source/WebKit/mac/Misc/WebIconDatabase.mm 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebKit/mac/Misc/WebIconDatabase.mm 2016-10-31 18:43:25 UTC (rev 208162)
@@ -163,7 +163,7 @@
ASSERT(size.height);
Image* image = iconDatabase().defaultIcon(IntSize(size));
- return image ? image->getNSImage() : nil;
+ return image ? image->snapshotNSImage().autorelease() : nil;
}
- (NSImage *)defaultIconForURL:(NSString *)URL withSize:(NSSize)size
@@ -470,7 +470,7 @@
// to WebCore::Image at some point.
if (!image)
return nil;
- NSImage* nsImage = image->getNSImage();
+ NSImage* nsImage = image->nsImage();
if (!nsImage)
return nil;
if (!NSEqualSizes([nsImage size], size)) {
Modified: branches/safari-602-branch/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm (208161 => 208162)
--- branches/safari-602-branch/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm 2016-10-31 18:43:25 UTC (rev 208162)
@@ -226,7 +226,7 @@
if (!image)
return nil;
- return [[image->getNSImage() retain] autorelease];
+ return image->snapshotNSImage();
}
#endif
@@ -242,7 +242,7 @@
if (Image* image = page->contextMenuController().context().controlledImage()) {
ASSERT(page->contextMenuController().context().hitTestResult().innerNode());
- RetainPtr<NSItemProvider> itemProvider = adoptNS([[NSItemProvider alloc] initWithItem:image->getNSImage() typeIdentifier:@"public.image"]);
+ RetainPtr<NSItemProvider> itemProvider = adoptNS([[NSItemProvider alloc] initWithItem:image->snapshotNSImage().autorelease() typeIdentifier:@"public.image"]);
bool isContentEditable = page->contextMenuController().context().hitTestResult().innerNode()->isContentEditable();
m_sharingServicePickerController = adoptNS([[WebSharingServicePickerController alloc] initWithItems:@[ itemProvider.get() ] includeEditorServices:isContentEditable client:this style:NSSharingServicePickerStyleRollover]);
Modified: branches/safari-602-branch/Source/WebKit/mac/WebView/WebHTMLView.mm (208161 => 208162)
--- branches/safari-602-branch/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-10-31 18:43:25 UTC (rev 208162)
@@ -2210,7 +2210,7 @@
[archive release];
} else if ([type isEqual:NSTIFFPboardType] && [self promisedDragTIFFDataSource]) {
if (Image* image = [self promisedDragTIFFDataSource]->image())
- [pasteboard setData:(NSData *)image->getTIFFRepresentation() forType:NSTIFFPboardType];
+ [pasteboard setData:(NSData *)image->tiffRepresentation() forType:NSTIFFPboardType];
[self setPromisedDragTIFFDataSource:0];
}
}
Modified: branches/safari-602-branch/Source/WebKit2/ChangeLog (208161 => 208162)
--- branches/safari-602-branch/Source/WebKit2/ChangeLog 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebKit2/ChangeLog 2016-10-31 18:43:25 UTC (rev 208162)
@@ -1,3 +1,15 @@
+2016-10-31 Matthew Hanson <matthew_han...@apple.com>
+
+ Merge r206802. rdar://problem/28409525
+
+ 2016-10-28 Said Abou-Hallawa <sabouhall...@apple.com>
+
+ The dragged image should be the current frame only of the animated image
+ https://bugs.webkit.org/show_bug.cgi?id=162109
+
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::provideDataForPasteboard): Call the Image function with its new name.
+
2016-10-27 Matthew Hanson <matthew_han...@apple.com>
Merge r206684. rdar://problem/28545011
Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (208161 => 208162)
--- branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm 2016-10-31 17:46:10 UTC (rev 208161)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm 2016-10-31 18:43:25 UTC (rev 208162)
@@ -3032,7 +3032,7 @@
// FIXME: need to support NSRTFDPboardType
if ([type isEqual:NSTIFFPboardType] && m_promisedImage) {
- [pasteboard setData:(NSData *)m_promisedImage->getTIFFRepresentation() forType:NSTIFFPboardType];
+ [pasteboard setData:(NSData *)m_promisedImage->tiffRepresentation() forType:NSTIFFPboardType];
m_promisedImage = nullptr;
}
}