Title: [215211] trunk/Source/WebCore
Revision
215211
Author
commit-qu...@webkit.org
Date
2017-04-10 17:24:17 -0700 (Mon, 10 Apr 2017)

Log Message

CachedImage should stop decoding images when unknown type is detected
https://bugs.webkit.org/show_bug.cgi?id=170530

Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2017-04-10
Reviewed by Tim Horton.

If the status of the encoded data is "unknown type", WebKit should stop
decoding the rest of the data. Ideally WebKit should also cancel loading
the rest of the encoded data.

To do that we need to add a function to the ImageDecoder to return the
encodedDataStatus(). We also need to change the return type of Image::setData()
and Image::dataChanged() form bool to EncodedDataStatus.

* WebCore.xcodeproj/project.pbxproj: Add ImageTypes.h to the WebCore project.
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::addIncrementalDataBuffer): Replace checking !sizeAvailable
by checking if encodedDataStatus isn't an error but it has not reached
sizeAvailable state
* loader/cache/CachedResourceClientWalker.h:
(WebCore::CachedResourceClientWalker::CachedResourceClientWalker): Unrelated clean-up.
(WebCore::CachedResourceClientWalker::next): Ditto.
* loader/icon/IconRecord.cpp:
(WebCore::IconRecord::setImageData): Image::setData() used to return a bool. Now it returns
an EncodedDataStatus. !setData() now means setData() < EncodedDataStatus::SizeAvailable.
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::dataChanged): Replace the return of dataChanged() from bool
by EncodedDataStatus.
* platform/graphics/BitmapImage.h: Replace isSizeAvailable() by a new function
named encodedDataStatus().
* platform/graphics/Image.cpp:
(WebCore::Image::setData): Code clean-up and adding a clarification comment.
* platform/graphics/Image.h: Change the return of setData() and dataChanged() to be
EncodedDataStatus.
(WebCore::Image::dataChanged): Return EncodedDataStatus::Unknown as an indication
the size is not available but we do not have an error.
* platform/graphics/ImageTypes.h: Added.
Image definitions which are shared among Image, ImageDecoder, ImageSource,
ImageFrameCache and ImageFrame used to be added to ImageFrame.h. This has
been annoying since these definitions aren't related to ImageFrame only.
A new header file named ImageTypes.h is to the to include such definitions.
(WebCore::operator++):
* platform/graphics/ImageFrame.h:
(WebCore::operator++): Deleted.
* platform/graphics/ImageFrameCache.cpp:
(WebCore::ImageFrameCache::ImageFrameCache): This is the case of a BitmapImage without
a decoder but with a NativeImage. The status has to be EncodedDataStatus::Complete.
(WebCore::ImageFrameCache::growFrames): Replace if (isSizeAvailable()) by
if (encodedDataStatus() >= EncodedDataStatus::SizeAvailable).
(WebCore::ImageFrameCache::metadata): Ditto.
(WebCore::ImageFrameCache::encodedDataStatus): This is a replacement for isSizeAvailable().
Don't cache the EncodedDataStatus until it is Complete. Don't call didDecodeProperties()
until the status >= EncodedDataStatus::SizeAvailable.
(WebCore::ImageFrameCache::isSizeAvailable): Deleted.
* platform/graphics/ImageFrameCache.h: Replace isSizeAvailable() by encodedDataStatus().
* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::dataChanged): Make return an EncodedDataStatus instead of returning
a bool for isSizeAvailable.
* platform/graphics/ImageSource.h:
(WebCore::ImageSource::encodedDataStatus): Replace isSizeAvailable() by encodedDataStatus().
(WebCore::ImageSource::isSizeAvailable): Deleted.
* platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::ImageDecoder::encodedDataStatus): Replace isSizeAvailable() by encodedDataStatus().
The logic of this function is the following:
    -- CGImageSourceGetStatus() can return kCGImageStatusUnexpectedEOF, kCGImageStatusInvalidData
    or kCGImageStatusReadingHeader even if CG will end up recovering form the error and drawing
    the image. Actually CG initializes the status of CGImageSource before receiving any data
    with kCGImageStatusInvalidData. So the status will be considered an error only if all the
    data is received but CG does not move the status of this CGImageSource to Complete.
    -- If CGImageSourceGetStatus() returns Incomplete, this means CG already created the image
    reader and therefore the image type is known.
    -- If CGImageSourceGetStatus() returns UnknownType, this means CG could not create the
    image reader and this should be considered an error.
(WebCore::ImageDecoder::isSizeAvailable): Deleted.
* platform/graphics/cg/ImageDecoderCG.h: Replace isSizeAvailable() by encodedDataStatus().
* platform/graphics/cg/PDFDocumentImage.cpp:
(WebCore::PDFDocumentImage::dataChanged): The PDFDocument is created only when allDataReceived.
* platform/graphics/cg/PDFDocumentImage.h: Change the return type from bool to EncodedDataStatus.
* platform/image-decoders/ImageDecoder.h:
(WebCore::ImageDecoder::encodedDataStatus): Add a new function encodedDataStatus(). Deduce the
status of the encoded data from the flags m_failed, m_isAllDataReceived and m_sizeAvailable in
this order.
(WebCore::ImageDecoder::isSizeAvailable): Make this function uses encodedDataStatus().
* platform/image-decoders/bmp/BMPImageDecoder.cpp:
(WebCore::BMPImageDecoder::encodedDataStatus): Replace isSizeAvailable() by encodedDataStatus().
(WebCore::BMPImageDecoder::isSizeAvailable): Deleted.
* platform/image-decoders/bmp/BMPImageDecoder.h:
* platform/image-decoders/gif/GIFImageDecoder.cpp:
(WebCore::GIFImageDecoder::encodedDataStatus): Ditto.
(WebCore::GIFImageDecoder::isSizeAvailable): Deleted.
* platform/image-decoders/gif/GIFImageDecoder.h:
* platform/image-decoders/ico/ICOImageDecoder.cpp:
(WebCore::ICOImageDecoder::encodedDataStatus): Ditto.
(WebCore::ICOImageDecoder::isSizeAvailable): Deleted.
* platform/image-decoders/ico/ICOImageDecoder.h:
* platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
(WebCore::JPEGImageDecoder::encodedDataStatus): Ditto.
(WebCore::JPEGImageDecoder::isSizeAvailable): Deleted.
* platform/image-decoders/jpeg/JPEGImageDecoder.h:
* platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::PNGImageDecoder::encodedDataStatus): Ditto.
(WebCore::PNGImageDecoder::isSizeAvailable): Deleted.
* platform/image-decoders/png/PNGImageDecoder.h:
* platform/image-decoders/webp/WEBPImageDecoder.cpp:
(WebCore::WEBPImageDecoder::encodedDataStatus): Ditto.
(WebCore::WEBPImageDecoder::isSizeAvailable): Deleted.
* platform/image-decoders/webp/WEBPImageDecoder.h:
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::dataChanged): m_page is created only when allDataReceived is true.
* svg/graphics/SVGImage.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (215210 => 215211)


--- trunk/Source/WebCore/ChangeLog	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/ChangeLog	2017-04-11 00:24:17 UTC (rev 215211)
@@ -1,3 +1,115 @@
+2017-04-10  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        CachedImage should stop decoding images when unknown type is detected
+        https://bugs.webkit.org/show_bug.cgi?id=170530
+
+        Reviewed by Tim Horton.
+
+        If the status of the encoded data is "unknown type", WebKit should stop
+        decoding the rest of the data. Ideally WebKit should also cancel loading
+        the rest of the encoded data.
+        
+        To do that we need to add a function to the ImageDecoder to return the
+        encodedDataStatus(). We also need to change the return type of Image::setData()
+        and Image::dataChanged() form bool to EncodedDataStatus.
+
+        * WebCore.xcodeproj/project.pbxproj: Add ImageTypes.h to the WebCore project.
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::addIncrementalDataBuffer): Replace checking !sizeAvailable 
+        by checking if encodedDataStatus isn't an error but it has not reached
+        sizeAvailable state
+        * loader/cache/CachedResourceClientWalker.h:
+        (WebCore::CachedResourceClientWalker::CachedResourceClientWalker): Unrelated clean-up.
+        (WebCore::CachedResourceClientWalker::next): Ditto.
+        * loader/icon/IconRecord.cpp:
+        (WebCore::IconRecord::setImageData): Image::setData() used to return a bool. Now it returns
+        an EncodedDataStatus. !setData() now means setData() < EncodedDataStatus::SizeAvailable.
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::dataChanged): Replace the return of dataChanged() from bool
+        by EncodedDataStatus.
+        * platform/graphics/BitmapImage.h: Replace isSizeAvailable() by a new function
+        named encodedDataStatus().
+        * platform/graphics/Image.cpp:
+        (WebCore::Image::setData): Code clean-up and adding a clarification comment.
+        * platform/graphics/Image.h: Change the return of setData() and dataChanged() to be
+        EncodedDataStatus.
+        (WebCore::Image::dataChanged): Return EncodedDataStatus::Unknown as an indication
+        the size is not available but we do not have an error.
+        * platform/graphics/ImageTypes.h: Added.
+        Image definitions which are shared among Image, ImageDecoder, ImageSource,
+        ImageFrameCache and ImageFrame used to be added to ImageFrame.h. This has
+        been annoying since these definitions aren't related to ImageFrame only.
+        A new header file named ImageTypes.h is to the to include such definitions.
+        (WebCore::operator++):
+        * platform/graphics/ImageFrame.h:
+        (WebCore::operator++): Deleted.
+        * platform/graphics/ImageFrameCache.cpp:
+        (WebCore::ImageFrameCache::ImageFrameCache): This is the case of a BitmapImage without
+        a decoder but with a NativeImage. The status has to be EncodedDataStatus::Complete.
+        (WebCore::ImageFrameCache::growFrames): Replace if (isSizeAvailable()) by
+        if (encodedDataStatus() >= EncodedDataStatus::SizeAvailable).
+        (WebCore::ImageFrameCache::metadata): Ditto.
+        (WebCore::ImageFrameCache::encodedDataStatus): This is a replacement for isSizeAvailable().
+        Don't cache the EncodedDataStatus until it is Complete. Don't call didDecodeProperties()
+        until the status >= EncodedDataStatus::SizeAvailable.
+        (WebCore::ImageFrameCache::isSizeAvailable): Deleted.
+        * platform/graphics/ImageFrameCache.h: Replace isSizeAvailable() by encodedDataStatus().
+        * platform/graphics/ImageSource.cpp:
+        (WebCore::ImageSource::dataChanged): Make return an EncodedDataStatus instead of returning
+        a bool for isSizeAvailable.
+        * platform/graphics/ImageSource.h:
+        (WebCore::ImageSource::encodedDataStatus): Replace isSizeAvailable() by encodedDataStatus().
+        (WebCore::ImageSource::isSizeAvailable): Deleted.
+        * platform/graphics/cg/ImageDecoderCG.cpp:
+        (WebCore::ImageDecoder::encodedDataStatus): Replace isSizeAvailable() by encodedDataStatus().
+        The logic of this function is the following:
+            -- CGImageSourceGetStatus() can return kCGImageStatusUnexpectedEOF, kCGImageStatusInvalidData
+            or kCGImageStatusReadingHeader even if CG will end up recovering form the error and drawing
+            the image. Actually CG initializes the status of CGImageSource before receiving any data
+            with kCGImageStatusInvalidData. So the status will be considered an error only if all the
+            data is received but CG does not move the status of this CGImageSource to Complete.
+            -- If CGImageSourceGetStatus() returns Incomplete, this means CG already created the image
+            reader and therefore the image type is known.
+            -- If CGImageSourceGetStatus() returns UnknownType, this means CG could not create the
+            image reader and this should be considered an error.
+        (WebCore::ImageDecoder::isSizeAvailable): Deleted.
+        * platform/graphics/cg/ImageDecoderCG.h: Replace isSizeAvailable() by encodedDataStatus().
+        * platform/graphics/cg/PDFDocumentImage.cpp:
+        (WebCore::PDFDocumentImage::dataChanged): The PDFDocument is created only when allDataReceived.
+        * platform/graphics/cg/PDFDocumentImage.h: Change the return type from bool to EncodedDataStatus.
+        * platform/image-decoders/ImageDecoder.h: 
+        (WebCore::ImageDecoder::encodedDataStatus): Add a new function encodedDataStatus(). Deduce the
+        status of the encoded data from the flags m_failed, m_isAllDataReceived and m_sizeAvailable in
+        this order.
+        (WebCore::ImageDecoder::isSizeAvailable): Make this function uses encodedDataStatus().
+        * platform/image-decoders/bmp/BMPImageDecoder.cpp:
+        (WebCore::BMPImageDecoder::encodedDataStatus): Replace isSizeAvailable() by encodedDataStatus().
+        (WebCore::BMPImageDecoder::isSizeAvailable): Deleted.
+        * platform/image-decoders/bmp/BMPImageDecoder.h:
+        * platform/image-decoders/gif/GIFImageDecoder.cpp:
+        (WebCore::GIFImageDecoder::encodedDataStatus): Ditto.
+        (WebCore::GIFImageDecoder::isSizeAvailable): Deleted.
+        * platform/image-decoders/gif/GIFImageDecoder.h:
+        * platform/image-decoders/ico/ICOImageDecoder.cpp:
+        (WebCore::ICOImageDecoder::encodedDataStatus): Ditto.
+        (WebCore::ICOImageDecoder::isSizeAvailable): Deleted.
+        * platform/image-decoders/ico/ICOImageDecoder.h:
+        * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
+        (WebCore::JPEGImageDecoder::encodedDataStatus): Ditto.
+        (WebCore::JPEGImageDecoder::isSizeAvailable): Deleted.
+        * platform/image-decoders/jpeg/JPEGImageDecoder.h:
+        * platform/image-decoders/png/PNGImageDecoder.cpp:
+        (WebCore::PNGImageDecoder::encodedDataStatus): Ditto.
+        (WebCore::PNGImageDecoder::isSizeAvailable): Deleted.
+        * platform/image-decoders/png/PNGImageDecoder.h:
+        * platform/image-decoders/webp/WEBPImageDecoder.cpp:
+        (WebCore::WEBPImageDecoder::encodedDataStatus): Ditto.
+        (WebCore::WEBPImageDecoder::isSizeAvailable): Deleted.
+        * platform/image-decoders/webp/WEBPImageDecoder.h:
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::dataChanged): m_page is created only when allDataReceived is true.
+        * svg/graphics/SVGImage.h:
+
 2017-04-10  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Mark SVG-Within-OpenType as "Under Consideration"

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (215210 => 215211)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-04-11 00:24:17 UTC (rev 215211)
@@ -2501,6 +2501,7 @@
 		53EF766C16531994004CBE49 /* SettingsMacros.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 53EF766A16530A61004CBE49 /* SettingsMacros.h */; };
 		550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
 		550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		5550CB421E955E3C00111AA0 /* ImageTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 5550CB411E955E3C00111AA0 /* ImageTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		555130011E7CCCCB00A69E38 /* DecodingOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 555130001E7CCCCA00A69E38 /* DecodingOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		555B87EC1CAAF0AB00349425 /* ImageDecoderCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */; };
 		555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; };
@@ -10203,6 +10204,7 @@
 		53EF766A16530A61004CBE49 /* SettingsMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsMacros.h; sourceTree = "<group>"; };
 		550A0BC7085F6039007353D6 /* QualifiedName.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedName.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		550A0BC8085F6039007353D6 /* QualifiedName.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = QualifiedName.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+		5550CB411E955E3C00111AA0 /* ImageTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageTypes.h; sourceTree = "<group>"; };
 		555130001E7CCCCA00A69E38 /* DecodingOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecodingOptions.h; sourceTree = "<group>"; };
 		555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoderCG.cpp; sourceTree = "<group>"; };
 		555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageDecoderCG.h; sourceTree = "<group>"; };
@@ -23031,6 +23033,7 @@
 				43D2597613C816F400608559 /* ImageBuffer.cpp */,
 				B2A10B910B3818BD00099AA4 /* ImageBuffer.h */,
 				22BD9F7D1353625C009BD102 /* ImageBufferData.h */,
+				5550CB411E955E3C00111AA0 /* ImageTypes.h */,
 				5576A5621D88A70800CCC04C /* ImageFrame.cpp */,
 				5576A5631D88A70800CCC04C /* ImageFrame.h */,
 				5597F8241D91C3130066BC21 /* ImageFrameCache.cpp */,
@@ -28754,6 +28757,7 @@
 				CE1252391A166FA000864480 /* QuickLookSPI.h in Headers */,
 				072AE1E8183C0741000A5988 /* QuickTimePluginReplacement.h in Headers */,
 				379E371713736A6600B9E919 /* QuotedPrintable.h in Headers */,
+				5550CB421E955E3C00111AA0 /* ImageTypes.h in Headers */,
 				5A574F29131DB96D00471B88 /* QuotesData.h in Headers */,
 				B22279720D00BF220071B782 /* RadialGradientAttributes.h in Headers */,
 				93F925430F7EF5B8007E37C9 /* RadioButtonGroups.h in Headers */,

Modified: trunk/Source/WebCore/loader/cache/CachedImage.cpp (215210 => 215211)


--- trunk/Source/WebCore/loader/cache/CachedImage.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/loader/cache/CachedImage.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -399,11 +399,11 @@
     // Have the image update its data from its internal buffer.
     // It will not do anything now, but will delay decoding until
     // queried for info (like size or specific image frames).
-    bool sizeAvailable = m_image->setData(&data, false);
-    if (!sizeAvailable)
+    EncodedDataStatus encodedDataStatus = m_image->setData(&data, false);
+    if (encodedDataStatus > EncodedDataStatus::Error && encodedDataStatus < EncodedDataStatus::SizeAvailable)
         return;
 
-    if (m_image->isNull()) {
+    if (encodedDataStatus == EncodedDataStatus::Error || m_image->isNull()) {
         // Image decoding failed. Either we need more image data or the image data is malformed.
         error(errorOccurred() ? status() : DecodeError);
         if (inCache())

Modified: trunk/Source/WebCore/loader/cache/CachedResourceClientWalker.h (215210 => 215211)


--- trunk/Source/WebCore/loader/cache/CachedResourceClientWalker.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/loader/cache/CachedResourceClientWalker.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -32,16 +32,16 @@
 
 // Call this "walker" instead of iterator so people won't expect Qt or STL-style iterator interface.
 // Just keep calling next() on this. It's safe from deletions of items.
-template<typename T> class CachedResourceClientWalker {
+template<typename T>
+class CachedResourceClientWalker {
 public:
-    CachedResourceClientWalker(const HashCountedSet<CachedResourceClient*>& set)
-        : m_clientSet(set), m_clientVector(set.size()), m_index(0)
+    CachedResourceClientWalker(const HashCountedSet<CachedResourceClient*>& clientSet)
+        : m_clientSet(clientSet)
+        , m_clientVector(clientSet.size())
     {
-        typedef HashCountedSet<CachedResourceClient*>::const_iterator Iterator;
-        Iterator end = set.end();
         size_t clientIndex = 0;
-        for (Iterator current = set.begin(); current != end; ++current)
-            m_clientVector[clientIndex++] = current->key;
+        for (const auto& client : clientSet)
+            m_clientVector[clientIndex++] = client.key;
     }
 
     T* next()
@@ -54,13 +54,12 @@
                 return static_cast<T*>(next);
             }
         }
-        
         return nullptr;
     }
 private:
     const HashCountedSet<CachedResourceClient*>& m_clientSet;
     Vector<CachedResourceClient*> m_clientVector;
-    size_t m_index;
+    size_t m_index { 0 };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/icon/IconRecord.cpp (215210 => 215211)


--- trunk/Source/WebCore/loader/icon/IconRecord.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/loader/icon/IconRecord.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -69,7 +69,7 @@
     m_image = BitmapImage::create();
 
     // Copy the provided data into the buffer of the new Image object.
-    if (!m_image->setData(WTFMove(data), true)) {
+    if (m_image->setData(WTFMove(data), true) < EncodedDataStatus::SizeAvailable) {
         LOG(IconDatabase, "Manual image data for iconURL '%s' FAILED - it was probably invalid image data", m_iconURL.ascii().data());
         m_image = nullptr;
     }

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (215210 => 215211)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -97,7 +97,7 @@
     destroyDecodedData(destroyAll);
 }
 
-bool BitmapImage::dataChanged(bool allDataReceived)
+EncodedDataStatus BitmapImage::dataChanged(bool allDataReceived)
 {
     return m_source.dataChanged(data(), allDataReceived);
 }

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (215210 => 215211)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -68,10 +68,10 @@
     
     bool hasSingleSecurityOrigin() const override { return true; }
 
-    bool dataChanged(bool allDataReceived) override;
+    EncodedDataStatus dataChanged(bool allDataReceived) override;
     unsigned decodedSize() const { return m_source.decodedSize(); }
 
-    bool isSizeAvailable() const { return m_source.isSizeAvailable(); }
+    EncodedDataStatus encodedDataStatus() const { return m_source.encodedDataStatus(); }
     size_t frameCount() const { return m_source.frameCount(); }
     RepetitionCount repetitionCount() const { return m_source.repetitionCount(); }
     String filenameExtension() const override { return m_source.filenameExtension(); }

Modified: trunk/Source/WebCore/platform/graphics/Image.cpp (215210 => 215211)


--- trunk/Source/WebCore/platform/graphics/Image.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/graphics/Image.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -63,19 +63,17 @@
 
 bool Image::supportsType(const String& type)
 {
-    return MIMETypeRegistry::isSupportedImageResourceMIMEType(type); 
+    return MIMETypeRegistry::isSupportedImageResourceMIMEType(type);
 } 
 
-bool Image::setData(RefPtr<SharedBuffer>&& data, bool allDataReceived)
+EncodedDataStatus Image::setData(RefPtr<SharedBuffer>&& data, bool allDataReceived)
 {
     m_encodedImageData = WTFMove(data);
-    if (!m_encodedImageData.get())
-        return true;
 
-    int length = m_encodedImageData->size();
-    if (!length)
-        return true;
-    
+    // Don't do anything; it is an empty image.
+    if (!m_encodedImageData.get() || !m_encodedImageData->size())
+        return EncodedDataStatus::Complete;
+
     return dataChanged(allDataReceived);
 }
 

Modified: trunk/Source/WebCore/platform/graphics/Image.h (215210 => 215211)


--- trunk/Source/WebCore/platform/graphics/Image.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/graphics/Image.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -33,6 +33,7 @@
 #include "FloatSize.h"
 #include "GraphicsTypes.h"
 #include "ImageOrientation.h"
+#include "ImageTypes.h"
 #include "NativeImage.h"
 #include <wtf/Optional.h>
 #include <wtf/PassRefPtr.h>
@@ -115,9 +116,9 @@
     virtual FloatSize originalSize() const { return size(); }
 #endif
 
-    WEBCORE_EXPORT bool setData(RefPtr<SharedBuffer>&& data, bool allDataReceived);
-    virtual bool dataChanged(bool /*allDataReceived*/) { return false; }
-    
+    WEBCORE_EXPORT EncodedDataStatus setData(RefPtr<SharedBuffer>&& data, bool allDataReceived);
+    virtual EncodedDataStatus dataChanged(bool /*allDataReceived*/) { return EncodedDataStatus::Unknown; }
+
     virtual String filenameExtension() const { return String(); } // null string if unknown
 
     virtual void destroyDecodedData(bool destroyAll = true) = 0;

Modified: trunk/Source/WebCore/platform/graphics/ImageFrame.h (215210 => 215211)


--- trunk/Source/WebCore/platform/graphics/ImageFrame.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/graphics/ImageFrame.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -29,6 +29,7 @@
 #include "DecodingOptions.h"
 #include "ImageBackingStore.h"
 #include "ImageOrientation.h"
+#include "ImageTypes.h"
 #include "IntSize.h"
 #include "NativeImage.h"
 #include <wtf/Deque.h>
@@ -35,45 +36,6 @@
 
 namespace WebCore {
 
-class Color;
-
-// There are four subsampling levels: 0 = 1x, 1 = 0.5x, 2 = 0.25x, 3 = 0.125x.
-enum class SubsamplingLevel {
-    First = 0,
-    Default = First,
-    Level0 = First,
-    Level1,
-    Level2,
-    Level3,
-    Last = Level3,
-    Max
-};
-
-inline SubsamplingLevel& operator++(SubsamplingLevel& subsamplingLevel)
-{
-    subsamplingLevel = static_cast<SubsamplingLevel>(static_cast<int>(subsamplingLevel) + 1);
-    ASSERT(subsamplingLevel <= SubsamplingLevel::Max);
-    return subsamplingLevel;
-}
-
-typedef int RepetitionCount;
-
-enum {
-    RepetitionCountNone = 0,
-    RepetitionCountOnce = 1,
-    RepetitionCountInfinite = -1,
-};
-
-enum class AlphaOption {
-    Premultiplied,
-    NotPremultiplied
-};
-
-enum class GammaAndColorProfileOption {
-    Applied,
-    Ignored
-};
-
 class ImageFrame {
     friend class ImageFrameCache;
 public:

Modified: trunk/Source/WebCore/platform/graphics/ImageFrameCache.cpp (215210 => 215211)


--- trunk/Source/WebCore/platform/graphics/ImageFrameCache.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/graphics/ImageFrameCache.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -54,7 +54,7 @@
 ImageFrameCache::ImageFrameCache(NativeImagePtr&& nativeImage)
 {
     m_frameCount = 1;
-    m_isSizeAvailable = true;
+    m_encodedDataStatus = EncodedDataStatus::Complete;
     growFrames();
 
     setNativeImage(WTFMove(nativeImage));
@@ -435,17 +435,24 @@
     return cachedValue->value();
 }
 
-bool ImageFrameCache::isSizeAvailable()
+EncodedDataStatus ImageFrameCache::encodedDataStatus()
 {
-    if (m_isSizeAvailable)
-        return m_isSizeAvailable.value();
+    if (m_encodedDataStatus)
+        return m_encodedDataStatus.value();
     
-    if (!isDecoderAvailable() || !m_decoder->isSizeAvailable())
-        return false;
+    if (!isDecoderAvailable())
+        return EncodedDataStatus::Unknown;
     
-    m_isSizeAvailable = true;
+    EncodedDataStatus status = m_decoder->encodedDataStatus();
+    if (status < EncodedDataStatus::SizeAvailable)
+        return status;
+
     didDecodeProperties(m_decoder->bytesDecodedToDetermineProperties());
-    return true;
+    if (status < EncodedDataStatus::Complete)
+        return status;
+    
+    m_encodedDataStatus = status;
+    return status;
 }
 
 size_t ImageFrameCache::frameCount()

Modified: trunk/Source/WebCore/platform/graphics/ImageFrameCache.h (215210 => 215211)


--- trunk/Source/WebCore/platform/graphics/ImageFrameCache.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/graphics/ImageFrameCache.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -77,7 +77,8 @@
 
     // Image metadata which is calculated either by the ImageDecoder or directly
     // from the NativeImage if this class was created for a memory image.
-    bool isSizeAvailable();
+    EncodedDataStatus encodedDataStatus();
+    bool isSizeAvailable() { return encodedDataStatus() >= EncodedDataStatus::SizeAvailable; }
     size_t frameCount();
     RepetitionCount repetitionCount();
     String filenameExtension();
@@ -162,7 +163,7 @@
     RefPtr<WorkQueue> m_decodingQueue;
 
     // Image metadata.
-    std::optional<bool> m_isSizeAvailable;
+    std::optional<EncodedDataStatus> m_encodedDataStatus;
     std::optional<size_t> m_frameCount;
     std::optional<RepetitionCount> m_repetitionCount;
     std::optional<String> m_filenameExtension;

Modified: trunk/Source/WebCore/platform/graphics/ImageSource.cpp (215210 => 215211)


--- trunk/Source/WebCore/platform/graphics/ImageSource.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -111,7 +111,7 @@
     m_decoder->setData(*data, allDataReceived);
 }
 
-bool ImageSource::dataChanged(SharedBuffer* data, bool allDataReceived)
+EncodedDataStatus ImageSource::dataChanged(SharedBuffer* data, bool allDataReceived)
 {
     m_frameCache->destroyIncompleteDecodedData();
 
@@ -138,11 +138,12 @@
 #endif
 
     m_frameCache->clearMetadata();
-    if (!isSizeAvailable())
-        return false;
+    EncodedDataStatus status = encodedDataStatus();
+    if (status < EncodedDataStatus::SizeAvailable)
+        return status;
 
     m_frameCache->growFrames();
-    return true;
+    return status;
 }
 
 bool ImageSource::isAllDataReceived()

Modified: trunk/Source/WebCore/platform/graphics/ImageSource.h (215210 => 215211)


--- trunk/Source/WebCore/platform/graphics/ImageSource.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -63,7 +63,7 @@
     bool isDecoderAvailable() const { return m_decoder.get(); }
 
     void setData(SharedBuffer* data, bool allDataReceived);
-    bool dataChanged(SharedBuffer* data, bool allDataReceived);
+    EncodedDataStatus dataChanged(SharedBuffer* data, bool allDataReceived);
 
     unsigned decodedSize() const { return m_frameCache->decodedSize(); }
     bool isAllDataReceived();
@@ -75,7 +75,7 @@
     void stopAsyncDecodingQueue() { m_frameCache->stopAsyncDecodingQueue(); }
 
     // Image metadata which is calculated by the decoder or can deduced by the case of the memory NativeImage.
-    bool isSizeAvailable() { return m_frameCache->isSizeAvailable(); }
+    EncodedDataStatus encodedDataStatus() { return m_frameCache->encodedDataStatus(); }
     size_t frameCount() { return m_frameCache->frameCount(); }
     RepetitionCount repetitionCount() { return m_frameCache->repetitionCount(); }
     String filenameExtension() { return m_frameCache->filenameExtension(); }

Added: trunk/Source/WebCore/platform/graphics/ImageTypes.h (0 => 215211)


--- trunk/Source/WebCore/platform/graphics/ImageTypes.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ImageTypes.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2017 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+// There are four subsampling levels: 0 = 1x, 1 = 0.5x, 2 = 0.25x, 3 = 0.125x.
+enum class SubsamplingLevel {
+    First = 0,
+    Default = First,
+    Level0 = First,
+    Level1,
+    Level2,
+    Level3,
+    Last = Level3,
+    Max
+};
+
+inline SubsamplingLevel& operator++(SubsamplingLevel& subsamplingLevel)
+{
+    subsamplingLevel = static_cast<SubsamplingLevel>(static_cast<int>(subsamplingLevel) + 1);
+    ASSERT(subsamplingLevel <= SubsamplingLevel::Max);
+    return subsamplingLevel;
+}
+
+typedef int RepetitionCount;
+
+enum {
+    RepetitionCountNone = 0,
+    RepetitionCountOnce = 1,
+    RepetitionCountInfinite = -1,
+};
+
+enum class AlphaOption {
+    Premultiplied,
+    NotPremultiplied
+};
+
+enum class GammaAndColorProfileOption {
+    Applied,
+    Ignored
+};
+    
+enum class EncodedDataStatus {
+    Error,
+    Unknown,
+    TypeAvailable,
+    SizeAvailable,
+    Complete
+};
+
+}

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp (215210 => 215211)


--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -175,18 +175,38 @@
     return WebCore::preferredExtensionForImageSourceType(imageSourceType);
 }
 
-bool ImageDecoder::isSizeAvailable() const
+EncodedDataStatus ImageDecoder::encodedDataStatus() const
 {
-    // Ragnaros yells: TOO SOON! You have awakened me TOO SOON, Executus!
-    if (CGImageSourceGetStatus(m_nativeDecoder.get()) < kCGImageStatusIncomplete)
-        return false;
-    
-    RetainPtr<CFDictionaryRef> image0Properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get()));
-    if (!image0Properties)
-        return false;
-    
-    return CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelWidth)
-    && CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelHeight);
+    switch (CGImageSourceGetStatus(m_nativeDecoder.get())) {
+    case kCGImageStatusUnknownType:
+        return EncodedDataStatus::Error;
+
+    case kCGImageStatusUnexpectedEOF:
+    case kCGImageStatusInvalidData:
+    case kCGImageStatusReadingHeader:
+        // Ragnaros yells: TOO SOON! You have awakened me TOO SOON, Executus!
+        if (!m_isAllDataReceived)
+            return EncodedDataStatus::Unknown;
+
+        return EncodedDataStatus::Error;
+
+    case kCGImageStatusIncomplete: {
+        RetainPtr<CFDictionaryRef> image0Properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get()));
+        if (!image0Properties)
+            return EncodedDataStatus::TypeAvailable;
+        
+        if (!CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelWidth) || !CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelHeight))
+            return EncodedDataStatus::TypeAvailable;
+        
+        return EncodedDataStatus::SizeAvailable;
+    }
+
+    case kCGImageStatusComplete:
+        return EncodedDataStatus::Complete;
+    }
+
+    ASSERT_NOT_REACHED();
+    return EncodedDataStatus::Unknown;
 }
 
 size_t ImageDecoder::frameCount() const

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h (215210 => 215211)


--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -47,7 +47,8 @@
     
     static size_t bytesDecodedToDetermineProperties();
 
-    bool isSizeAvailable() const;
+    EncodedDataStatus encodedDataStatus() const;
+    bool isSizeAvailable() { return encodedDataStatus() >= EncodedDataStatus::SizeAvailable; }
     size_t frameCount() const;
     RepetitionCount repetitionCount() const;
     String filenameExtension() const;

Modified: trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp (215210 => 215211)


--- trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -87,7 +87,7 @@
     intrinsicRatio = FloatSize();
 }
 
-bool PDFDocumentImage::dataChanged(bool allDataReceived)
+EncodedDataStatus PDFDocumentImage::dataChanged(bool allDataReceived)
 {
     ASSERT(!m_document);
     if (allDataReceived && !m_document) {
@@ -98,7 +98,7 @@
             computeBoundsForCurrentPage();
         }
     }
-    return m_document; // Return true if size is available.
+    return m_document ? EncodedDataStatus::Complete : EncodedDataStatus::Unknown;
 }
 
 void PDFDocumentImage::setPdfImageCachingPolicy(PDFImageCachingPolicy pdfImageCachingPolicy)

Modified: trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h (215210 => 215211)


--- trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -65,7 +65,7 @@
 
     bool hasSingleSecurityOrigin() const override { return true; }
 
-    bool dataChanged(bool allDataReceived) override;
+    EncodedDataStatus dataChanged(bool allDataReceived) override;
 
     void destroyDecodedData(bool /*destroyAll*/ = true) override;
 

Modified: trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h (215210 => 215211)


--- trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -81,11 +81,22 @@
         // Lazily-decodes enough of the image to get the size (if possible).
         // FIXME: Right now that has to be done by each subclass; factor the
         // decode call out and use it here.
-        virtual bool isSizeAvailable()
+        virtual EncodedDataStatus encodedDataStatus()
         {
-            return !m_failed && m_sizeAvailable;
+            if (m_failed)
+                return EncodedDataStatus::Error;
+
+            if (m_isAllDataReceived)
+                return EncodedDataStatus::Complete;
+
+            if (m_sizeAvailable)
+                return EncodedDataStatus::SizeAvailable;
+
+            return EncodedDataStatus::TypeAvailable;
         }
 
+        bool isSizeAvailable() { return encodedDataStatus() >= EncodedDataStatus::SizeAvailable; }
+
         virtual IntSize size() { return isSizeAvailable() ? m_size : IntSize(); }
 
         IntSize scaledSize()

Modified: trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp (215210 => 215211)


--- trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -56,12 +56,12 @@
         m_reader->setData(&data);
 }
 
-bool BMPImageDecoder::isSizeAvailable()
+EncodedDataStatus BMPImageDecoder::encodedDataStatus()
 {
     if (!ImageDecoder::isSizeAvailable())
         decode(true);
 
-    return ImageDecoder::isSizeAvailable();
+    return ImageDecoder::encodedDataStatus();
 }
 
 ImageFrame* BMPImageDecoder::frameBufferAtIndex(size_t index)

Modified: trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h (215210 => 215211)


--- trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -42,7 +42,7 @@
         // ImageDecoder
         String filenameExtension() const override { return "bmp"; }
         void setData(SharedBuffer&, bool allDataReceived) override;
-        bool isSizeAvailable() override;
+        EncodedDataStatus encodedDataStatus() override;
         ImageFrame* frameBufferAtIndex(size_t index) override;
         // CAUTION: setFailed() deletes |m_reader|.  Be careful to avoid
         // accessing deleted memory, especially when calling this from inside

Modified: trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp (215210 => 215211)


--- trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -50,12 +50,12 @@
         m_reader->setData(&data);
 }
 
-bool GIFImageDecoder::isSizeAvailable()
+EncodedDataStatus GIFImageDecoder::encodedDataStatus()
 {
     if (!ImageDecoder::isSizeAvailable())
-         decode(0, GIFSizeQuery);
+        decode(0, GIFSizeQuery);
 
-    return ImageDecoder::isSizeAvailable();
+    return ImageDecoder::encodedDataStatus();
 }
 
 bool GIFImageDecoder::setSize(const IntSize& size)

Modified: trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h (215210 => 215211)


--- trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -43,7 +43,7 @@
         // ImageDecoder
         String filenameExtension() const override { return "gif"; }
         void setData(SharedBuffer& data, bool allDataReceived) override;
-        bool isSizeAvailable() override;
+        EncodedDataStatus encodedDataStatus() override;
         bool setSize(const IntSize&) override;
         size_t frameCount() const override;
         RepetitionCount repetitionCount() const override;

Modified: trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp (215210 => 215211)


--- trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -69,12 +69,12 @@
         setDataForPNGDecoderAtIndex(i);
 }
 
-bool ICOImageDecoder::isSizeAvailable()
+EncodedDataStatus ICOImageDecoder::encodedDataStatus()
 {
     if (!ImageDecoder::isSizeAvailable())
         decode(0, true);
 
-    return ImageDecoder::isSizeAvailable();
+    return ImageDecoder::encodedDataStatus();
 }
 
 IntSize ICOImageDecoder::size()

Modified: trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h (215210 => 215211)


--- trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -45,7 +45,7 @@
         // ImageDecoder
         String filenameExtension() const override { return "ico"; }
         void setData(SharedBuffer&, bool allDataReceived) override;
-        bool isSizeAvailable() override;
+        EncodedDataStatus encodedDataStatus() override;
         IntSize size() override;
         IntSize frameSizeAtIndex(size_t, SubsamplingLevel) override;
         bool setSize(const IntSize&) override;

Modified: trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp (215210 => 215211)


--- trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -510,12 +510,12 @@
 {
 }
 
-bool JPEGImageDecoder::isSizeAvailable()
+EncodedDataStatus JPEGImageDecoder::encodedDataStatus()
 {
     if (!ImageDecoder::isSizeAvailable())
-         decode(true);
+        decode(true);
 
-    return ImageDecoder::isSizeAvailable();
+    return ImageDecoder::encodedDataStatus();
 }
 
 bool JPEGImageDecoder::setSize(const IntSize& size)

Modified: trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h (215210 => 215211)


--- trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -48,7 +48,7 @@
 
         // ImageDecoder
         String filenameExtension() const override { return "jpg"; }
-        bool isSizeAvailable() override;
+        EncodedDataStatus encodedDataStatus() override;
         bool setSize(const IntSize&) override;
         ImageFrame* frameBufferAtIndex(size_t index) override;
         // CAUTION: setFailed() deletes |m_reader|.  Be careful to avoid

Modified: trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp (215210 => 215211)


--- trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -239,12 +239,12 @@
 }
 #endif
 
-bool PNGImageDecoder::isSizeAvailable()
+EncodedDataStatus PNGImageDecoder::encodedDataStatus()
 {
     if (!ImageDecoder::isSizeAvailable())
         decode(true, 0);
 
-    return ImageDecoder::isSizeAvailable();
+    return ImageDecoder::encodedDataStatus();
 }
 
 bool PNGImageDecoder::setSize(const IntSize& size)

Modified: trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h (215210 => 215211)


--- trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -46,7 +46,7 @@
         size_t frameCount() const override { return m_frameCount; }
         RepetitionCount repetitionCount() const override;
 #endif
-        bool isSizeAvailable() override;
+        EncodedDataStatus encodedDataStatus() override;
         bool setSize(const IntSize&) override;
         ImageFrame* frameBufferAtIndex(size_t index) override;
         // CAUTION: setFailed() deletes |m_reader|.  Be careful to avoid

Modified: trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp (215210 => 215211)


--- trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -64,12 +64,12 @@
     m_decoder = 0;
 }
 
-bool WEBPImageDecoder::isSizeAvailable()
+EncodedDataStatus WEBPImageDecoder::encodedDataStatus()
 {
     if (!ImageDecoder::isSizeAvailable())
-         decode(true);
+        decode(true);
 
-    return ImageDecoder::isSizeAvailable();
+    return ImageDecoder::encodedDataStatus();
 }
 
 ImageFrame* WEBPImageDecoder::frameBufferAtIndex(size_t index)

Modified: trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h (215210 => 215211)


--- trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -42,7 +42,7 @@
     virtual ~WEBPImageDecoder();
 
     String filenameExtension() const override { return "webp"; }
-    bool isSizeAvailable() override;
+    EncodedDataStatus encodedDataStatus() override;
     ImageFrame* frameBufferAtIndex(size_t index) override;
 
 private:

Modified: trunk/Source/WebCore/svg/graphics/SVGImage.cpp (215210 => 215211)


--- trunk/Source/WebCore/svg/graphics/SVGImage.cpp	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.cpp	2017-04-11 00:24:17 UTC (rev 215211)
@@ -416,11 +416,11 @@
     vm.heap.deprecatedReportExtraMemory(decodedImageMemoryCost + data()->size());
 }
 
-bool SVGImage::dataChanged(bool allDataReceived)
+EncodedDataStatus SVGImage::dataChanged(bool allDataReceived)
 {
-    // Don't do anything if is an empty image.
+    // Don't do anything; it is an empty image.
     if (!data()->size())
-        return true;
+        return EncodedDataStatus::Complete;
 
     if (allDataReceived) {
         PageConfiguration pageConfiguration(
@@ -466,7 +466,7 @@
         reportApproximateMemoryCost();
     }
 
-    return m_page != nullptr;
+    return m_page ? EncodedDataStatus::Complete : EncodedDataStatus::Unknown;
 }
 
 String SVGImage::filenameExtension() const

Modified: trunk/Source/WebCore/svg/graphics/SVGImage.h (215210 => 215211)


--- trunk/Source/WebCore/svg/graphics/SVGImage.h	2017-04-11 00:23:03 UTC (rev 215210)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.h	2017-04-11 00:24:17 UTC (rev 215211)
@@ -86,7 +86,7 @@
     void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) final;
 
     void reportApproximateMemoryCost() const;
-    bool dataChanged(bool allDataReceived) final;
+    EncodedDataStatus dataChanged(bool allDataReceived) final;
 
     // FIXME: SVGImages will be unable to prune because this function is not implemented yet.
     void destroyDecodedData(bool) final { }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to