Index: third_party/WebKit/Source/platform/graphics/ImageSource.cpp |
diff --git a/third_party/WebKit/Source/platform/graphics/ImageSource.cpp b/third_party/WebKit/Source/platform/graphics/ImageSource.cpp |
index 50d5fe282aa1de2d9e0bc7ae06ff4a6533ce53af..af677889fd789baf92d0d7bef58f28ab5f52c2ed 100644 |
--- a/third_party/WebKit/Source/platform/graphics/ImageSource.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/ImageSource.cpp |
@@ -51,16 +51,21 @@ PassRefPtr<SharedBuffer> ImageSource::data() |
return m_decoder ? m_decoder->data() : nullptr; |
} |
-ImageDecoder::SniffResult ImageSource::setData(SharedBuffer& data, bool allDataReceived) |
+bool ImageSource::setData(PassRefPtr<SharedBuffer> passData, bool allDataReceived) |
{ |
- ImageDecoder::SniffResult result = ImageDecoder::determineImageType(data); |
- if (!m_decoder) |
- m_decoder = DeferredImageDecoder::create(result, ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied); |
+ RefPtr<SharedBuffer> data = passData; |
+ |
+ if (m_decoder) { |
+ m_decoder->setData(data.release(), allDataReceived); |
+ // If the decoder is pre-instantiated, it means we've already validated the data/signature |
+ // at some point. |
+ return true; |
+ } |
- if (m_decoder) |
- m_decoder->setData(data, allDataReceived); |
+ m_decoder = DeferredImageDecoder::create(data, allDataReceived, ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied); |
- return result; |
+ // Insufficient data is not a failure. |
+ return m_decoder || !ImageDecoder::hasSufficientDataToSniffImageType(*data); |
} |
String ImageSource::filenameExtension() const |