<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[208162] branches/safari-602-branch/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/208162">208162</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2016-10-31 11:43:25 -0700 (Mon, 31 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/206802">r206802</a>. rdar://problem/28409525</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari602branchSourceWebCoreChangeLog">branches/safari-602-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari602branchSourceWebCorebindingsobjcDOMmm">branches/safari-602-branch/Source/WebCore/bindings/objc/DOM.mm</a></li>
<li><a href="#branchessafari602branchSourceWebCoredomDataTransferMacmm">branches/safari-602-branch/Source/WebCore/dom/DataTransferMac.mm</a></li>
<li><a href="#branchessafari602branchSourceWebCoreeditingcocoaHTMLConvertermm">branches/safari-602-branch/Source/WebCore/editing/cocoa/HTMLConverter.mm</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformgraphicsBitmapImagecpp">branches/safari-602-branch/Source/WebCore/platform/graphics/BitmapImage.cpp</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformgraphicsBitmapImageh">branches/safari-602-branch/Source/WebCore/platform/graphics/BitmapImage.h</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformgraphicsImageh">branches/safari-602-branch/Source/WebCore/platform/graphics/Image.h</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformgraphicsmacImageMacmm">branches/safari-602-branch/Source/WebCore/platform/graphics/mac/ImageMac.mm</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformmacCursorMacmm">branches/safari-602-branch/Source/WebCore/platform/mac/CursorMac.mm</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformmacDragImageMacmm">branches/safari-602-branch/Source/WebCore/platform/mac/DragImageMac.mm</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformmacPasteboardMacmm">branches/safari-602-branch/Source/WebCore/platform/mac/PasteboardMac.mm</a></li>
<li><a href="#branchessafari602branchSourceWebKitmacChangeLog">branches/safari-602-branch/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#branchessafari602branchSourceWebKitmacMiscWebElementDictionarymm">branches/safari-602-branch/Source/WebKit/mac/Misc/WebElementDictionary.mm</a></li>
<li><a href="#branchessafari602branchSourceWebKitmacMiscWebIconDatabasemm">branches/safari-602-branch/Source/WebKit/mac/Misc/WebIconDatabase.mm</a></li>
<li><a href="#branchessafari602branchSourceWebKitmacWebCoreSupportWebContextMenuClientmm">branches/safari-602-branch/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm</a></li>
<li><a href="#branchessafari602branchSourceWebKitmacWebViewWebHTMLViewmm">branches/safari-602-branch/Source/WebKit/mac/WebView/WebHTMLView.mm</a></li>
<li><a href="#branchessafari602branchSourceWebKit2ChangeLog">branches/safari-602-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessCocoaWebViewImplmm">branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari602branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/ChangeLog (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2016-10-31  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+        Merge r206802. rdar://problem/28409525
+
+    2016-10-28  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+            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.
+
</ins><span class="cx"> 2016-10-27  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge r207848. rdar://problem/28216276
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCorebindingsobjcDOMmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/bindings/objc/DOM.mm (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -713,7 +713,7 @@
</span><span class="cx">     auto* cachedImage = downcast&lt;RenderImage&gt;(*renderer).cachedImage();
</span><span class="cx">     if (!cachedImage || cachedImage-&gt;errorOccurred())
</span><span class="cx">         return nil;
</span><del>-    return cachedImage-&gt;imageForRenderer(renderer)-&gt;getNSImage();
</del><ins>+    return cachedImage-&gt;imageForRenderer(renderer)-&gt;nsImage();
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -739,7 +739,7 @@
</span><span class="cx">     WebCore::CachedImage* cachedImage = downcast&lt;RenderImage&gt;(*renderer).cachedImage();
</span><span class="cx">     if (!cachedImage || cachedImage-&gt;errorOccurred())
</span><span class="cx">         return nil;
</span><del>-    return (NSData *)cachedImage-&gt;imageForRenderer(renderer)-&gt;getTIFFRepresentation();
</del><ins>+    return (NSData *)cachedImage-&gt;imageForRenderer(renderer)-&gt;tiffRepresentation();
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoredomDataTransferMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/dom/DataTransferMac.mm (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx">             location.setY(imageRect.height() - (elementRect.y() - imageRect.y() + m_dragLocation.y()));
</span><span class="cx">         }
</span><span class="cx">     } else if (m_dragImage) {
</span><del>-        result = m_dragImage-&gt;image()-&gt;getNSImage();
</del><ins>+        result = m_dragImage-&gt;image()-&gt;snapshotNSImage();
</ins><span class="cx">         
</span><span class="cx">         location = m_dragLocation;
</span><span class="cx">         location.setY([result size].height - location.y());
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreeditingcocoaHTMLConvertermm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/editing/cocoa/HTMLConverter.mm (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -2464,7 +2464,7 @@
</span><span class="cx">     if (is&lt;RenderImage&gt;(renderer)) {
</span><span class="cx">         auto* image = downcast&lt;RenderImage&gt;(*renderer).cachedImage();
</span><span class="cx">         if (image &amp;&amp; !image-&gt;errorOccurred()) {
</span><del>-            RetainPtr&lt;NSFileWrapper&gt; wrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:(NSData *)image-&gt;imageForRenderer(renderer)-&gt;getTIFFRepresentation()]);
</del><ins>+            RetainPtr&lt;NSFileWrapper&gt; wrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:(NSData *)image-&gt;imageForRenderer(renderer)-&gt;tiffRepresentation()]);
</ins><span class="cx">             [wrapper setPreferredFilename:@&quot;image.tiff&quot;];
</span><span class="cx">             return wrapper;
</span><span class="cx">         }
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformgraphicsBitmapImagecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/BitmapImage.cpp (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -426,6 +426,21 @@
</span><span class="cx">     return frameImageAtIndex(currentFrame());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if USE(CG)
+Vector&lt;NativeImagePtr&gt; BitmapImage::framesNativeImages()
+{
+    Vector&lt;NativeImagePtr&gt; images;
+    size_t count = frameCount();
+
+    for (size_t i = 0; i &lt; count; ++i) {
+        if (auto image = frameImageAtIndex(i))
+            images.append(image);
+    }
+
+    return images;
+}
+#endif
+
</ins><span class="cx"> bool BitmapImage::frameHasAlphaAtIndex(size_t index)
</span><span class="cx"> {
</span><span class="cx">     if (!ensureFrameIsCached(index, CacheMetadataOnly))
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformgraphicsBitmapImageh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/BitmapImage.h (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -148,11 +148,12 @@
</span><span class="cx">     // Accessors for native image formats.
</span><span class="cx"> 
</span><span class="cx"> #if USE(APPKIT)
</span><del>-    NSImage* getNSImage() override;
</del><ins>+    NSImage *nsImage() override;
+    RetainPtr&lt;NSImage&gt; snapshotNSImage() override;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><del>-    CFDataRef getTIFFRepresentation() override;
</del><ins>+    CFDataRef tiffRepresentation() override;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(CG)
</span><span class="lines">@@ -176,6 +177,9 @@
</span><span class="cx"> 
</span><span class="cx">     NativeImagePtr nativeImageForCurrentFrame() override;
</span><span class="cx">     ImageOrientation orientationForCurrentFrame() override { return frameOrientationAtIndex(currentFrame()); }
</span><ins>+#if USE(CG)
+    Vector&lt;NativeImagePtr&gt; framesNativeImages() override;
+#endif
</ins><span class="cx"> 
</span><span class="cx">     bool currentFrameKnownToBeOpaque() override;
</span><span class="cx"> 
</span><span class="lines">@@ -281,6 +285,10 @@
</span><span class="cx">     bool notSolidColor() override;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(COCOA)
+    RetainPtr&lt;CFDataRef&gt; tiffRepresentation(const Vector&lt;NativeImagePtr&gt;&amp;);
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx">     void clearTimer();
</span><span class="cx">     void startTimer(double delay);
</span><span class="lines">@@ -301,10 +309,10 @@
</span><span class="cx">     double m_desiredFrameStartTime { 0 }; // The system time at which we hope to see the next call to startAnimation().
</span><span class="cx"> 
</span><span class="cx"> #if USE(APPKIT)
</span><del>-    mutable RetainPtr&lt;NSImage&gt; m_nsImage; // A cached NSImage of frame 0. Only built lazily if someone actually queries for one.
</del><ins>+    mutable RetainPtr&lt;NSImage&gt; m_nsImage; // A cached NSImage of all the frames. Only built lazily if someone actually queries for one.
</ins><span class="cx"> #endif
</span><span class="cx"> #if USE(CG)
</span><del>-    mutable RetainPtr&lt;CFDataRef&gt; m_tiffRep; // Cached TIFF rep for frame 0. Only built lazily if someone queries for one.
</del><ins>+    mutable RetainPtr&lt;CFDataRef&gt; m_tiffRep; // Cached TIFF rep for all the frames. Only built lazily if someone queries for one.
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     // 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
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformgraphicsImageh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/Image.h (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -139,15 +139,17 @@
</span><span class="cx"> 
</span><span class="cx">     virtual NativeImagePtr nativeImageForCurrentFrame() { return nullptr; }
</span><span class="cx">     virtual ImageOrientation orientationForCurrentFrame() { return ImageOrientation(); }
</span><ins>+    virtual Vector&lt;NativeImagePtr&gt; framesNativeImages() { return { }; }
</ins><span class="cx"> 
</span><span class="cx">     // Accessors for native image formats.
</span><span class="cx"> 
</span><span class="cx"> #if USE(APPKIT)
</span><del>-    virtual NSImage* getNSImage() { return nullptr; }
</del><ins>+    virtual NSImage *nsImage() { return nullptr; }
+    virtual RetainPtr&lt;NSImage&gt; snapshotNSImage() { return nullptr; }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><del>-    virtual CFDataRef getTIFFRepresentation() { return nullptr; }
</del><ins>+    virtual CFDataRef tiffRepresentation() { return nullptr; }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(CG)
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformgraphicsmacImageMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/mac/ImageMac.mm (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -80,56 +80,66 @@
</span><span class="cx">     return Image::nullImage();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-CFDataRef BitmapImage::getTIFFRepresentation()
</del><ins>+RetainPtr&lt;CFDataRef&gt; BitmapImage::tiffRepresentation(const Vector&lt;NativeImagePtr&gt;&amp; nativeImages)
</ins><span class="cx"> {
</span><del>-    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
</del><ins>+    // If nativeImages.size() is zero, we know for certain this image doesn't have valid data
</ins><span class="cx">     // Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully,
</span><span class="cx">     // in certain circumstances that call will spam the console with an error message
</span><del>-    if (!numFrames)
-        return 0;
</del><ins>+    if (!nativeImages.size())
+        return nullptr;
</ins><span class="cx"> 
</span><del>-    Vector&lt;CGImageRef&gt; images;
-    for (unsigned i = 0; i &lt; numFrames; ++i ) {
-        CGImageRef cgImage = frameImageAtIndex(i).get();
-        if (cgImage)
-            images.append(cgImage);
-    }
-
-    unsigned numValidFrames = images.size();
-
</del><span class="cx">     RetainPtr&lt;CFMutableDataRef&gt; data = adoptCF(CFDataCreateMutable(0, 0));
</span><del>-    RetainPtr&lt;CGImageDestinationRef&gt; destination = adoptCF(CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, numValidFrames, 0));
</del><ins>+    RetainPtr&lt;CGImageDestinationRef&gt; destination = adoptCF(CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, nativeImages.size(), 0));
</ins><span class="cx"> 
</span><span class="cx">     if (!destination)
</span><span class="cx">         return 0;
</span><span class="cx"> 
</span><del>-    for (unsigned i = 0; i &lt; numValidFrames; ++i)
-        CGImageDestinationAddImage(destination.get(), images[i], 0);
</del><ins>+    for (auto nativeImage : nativeImages)
+        CGImageDestinationAddImage(destination.get(), nativeImage.get(), 0);
</ins><span class="cx"> 
</span><span class="cx">     CGImageDestinationFinalize(destination.get());
</span><ins>+    return data;
+}
</ins><span class="cx"> 
</span><ins>+CFDataRef BitmapImage::tiffRepresentation()
+{
+    if (m_tiffRep)
+        return m_tiffRep.get();
+
+    auto data = tiffRepresentation(framesNativeImages());
+    if (!data)
+        return nullptr;
+
</ins><span class="cx">     m_tiffRep = data;
</span><span class="cx">     return m_tiffRep.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if USE(APPKIT)
</span><del>-NSImage* BitmapImage::getNSImage()
</del><ins>+NSImage* BitmapImage::nsImage()
</ins><span class="cx"> {
</span><span class="cx">     if (m_nsImage)
</span><span class="cx">         return m_nsImage.get();
</span><span class="cx"> 
</span><del>-    CFDataRef data = getTIFFRepresentation();
</del><ins>+    CFDataRef data = tiffRepresentation();
</ins><span class="cx">     if (!data)
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     
</span><span class="cx">     m_nsImage = adoptNS([[NSImage alloc] initWithData:(NSData*)data]);
</span><span class="cx">     return m_nsImage.get();
</span><span class="cx"> }
</span><ins>+
+RetainPtr&lt;NSImage&gt; BitmapImage::snapshotNSImage()
+{
+    auto nativeImage = this-&gt;nativeImageForCurrentFrame();
+    if (!nativeImage)
+        return nullptr;
+
+    auto data = tiffRepresentation({ nativeImage });
+    if (!data)
+        return nullptr;
+
+    return adoptNS([[NSImage alloc] initWithData:(NSData *)data.get()]);
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformmacCursorMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/mac/CursorMac.mm (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -48,9 +48,9 @@
</span><span class="cx"> #endif
</span><span class="cx"> {
</span><span class="cx">     // FIXME: The cursor won't animate.  Not sure if that's a big deal.
</span><del>-    NSImage* nsImage = image-&gt;getNSImage();
</del><ins>+    auto nsImage = image-&gt;snapshotNSImage();
</ins><span class="cx">     if (!nsImage)
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     BEGIN_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MOUSE_CURSOR_SCALE)
</span><span class="lines">@@ -78,7 +78,7 @@
</span><span class="cx">     [[[nsImage representations] objectAtIndex:0] setSize:expandedSize];
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    return adoptNS([[NSCursor alloc] initWithImage:nsImage hotSpot:hotSpot]);
</del><ins>+    return adoptNS([[NSCursor alloc] initWithImage:nsImage.get() hotSpot:hotSpot]);
</ins><span class="cx">     END_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformmacDragImageMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/mac/DragImageMac.mm (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -121,7 +121,7 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma clang diagnostic push
</span><span class="cx"> #pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
</span><del>-            [image-&gt;getNSImage() drawInRect:destRect fromRect:NSMakeRect(0, 0, size.width(), size.height()) operation:NSCompositeSourceOver fraction:1.0];
</del><ins>+            [image-&gt;snapshotNSImage() drawInRect:destRect fromRect:NSMakeRect(0, 0, size.width(), size.height()) operation:NSCompositeSourceOver fraction:1.0];
</ins><span class="cx"> #pragma clang diagnostic pop
</span><span class="cx">             [rotatedDragImage.get() unlockFocus];
</span><span class="cx"> 
</span><span class="lines">@@ -129,7 +129,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    RetainPtr&lt;NSImage&gt; dragImage = adoptNS([image-&gt;getNSImage() copy]);
</del><ins>+    auto dragImage = image-&gt;snapshotNSImage();
</ins><span class="cx">     [dragImage.get() setSize:(NSSize)size];
</span><span class="cx">     return dragImage;
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformmacPasteboardMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/mac/PasteboardMac.mm (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -255,7 +255,7 @@
</span><span class="cx"> 
</span><span class="cx"> void Pasteboard::write(const PasteboardImage&amp; pasteboardImage)
</span><span class="cx"> {
</span><del>-    CFDataRef imageData = pasteboardImage.image-&gt;getTIFFRepresentation();
</del><ins>+    CFDataRef imageData = pasteboardImage.image-&gt;tiffRepresentation();
</ins><span class="cx">     if (!imageData)
</span><span class="cx">         return;
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit/mac/ChangeLog (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-10-31  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+        Merge r206802. rdar://problem/28409525
+
+    2016-10-28  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+            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.
+
</ins><span class="cx"> 2016-10-26  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge r207171. rdar://problem/28857503
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKitmacMiscWebElementDictionarymm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit/mac/Misc/WebElementDictionary.mm (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -204,7 +204,7 @@
</span><span class="cx"> - (NSImage *)_image
</span><span class="cx"> {
</span><span class="cx">     Image* image = _result-&gt;image();
</span><del>-    return image ? image-&gt;getNSImage() : nil;
</del><ins>+    return image ? image-&gt;nsImage() : nil;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (NSValue *)_imageRect
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKitmacMiscWebIconDatabasemm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit/mac/Misc/WebIconDatabase.mm (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -163,7 +163,7 @@
</span><span class="cx">     ASSERT(size.height);
</span><span class="cx">     
</span><span class="cx">     Image* image = iconDatabase().defaultIcon(IntSize(size));
</span><del>-    return image ? image-&gt;getNSImage() : nil;
</del><ins>+    return image ? image-&gt;snapshotNSImage().autorelease() : nil;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (NSImage *)defaultIconForURL:(NSString *)URL withSize:(NSSize)size
</span><span class="lines">@@ -470,7 +470,7 @@
</span><span class="cx">     // to WebCore::Image at some point.
</span><span class="cx">     if (!image)
</span><span class="cx">         return nil;
</span><del>-    NSImage* nsImage = image-&gt;getNSImage();
</del><ins>+    NSImage* nsImage = image-&gt;nsImage();
</ins><span class="cx">     if (!nsImage)
</span><span class="cx">         return nil;
</span><span class="cx">     if (!NSEqualSizes([nsImage size], size)) {
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKitmacWebCoreSupportWebContextMenuClientmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -226,7 +226,7 @@
</span><span class="cx">     if (!image)
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><del>-    return [[image-&gt;getNSImage() retain] autorelease];
</del><ins>+    return image-&gt;snapshotNSImage();
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -242,7 +242,7 @@
</span><span class="cx">     if (Image* image = page-&gt;contextMenuController().context().controlledImage()) {
</span><span class="cx">         ASSERT(page-&gt;contextMenuController().context().hitTestResult().innerNode());
</span><span class="cx"> 
</span><del>-        RetainPtr&lt;NSItemProvider&gt; itemProvider = adoptNS([[NSItemProvider alloc] initWithItem:image-&gt;getNSImage() typeIdentifier:@&quot;public.image&quot;]);
</del><ins>+        RetainPtr&lt;NSItemProvider&gt; itemProvider = adoptNS([[NSItemProvider alloc] initWithItem:image-&gt;snapshotNSImage().autorelease() typeIdentifier:@&quot;public.image&quot;]);
</ins><span class="cx"> 
</span><span class="cx">         bool isContentEditable = page-&gt;contextMenuController().context().hitTestResult().innerNode()-&gt;isContentEditable();
</span><span class="cx">         m_sharingServicePickerController = adoptNS([[WebSharingServicePickerController alloc] initWithItems:@[ itemProvider.get() ] includeEditorServices:isContentEditable client:this style:NSSharingServicePickerStyleRollover]);
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKitmacWebViewWebHTMLViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit/mac/WebView/WebHTMLView.mm (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -2210,7 +2210,7 @@
</span><span class="cx">         [archive release];
</span><span class="cx">     } else if ([type isEqual:NSTIFFPboardType] &amp;&amp; [self promisedDragTIFFDataSource]) {
</span><span class="cx">         if (Image* image = [self promisedDragTIFFDataSource]-&gt;image())
</span><del>-            [pasteboard setData:(NSData *)image-&gt;getTIFFRepresentation() forType:NSTIFFPboardType];
</del><ins>+            [pasteboard setData:(NSData *)image-&gt;tiffRepresentation() forType:NSTIFFPboardType];
</ins><span class="cx">         [self setPromisedDragTIFFDataSource:0];
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/ChangeLog (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-10-31  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+        Merge r206802. rdar://problem/28409525
+
+    2016-10-28  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+            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.
+
</ins><span class="cx"> 2016-10-27  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge r206684. rdar://problem/28545011
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessCocoaWebViewImplmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (208161 => 208162)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -3032,7 +3032,7 @@
</span><span class="cx">     // FIXME: need to support NSRTFDPboardType
</span><span class="cx"> 
</span><span class="cx">     if ([type isEqual:NSTIFFPboardType] &amp;&amp; m_promisedImage) {
</span><del>-        [pasteboard setData:(NSData *)m_promisedImage-&gt;getTIFFRepresentation() forType:NSTIFFPboardType];
</del><ins>+        [pasteboard setData:(NSData *)m_promisedImage-&gt;tiffRepresentation() forType:NSTIFFPboardType];
</ins><span class="cx">         m_promisedImage = nullptr;
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>