<!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>[198782] trunk/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/198782">198782</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-03-29 09:18:25 -0700 (Tue, 29 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Create a CG ImageDecoder class instead of defining it as CGImageSourceRef
https://bugs.webkit.org/show_bug.cgi?id=155422

Patch by Said Abou-Hallawa &lt;sabouhallawa@apple,com&gt; on 2016-03-29
Reviewed by Simon Fraser.

Move the image CG decoding code from the class ImageSource out to a new
class named ImageDecoder. The purpose of this split is to unify the code
of the ImageSource for all platforms. This class should be a container
for the ImageDecoder. All the direct frame manipulation like querying the
frame metadata or creating a frame image should be the responsibility of
the ImageDecoder. The ImageSource will be responsible of the image frame
caching. When responding to a frame metadata query, for example. the
ImageSource checks its cache first. If an entry does not exist for the
requested frame, the ImageSource will cache the image and the metadata
of this frame. The ImageSource will respond at the end from the image
frame cache.

The plan after this patch is is the following:
    -- Move the new class to separate files
    -- Merge the ImageSource.cpp and ImageSourceCG.cpp. in one file
    -- Move caching the FrameData from BitmapImage to ImageSource.

* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::imageSizeForRenderer):
BitmapImage::sizeRespectingOrientation() does not take any argument now.
Fix the call to this function and delete the conditionally compiled code
since the code is the same for the two cases.

* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::updateSize):
(WebCore::BitmapImage::sizeRespectingOrientation):
(WebCore::BitmapImage::frameImageAtIndex):
(WebCore::BitmapImage::BitmapImage):
An image can have two sizes: size() and sizeRespectingOrientation(). The
sizeRespectingOrientation() is the transpose of size() iff the image
orientation has usesWidthAsHeight() is true. So there is no need for the
ImageOrientationDescription argument. So there is no need for the members
m_imageOrientation or m_shouldRespectImageOrientation. Also move
m_allowSubsampling and m_minimumSubsamplingLevel (which should be named
m_maximumSubsamplingLevel) to ImageSource instead.

(WebCore::BitmapImage::frameOrientationAtIndex): Replace DefaultImageOrientation
by ImageOrientation().

(WebCore::BitmapImage::dump): Move dumping the image metadata to the
ImageSource.

* platform/graphics/BitmapImage.h:

* platform/graphics/GraphicsContext.h:
* platform/graphics/ImageOrientation.h:
(WebCore::ImageOrientation::ImageOrientation):
(WebCore::ImageOrientation::fromEXIFValue):
(WebCore::ImageOrientation::operator ImageOrientationEnum):
Add a casting operator to ImageOrientation so it can be dumped as enum
value. Also add a default constructor and make the other constructor be
explicit. All the rvalues DefaultImageOrientation should be replaced by
ImageOrientation().

* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::ImageSource):
(WebCore::ImageSource::clear):
m_decoder is now a unique_ptr. To release it, assign it to nullptr.

(WebCore::ImageSource::ensureDecoderIsCreated): Ensure m_decoder is created.

(WebCore::ImageSource::setData): Call ensureDecoderIsCreated() before
actually setting the data.

(WebCore::ImageSource::isSizeAvailable): Use initialized();

(WebCore::ImageSource::size):
(WebCore::ImageSource::sizeRespectingOrientation):
(WebCore::ImageSource::frameSizeAtIndex):
These functions return the size of the image.

(WebCore::ImageSource::getHotSpot):
(WebCore::ImageSource::repetitionCount):
(WebCore::ImageSource::frameCount):
(WebCore::ImageSource::createFrameImageAtIndex):
(WebCore::ImageSource::frameDurationAtIndex):
(WebCore::ImageSource::orientationAtIndex):
(WebCore::ImageSource::frameHasAlphaAtIndex):
(WebCore::ImageSource::frameIsCompleteAtIndex):
(WebCore::ImageSource::frameBytesAtIndex):
Check for initialized() instead of checking m_decoder.

(WebCore::ImageSource::dump): Dump the image metadata.

(WebCore::ImageSource::initialized): Deleted.

* platform/graphics/ImageSource.h: The image decoder is now named
ImageDecoder for all platforms.

(WebCore::ImageSource::initialized): Moved to the header file.

(WebCore::ImageSource::setAllowSubsampling): Moved from BitmapImage.

* platform/graphics/cairo/BitmapImageCairo.cpp:
(WebCore::BitmapImage::BitmapImage):
(WebCore::BitmapImage::determineMinimumSubsamplingLevel): Deleted.
Delete initializing m_minimumSubsamplingLevel and determineMinimumSubsamplingLevel()
since they are moved to ImageSource.

* platform/graphics/cg/BitmapImageCG.cpp:
(WebCore::BitmapImage::BitmapImage):
(WebCore::BitmapImage::determineMinimumSubsamplingLevel): Deleted.
Delete members and methods which are now owned and calculated by ImageSource.

* platform/graphics/cg/ImageSourceCG.cpp:
(WebCore::ImageDecoder::create): Returns a CG ImageDecoder object.

(WebCore::orientationFromProperties):  Replace DefaultImageOrientation
by ImageOrientation().

(WebCore::ImageDecoder::ImageDecoder): Creates a native CG image decoder.

(WebCore::ImageDecoder::~ImageDecoder): Releases the native CG image decoder.

(WebCore::ImageDecoder::subsamplingLevelForScale): Moved from ImageSource.
A new argument named 'maximumSubsamplingLevel' is added to low filter the
return value.

(WebCore::ImageDecoder::bytesDecodedToDetermineProperties):
(WebCore::ImageDecoder::filenameExtension):
(WebCore::ImageDecoder::isSizeAvailable):
(WebCore::ImageDecoder::size):
(WebCore::ImageDecoder::frameCount):
(WebCore::ImageDecoder::repetitionCount):
(WebCore::ImageDecoder::hotSpot):
(WebCore::ImageDecoder::frameSizeAtIndex):
(WebCore::ImageDecoder::frameIsCompleteAtIndex):
(WebCore::ImageDecoder::orientationAtIndex):
(WebCore::ImageDecoder::frameDurationAtIndex):
(WebCore::ImageDecoder::allowSubsamplingOfFrameAtIndex):
(WebCore::ImageDecoder::frameHasAlphaAtIndex):
(WebCore::ImageDecoder::frameBytesAtIndex):
(WebCore::ImageDecoder::createFrameImageAtIndex):
(WebCore::ImageDecoder::setData):
The code of these function was moved from the functions of ImageSource.

(WebCore::ImageSource::ImageSource):
(WebCore::ImageSource::~ImageSource):
(WebCore::ImageSource::clear):
(WebCore::ImageSource::ensureDecoderIsCreated):
(WebCore::ImageSource::setData):
(WebCore::ImageSource::filenameExtension):
(WebCore::ImageSource::calculateMaximumSubsamplingLevel):
(WebCore::ImageSource::maximumSubsamplingLevel):
(WebCore::ImageSource::subsamplingLevelForScale):
(WebCore::ImageSource::isSizeAvailable):
(WebCore::ImageSource::allowSubsamplingOfFrameAtIndex):
(WebCore::ImageSource::frameSizeAtIndex):
(WebCore::ImageSource::orientationAtIndex):
(WebCore::ImageSource::size):
(WebCore::ImageSource::sizeRespectingOrientation):
(WebCore::ImageSource::getHotSpot):
(WebCore::ImageSource::bytesDecodedToDetermineProperties):
(WebCore::ImageSource::repetitionCount):
(WebCore::ImageSource::frameCount):
(WebCore::ImageSource::createFrameImageAtIndex):
(WebCore::ImageSource::frameIsCompleteAtIndex):
(WebCore::ImageSource::frameDurationAtIndex):
(WebCore::ImageSource::frameHasAlphaAtIndex):
(WebCore::ImageSource::frameBytesAtIndex):
Call m_decoder's function to do the real work.

(WebCore::ImageSource::dump): Dump the image metadata.

(WebCore::ImageSource::initialized): Deleted.

* platform/image-decoders/ImageDecoder.cpp:
(WebCore::ImageDecoder::create):
* platform/image-decoders/ImageDecoder.h:
Change the return of ImageDecoder::create() to be unique_ptr.

* platform/mac/DragImageMac.mm:
(WebCore::createDragImageFromImage): Delete unneeded argument.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedImagecpp">trunk/Source/WebCore/loader/cache/CachedImage.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsBitmapImagecpp">trunk/Source/WebCore/platform/graphics/BitmapImage.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsBitmapImageh">trunk/Source/WebCore/platform/graphics/BitmapImage.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContexth">trunk/Source/WebCore/platform/graphics/GraphicsContext.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageOrientationh">trunk/Source/WebCore/platform/graphics/ImageOrientation.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageSourcecpp">trunk/Source/WebCore/platform/graphics/ImageSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageSourceh">trunk/Source/WebCore/platform/graphics/ImageSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoBitmapImageCairocpp">trunk/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgBitmapImageCGcpp">trunk/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgImageSourceCGcpp">trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersImageDecodercpp">trunk/Source/WebCore/platform/image-decoders/ImageDecoder.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersImageDecoderh">trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacDragImageMacmm">trunk/Source/WebCore/platform/mac/DragImageMac.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/ChangeLog        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -1,3 +1,184 @@
</span><ins>+2016-03-29  Said Abou-Hallawa  &lt;sabouhallawa@apple,com&gt;
+
+        Create a CG ImageDecoder class instead of defining it as CGImageSourceRef
+        https://bugs.webkit.org/show_bug.cgi?id=155422
+
+        Reviewed by Simon Fraser.
+
+        Move the image CG decoding code from the class ImageSource out to a new
+        class named ImageDecoder. The purpose of this split is to unify the code
+        of the ImageSource for all platforms. This class should be a container
+        for the ImageDecoder. All the direct frame manipulation like querying the
+        frame metadata or creating a frame image should be the responsibility of
+        the ImageDecoder. The ImageSource will be responsible of the image frame
+        caching. When responding to a frame metadata query, for example. the
+        ImageSource checks its cache first. If an entry does not exist for the
+        requested frame, the ImageSource will cache the image and the metadata
+        of this frame. The ImageSource will respond at the end from the image
+        frame cache.

+        The plan after this patch is is the following:
+            -- Move the new class to separate files
+            -- Merge the ImageSource.cpp and ImageSourceCG.cpp. in one file
+            -- Move caching the FrameData from BitmapImage to ImageSource.

+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::imageSizeForRenderer):
+        BitmapImage::sizeRespectingOrientation() does not take any argument now.
+        Fix the call to this function and delete the conditionally compiled code 
+        since the code is the same for the two cases.

+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::updateSize):
+        (WebCore::BitmapImage::sizeRespectingOrientation):
+        (WebCore::BitmapImage::frameImageAtIndex):
+        (WebCore::BitmapImage::BitmapImage):
+        An image can have two sizes: size() and sizeRespectingOrientation(). The
+        sizeRespectingOrientation() is the transpose of size() iff the image
+        orientation has usesWidthAsHeight() is true. So there is no need for the
+        ImageOrientationDescription argument. So there is no need for the members
+        m_imageOrientation or m_shouldRespectImageOrientation. Also move
+        m_allowSubsampling and m_minimumSubsamplingLevel (which should be named
+        m_maximumSubsamplingLevel) to ImageSource instead.
+
+        (WebCore::BitmapImage::frameOrientationAtIndex): Replace DefaultImageOrientation
+        by ImageOrientation().
+        
+        (WebCore::BitmapImage::dump): Move dumping the image metadata to the
+        ImageSource.
+        
+        * platform/graphics/BitmapImage.h:
+        
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/ImageOrientation.h:
+        (WebCore::ImageOrientation::ImageOrientation):
+        (WebCore::ImageOrientation::fromEXIFValue):
+        (WebCore::ImageOrientation::operator ImageOrientationEnum):
+        Add a casting operator to ImageOrientation so it can be dumped as enum
+        value. Also add a default constructor and make the other constructor be
+        explicit. All the rvalues DefaultImageOrientation should be replaced by
+        ImageOrientation().
+
+        * platform/graphics/ImageSource.cpp:
+        (WebCore::ImageSource::ImageSource):
+        (WebCore::ImageSource::clear):
+        m_decoder is now a unique_ptr. To release it, assign it to nullptr.
+
+        (WebCore::ImageSource::ensureDecoderIsCreated): Ensure m_decoder is created.
+        
+        (WebCore::ImageSource::setData): Call ensureDecoderIsCreated() before
+        actually setting the data.
+        
+        (WebCore::ImageSource::isSizeAvailable): Use initialized();
+        
+        (WebCore::ImageSource::size):
+        (WebCore::ImageSource::sizeRespectingOrientation):
+        (WebCore::ImageSource::frameSizeAtIndex):
+        These functions return the size of the image.
+    
+        (WebCore::ImageSource::getHotSpot):
+        (WebCore::ImageSource::repetitionCount):
+        (WebCore::ImageSource::frameCount):
+        (WebCore::ImageSource::createFrameImageAtIndex):
+        (WebCore::ImageSource::frameDurationAtIndex):
+        (WebCore::ImageSource::orientationAtIndex):
+        (WebCore::ImageSource::frameHasAlphaAtIndex):
+        (WebCore::ImageSource::frameIsCompleteAtIndex):
+        (WebCore::ImageSource::frameBytesAtIndex):
+        Check for initialized() instead of checking m_decoder.
+        
+        (WebCore::ImageSource::dump): Dump the image metadata.
+        
+        (WebCore::ImageSource::initialized): Deleted.
+        
+        * platform/graphics/ImageSource.h: The image decoder is now named
+        ImageDecoder for all platforms.
+        
+        (WebCore::ImageSource::initialized): Moved to the header file.
+
+        (WebCore::ImageSource::setAllowSubsampling): Moved from BitmapImage.
+        
+        * platform/graphics/cairo/BitmapImageCairo.cpp:
+        (WebCore::BitmapImage::BitmapImage):
+        (WebCore::BitmapImage::determineMinimumSubsamplingLevel): Deleted.
+        Delete initializing m_minimumSubsamplingLevel and determineMinimumSubsamplingLevel()
+        since they are moved to ImageSource.
+        
+        * platform/graphics/cg/BitmapImageCG.cpp:
+        (WebCore::BitmapImage::BitmapImage):
+        (WebCore::BitmapImage::determineMinimumSubsamplingLevel): Deleted.
+        Delete members and methods which are now owned and calculated by ImageSource.
+        
+        * platform/graphics/cg/ImageSourceCG.cpp:
+        (WebCore::ImageDecoder::create): Returns a CG ImageDecoder object.
+        
+        (WebCore::orientationFromProperties):  Replace DefaultImageOrientation
+        by ImageOrientation().
+        
+        (WebCore::ImageDecoder::ImageDecoder): Creates a native CG image decoder.
+        
+        (WebCore::ImageDecoder::~ImageDecoder): Releases the native CG image decoder.
+        
+        (WebCore::ImageDecoder::subsamplingLevelForScale): Moved from ImageSource.
+        A new argument named 'maximumSubsamplingLevel' is added to low filter the
+        return value.
+        
+        (WebCore::ImageDecoder::bytesDecodedToDetermineProperties):
+        (WebCore::ImageDecoder::filenameExtension):
+        (WebCore::ImageDecoder::isSizeAvailable):
+        (WebCore::ImageDecoder::size):
+        (WebCore::ImageDecoder::frameCount):
+        (WebCore::ImageDecoder::repetitionCount):
+        (WebCore::ImageDecoder::hotSpot):
+        (WebCore::ImageDecoder::frameSizeAtIndex):
+        (WebCore::ImageDecoder::frameIsCompleteAtIndex):
+        (WebCore::ImageDecoder::orientationAtIndex):
+        (WebCore::ImageDecoder::frameDurationAtIndex):
+        (WebCore::ImageDecoder::allowSubsamplingOfFrameAtIndex):
+        (WebCore::ImageDecoder::frameHasAlphaAtIndex):
+        (WebCore::ImageDecoder::frameBytesAtIndex):
+        (WebCore::ImageDecoder::createFrameImageAtIndex):
+        (WebCore::ImageDecoder::setData):
+        The code of these function was moved from the functions of ImageSource.
+        
+        (WebCore::ImageSource::ImageSource):
+        (WebCore::ImageSource::~ImageSource):
+        (WebCore::ImageSource::clear):
+        (WebCore::ImageSource::ensureDecoderIsCreated):
+        (WebCore::ImageSource::setData):
+        (WebCore::ImageSource::filenameExtension):
+        (WebCore::ImageSource::calculateMaximumSubsamplingLevel):
+        (WebCore::ImageSource::maximumSubsamplingLevel):
+        (WebCore::ImageSource::subsamplingLevelForScale):
+        (WebCore::ImageSource::isSizeAvailable):
+        (WebCore::ImageSource::allowSubsamplingOfFrameAtIndex):
+        (WebCore::ImageSource::frameSizeAtIndex):
+        (WebCore::ImageSource::orientationAtIndex):
+        (WebCore::ImageSource::size):
+        (WebCore::ImageSource::sizeRespectingOrientation):
+        (WebCore::ImageSource::getHotSpot):
+        (WebCore::ImageSource::bytesDecodedToDetermineProperties):
+        (WebCore::ImageSource::repetitionCount):
+        (WebCore::ImageSource::frameCount):
+        (WebCore::ImageSource::createFrameImageAtIndex):
+        (WebCore::ImageSource::frameIsCompleteAtIndex):
+        (WebCore::ImageSource::frameDurationAtIndex):
+        (WebCore::ImageSource::frameHasAlphaAtIndex):
+        (WebCore::ImageSource::frameBytesAtIndex):
+        Call m_decoder's function to do the real work.
+        
+        (WebCore::ImageSource::dump): Dump the image metadata.
+        
+        (WebCore::ImageSource::initialized): Deleted.
+        
+        * platform/image-decoders/ImageDecoder.cpp:
+        (WebCore::ImageDecoder::create):
+        * platform/image-decoders/ImageDecoder.h:
+        Change the return of ImageDecoder::create() to be unique_ptr.
+        
+        * platform/mac/DragImageMac.mm:
+        (WebCore::createDragImageFromImage): Delete unneeded argument.
+
</ins><span class="cx"> 2016-03-29  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         media/track/track-remove-track.html is flaky, crashing and failing
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedImage.cpp (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedImage.cpp        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/loader/cache/CachedImage.cpp        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -272,22 +272,14 @@
</span><span class="cx">     if (!m_image)
</span><span class="cx">         return LayoutSize();
</span><span class="cx"> 
</span><del>-    LayoutSize imageSize(m_image-&gt;size());
</del><ins>+    LayoutSize imageSize;
</ins><span class="cx"> 
</span><del>-#if ENABLE(CSS_IMAGE_ORIENTATION)
-    if (renderer &amp;&amp; is&lt;BitmapImage&gt;(*m_image)) {
-        ImageOrientationDescription orientationDescription(renderer-&gt;shouldRespectImageOrientation(), renderer-&gt;style().imageOrientation());
-        if (orientationDescription.respectImageOrientation() == RespectImageOrientation)
-            imageSize = LayoutSize(downcast&lt;BitmapImage&gt;(*m_image).sizeRespectingOrientation(orientationDescription));
-    }
-#else
-    if (is&lt;BitmapImage&gt;(*m_image) &amp;&amp; (renderer &amp;&amp; renderer-&gt;shouldRespectImageOrientation() == RespectImageOrientation))
</del><ins>+    if (is&lt;BitmapImage&gt;(*m_image) &amp;&amp; renderer &amp;&amp; renderer-&gt;shouldRespectImageOrientation() == RespectImageOrientation)
</ins><span class="cx">         imageSize = LayoutSize(downcast&lt;BitmapImage&gt;(*m_image).sizeRespectingOrientation());
</span><del>-#endif // ENABLE(CSS_IMAGE_ORIENTATION)
-
-    else if (is&lt;SVGImage&gt;(*m_image) &amp;&amp; sizeType == UsedSize) {
</del><ins>+    else if (is&lt;SVGImage&gt;(*m_image) &amp;&amp; sizeType == UsedSize)
</ins><span class="cx">         imageSize = LayoutSize(m_svgImageCache-&gt;imageSizeForRenderer(renderer));
</span><del>-    }
</del><ins>+    else
+        imageSize = LayoutSize(m_image-&gt;size());
</ins><span class="cx"> 
</span><span class="cx">     if (multiplier == 1.0f)
</span><span class="cx">         return imageSize;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsBitmapImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -47,9 +47,6 @@
</span><span class="cx"> 
</span><span class="cx"> BitmapImage::BitmapImage(ImageObserver* observer)
</span><span class="cx">     : Image(observer)
</span><del>-    , m_minimumSubsamplingLevel(0)
-    , m_imageOrientation(OriginTopLeft)
-    , m_shouldRespectImageOrientation(false)
</del><span class="cx">     , m_currentFrame(0)
</span><span class="cx">     , m_repetitionCount(cAnimationNone)
</span><span class="cx">     , m_repetitionCountStatus(Unknown)
</span><span class="lines">@@ -62,9 +59,6 @@
</span><span class="cx">     // FIXME: We should expose a setting to enable/disable progressive loading remove the PLATFORM(IOS)-guard.
</span><span class="cx">     , m_progressiveLoadChunkTime(0)
</span><span class="cx">     , m_progressiveLoadChunkCount(0)
</span><del>-    , m_allowSubsampling(true)
-#else
-    , m_allowSubsampling(false)
</del><span class="cx"> #endif
</span><span class="cx">     , m_isSolidColor(false)
</span><span class="cx">     , m_checkedForSolidColor(false)
</span><span class="lines">@@ -236,20 +230,15 @@
</span><span class="cx">         imageObserver()-&gt;decodedSizeChanged(this, deltaBytes);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void BitmapImage::updateSize(ImageOrientationDescription description) const
</del><ins>+void BitmapImage::updateSize() const
</ins><span class="cx"> {
</span><span class="cx">     if (!m_sizeAvailable || m_haveSize)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_size = m_source.size(description);
-    m_sizeRespectingOrientation = m_source.size(ImageOrientationDescription(RespectImageOrientation, description.imageOrientation()));
</del><ins>+    m_size = m_source.size();
+    m_sizeRespectingOrientation = m_source.sizeRespectingOrientation();
</ins><span class="cx"> 
</span><del>-    m_imageOrientation = static_cast&lt;unsigned&gt;(description.imageOrientation());
-    m_shouldRespectImageOrientation = static_cast&lt;unsigned&gt;(description.respectImageOrientation());
-
</del><span class="cx">     m_haveSize = true;
</span><del>-
-    determineMinimumSubsamplingLevel();
</del><span class="cx">     didDecodeProperties();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -259,9 +248,9 @@
</span><span class="cx">     return m_size;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-IntSize BitmapImage::sizeRespectingOrientation(ImageOrientationDescription description) const
</del><ins>+IntSize BitmapImage::sizeRespectingOrientation() const
</ins><span class="cx"> {
</span><del>-    updateSize(description);
</del><ins>+    updateSize();
</ins><span class="cx">     return m_sizeRespectingOrientation;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -391,7 +380,7 @@
</span><span class="cx">     if (index &gt;= frameCount())
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    SubsamplingLevel subsamplingLevel = std::min(m_source.subsamplingLevelForScale(presentationScaleHint), m_minimumSubsamplingLevel);
</del><ins>+    SubsamplingLevel subsamplingLevel = m_source.subsamplingLevelForScale(presentationScaleHint);
</ins><span class="cx"> 
</span><span class="cx">     // We may have cached a frame with a higher subsampling level, in which case we need to
</span><span class="cx">     // re-decode with a lower level.
</span><span class="lines">@@ -452,7 +441,7 @@
</span><span class="cx"> ImageOrientation BitmapImage::frameOrientationAtIndex(size_t index)
</span><span class="cx"> {
</span><span class="cx">     if (!ensureFrameIsCached(index, CacheMetadataOnly))
</span><del>-        return DefaultImageOrientation;
</del><ins>+        return ImageOrientation();
</ins><span class="cx"> 
</span><span class="cx">     if (m_frames[index].m_haveMetadata)
</span><span class="cx">         return m_frames[index].m_orientation;
</span><span class="lines">@@ -710,13 +699,10 @@
</span><span class="cx">         ts.dumpProperty(&quot;current-frame&quot;, m_currentFrame);
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    if (allowSubsampling())
-        ts.dumpProperty(&quot;allow-subsampling&quot;, allowSubsampling());
</del><span class="cx">     if (m_isSolidColor)
</span><span class="cx">         ts.dumpProperty(&quot;solid-color&quot;, m_isSolidColor);
</span><span class="cx">     
</span><del>-    if (m_imageOrientation != OriginTopLeft)
-        ts.dumpProperty(&quot;orientation&quot;, m_imageOrientation);
</del><ins>+    m_source.dump(ts);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsBitmapImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/BitmapImage.h        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -123,7 +123,7 @@
</span><span class="cx"> 
</span><span class="cx">     // FloatSize due to override.
</span><span class="cx">     FloatSize size() const override;
</span><del>-    IntSize sizeRespectingOrientation(ImageOrientationDescription = ImageOrientationDescription()) const;
</del><ins>+    IntSize sizeRespectingOrientation() const;
</ins><span class="cx"> 
</span><span class="cx">     bool getHotSpot(IntPoint&amp;) const override;
</span><span class="cx"> 
</span><span class="lines">@@ -179,16 +179,14 @@
</span><span class="cx">     
</span><span class="cx">     bool canAnimate();
</span><span class="cx"> 
</span><del>-    bool allowSubsampling() const { return m_allowSubsampling; }
-    void setAllowSubsampling(bool allowSubsampling) { m_allowSubsampling = allowSubsampling; }
</del><ins>+    void setAllowSubsampling(bool allowSubsampling) { m_source.setAllowSubsampling(allowSubsampling); }
</ins><span class="cx"> 
</span><span class="cx">     size_t currentFrame() const { return m_currentFrame; }
</span><span class="cx">     
</span><span class="cx"> private:
</span><span class="cx">     bool isBitmapImage() const override { return true; }
</span><span class="cx"> 
</span><del>-    void updateSize(ImageOrientationDescription = ImageOrientationDescription()) const;
-    void determineMinimumSubsamplingLevel() const;
</del><ins>+    void updateSize() const;
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     enum RepetitionCountStatus {
</span><span class="lines">@@ -295,11 +293,6 @@
</span><span class="cx">     mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image).
</span><span class="cx">     mutable IntSize m_sizeRespectingOrientation;
</span><span class="cx"> 
</span><del>-    mutable SubsamplingLevel m_minimumSubsamplingLevel;
-
-    mutable unsigned m_imageOrientation : 4; // ImageOrientationEnum
-    mutable unsigned m_shouldRespectImageOrientation : 1; // RespectImageOrientationEnum
-
</del><span class="cx">     size_t m_currentFrame; // The index of the current frame of animation.
</span><span class="cx">     Vector&lt;FrameData, 1&gt; m_frames; // An array of the cached frames of the animation. We have to ref frames to pin them in the cache.
</span><span class="cx"> 
</span><span class="lines">@@ -327,8 +320,6 @@
</span><span class="cx">     double m_progressiveLoadChunkTime;
</span><span class="cx">     uint16_t m_progressiveLoadChunkCount;
</span><span class="cx"> #endif
</span><del>-
-    bool m_allowSubsampling : 1; // Whether we should attempt subsampling if this image is very large.
</del><span class="cx">     bool m_isSolidColor : 1; // Whether or not we are a 1x1 solid image.
</span><span class="cx">     bool m_checkedForSolidColor : 1; // Whether we've checked the frame for solid color.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -302,7 +302,7 @@
</span><span class="cx">     const GraphicsContextState&amp; state() const { return m_state; }
</span><span class="cx"> 
</span><span class="cx"> #if USE(CG) || USE(CAIRO)
</span><del>-    WEBCORE_EXPORT void drawNativeImage(const NativeImagePtr&amp;, const FloatSize&amp; selfSize, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, ImageOrientation = DefaultImageOrientation);
</del><ins>+    WEBCORE_EXPORT void drawNativeImage(const NativeImagePtr&amp;, const FloatSize&amp; selfSize, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, ImageOrientation = ImageOrientation());
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(CG)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageOrientationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageOrientation.h (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageOrientation.h        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/platform/graphics/ImageOrientation.h        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -84,7 +84,12 @@
</span><span class="cx"> 
</span><span class="cx"> class ImageOrientation {
</span><span class="cx"> public:
</span><del>-    ImageOrientation(ImageOrientationEnum orientation = DefaultImageOrientation)
</del><ins>+    ImageOrientation()
+        : m_orientation(DefaultImageOrientation)
+    {
+    }
+
+    explicit ImageOrientation(ImageOrientationEnum orientation)
</ins><span class="cx">         : m_orientation(orientation)
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="lines">@@ -101,14 +106,16 @@
</span><span class="cx">     {
</span><span class="cx">         // Values direct from images may be invalid, in which case we use the default.
</span><span class="cx">         if (exifValue &lt; OriginTopLeft || exifValue &gt; OriginLeftBottom)
</span><del>-            return DefaultImageOrientation;
-        return static_cast&lt;ImageOrientationEnum&gt;(exifValue);
</del><ins>+            return ImageOrientation();
+        return ImageOrientation(static_cast&lt;ImageOrientationEnum&gt;(exifValue));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // This transform can be used for drawing an image according to the orientation.
</span><span class="cx">     // It should be used in a right-handed coordinate system.
</span><span class="cx">     AffineTransform transformFromDefault(const FloatSize&amp; drawnSize) const;
</span><span class="cx"> 
</span><ins>+    inline operator ImageOrientationEnum() const { return m_orientation; }
+    
</ins><span class="cx">     inline bool operator==(const ImageOrientation&amp; other) const { return other.m_orientation == m_orientation; }
</span><span class="cx">     inline bool operator!=(const ImageOrientation&amp; other) const { return !(*this == other); }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageSource.cpp (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageSource.cpp        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.cpp        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -43,8 +43,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> ImageSource::ImageSource(ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption)
</span><del>-    : m_decoder(0)
-    , m_alphaOption(alphaOption)
</del><ins>+    : m_alphaOption(alphaOption)
</ins><span class="cx">     , m_gammaAndColorProfileOption(gammaAndColorProfileOption)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -62,29 +61,38 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    delete m_decoder;
-    m_decoder = 0;
</del><ins>+    m_decoder = nullptr;
+
</ins><span class="cx">     if (data)
</span><span class="cx">         setData(data, allDataReceived);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageSource::initialized() const
</del><ins>+void ImageSource::ensureDecoderIsCreated(SharedBuffer* data)
</ins><span class="cx"> {
</span><del>-    return m_decoder;
-}
-
-void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
-{
</del><ins>+    if (initialized())
+        return;
+    
</ins><span class="cx">     // Make the decoder by sniffing the bytes.
</span><span class="cx">     // This method will examine the data and instantiate an instance of the appropriate decoder plugin.
</span><span class="cx">     // If insufficient bytes are available to determine the image type, no decoder plugin will be
</span><span class="cx">     // made.
</span><del>-    if (!m_decoder) {
-        m_decoder = static_cast&lt;NativeImageDecoderPtr&gt;(NativeImageDecoder::create(*data, m_alphaOption, m_gammaAndColorProfileOption));
</del><ins>+    m_decoder = ImageDecoder::create(*data, m_alphaOption, m_gammaAndColorProfileOption);
</ins><span class="cx"> #if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
</span><del>-        if (m_decoder &amp;&amp; s_maxPixelsPerDecodedImage)
-            m_decoder-&gt;setMaxNumPixels(s_maxPixelsPerDecodedImage);
</del><ins>+    if (m_decoder &amp;&amp; s_maxPixelsPerDecodedImage)
+        m_decoder-&gt;setMaxNumPixels(s_maxPixelsPerDecodedImage);
</ins><span class="cx"> #endif
</span><ins>+}
+
+void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
+{
+    if (!data)
+        return;
+    
+    ensureDecoderIsCreated(data);
+    
+    if (!initialized()) {
+        ASSERT_NOT_REACHED();
+        return;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (m_decoder)
</span><span class="lines">@@ -108,29 +116,33 @@
</span><span class="cx"> 
</span><span class="cx"> bool ImageSource::isSizeAvailable()
</span><span class="cx"> {
</span><del>-    return m_decoder &amp;&amp; m_decoder-&gt;isSizeAvailable();
</del><ins>+    return initialized() &amp;&amp; m_decoder-&gt;isSizeAvailable();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-IntSize ImageSource::size(ImageOrientationDescription description) const
</del><ins>+IntSize ImageSource::size() const
</ins><span class="cx"> {
</span><del>-    return frameSizeAtIndex(0, 0, description);
</del><ins>+    return frameSizeAtIndex(0, 0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-IntSize ImageSource::frameSizeAtIndex(size_t index, SubsamplingLevel, ImageOrientationDescription description) const
</del><ins>+IntSize ImageSource::sizeRespectingOrientation() const
</ins><span class="cx"> {
</span><del>-    if (!m_decoder)
-        return IntSize();
</del><ins>+    return frameSizeAtIndex(0, 0, RespectImageOrientation);
+}
</ins><span class="cx"> 
</span><ins>+IntSize ImageSource::frameSizeAtIndex(size_t index, SubsamplingLevel, RespectImageOrientationEnum shouldRespectImageOrientation) const
+{
+    if (!initialized())
+        return { };
+
</ins><span class="cx">     IntSize size = m_decoder-&gt;frameSizeAtIndex(index);
</span><del>-    if ((description.respectImageOrientation() == RespectImageOrientation) &amp;&amp; m_decoder-&gt;orientation().usesWidthAsHeight())
-        return IntSize(size.height(), size.width());
-
-    return size;
</del><ins>+    ImageOrientation orientation = m_decoder-&gt;orientation();
+    
+    return shouldRespectImageOrientation == RespectImageOrientation &amp;&amp; orientation.usesWidthAsHeight() ? size.transposedSize() : size;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ImageSource::getHotSpot(IntPoint&amp; hotSpot) const
</span><span class="cx"> {
</span><del>-    return m_decoder ? m_decoder-&gt;hotSpot(hotSpot) : false;
</del><ins>+    return initialized() &amp;&amp; m_decoder-&gt;hotSpot(hotSpot);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> size_t ImageSource::bytesDecodedToDetermineProperties() const
</span><span class="lines">@@ -140,28 +152,28 @@
</span><span class="cx"> 
</span><span class="cx"> int ImageSource::repetitionCount()
</span><span class="cx"> {
</span><del>-    return m_decoder ? m_decoder-&gt;repetitionCount() : cAnimationNone;
</del><ins>+    return initialized() ? m_decoder-&gt;repetitionCount() : cAnimationNone;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> size_t ImageSource::frameCount() const
</span><span class="cx"> {
</span><del>-    return m_decoder ? m_decoder-&gt;frameCount() : 0;
</del><ins>+    return initialized() ? m_decoder-&gt;frameCount() : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> NativeImagePtr ImageSource::createFrameImageAtIndex(size_t index, SubsamplingLevel)
</span><span class="cx"> {
</span><del>-    if (!m_decoder)
</del><ins>+    if (!initialized())
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    ImageFrame* buffer = m_decoder-&gt;frameBufferAtIndex(index);
-    if (!buffer || buffer-&gt;status() == ImageFrame::FrameEmpty)
-        return nullptr;
-
</del><span class="cx">     // Zero-height images can cause problems for some ports.  If we have an
</span><span class="cx">     // empty image dimension, just bail.
</span><span class="cx">     if (size().isEmpty())
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><ins>+    ImageFrame* buffer = m_decoder-&gt;frameBufferAtIndex(index);
+    if (!buffer || buffer-&gt;status() == ImageFrame::FrameEmpty)
+        return nullptr;
+
</ins><span class="cx">     // Return the buffer contents as a native image.  For some ports, the data
</span><span class="cx">     // is already in a native container, and this just increments its refcount.
</span><span class="cx">     return buffer-&gt;asNewNativeImage();
</span><span class="lines">@@ -169,7 +181,7 @@
</span><span class="cx"> 
</span><span class="cx"> float ImageSource::frameDurationAtIndex(size_t index)
</span><span class="cx"> {
</span><del>-    if (!m_decoder)
</del><ins>+    if (!initialized())
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><span class="cx">     ImageFrame* buffer = m_decoder-&gt;frameBufferAtIndex(index);
</span><span class="lines">@@ -188,19 +200,17 @@
</span><span class="cx"> 
</span><span class="cx"> ImageOrientation ImageSource::orientationAtIndex(size_t) const
</span><span class="cx"> {
</span><del>-    return m_decoder ? m_decoder-&gt;orientation() : DefaultImageOrientation;
</del><ins>+    return initialized() ? m_decoder-&gt;orientation() : ImageOrientation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ImageSource::frameHasAlphaAtIndex(size_t index)
</span><span class="cx"> {
</span><del>-    if (!m_decoder)
-        return true;
-    return m_decoder-&gt;frameHasAlphaAtIndex(index);
</del><ins>+    return !initialized() || m_decoder-&gt;frameHasAlphaAtIndex(index);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ImageSource::frameIsCompleteAtIndex(size_t index)
</span><span class="cx"> {
</span><del>-    if (!m_decoder)
</del><ins>+    if (!initialized())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     ImageFrame* buffer = m_decoder-&gt;frameBufferAtIndex(index);
</span><span class="lines">@@ -209,11 +219,19 @@
</span><span class="cx"> 
</span><span class="cx"> unsigned ImageSource::frameBytesAtIndex(size_t index, SubsamplingLevel) const
</span><span class="cx"> {
</span><del>-    if (!m_decoder)
-        return 0;
-    return m_decoder-&gt;frameBytesAtIndex(index);
</del><ins>+    return initialized() ? m_decoder-&gt;frameBytesAtIndex(index) : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ImageSource::dump(TextStream&amp; ts) const
+{
+    if (m_allowSubsampling)
+        ts.dumpProperty(&quot;allow-subsampling&quot;, m_allowSubsampling);
+    
+    ImageOrientation orientation = orientationAtIndex(0);
+    if (orientation != OriginTopLeft)
+        ts.dumpProperty(&quot;orientation&quot;, orientation);
</ins><span class="cx"> }
</span><ins>+    
+}
</ins><span class="cx"> 
</span><span class="cx"> #endif // USE(CG)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageSource.h (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageSource.h        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.h        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ImageOrientation.h&quot;
</span><span class="cx"> #include &quot;NativeImagePtr.h&quot;
</span><ins>+#include &quot;TextStream.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/Noncopyable.h&gt;
</span><span class="lines">@@ -45,20 +46,8 @@
</span><span class="cx"> class IntPoint;
</span><span class="cx"> class IntSize;
</span><span class="cx"> class SharedBuffer;
</span><del>-
-#if USE(CG)
-typedef CGImageSourceRef NativeImageDecoderPtr;
-#else
</del><span class="cx"> class ImageDecoder;
</span><del>-typedef ImageDecoder* NativeImageDecoderPtr;
-#endif
</del><span class="cx"> 
</span><del>-#if USE(CG)
-#define NativeImageDecoder ImageDecoder
-#else
-typedef ImageDecoder NativeImageDecoder;
-#endif
-
</del><span class="cx"> // Right now GIFs are the only recognized image format that supports animation.
</span><span class="cx"> // The animation system and the constants below are designed with this in mind.
</span><span class="cx"> // GIFs have an optional 16-bit unsigned loop count that describes how an
</span><span class="lines">@@ -82,6 +71,7 @@
</span><span class="cx"> 
</span><span class="cx"> class ImageSource {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(ImageSource);
</span><ins>+    friend class BitmapImage;
</ins><span class="cx"> public:
</span><span class="cx">     enum AlphaOption {
</span><span class="cx">         AlphaPremultiplied,
</span><span class="lines">@@ -122,19 +112,24 @@
</span><span class="cx">                SharedBuffer* data = NULL,
</span><span class="cx">                bool allDataReceived = false);
</span><span class="cx"> 
</span><del>-    bool initialized() const;
</del><ins>+    bool initialized() const { return m_decoder.get(); }
</ins><span class="cx"> 
</span><span class="cx">     void setData(SharedBuffer* data, bool allDataReceived);
</span><span class="cx">     String filenameExtension() const;
</span><span class="cx"> 
</span><span class="cx">     SubsamplingLevel subsamplingLevelForScale(float) const;
</span><span class="cx">     bool allowSubsamplingOfFrameAtIndex(size_t) const;
</span><ins>+    void setAllowSubsampling(bool allowSubsampling) { m_allowSubsampling = allowSubsampling; }
+    SubsamplingLevel maximumSubsamplingLevel() const;
</ins><span class="cx"> 
</span><span class="cx">     bool isSizeAvailable();
</span><ins>+    
</ins><span class="cx">     // Always original size, without subsampling.
</span><del>-    IntSize size(ImageOrientationDescription = ImageOrientationDescription()) const;
</del><ins>+    IntSize size() const;
+    IntSize sizeRespectingOrientation() const;
+    
</ins><span class="cx">     // Size of optionally subsampled frame.
</span><del>-    IntSize frameSizeAtIndex(size_t, SubsamplingLevel = 0, ImageOrientationDescription = ImageOrientationDescription()) const;
</del><ins>+    IntSize frameSizeAtIndex(size_t, SubsamplingLevel = 0, RespectImageOrientationEnum = DoNotRespectImageOrientation) const;
</ins><span class="cx"> 
</span><span class="cx">     bool getHotSpot(IntPoint&amp;) const;
</span><span class="cx"> 
</span><span class="lines">@@ -163,7 +158,17 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    NativeImageDecoderPtr m_decoder;
</del><ins>+    void ensureDecoderIsCreated(SharedBuffer*);
+    SubsamplingLevel calculateMaximumSubsamplingLevel() const;
+    void dump(TextStream&amp;) const;
+    
+    std::unique_ptr&lt;ImageDecoder&gt; m_decoder;
+    
+#if PLATFORM(IOS)
+    bool m_allowSubsampling { true };
+#else
+    bool m_allowSubsampling { false };
+#endif
</ins><span class="cx"> 
</span><span class="cx"> #if !USE(CG)
</span><span class="cx">     AlphaOption m_alphaOption;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoBitmapImageCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -41,7 +41,6 @@
</span><span class="cx"> BitmapImage::BitmapImage(RefPtr&lt;cairo_surface_t&gt;&amp;&amp; nativeImage, ImageObserver* observer)
</span><span class="cx">     : Image(observer)
</span><span class="cx">     , m_size(cairoSurfaceSize(nativeImage.get()))
</span><del>-    , m_minimumSubsamplingLevel(0)
</del><span class="cx">     , m_currentFrame(0)
</span><span class="cx">     , m_repetitionCount(cAnimationNone)
</span><span class="cx">     , m_repetitionCountStatus(Unknown)
</span><span class="lines">@@ -122,11 +121,6 @@
</span><span class="cx">         imageObserver()-&gt;didDraw(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void BitmapImage::determineMinimumSubsamplingLevel() const
-{
-    m_minimumSubsamplingLevel = 0;
-}
-
</del><span class="cx"> void BitmapImage::checkForSolidColor()
</span><span class="cx"> {
</span><span class="cx">     m_isSolidColor = false;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgBitmapImageCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -55,7 +55,6 @@
</span><span class="cx">     if (clearMetadata)
</span><span class="cx">         m_haveMetadata = false;
</span><span class="cx"> 
</span><del>-    m_orientation = DefaultImageOrientation;
</del><span class="cx">     m_subsamplingLevel = 0;
</span><span class="cx"> 
</span><span class="cx">     if (m_image) {
</span><span class="lines">@@ -70,9 +69,6 @@
</span><span class="cx"> 
</span><span class="cx"> BitmapImage::BitmapImage(RetainPtr&lt;CGImageRef&gt;&amp;&amp; image, ImageObserver* observer)
</span><span class="cx">     : Image(observer)
</span><del>-    , m_minimumSubsamplingLevel(0)
-    , m_imageOrientation(OriginTopLeft)
-    , m_shouldRespectImageOrientation(false)
</del><span class="cx">     , m_currentFrame(0)
</span><span class="cx">     , m_repetitionCount(cAnimationNone)
</span><span class="cx">     , m_repetitionCountStatus(Unknown)
</span><span class="lines">@@ -105,28 +101,6 @@
</span><span class="cx">     checkForSolidColor();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void BitmapImage::determineMinimumSubsamplingLevel() const
-{
-    if (!m_allowSubsampling)
-        return;
-
-    if (!m_source.allowSubsamplingOfFrameAtIndex(0))
-        return;
-
-    // Values chosen to be appropriate for iOS.
-    const int cMaximumImageAreaBeforeSubsampling = 5 * 1024 * 1024;
-    const SubsamplingLevel maxSubsamplingLevel = 3;
-
-    SubsamplingLevel currentLevel = 0;
-    for ( ; currentLevel &lt;= maxSubsamplingLevel; ++currentLevel) {
-        IntSize frameSize = m_source.frameSizeAtIndex(0, currentLevel);
-        if (frameSize.area() &lt; cMaximumImageAreaBeforeSubsampling)
-            break;
-    }
-
-    m_minimumSubsamplingLevel = currentLevel;
-}
-
</del><span class="cx"> void BitmapImage::checkForSolidColor()
</span><span class="cx"> {
</span><span class="cx">     m_checkedForSolidColor = true;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgImageSourceCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -51,61 +51,53 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><ins>+    
+class ImageDecoder {
+public:
+    ImageDecoder();
+    
+    static std::unique_ptr&lt;ImageDecoder&gt; create()
+    {
+        return std::make_unique&lt;ImageDecoder&gt;();
+    }
</ins><span class="cx"> 
</span><del>-const CFStringRef WebCoreCGImagePropertyAPNGUnclampedDelayTime = CFSTR(&quot;UnclampedDelayTime&quot;);
-const CFStringRef WebCoreCGImagePropertyAPNGDelayTime = CFSTR(&quot;DelayTime&quot;);
-const CFStringRef WebCoreCGImagePropertyAPNGLoopCount = CFSTR(&quot;LoopCount&quot;);
</del><ins>+    static size_t bytesDecodedToDetermineProperties();
+    static SubsamplingLevel subsamplingLevelForScale(float scale, SubsamplingLevel maximumSubsamplingLevel);
</ins><span class="cx"> 
</span><del>-const CFStringRef kCGImageSourceShouldPreferRGB32 = CFSTR(&quot;kCGImageSourceShouldPreferRGB32&quot;);
-const CFStringRef kCGImageSourceSkipMetadata = CFSTR(&quot;kCGImageSourceSkipMetadata&quot;);
</del><ins>+    String filenameExtension() const;
+    bool isSizeAvailable() const;
+    
+    // Always original size, without subsampling.
+    IntSize size() const;
+    size_t frameCount() const;
+    int repetitionCount() const;
+    bool hotSpot(IntPoint&amp; hotSpot) const;
</ins><span class="cx"> 
</span><del>-#if !PLATFORM(COCOA)
-size_t sharedBufferGetBytesAtPosition(void* info, void* buffer, off_t position, size_t count)
-{
-    SharedBuffer* sharedBuffer = static_cast&lt;SharedBuffer*&gt;(info);
-    size_t sourceSize = sharedBuffer-&gt;size();
-    if (position &gt;= sourceSize)
-        return 0;
</del><ins>+    IntSize frameSizeAtIndex(size_t, SubsamplingLevel) const;
+    bool frameIsCompleteAtIndex(size_t) const;
+    ImageOrientation orientationAtIndex(size_t) const;
</ins><span class="cx"> 
</span><del>-    const char* source = sharedBuffer-&gt;data() + position;
-    size_t amount = std::min&lt;size_t&gt;(count, sourceSize - position);
-    memcpy(buffer, source, amount);
-    return amount;
-}
</del><ins>+    float frameDurationAtIndex(size_t) const;
+    bool frameHasAlphaAtIndex(size_t) const;
+    bool allowSubsamplingOfFrameAtIndex(size_t) const;
+    unsigned frameBytesAtIndex(size_t, SubsamplingLevel = 0) const;
</ins><span class="cx"> 
</span><del>-void sharedBufferRelease(void* info)
-{
-    SharedBuffer* sharedBuffer = static_cast&lt;SharedBuffer*&gt;(info);
-    sharedBuffer-&gt;deref();
-}
-#endif
</del><ins>+    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel) const;
</ins><span class="cx"> 
</span><del>-ImageSource::ImageSource(ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption)
-    : m_decoder(0)
-{
-    // FIXME: AlphaOption and GammaAndColorProfileOption are ignored.
-}
</del><ins>+    void setData(CFDataRef, bool allDataReceived);
+    void setData(SharedBuffer*, bool allDataReceived);
</ins><span class="cx"> 
</span><del>-ImageSource::~ImageSource()
-{
-    clear(true);
-}
</del><ins>+protected:
+    mutable IntSize m_size;
+    RetainPtr&lt;CGImageSourceRef&gt; m_nativeDecoder;
+};
</ins><span class="cx"> 
</span><del>-void ImageSource::clear(bool destroyAllFrames, size_t, SharedBuffer* data, bool allDataReceived)
-{
-    // Recent versions of ImageIO discard previously decoded image frames if the client
-    // application no longer holds references to them, so there's no need to throw away
-    // the decoder unless we're explicitly asked to destroy all of the frames.
-    if (!destroyAllFrames)
-        return;
</del><ins>+const CFStringRef WebCoreCGImagePropertyAPNGUnclampedDelayTime = CFSTR(&quot;UnclampedDelayTime&quot;);
+const CFStringRef WebCoreCGImagePropertyAPNGDelayTime = CFSTR(&quot;DelayTime&quot;);
+const CFStringRef WebCoreCGImagePropertyAPNGLoopCount = CFSTR(&quot;LoopCount&quot;);
</ins><span class="cx"> 
</span><del>-    if (m_decoder) {
-        CFRelease(m_decoder);
-        m_decoder = 0;
-    }
-    if (data)
-        setData(data, allDataReceived);
-}
</del><ins>+const CFStringRef kCGImageSourceShouldPreferRGB32 = CFSTR(&quot;kCGImageSourceShouldPreferRGB32&quot;);
+const CFStringRef kCGImageSourceSkipMetadata = CFSTR(&quot;kCGImageSourceSkipMetadata&quot;);
</ins><span class="cx"> 
</span><span class="cx"> static RetainPtr&lt;CFDictionaryRef&gt; createImageSourceOptions(SubsamplingLevel subsamplingLevel)
</span><span class="cx"> {
</span><span class="lines">@@ -135,173 +127,99 @@
</span><span class="cx">     return options;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageSource::initialized() const
-{
-    return m_decoder;
-}
-
-void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
-{
-#if PLATFORM(COCOA)
-    if (!m_decoder)
-        m_decoder = CGImageSourceCreateIncremental(0);
-    // On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge.  We use SharedBuffer's ability
-    // to wrap itself inside CFData to get around this, ensuring that ImageIO is really looking at the SharedBuffer.
-    CGImageSourceUpdateData(m_decoder, data-&gt;createCFData().get(), allDataReceived);
-#else
-    if (!m_decoder)
-        m_decoder = CGImageSourceCreateIncremental(0);
-    // Create a CGDataProvider to wrap the SharedBuffer.
-    data-&gt;ref();
-    // We use the GetBytesAtPosition callback rather than the GetBytePointer one because SharedBuffer
-    // does not provide a way to lock down the byte pointer and guarantee that it won't move, which
-    // is a requirement for using the GetBytePointer callback.
-    CGDataProviderDirectCallbacks providerCallbacks = { 0, 0, 0, sharedBufferGetBytesAtPosition, sharedBufferRelease };
-    RetainPtr&lt;CGDataProviderRef&gt; dataProvider = adoptCF(CGDataProviderCreateDirect(data, data-&gt;size(), &amp;providerCallbacks));
-    CGImageSourceUpdateDataProvider(m_decoder, dataProvider.get(), allDataReceived);
-#endif
-}
-
-String ImageSource::filenameExtension() const
-{
-    if (!m_decoder)
-        return String();
-    CFStringRef imageSourceType = CGImageSourceGetType(m_decoder);
-    return WebCore::preferredExtensionForImageSourceType(imageSourceType);
-}
-
-SubsamplingLevel ImageSource::subsamplingLevelForScale(float scale) const
-{
-    // There are four subsampling levels: 0 = 1x, 1 = 0.5x, 2 = 0.25x, 3 = 0.125x.
-    float clampedScale = std::max&lt;float&gt;(0.125, std::min&lt;float&gt;(1, scale));
-    int result = ceilf(log2f(1 / clampedScale));
-    ASSERT(result &gt;=0 &amp;&amp; result &lt;= 3);
-    return result;
-}
-
-bool ImageSource::isSizeAvailable()
-{
-    // Ragnaros yells: TOO SOON! You have awakened me TOO SOON, Executus!
-    if (CGImageSourceGetStatus(m_decoder) &lt; kCGImageStatusIncomplete)
-        return false;
-
-    RetainPtr&lt;CFDictionaryRef&gt; image0Properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_decoder, 0, imageSourceOptions().get()));
-    if (!image0Properties)
-        return false;
-
-    return CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelWidth)
-        &amp;&amp; CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelHeight);
-}
-
</del><span class="cx"> static ImageOrientation orientationFromProperties(CFDictionaryRef imageProperties)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(imageProperties);
</span><span class="cx">     CFNumberRef orientationProperty = (CFNumberRef)CFDictionaryGetValue(imageProperties, kCGImagePropertyOrientation);
</span><span class="cx">     if (!orientationProperty)
</span><del>-        return DefaultImageOrientation;
</del><ins>+        return ImageOrientation();
</ins><span class="cx"> 
</span><span class="cx">     int exifValue;
</span><span class="cx">     CFNumberGetValue(orientationProperty, kCFNumberIntType, &amp;exifValue);
</span><span class="cx">     return ImageOrientation::fromEXIFValue(exifValue);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageSource::allowSubsamplingOfFrameAtIndex(size_t) const
</del><ins>+#if !PLATFORM(COCOA)
+size_t sharedBufferGetBytesAtPosition(void* info, void* buffer, off_t position, size_t count)
</ins><span class="cx"> {
</span><del>-    RetainPtr&lt;CFDictionaryRef&gt; properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_decoder, 0, imageSourceOptions().get()));
-    if (!properties)
-        return false;
</del><ins>+    SharedBuffer* sharedBuffer = static_cast&lt;SharedBuffer*&gt;(info);
+    size_t sourceSize = sharedBuffer-&gt;size();
+    if (position &gt;= sourceSize)
+        return 0;
</ins><span class="cx"> 
</span><del>-    CFDictionaryRef jfifProperties = static_cast&lt;CFDictionaryRef&gt;(CFDictionaryGetValue(properties.get(), kCGImagePropertyJFIFDictionary));
-    if (jfifProperties) {
-        CFBooleanRef isProgCFBool = static_cast&lt;CFBooleanRef&gt;(CFDictionaryGetValue(jfifProperties, kCGImagePropertyJFIFIsProgressive));
-        if (isProgCFBool) {
-            bool isProgressive = CFBooleanGetValue(isProgCFBool);
-            // Workaround for &lt;rdar://problem/5184655&gt; - Hang rendering very large progressive JPEG. Decoding progressive
-            // images hangs for a very long time right now. Until this is fixed, don't sub-sample progressive images. This
-            // will cause them to fail our large image check and they won't be decoded.
-            // FIXME: Remove once underlying issue is fixed (&lt;rdar://problem/5191418&gt;)
-            return !isProgressive;
-        }
-    }
-
-    return true;
</del><ins>+    const char* source = sharedBuffer-&gt;data() + position;
+    size_t amount = std::min&lt;size_t&gt;(count, sourceSize - position);
+    memcpy(buffer, source, amount);
+    return amount;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-IntSize ImageSource::frameSizeAtIndex(size_t index, SubsamplingLevel subsamplingLevel, ImageOrientationDescription description) const
</del><ins>+void sharedBufferRelease(void* info)
</ins><span class="cx"> {
</span><del>-    RetainPtr&lt;CFDictionaryRef&gt; properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions(subsamplingLevel).get()));
-
-    if (!properties)
-        return IntSize();
-
-    int width = 0;
-    int height = 0;
-    CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyPixelWidth);
-    if (num)
-        CFNumberGetValue(num, kCFNumberIntType, &amp;width);
-    num = (CFNumberRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyPixelHeight);
-    if (num)
-        CFNumberGetValue(num, kCFNumberIntType, &amp;height);
-
-    if ((description.respectImageOrientation() == RespectImageOrientation) &amp;&amp; orientationFromProperties(properties.get()).usesWidthAsHeight())
-        return IntSize(height, width);
-
-    return IntSize(width, height);
</del><ins>+    SharedBuffer* sharedBuffer = static_cast&lt;SharedBuffer*&gt;(info);
+    sharedBuffer-&gt;deref();
</ins><span class="cx"> }
</span><del>-
-ImageOrientation ImageSource::orientationAtIndex(size_t index) const
</del><ins>+#endif
+    
+ImageDecoder::ImageDecoder()
</ins><span class="cx"> {
</span><del>-    RetainPtr&lt;CFDictionaryRef&gt; properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions().get()));
-    if (!properties)
-        return DefaultImageOrientation;
-
-    return orientationFromProperties(properties.get());
</del><ins>+    m_nativeDecoder = adoptCF(CGImageSourceCreateIncremental(nullptr));
</ins><span class="cx"> }
</span><ins>+    
+SubsamplingLevel ImageDecoder::subsamplingLevelForScale(float scale, SubsamplingLevel maximumSubsamplingLevel)
+{
+    // There are four subsampling levels: 0 = 1x, 1 = 0.5x, 2 = 0.25x, 3 = 0.125x.
+    float clampedScale = std::max&lt;float&gt;(0.125, std::min&lt;float&gt;(1, scale));
+    SubsamplingLevel result = ceilf(log2f(1 / clampedScale));
+    ASSERT(result &gt;=0 &amp;&amp; result &lt;= 3);
+    return std::min(result, maximumSubsamplingLevel);
+}
</ins><span class="cx"> 
</span><del>-IntSize ImageSource::size(ImageOrientationDescription description) const
</del><ins>+size_t ImageDecoder::bytesDecodedToDetermineProperties()
</ins><span class="cx"> {
</span><del>-    return frameSizeAtIndex(0, 0, description);
</del><ins>+    // Measured by tracing malloc/calloc calls on Mac OS 10.6.6, x86_64.
+    // A non-zero value ensures cached images with no decoded frames still enter
+    // the live decoded resources list when the CGImageSource decodes image
+    // properties, allowing the cache to prune the partially decoded image.
+    // This value is likely to be inaccurate on other platforms, but the overall
+    // behavior is unchanged.
+    return 13088;
</ins><span class="cx"> }
</span><ins>+    
+String ImageDecoder::filenameExtension() const
+{
+    CFStringRef imageSourceType = CGImageSourceGetType(m_nativeDecoder.get());
+    return WebCore::preferredExtensionForImageSourceType(imageSourceType);
+}
</ins><span class="cx"> 
</span><del>-bool ImageSource::getHotSpot(IntPoint&amp; hotSpot) const
</del><ins>+bool ImageDecoder::isSizeAvailable() const
</ins><span class="cx"> {
</span><del>-    RetainPtr&lt;CFDictionaryRef&gt; properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_decoder, 0, imageSourceOptions().get()));
-    if (!properties)
</del><ins>+    // Ragnaros yells: TOO SOON! You have awakened me TOO SOON, Executus!
+    if (CGImageSourceGetStatus(m_nativeDecoder.get()) &lt; kCGImageStatusIncomplete)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    int x = -1, y = -1;
-    CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(properties.get(), CFSTR(&quot;hotspotX&quot;));
-    if (!num || !CFNumberGetValue(num, kCFNumberIntType, &amp;x))
</del><ins>+    RetainPtr&lt;CFDictionaryRef&gt; image0Properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get()));
+    if (!image0Properties)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    num = (CFNumberRef)CFDictionaryGetValue(properties.get(), CFSTR(&quot;hotspotY&quot;));
-    if (!num || !CFNumberGetValue(num, kCFNumberIntType, &amp;y))
-        return false;
</del><ins>+    return CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelWidth)
+        &amp;&amp; CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelHeight);
+}
</ins><span class="cx"> 
</span><del>-    if (x &lt; 0 || y &lt; 0)
-        return false;
-
-    hotSpot = IntPoint(x, y);
-    return true;
</del><ins>+IntSize ImageDecoder::size() const
+{
+    if (m_size.isEmpty())
+        m_size = frameSizeAtIndex(0, 0);
+    return m_size;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-size_t ImageSource::bytesDecodedToDetermineProperties() const
</del><ins>+size_t ImageDecoder::frameCount() const
</ins><span class="cx"> {
</span><del>-    // Measured by tracing malloc/calloc calls on Mac OS 10.6.6, x86_64.
-    // A non-zero value ensures cached images with no decoded frames still enter
-    // the live decoded resources list when the CGImageSource decodes image
-    // properties, allowing the cache to prune the partially decoded image.
-    // This value is likely to be inaccurate on other platforms, but the overall
-    // behavior is unchanged.
-    return 13088;
</del><ins>+    return CGImageSourceGetCount(m_nativeDecoder.get());
</ins><span class="cx"> }
</span><del>-    
-int ImageSource::repetitionCount()
</del><ins>+
+int ImageDecoder::repetitionCount() const
</ins><span class="cx"> {
</span><del>-    if (!initialized())
-        return cAnimationLoopOnce;
-
-    RetainPtr&lt;CFDictionaryRef&gt; properties = adoptCF(CGImageSourceCopyProperties(m_decoder, imageSourceOptions().get()));
</del><ins>+    RetainPtr&lt;CFDictionaryRef&gt; properties = adoptCF(CGImageSourceCopyProperties(m_nativeDecoder.get(), imageSourceOptions().get()));
</ins><span class="cx">     if (!properties)
</span><span class="cx">         return cAnimationLoopOnce;
</span><span class="cx"> 
</span><span class="lines">@@ -335,61 +253,67 @@
</span><span class="cx">     return cAnimationNone;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-size_t ImageSource::frameCount() const
</del><ins>+bool ImageDecoder::hotSpot(IntPoint&amp; hotSpot) const
</ins><span class="cx"> {
</span><del>-    return m_decoder ? CGImageSourceGetCount(m_decoder) : 0;
</del><ins>+    RetainPtr&lt;CFDictionaryRef&gt; properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get()));
+    if (!properties)
+        return false;
+
+    int x = -1, y = -1;
+    CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(properties.get(), CFSTR(&quot;hotspotX&quot;));
+    if (!num || !CFNumberGetValue(num, kCFNumberIntType, &amp;x))
+        return false;
+
+    num = (CFNumberRef)CFDictionaryGetValue(properties.get(), CFSTR(&quot;hotspotY&quot;));
+    if (!num || !CFNumberGetValue(num, kCFNumberIntType, &amp;y))
+        return false;
+
+    if (x &lt; 0 || y &lt; 0)
+        return false;
+
+    hotSpot = IntPoint(x, y);
+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-RetainPtr&lt;CGImageRef&gt; ImageSource::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel)
</del><ins>+IntSize ImageDecoder::frameSizeAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const
</ins><span class="cx"> {
</span><del>-    if (!initialized())
-        return nullptr;
</del><ins>+    RetainPtr&lt;CFDictionaryRef&gt; properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), index, imageSourceOptions(subsamplingLevel).get()));
</ins><span class="cx"> 
</span><del>-    RetainPtr&lt;CGImageRef&gt; image = adoptCF(CGImageSourceCreateImageAtIndex(m_decoder, index, imageSourceOptions(subsamplingLevel).get()));
</del><ins>+    if (!properties)
+        return { };
</ins><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
-    // &lt;rdar://problem/7371198&gt; - CoreGraphics changed the default caching behaviour in iOS 4.0 to kCGImageCachingTransient
-    // which caused a performance regression for us since the images had to be resampled/recreated every time we called
-    // CGContextDrawImage. We now tell CG to cache the drawn images. See also &lt;rdar://problem/14366755&gt; -
-    // CoreGraphics needs to un-deprecate kCGImageCachingTemporary since it's still not the default.
-#if COMPILER(CLANG)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
-#endif
-    CGImageSetCachingFlags(image.get(), kCGImageCachingTemporary);
-#if COMPILER(CLANG)
-#pragma clang diagnostic pop
-#endif
-#endif // PLATFORM(IOS)
</del><ins>+    int width = 0;
+    int height = 0;
+    CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyPixelWidth);
+    if (num)
+        CFNumberGetValue(num, kCFNumberIntType, &amp;width);
</ins><span class="cx"> 
</span><del>-    CFStringRef imageUTI = CGImageSourceGetType(m_decoder);
-    static const CFStringRef xbmUTI = CFSTR(&quot;public.xbitmap-image&quot;);
</del><ins>+    num = (CFNumberRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyPixelHeight);
+    if (num)
+        CFNumberGetValue(num, kCFNumberIntType, &amp;height);
</ins><span class="cx"> 
</span><del>-    if (!imageUTI)
-        return image;
-
-    if (!CFEqual(imageUTI, xbmUTI))
-        return image;
-    
-    // If it is an xbm image, mask out all the white areas to render them transparent.
-    const CGFloat maskingColors[6] = {255, 255,  255, 255, 255, 255};
-    RetainPtr&lt;CGImageRef&gt; maskedImage = adoptCF(CGImageCreateWithMaskingColors(image.get(), maskingColors));
-    return maskedImage ? maskedImage : image;
</del><ins>+    return IntSize(width, height);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageSource::frameIsCompleteAtIndex(size_t index)
</del><ins>+bool ImageDecoder::frameIsCompleteAtIndex(size_t index) const
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(frameCount());
</span><del>-    return CGImageSourceGetStatusAtIndex(m_decoder, index) == kCGImageStatusComplete;
</del><ins>+    return CGImageSourceGetStatusAtIndex(m_nativeDecoder.get(), index) == kCGImageStatusComplete;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-float ImageSource::frameDurationAtIndex(size_t index)
</del><ins>+ImageOrientation ImageDecoder::orientationAtIndex(size_t index) const
</ins><span class="cx"> {
</span><del>-    if (!initialized())
-        return 0;
</del><ins>+    RetainPtr&lt;CFDictionaryRef&gt; properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), index, imageSourceOptions().get()));
+    if (!properties)
+        return ImageOrientation();
</ins><span class="cx"> 
</span><ins>+    return orientationFromProperties(properties.get());
+}
+
+float ImageDecoder::frameDurationAtIndex(size_t index) const
+{
</ins><span class="cx">     float duration = 0;
</span><del>-    RetainPtr&lt;CFDictionaryRef&gt; properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions().get()));
</del><ins>+    RetainPtr&lt;CFDictionaryRef&gt; properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), index, imageSourceOptions().get()));
</ins><span class="cx">     if (properties) {
</span><span class="cx">         CFDictionaryRef gifProperties = (CFDictionaryRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyGIFDictionary);
</span><span class="cx">         if (gifProperties) {
</span><span class="lines">@@ -420,15 +344,34 @@
</span><span class="cx">     return duration;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageSource::frameHasAlphaAtIndex(size_t index)
</del><ins>+bool ImageDecoder::allowSubsamplingOfFrameAtIndex(size_t) const
</ins><span class="cx"> {
</span><del>-    if (!m_decoder)
-        return false; // FIXME: why doesn't this return true?
</del><ins>+    RetainPtr&lt;CFDictionaryRef&gt; properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get()));
+    if (!properties)
+        return false;
</ins><span class="cx"> 
</span><ins>+    CFDictionaryRef jfifProperties = static_cast&lt;CFDictionaryRef&gt;(CFDictionaryGetValue(properties.get(), kCGImagePropertyJFIFDictionary));
+    if (jfifProperties) {
+        CFBooleanRef isProgCFBool = static_cast&lt;CFBooleanRef&gt;(CFDictionaryGetValue(jfifProperties, kCGImagePropertyJFIFIsProgressive));
+        if (isProgCFBool) {
+            bool isProgressive = CFBooleanGetValue(isProgCFBool);
+            // Workaround for &lt;rdar://problem/5184655&gt; - Hang rendering very large progressive JPEG. Decoding progressive
+            // images hangs for a very long time right now. Until this is fixed, don't sub-sample progressive images. This
+            // will cause them to fail our large image check and they won't be decoded.
+            // FIXME: Remove once underlying issue is fixed (&lt;rdar://problem/5191418&gt;)
+            return !isProgressive;
+        }
+    }
+
+    return true;
+}
+
+bool ImageDecoder::frameHasAlphaAtIndex(size_t index) const
+{
</ins><span class="cx">     if (!frameIsCompleteAtIndex(index))
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    CFStringRef imageType = CGImageSourceGetType(m_decoder);
</del><ins>+    CFStringRef imageType = CGImageSourceGetType(m_nativeDecoder.get());
</ins><span class="cx"> 
</span><span class="cx">     // Return false if there is no image type or the image type is JPEG, because
</span><span class="cx">     // JPEG does not support alpha transparency.
</span><span class="lines">@@ -441,11 +384,245 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+unsigned ImageDecoder::frameBytesAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const
+{
+    IntSize frameSize = frameSizeAtIndex(index, subsamplingLevel);
+    return frameSize.area() * 4;
+}
+
+NativeImagePtr ImageDecoder::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const
+{
+    RetainPtr&lt;CGImageRef&gt; image = adoptCF(CGImageSourceCreateImageAtIndex(m_nativeDecoder.get(), index, imageSourceOptions(subsamplingLevel).get()));
+
+#if PLATFORM(IOS)
+    // &lt;rdar://problem/7371198&gt; - CoreGraphics changed the default caching behaviour in iOS 4.0 to kCGImageCachingTransient
+    // which caused a performance regression for us since the images had to be resampled/recreated every time we called
+    // CGContextDrawImage. We now tell CG to cache the drawn images. See also &lt;rdar://problem/14366755&gt; -
+    // CoreGraphics needs to un-deprecate kCGImageCachingTemporary since it's still not the default.
+#if COMPILER(CLANG)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
+#endif
+        CGImageSetCachingFlags(image.get(), kCGImageCachingTemporary);
+#if COMPILER(CLANG)
+#pragma clang diagnostic pop
+#endif
+#endif // PLATFORM(IOS)
+
+    CFStringRef imageUTI = CGImageSourceGetType(m_nativeDecoder.get());
+    static const CFStringRef xbmUTI = CFSTR(&quot;public.xbitmap-image&quot;);
+
+    if (!imageUTI)
+        return image;
+
+    if (!CFEqual(imageUTI, xbmUTI))
+        return image;
+
+    // If it is an xbm image, mask out all the white areas to render them transparent.
+    const CGFloat maskingColors[6] = {255, 255,  255, 255, 255, 255};
+    RetainPtr&lt;CGImageRef&gt; maskedImage = adoptCF(CGImageCreateWithMaskingColors(image.get(), maskingColors));
+    return maskedImage ? maskedImage : image;
+}
+
+void ImageDecoder::setData(CFDataRef data, bool allDataReceived)
+{
+    CGImageSourceUpdateData(m_nativeDecoder.get(), data, allDataReceived);
+}
+
+void ImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
+{
+#if PLATFORM(COCOA)
+    // On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge.
+    // We use SharedBuffer's ability to wrap itself inside CFData to get around this, ensuring that ImageIO is
+    // really looking at the SharedBuffer.
+    setData(data-&gt;createCFData().get(), allDataReceived);
+    CGImageSourceUpdateData(m_nativeDecoder.get(), data-&gt;createCFData().get(), allDataReceived);
+#else
+    // Create a CGDataProvider to wrap the SharedBuffer.
+    data-&gt;ref();
+    // We use the GetBytesAtPosition callback rather than the GetBytePointer one because SharedBuffer
+    // does not provide a way to lock down the byte pointer and guarantee that it won't move, which
+    // is a requirement for using the GetBytePointer callback.
+    CGDataProviderDirectCallbacks providerCallbacks = { 0, 0, 0, sharedBufferGetBytesAtPosition, sharedBufferRelease };
+    RetainPtr&lt;CGDataProviderRef&gt; dataProvider = adoptCF(CGDataProviderCreateDirect(data, data-&gt;size(), &amp;providerCallbacks));
+    CGImageSourceUpdateDataProvider(m_nativeDecoder.get(), dataProvider.get(), allDataReceived);
+#endif
+}
+
+ImageSource::ImageSource(ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption)
+{
+    // FIXME: AlphaOption and GammaAndColorProfileOption are ignored.
+}
+
+ImageSource::~ImageSource()
+{
+    clear(true);
+}
+
+void ImageSource::clear(bool destroyAllFrames, size_t, SharedBuffer* data, bool allDataReceived)
+{
+    // Recent versions of ImageIO discard previously decoded image frames if the client
+    // application no longer holds references to them, so there's no need to throw away
+    // the decoder unless we're explicitly asked to destroy all of the frames.
+    if (!destroyAllFrames)
+        return;
+
+    m_decoder = nullptr;
+    
+    if (data)
+        setData(data, allDataReceived);
+}
+    
+void ImageSource::ensureDecoderIsCreated(SharedBuffer*)
+{
+    if (initialized())
+        return;
+    m_decoder = ImageDecoder::create();
+}
+
+void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
+{
+    if (!data)
+        return;
+    
+    ensureDecoderIsCreated(data);
+    
+    if (!initialized()) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+    
+    m_decoder-&gt;setData(data, allDataReceived);
+}
+
+String ImageSource::filenameExtension() const
+{
+    return initialized() ? m_decoder-&gt;filenameExtension() : String();
+}
+    
+SubsamplingLevel ImageSource::calculateMaximumSubsamplingLevel() const
+{
+    if (!m_allowSubsampling || !allowSubsamplingOfFrameAtIndex(0))
+        return 0;
+
+    // Values chosen to be appropriate for iOS.
+    const int cMaximumImageAreaBeforeSubsampling = 5 * 1024 * 1024;
+    const SubsamplingLevel maxSubsamplingLevel = 3;
+
+    SubsamplingLevel currentLevel = 0;
+    for ( ; currentLevel &lt;= maxSubsamplingLevel; ++currentLevel) {
+        IntSize frameSize = frameSizeAtIndex(0, currentLevel);
+        if (frameSize.area() &lt; cMaximumImageAreaBeforeSubsampling)
+            break;
+    }
+
+    return currentLevel;
+}
+    
+SubsamplingLevel ImageSource::maximumSubsamplingLevel() const
+{
+#if PLATFORM(IOS)
+    return calculateMaximumSubsamplingLevel();
+#endif
+    return 0;
+}
+
+SubsamplingLevel ImageSource::subsamplingLevelForScale(float scale) const
+{
+    return ImageDecoder::subsamplingLevelForScale(scale, maximumSubsamplingLevel());
+}
+
+bool ImageSource::isSizeAvailable()
+{
+    return initialized() &amp;&amp; m_decoder-&gt;isSizeAvailable();
+}
+
+bool ImageSource::allowSubsamplingOfFrameAtIndex(size_t index) const
+{
+    return initialized() &amp;&amp; m_decoder-&gt;allowSubsamplingOfFrameAtIndex(index);
+}
+
+IntSize ImageSource::frameSizeAtIndex(size_t index, SubsamplingLevel subsamplingLevel, RespectImageOrientationEnum shouldRespectImageOrientation) const
+{
+    if (!initialized())
+        return { };
+    
+    IntSize size = m_decoder-&gt;frameSizeAtIndex(index, subsamplingLevel);
+    ImageOrientation orientation = m_decoder-&gt;orientationAtIndex(index);
+    
+    return shouldRespectImageOrientation == RespectImageOrientation &amp;&amp; orientation.usesWidthAsHeight() ? size.transposedSize() : size;
+}
+
+ImageOrientation ImageSource::orientationAtIndex(size_t index) const
+{
+    return initialized() ? m_decoder-&gt;orientationAtIndex(index) : ImageOrientation();
+}
+
+IntSize ImageSource::size() const
+{
+    return frameSizeAtIndex(0, 0);
+}
+    
+IntSize ImageSource::sizeRespectingOrientation() const
+{
+    return frameSizeAtIndex(0, 0, RespectImageOrientation);
+}
+
+bool ImageSource::getHotSpot(IntPoint&amp; hotSpot) const
+{
+    return initialized() &amp;&amp; m_decoder-&gt;hotSpot(hotSpot);
+}
+
+size_t ImageSource::bytesDecodedToDetermineProperties() const
+{
+    return ImageDecoder::bytesDecodedToDetermineProperties();
+}
+    
+int ImageSource::repetitionCount()
+{
+    return initialized() ? m_decoder-&gt;repetitionCount() : cAnimationLoopOnce;
+}
+
+size_t ImageSource::frameCount() const
+{
+    return initialized() ? m_decoder-&gt;frameCount() : 0;
+}
+
+RetainPtr&lt;CGImageRef&gt; ImageSource::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel)
+{
+    return initialized() ? m_decoder-&gt;createFrameImageAtIndex(index, subsamplingLevel) : nullptr;
+}
+
+bool ImageSource::frameIsCompleteAtIndex(size_t index)
+{
+    return initialized() &amp;&amp; m_decoder-&gt;frameIsCompleteAtIndex(index);
+}
+
+float ImageSource::frameDurationAtIndex(size_t index)
+{
+    return initialized() ? m_decoder-&gt;frameDurationAtIndex(index) : 0;
+}
+
+bool ImageSource::frameHasAlphaAtIndex(size_t index)
+{
+    return !initialized() || m_decoder-&gt;frameHasAlphaAtIndex(index);
+}
+
</ins><span class="cx"> unsigned ImageSource::frameBytesAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const
</span><span class="cx"> {
</span><del>-    IntSize frameSize = frameSizeAtIndex(index, subsamplingLevel, ImageOrientationDescription(RespectImageOrientation));
-    return frameSize.width() * frameSize.height() * 4;
</del><ins>+    IntSize frameSize = frameSizeAtIndex(index, subsamplingLevel);
+    return frameSize.area() * 4;
</ins><span class="cx"> }
</span><ins>+    
+void ImageSource::dump(TextStream&amp; ts) const
+{
+    if (m_allowSubsampling)
+        ts.dumpProperty(&quot;allow-subsampling&quot;, m_allowSubsampling);
+    
+    ImageOrientation orientation = orientationAtIndex(0);
+    if (orientation != OriginTopLeft)
+        ts.dumpProperty(&quot;orientation&quot;, orientation);
+}
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersImageDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/ImageDecoder.cpp (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/ImageDecoder.cpp        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/platform/image-decoders/ImageDecoder.cpp        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -95,35 +95,35 @@
</span><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ImageDecoder* ImageDecoder::create(const SharedBuffer&amp; data, ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption)
</del><ins>+std::unique_ptr&lt;ImageDecoder&gt; ImageDecoder::create(const SharedBuffer&amp; data, ImageSource::AlphaOption alphaOption, ImageSource::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="cx">     unsigned length = copyFromSharedBuffer(contents, lengthOfLongestSignature, data, 0);
</span><span class="cx">     if (length &lt; lengthOfLongestSignature)
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx"> 
</span><span class="cx">     if (matchesGIFSignature(contents))
</span><del>-        return new GIFImageDecoder(alphaOption, gammaAndColorProfileOption);
</del><ins>+        return std::unique_ptr&lt;ImageDecoder&gt; { std::make_unique&lt;GIFImageDecoder&gt;(alphaOption, gammaAndColorProfileOption) };
</ins><span class="cx"> 
</span><span class="cx">     if (matchesPNGSignature(contents))
</span><del>-        return new PNGImageDecoder(alphaOption, gammaAndColorProfileOption);
</del><ins>+        return std::unique_ptr&lt;ImageDecoder&gt; { std::make_unique&lt;PNGImageDecoder&gt;(alphaOption, gammaAndColorProfileOption) };
</ins><span class="cx"> 
</span><span class="cx">     if (matchesICOSignature(contents) || matchesCURSignature(contents))
</span><del>-        return new ICOImageDecoder(alphaOption, gammaAndColorProfileOption);
</del><ins>+        return std::unique_ptr&lt;ImageDecoder&gt; { std::make_unique&lt;ICOImageDecoder&gt;(alphaOption, gammaAndColorProfileOption) };
</ins><span class="cx"> 
</span><span class="cx">     if (matchesJPEGSignature(contents))
</span><del>-        return new JPEGImageDecoder(alphaOption, gammaAndColorProfileOption);
</del><ins>+        return std::unique_ptr&lt;ImageDecoder&gt; { std::make_unique&lt;JPEGImageDecoder&gt;(alphaOption, gammaAndColorProfileOption) };
</ins><span class="cx"> 
</span><span class="cx"> #if USE(WEBP)
</span><span class="cx">     if (matchesWebPSignature(contents))
</span><del>-        return new WEBPImageDecoder(alphaOption, gammaAndColorProfileOption);
</del><ins>+        return std::unique_ptr&lt;ImageDecoder&gt; { std::make_unique&lt;WEBPImageDecoder&gt;(alphaOption, gammaAndColorProfileOption) };
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     if (matchesBMPSignature(contents))
</span><del>-        return new BMPImageDecoder(alphaOption, gammaAndColorProfileOption);
</del><ins>+        return std::unique_ptr&lt;ImageDecoder&gt; { std::make_unique&lt;BMPImageDecoder&gt;(alphaOption, gammaAndColorProfileOption) };
</ins><span class="cx"> 
</span><del>-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ImageFrame::ImageFrame()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersImageDecoderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -248,7 +248,7 @@
</span><span class="cx">         // Returns a caller-owned decoder of the appropriate type.  Returns 0 if
</span><span class="cx">         // we can't sniff a supported type from the provided data (possibly
</span><span class="cx">         // because there isn't enough data yet).
</span><del>-        static ImageDecoder* create(const SharedBuffer&amp; data, ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption);
</del><ins>+        static std::unique_ptr&lt;ImageDecoder&gt; create(const SharedBuffer&amp; data, ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption);
</ins><span class="cx"> 
</span><span class="cx">         virtual String filenameExtension() const = 0;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacDragImageMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/DragImageMac.mm (198781 => 198782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/DragImageMac.mm        2016-03-29 15:42:46 UTC (rev 198781)
+++ trunk/Source/WebCore/platform/mac/DragImageMac.mm        2016-03-29 16:18:25 UTC (rev 198782)
</span><span class="lines">@@ -91,7 +91,7 @@
</span><span class="cx">     if (is&lt;BitmapImage&gt;(*image)) {
</span><span class="cx">         ImageOrientation orientation;
</span><span class="cx">         BitmapImage&amp; bitmapImage = downcast&lt;BitmapImage&gt;(*image);
</span><del>-        IntSize sizeRespectingOrientation = bitmapImage.sizeRespectingOrientation(description);
</del><ins>+        IntSize sizeRespectingOrientation = bitmapImage.sizeRespectingOrientation();
</ins><span class="cx"> 
</span><span class="cx">         if (description.respectImageOrientation() == RespectImageOrientation)
</span><span class="cx">             orientation = bitmapImage.orientationForCurrentFrame();
</span></span></pre>
</div>
</div>

</body>
</html>