Changeset 206802 in webkit
- Timestamp:
- Oct 4, 2016, 6:52:35 PM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r206801 r206802 1 2016-10-04 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 snapshotNSImage() 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::snapshotNSImage): 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::snapshotNSImage): 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 snapshotNSImage() since the cursor does not animate anyway. 30 * platform/mac/DragImageMac.mm: 31 (WebCore::createDragImageFromImage): Use snapshotNSImage() for the dragImage. 32 * platform/mac/PasteboardMac.mm: 33 (WebCore::Pasteboard::write): Call the Image function with its new name. 34 1 35 2016-10-04 Andy Estes <aestes@apple.com> 2 36 -
trunk/Source/WebCore/dom/DataTransferMac.mm
r206720 r206802 50 50 } 51 51 } else if (m_dragImage) { 52 result = m_dragImage->image()-> getNSImage();52 result = m_dragImage->image()->snapshotNSImage(); 53 53 54 54 location = m_dragLocation; -
trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm
r206720 r206802 2465 2465 auto* image = downcast<RenderImage>(*renderer).cachedImage(); 2466 2466 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()]); 2468 2468 [wrapper setPreferredFilename:@"image.tiff"]; 2469 2469 return wrapper; -
trunk/Source/WebCore/platform/graphics/BitmapImage.h
r206742 r206802 97 97 // Accessors for native image formats. 98 98 #if USE(APPKIT) 99 NSImage* getNSImage() override; 99 NSImage *nsImage() override; 100 RetainPtr<NSImage> snapshotNSImage() override; 100 101 #endif 101 102 102 103 #if PLATFORM(COCOA) 103 CFDataRef getTIFFRepresentation() override;104 CFDataRef tiffRepresentation() override; 104 105 #endif 105 106 … … 179 180 #endif 180 181 182 #if PLATFORM(COCOA) 183 RetainPtr<CFDataRef> tiffRepresentation(const Vector<NativeImagePtr>&); 184 #endif 185 181 186 private: 182 187 void clearTimer(); … … 195 200 196 201 #if USE(APPKIT) 197 mutable RetainPtr<NSImage> m_nsImage; // A cached NSImage of frame 0. Only built lazily if someone actually queries for one.202 mutable RetainPtr<NSImage> m_nsImage; // A cached NSImage of all the frames. Only built lazily if someone actually queries for one. 198 203 #endif 199 204 #if USE(CG) 200 mutable RetainPtr<CFDataRef> m_tiffRep; // Cached TIFF rep for frame 0. Only built lazily if someone queries for one.205 mutable RetainPtr<CFDataRef> m_tiffRep; // Cached TIFF rep for all the frames. Only built lazily if someone queries for one. 201 206 #endif 202 207 RefPtr<Image> m_cachedImage; -
trunk/Source/WebCore/platform/graphics/Image.h
r206720 r206802 147 147 148 148 #if USE(APPKIT) 149 virtual NSImage* getNSImage() { return nullptr; } 149 virtual NSImage *nsImage() { return nullptr; } 150 virtual RetainPtr<NSImage> snapshotNSImage() { return nullptr; } 150 151 #endif 151 152 152 153 #if PLATFORM(COCOA) 153 virtual CFDataRef getTIFFRepresentation() { return nullptr; }154 virtual CFDataRef tiffRepresentation() { return nullptr; } 154 155 #endif 155 156 … … 194 195 // Supporting tiled drawing 195 196 virtual Color singlePixelSolidColor() const { return Color(); } 196 197 197 198 private: 198 199 RefPtr<SharedBuffer> m_encodedImageData; -
trunk/Source/WebCore/platform/graphics/mac/ImageMac.mm
r206720 r206802 75 75 } 76 76 77 CFDataRef BitmapImage::getTIFFRepresentation()77 RetainPtr<CFDataRef> BitmapImage::tiffRepresentation(const Vector<NativeImagePtr>& nativeImages) 78 78 { 79 if (m_tiffRep) 80 return m_tiffRep.get(); 81 82 auto nativeImages = this->framesNativeImages(); 83 84 // If framesImages.size() is zero, we know for certain this image doesn't have valid data 79 // If nativeImages.size() is zero, we know for certain this image doesn't have valid data 85 80 // Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully, 86 81 // in certain circumstances that call will spam the console with an error message … … 98 93 99 94 CGImageDestinationFinalize(destination.get()); 95 return data; 96 } 97 98 CFDataRef BitmapImage::tiffRepresentation() 99 { 100 if (m_tiffRep) 101 return m_tiffRep.get(); 102 103 auto data = tiffRepresentation(framesNativeImages()); 104 if (!data) 105 return nullptr; 100 106 101 107 m_tiffRep = data; 102 108 return m_tiffRep.get(); 109 110 103 111 } 104 112 105 113 #if USE(APPKIT) 106 NSImage* BitmapImage:: getNSImage()114 NSImage* BitmapImage::nsImage() 107 115 { 108 116 if (m_nsImage) 109 117 return m_nsImage.get(); 110 118 111 CFDataRef data = getTIFFRepresentation();119 CFDataRef data = tiffRepresentation(); 112 120 if (!data) 113 return 0;121 return nullptr; 114 122 115 123 m_nsImage = adoptNS([[NSImage alloc] initWithData:(NSData*)data]); 116 124 return m_nsImage.get(); 117 125 } 126 127 RetainPtr<NSImage> BitmapImage::snapshotNSImage() 128 { 129 auto nativeImage = this->nativeImageForCurrentFrame(); 130 if (!nativeImage) 131 return nullptr; 132 133 auto data = tiffRepresentation({ nativeImage }); 134 if (!data) 135 return nullptr; 136 137 return adoptNS([[NSImage alloc] initWithData:(NSData*)data.get()]); 138 } 118 139 #endif 119 140 -
trunk/Source/WebCore/platform/mac/CursorMac.mm
r206720 r206802 49 49 { 50 50 // FIXME: The cursor won't animate. Not sure if that's a big deal. 51 NSImage* nsImage = image->getNSImage();51 auto nsImage = image->snapshotNSImage(); 52 52 if (!nsImage) 53 return 0;53 return nullptr; 54 54 BEGIN_BLOCK_OBJC_EXCEPTIONS; 55 55 … … 79 79 #endif 80 80 81 return adoptNS([[NSCursor alloc] initWithImage:nsImage hotSpot:hotSpot]);81 return adoptNS([[NSCursor alloc] initWithImage:nsImage.get() hotSpot:hotSpot]); 82 82 END_BLOCK_OBJC_EXCEPTIONS; 83 83 return nullptr; -
trunk/Source/WebCore/platform/mac/DragImageMac.mm
r206720 r206802 122 122 #pragma clang diagnostic push 123 123 #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->snapshotNSImage() drawInRect:destRect fromRect:NSMakeRect(0, 0, size.width(), size.height()) operation:NSCompositeSourceOver fraction:1.0]; 125 125 #pragma clang diagnostic pop 126 126 [rotatedDragImage.get() unlockFocus]; … … 130 130 } 131 131 132 RetainPtr<NSImage> dragImage = adoptNS([image->getNSImage() copy]);132 auto dragImage = image->snapshotNSImage(); 133 133 [dragImage.get() setSize:(NSSize)size]; 134 134 return dragImage; -
trunk/Source/WebCore/platform/mac/PasteboardMac.mm
r206720 r206802 256 256 void Pasteboard::write(const PasteboardImage& pasteboardImage) 257 257 { 258 CFDataRef imageData = pasteboardImage.image-> getTIFFRepresentation();258 CFDataRef imageData = pasteboardImage.image->tiffRepresentation(); 259 259 if (!imageData) 260 260 return; -
trunk/Source/WebKit/mac/ChangeLog
r206720 r206802 1 2016-10-04 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 snapshotNSImage() to create the icon image. 15 (webGetNSImage): Call the Image function with its new name. 16 * WebCoreSupport/WebContextMenuClient.mm: 17 (WebContextMenuClient::imageForCurrentSharingServicePickerItem): Call snapshotNSImage() instead of nsImage().. 18 (WebContextMenuClient::contextMenuForEvent): Ditto. 19 * WebView/WebHTMLView.mm: 20 (-[WebHTMLView pasteboard:provideDataForType:]): Call the Image function with its new name. 21 1 22 2016-10-02 Ryan Haddad <ryanhaddad@apple.com> 2 23 -
trunk/Source/WebKit/mac/DOM/DOM.mm
r206720 r206802 671 671 if (!cachedImage || cachedImage->errorOccurred()) 672 672 return nil; 673 return cachedImage->imageForRenderer(renderer)-> getNSImage();673 return cachedImage->imageForRenderer(renderer)->nsImage(); 674 674 } 675 675 … … 699 699 if (!cachedImage || cachedImage->errorOccurred()) 700 700 return nil; 701 return (NSData *)cachedImage->imageForRenderer(renderer)-> getTIFFRepresentation();701 return (NSData *)cachedImage->imageForRenderer(renderer)->tiffRepresentation(); 702 702 } 703 703 -
trunk/Source/WebKit/mac/Misc/WebElementDictionary.mm
r206720 r206802 205 205 { 206 206 Image* image = _result->image(); 207 return image ? image-> getNSImage() : nil;207 return image ? image->nsImage() : nil; 208 208 } 209 209 -
trunk/Source/WebKit/mac/Misc/WebIconDatabase.mm
r206720 r206802 164 164 165 165 Image* image = iconDatabase().defaultIcon(IntSize(size)); 166 return image ? image-> getNSImage() : nil;166 return image ? image->snapshotNSImage().autorelease() : nil; 167 167 } 168 168 … … 471 471 if (!image) 472 472 return nil; 473 NSImage* nsImage = image-> getNSImage();473 NSImage* nsImage = image->nsImage(); 474 474 if (!nsImage) 475 475 return nil; -
trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm
r206720 r206802 227 227 return nil; 228 228 229 return [[image->getNSImage() retain] autorelease];229 return image->snapshotNSImage(); 230 230 } 231 231 #endif … … 243 243 ASSERT(page->contextMenuController().context().hitTestResult().innerNode()); 244 244 245 RetainPtr<NSItemProvider> itemProvider = adoptNS([[NSItemProvider alloc] initWithItem:image-> getNSImage() typeIdentifier:@"public.image"]);245 RetainPtr<NSItemProvider> itemProvider = adoptNS([[NSItemProvider alloc] initWithItem:image->snapshotNSImage().autorelease() typeIdentifier:@"public.image"]); 246 246 247 247 bool isContentEditable = page->contextMenuController().context().hitTestResult().innerNode()->isContentEditable(); -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r206720 r206802 2211 2211 } else if ([type isEqual:NSTIFFPboardType] && [self promisedDragTIFFDataSource]) { 2212 2212 if (Image* image = [self promisedDragTIFFDataSource]->image()) 2213 [pasteboard setData:(NSData *)image-> getTIFFRepresentation() forType:NSTIFFPboardType];2213 [pasteboard setData:(NSData *)image->tiffRepresentation() forType:NSTIFFPboardType]; 2214 2214 [self setPromisedDragTIFFDataSource:0]; 2215 2215 } -
trunk/Source/WebKit2/ChangeLog
r206799 r206802 1 2016-10-04 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 1 11 2016-10-04 Ryosuke Niwa <rniwa@webkit.org> 2 12 -
trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm
r206720 r206802 3039 3039 3040 3040 if ([type isEqual:NSTIFFPboardType] && m_promisedImage) { 3041 [pasteboard setData:(NSData *)m_promisedImage-> getTIFFRepresentation() forType:NSTIFFPboardType];3041 [pasteboard setData:(NSData *)m_promisedImage->tiffRepresentation() forType:NSTIFFPboardType]; 3042 3042 m_promisedImage = nullptr; 3043 3043 }
Note:
See TracChangeset
for help on using the changeset viewer.