<!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>[213842] releases/WebKitGTK/webkit-2.16/Source/WebCore</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/213842">213842</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2017-03-13 06:26:15 -0700 (Mon, 13 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/213833">r213833</a> - ImageDecoder can be deleted while the async decoder thread is still using it
https://bugs.webkit.org/show_bug.cgi?id=169199

Reviewed by Carlos Garcia Campos.

Make the image decoder used by ImageSource and ImageFrameCache into a RefPtr instead of
and unique_ptr, and pass a reference to the decoder thread. This ensures that the decoder
will stay alive as long as the decoding thread is processing frames. Also, stop the async
decoding queue if a new decoder is set to ImageFrameCache.

No new tests.

* platform/graphics/ImageFrameCache.cpp:
(WebCore::ImageFrameCache::setDecoder):
(WebCore::ImageFrameCache::decoder):
(WebCore::ImageFrameCache::startAsyncDecodingQueue):
(WebCore::ImageFrameCache::metadata):
* platform/graphics/ImageFrameCache.h:
(WebCore::ImageFrameCache::setDecoder): Deleted.
Moved to source file so we can keep the ImageDecoder forward declaration.
(WebCore::ImageFrameCache::decoder): Deleted.
Moved to source file so we can keep the ImageDecoder forward declaration.
* platform/graphics/ImageSource.h:
* platform/graphics/cg/ImageDecoderCG.h:
(WebCore::ImageDecoder::create):
* platform/graphics/win/ImageDecoderDirect2D.h:
(WebCore::ImageDecoder::create):
* platform/image-decoders/ImageDecoder.cpp:
(WebCore::ImageDecoder::create):
* platform/image-decoders/ImageDecoder.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCoreplatformgraphicsImageFrameCachecpp">releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/ImageFrameCache.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCoreplatformgraphicsImageFrameCacheh">releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/ImageFrameCache.h</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCoreplatformgraphicsImageSourceh">releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/ImageSource.h</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCoreplatformgraphicscgImageDecoderCGh">releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCoreplatformgraphicswinImageDecoderDirect2Dh">releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCoreplatformimagedecodersImageDecodercpp">releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/image-decoders/ImageDecoder.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCoreplatformimagedecodersImageDecoderh">releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/image-decoders/ImageDecoder.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit216SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog (213841 => 213842)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog        2017-03-13 13:24:51 UTC (rev 213841)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog        2017-03-13 13:26:15 UTC (rev 213842)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2017-03-13  Miguel Gomez  &lt;magomez@igalia.com&gt;
+
+        ImageDecoder can be deleted while the async decoder thread is still using it
+        https://bugs.webkit.org/show_bug.cgi?id=169199
+
+        Reviewed by Carlos Garcia Campos.
+
+        Make the image decoder used by ImageSource and ImageFrameCache into a RefPtr instead of
+        and unique_ptr, and pass a reference to the decoder thread. This ensures that the decoder
+        will stay alive as long as the decoding thread is processing frames. Also, stop the async
+        decoding queue if a new decoder is set to ImageFrameCache.
+
+        No new tests.
+
+        * platform/graphics/ImageFrameCache.cpp:
+        (WebCore::ImageFrameCache::setDecoder):
+        (WebCore::ImageFrameCache::decoder):
+        (WebCore::ImageFrameCache::startAsyncDecodingQueue):
+        (WebCore::ImageFrameCache::metadata):
+        * platform/graphics/ImageFrameCache.h:
+        (WebCore::ImageFrameCache::setDecoder): Deleted.
+        Moved to source file so we can keep the ImageDecoder forward declaration.
+        (WebCore::ImageFrameCache::decoder): Deleted.
+        Moved to source file so we can keep the ImageDecoder forward declaration.
+        * platform/graphics/ImageSource.h:
+        * platform/graphics/cg/ImageDecoderCG.h:
+        (WebCore::ImageDecoder::create):
+        * platform/graphics/win/ImageDecoderDirect2D.h:
+        (WebCore::ImageDecoder::create):
+        * platform/image-decoders/ImageDecoder.cpp:
+        (WebCore::ImageDecoder::create):
+        * platform/image-decoders/ImageDecoder.h:
+
</ins><span class="cx"> 2017-03-10  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute.html is unreliable
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCoreplatformgraphicsImageFrameCachecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/ImageFrameCache.cpp (213841 => 213842)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/ImageFrameCache.cpp        2017-03-13 13:24:51 UTC (rev 213841)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/ImageFrameCache.cpp        2017-03-13 13:26:15 UTC (rev 213842)
</span><span class="lines">@@ -70,6 +70,23 @@
</span><span class="cx">     ASSERT(!hasDecodingQueue());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ImageFrameCache::setDecoder(ImageDecoder* decoder)
+{
+    if (m_decoder == decoder)
+        return;
+
+    // Changing the decoder has to stop the decoding thread. The current frame will
+    // continue decoding safely because the decoding thread has its own
+    // reference of the old decoder.
+    stopAsyncDecodingQueue();
+    m_decoder = decoder;
+}
+
+ImageDecoder* ImageFrameCache::decoder() const
+{
+    return m_decoder.get();
+}
+
</ins><span class="cx"> void ImageFrameCache::destroyDecodedData(size_t frameCount, size_t excludeFrame)
</span><span class="cx"> {
</span><span class="cx">     unsigned decodedSize = 0;
</span><span class="lines">@@ -270,14 +287,15 @@
</span><span class="cx"> 
</span><span class="cx">     Ref&lt;ImageFrameCache&gt; protectedThis = Ref&lt;ImageFrameCache&gt;(*this);
</span><span class="cx">     Ref&lt;WorkQueue&gt; protectedQueue = decodingQueue();
</span><ins>+    Ref&lt;ImageDecoder&gt; protectedDecoder = Ref&lt;ImageDecoder&gt;(*m_decoder);
</ins><span class="cx"> 
</span><del>-    // We need to protect this and m_decodingQueue from being deleted while we are in the decoding loop.
-    decodingQueue()-&gt;dispatch([this, protectedThis = WTFMove(protectedThis), protectedQueue = WTFMove(protectedQueue)] {
</del><ins>+    // We need to protect this, m_decodingQueue and m_decoder from being deleted while we are in the decoding loop.
+    decodingQueue()-&gt;dispatch([this, protectedThis = WTFMove(protectedThis), protectedQueue = WTFMove(protectedQueue), protectedDecoder = WTFMove(protectedDecoder)] {
</ins><span class="cx">         ImageFrameRequest frameRequest;
</span><span class="cx"> 
</span><span class="cx">         while (m_frameRequestQueue.dequeue(frameRequest)) {
</span><span class="cx">             // Get the frame NativeImage on the decoding thread.
</span><del>-            NativeImagePtr nativeImage = m_decoder-&gt;createFrameImageAtIndex(frameRequest.index, frameRequest.subsamplingLevel, frameRequest.sizeForDrawing);
</del><ins>+            NativeImagePtr nativeImage = protectedDecoder-&gt;createFrameImageAtIndex(frameRequest.index, frameRequest.subsamplingLevel, frameRequest.sizeForDrawing);
</ins><span class="cx"> 
</span><span class="cx">             // Update the cached frames on the main thread to avoid updating the MemoryCache from a different thread.
</span><span class="cx">             callOnMainThread([this, protectedQueue = protectedQueue.copyRef(), nativeImage, frameRequest] () mutable {
</span><span class="lines">@@ -376,9 +394,9 @@
</span><span class="cx">         return defaultValue;
</span><span class="cx"> 
</span><span class="cx">     if (!cachedValue)
</span><del>-        return (m_decoder-&gt;*functor)();
</del><ins>+        return (*m_decoder.*functor)();
</ins><span class="cx"> 
</span><del>-    *cachedValue = (m_decoder-&gt;*functor)();
</del><ins>+    *cachedValue = (*m_decoder.*functor)();
</ins><span class="cx">     didDecodeProperties(m_decoder-&gt;bytesDecodedToDetermineProperties());
</span><span class="cx">     return cachedValue-&gt;value();
</span><span class="cx"> }
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCoreplatformgraphicsImageFrameCacheh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/ImageFrameCache.h (213841 => 213842)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/ImageFrameCache.h        2017-03-13 13:24:51 UTC (rev 213841)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/ImageFrameCache.h        2017-03-13 13:26:15 UTC (rev 213842)
</span><span class="lines">@@ -55,8 +55,8 @@
</span><span class="cx"> 
</span><span class="cx">     ~ImageFrameCache();
</span><span class="cx"> 
</span><del>-    void setDecoder(ImageDecoder* decoder) { m_decoder = decoder; }
-    ImageDecoder* decoder() const { return m_decoder; }
</del><ins>+    void setDecoder(ImageDecoder*);
+    ImageDecoder* decoder() const;
</ins><span class="cx"> 
</span><span class="cx">     unsigned decodedSize() const { return m_decodedSize; }
</span><span class="cx">     void destroyAllDecodedData() { destroyDecodedData(frameCount(), frameCount()); }
</span><span class="lines">@@ -135,7 +135,7 @@
</span><span class="cx">     const ImageFrame&amp; frameAtIndexCacheIfNeeded(size_t, ImageFrame::Caching, const std::optional&lt;SubsamplingLevel&gt;&amp; = { }, const std::optional&lt;IntSize&gt;&amp; sizeForDrawing = { });
</span><span class="cx"> 
</span><span class="cx">     Image* m_image { nullptr };
</span><del>-    ImageDecoder* m_decoder { nullptr };
</del><ins>+    RefPtr&lt;ImageDecoder&gt; m_decoder;
</ins><span class="cx">     unsigned m_decodedSize { 0 };
</span><span class="cx">     unsigned m_decodedPropertiesSize { 0 };
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCoreplatformgraphicsImageSourceh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/ImageSource.h (213841 => 213842)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/ImageSource.h        2017-03-13 13:24:51 UTC (rev 213841)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/ImageSource.h        2017-03-13 13:26:15 UTC (rev 213842)
</span><span class="lines">@@ -111,7 +111,7 @@
</span><span class="cx">     void setDecoderTargetContext(const GraphicsContext*);
</span><span class="cx"> 
</span><span class="cx">     Ref&lt;ImageFrameCache&gt; m_frameCache;
</span><del>-    std::unique_ptr&lt;ImageDecoder&gt; m_decoder;
</del><ins>+    RefPtr&lt;ImageDecoder&gt; m_decoder;
</ins><span class="cx"> 
</span><span class="cx">     std::optional&lt;SubsamplingLevel&gt; m_maximumSubsamplingLevel;
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCoreplatformgraphicscgImageDecoderCGh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h (213841 => 213842)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h        2017-03-13 13:24:51 UTC (rev 213841)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h        2017-03-13 13:26:15 UTC (rev 213842)
</span><span class="lines">@@ -35,14 +35,14 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class ImageDecoder {
</del><ins>+class ImageDecoder : public RefCounted&lt;ImageDecoder&gt; {
</ins><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx">     ImageDecoder(AlphaOption, GammaAndColorProfileOption);
</span><span class="cx"> 
</span><del>-    static std::unique_ptr&lt;ImageDecoder&gt; create(const SharedBuffer&amp;, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)
</del><ins>+    static Ref&lt;ImageDecoder&gt; create(const SharedBuffer&amp;, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)
</ins><span class="cx">     {
</span><del>-        return std::make_unique&lt;ImageDecoder&gt;(alphaOption, gammaAndColorProfileOption);
</del><ins>+        return adoptRef(*new ImageDecoder(alphaOption, gammaAndColorProfileOption));
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     static size_t bytesDecodedToDetermineProperties();
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCoreplatformgraphicswinImageDecoderDirect2Dh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h (213841 => 213842)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h        2017-03-13 13:24:51 UTC (rev 213841)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h        2017-03-13 13:26:15 UTC (rev 213842)
</span><span class="lines">@@ -36,14 +36,14 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class ImageDecoder {
</del><ins>+class ImageDecoder : public RefCounted&lt;ImageDecoder&gt; {
</ins><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx">     ImageDecoder();
</span><span class="cx">     
</span><del>-    static std::unique_ptr&lt;ImageDecoder&gt; create(const SharedBuffer&amp;, AlphaOption, GammaAndColorProfileOption)
</del><ins>+    static Ref&lt;ImageDecoder&gt; create(const SharedBuffer&amp;, AlphaOption, GammaAndColorProfileOption)
</ins><span class="cx">     {
</span><del>-        return std::make_unique&lt;ImageDecoder&gt;();
</del><ins>+        return adoptRef(*new ImageDecoder());
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     static size_t bytesDecodedToDetermineProperties();
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCoreplatformimagedecodersImageDecodercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/image-decoders/ImageDecoder.cpp (213841 => 213842)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/image-decoders/ImageDecoder.cpp        2017-03-13 13:24:51 UTC (rev 213841)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/image-decoders/ImageDecoder.cpp        2017-03-13 13:26:15 UTC (rev 213842)
</span><span class="lines">@@ -96,7 +96,7 @@
</span><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;ImageDecoder&gt; ImageDecoder::create(const SharedBuffer&amp; data, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)
</del><ins>+RefPtr&lt;ImageDecoder&gt; ImageDecoder::create(const SharedBuffer&amp; data, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)
</ins><span class="cx"> {
</span><span class="cx">     static const unsigned lengthOfLongestSignature = 14; // To wit: &quot;RIFF????WEBPVP&quot;
</span><span class="cx">     char contents[lengthOfLongestSignature];
</span><span class="lines">@@ -105,24 +105,24 @@
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx">     if (matchesGIFSignature(contents))
</span><del>-        return std::unique_ptr&lt;ImageDecoder&gt; { std::make_unique&lt;GIFImageDecoder&gt;(alphaOption, gammaAndColorProfileOption) };
</del><ins>+        return adoptRef(*new GIFImageDecoder(alphaOption, gammaAndColorProfileOption));
</ins><span class="cx"> 
</span><span class="cx">     if (matchesPNGSignature(contents))
</span><del>-        return std::unique_ptr&lt;ImageDecoder&gt; { std::make_unique&lt;PNGImageDecoder&gt;(alphaOption, gammaAndColorProfileOption) };
</del><ins>+        return adoptRef(*new PNGImageDecoder(alphaOption, gammaAndColorProfileOption));
</ins><span class="cx"> 
</span><span class="cx">     if (matchesICOSignature(contents) || matchesCURSignature(contents))
</span><del>-        return std::unique_ptr&lt;ImageDecoder&gt; { std::make_unique&lt;ICOImageDecoder&gt;(alphaOption, gammaAndColorProfileOption) };
</del><ins>+        return adoptRef(*new ICOImageDecoder(alphaOption, gammaAndColorProfileOption));
</ins><span class="cx"> 
</span><span class="cx">     if (matchesJPEGSignature(contents))
</span><del>-        return std::unique_ptr&lt;ImageDecoder&gt; { std::make_unique&lt;JPEGImageDecoder&gt;(alphaOption, gammaAndColorProfileOption) };
</del><ins>+        return adoptRef(*new JPEGImageDecoder(alphaOption, gammaAndColorProfileOption));
</ins><span class="cx"> 
</span><span class="cx"> #if USE(WEBP)
</span><span class="cx">     if (matchesWebPSignature(contents))
</span><del>-        return std::unique_ptr&lt;ImageDecoder&gt; { std::make_unique&lt;WEBPImageDecoder&gt;(alphaOption, gammaAndColorProfileOption) };
</del><ins>+        return adoptRef(*new WEBPImageDecoder(alphaOption, gammaAndColorProfileOption));
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     if (matchesBMPSignature(contents))
</span><del>-        return std::unique_ptr&lt;ImageDecoder&gt; { std::make_unique&lt;BMPImageDecoder&gt;(alphaOption, gammaAndColorProfileOption) };
</del><ins>+        return adoptRef(*new BMPImageDecoder(alphaOption, gammaAndColorProfileOption));
</ins><span class="cx"> 
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCoreplatformimagedecodersImageDecoderh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/image-decoders/ImageDecoder.h (213841 => 213842)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/image-decoders/ImageDecoder.h        2017-03-13 13:24:51 UTC (rev 213841)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/image-decoders/ImageDecoder.h        2017-03-13 13:26:15 UTC (rev 213842)
</span><span class="lines">@@ -47,7 +47,7 @@
</span><span class="cx">     // ENABLE(IMAGE_DECODER_DOWN_SAMPLING) allows image decoders to downsample
</span><span class="cx">     // at decode time.  Image decoders will downsample any images larger than
</span><span class="cx">     // |m_maxNumPixels|.  FIXME: Not yet supported by all decoders.
</span><del>-    class ImageDecoder {
</del><ins>+    class ImageDecoder : public RefCounted&lt;ImageDecoder&gt; {
</ins><span class="cx">         WTF_MAKE_NONCOPYABLE(ImageDecoder); WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx">     public:
</span><span class="cx">         ImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)
</span><span class="lines">@@ -60,10 +60,9 @@
</span><span class="cx">         {
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        // Returns a caller-owned decoder of the appropriate type.  Returns 0 if
-        // we can't sniff a supported type from the provided data (possibly
</del><ins>+        // Returns nullptr if we can't sniff a supported type from the provided data (possibly
</ins><span class="cx">         // because there isn't enough data yet).
</span><del>-        static std::unique_ptr&lt;ImageDecoder&gt; create(const SharedBuffer&amp; data, AlphaOption, GammaAndColorProfileOption);
</del><ins>+        static RefPtr&lt;ImageDecoder&gt; create(const SharedBuffer&amp; data, AlphaOption, GammaAndColorProfileOption);
</ins><span class="cx"> 
</span><span class="cx">         virtual String filenameExtension() const = 0;
</span><span class="cx">         
</span></span></pre>
</div>
</div>

</body>
</html>