Changeset 215729 in webkit
- Timestamp:
- Apr 25, 2017 5:35:18 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r215728 r215729 1 2017-04-25 Miguel Gomez <magomez@igalia.com> 2 3 Image decoders must have private constructors to avoid refcount misuse: ASSERTION FAILED: m_deletionHasBegun when destroying ImageDecoder 4 https://bugs.webkit.org/show_bug.cgi?id=171211 5 6 Reviewed by Carlos Garcia Campos. 7 8 Add a create method to each of the decoders and set their constructors as private. Change 9 ICOImageDecoder to store its internal PNG decoders as RefPtr and use the new create method, and 10 change ImageDecoder to use the create methods as well. 11 12 Covered by existent tests. 13 14 * platform/image-decoders/ImageDecoder.cpp: 15 (WebCore::ImageDecoder::create): 16 * platform/image-decoders/bmp/BMPImageDecoder.h: 17 * platform/image-decoders/gif/GIFImageDecoder.h: 18 * platform/image-decoders/ico/ICOImageDecoder.cpp: 19 (WebCore::ICOImageDecoder::decodeAtIndex): 20 * platform/image-decoders/ico/ICOImageDecoder.h: 21 * platform/image-decoders/jpeg/JPEGImageDecoder.h: 22 * platform/image-decoders/png/PNGImageDecoder.h: 23 * platform/image-decoders/webp/WEBPImageDecoder.h: 24 1 25 2017-04-25 Myles C. Maxfield <mmaxfield@apple.com> 2 26 -
trunk/Source/WebCore/platform/image-decoders/ImageDecoder.cpp
r215710 r215729 108 108 109 109 if (matchesGIFSignature(contents)) 110 return adoptRef(*new GIFImageDecoder(alphaOption, gammaAndColorProfileOption));110 return GIFImageDecoder::create(alphaOption, gammaAndColorProfileOption); 111 111 112 112 if (matchesPNGSignature(contents)) 113 return adoptRef(*new PNGImageDecoder(alphaOption, gammaAndColorProfileOption));113 return PNGImageDecoder::create(alphaOption, gammaAndColorProfileOption); 114 114 115 115 if (matchesICOSignature(contents) || matchesCURSignature(contents)) 116 return adoptRef(*new ICOImageDecoder(alphaOption, gammaAndColorProfileOption));116 return ICOImageDecoder::create(alphaOption, gammaAndColorProfileOption); 117 117 118 118 if (matchesJPEGSignature(contents)) 119 return adoptRef(*new JPEGImageDecoder(alphaOption, gammaAndColorProfileOption));119 return JPEGImageDecoder::create(alphaOption, gammaAndColorProfileOption); 120 120 121 121 #if USE(WEBP) 122 122 if (matchesWebPSignature(contents)) 123 return adoptRef(*new WEBPImageDecoder(alphaOption, gammaAndColorProfileOption));123 return WEBPImageDecoder::create(alphaOption, gammaAndColorProfileOption); 124 124 #endif 125 125 126 126 if (matchesBMPSignature(contents)) 127 return adoptRef(*new BMPImageDecoder(alphaOption, gammaAndColorProfileOption));127 return BMPImageDecoder::create(alphaOption, gammaAndColorProfileOption); 128 128 129 129 return nullptr; -
trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h
r215710 r215729 38 38 class BMPImageDecoder final : public ImageDecoder { 39 39 public: 40 BMPImageDecoder(AlphaOption, GammaAndColorProfileOption); 40 static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 41 { 42 return adoptRef(*new BMPImageDecoder(alphaOption, gammaAndColorProfileOption)); 43 } 41 44 42 45 // ImageDecoder … … 51 54 52 55 private: 56 BMPImageDecoder(AlphaOption, GammaAndColorProfileOption); 57 53 58 inline uint32_t readUint32(int offset) const 54 59 { -
trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h
r215710 r215729 36 36 class GIFImageDecoder final : public ImageDecoder { 37 37 public: 38 GIFImageDecoder(AlphaOption, GammaAndColorProfileOption); 38 static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 39 { 40 return adoptRef(*new GIFImageDecoder(alphaOption, gammaAndColorProfileOption)); 41 } 42 39 43 virtual ~GIFImageDecoder(); 40 44 … … 61 65 62 66 private: 67 GIFImageDecoder(AlphaOption, GammaAndColorProfileOption); 68 63 69 // If the query is GIFFullQuery, decodes the image up to (but not 64 70 // including) |haltAtFrame|. Otherwise, decodes as much as is needed to -
trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp
r215710 r215729 217 217 218 218 if (!m_pngDecoders[index]) { 219 m_pngDecoders[index] = std::make_unique< 220 PNGImageDecoder>(m_premultiplyAlpha ? AlphaOption::Premultiplied : AlphaOption::NotPremultiplied, 221 m_ignoreGammaAndColorProfile ? GammaAndColorProfileOption::Ignored : GammaAndColorProfileOption::Applied); 219 m_pngDecoders[index] = PNGImageDecoder::create(m_premultiplyAlpha ? AlphaOption::Premultiplied : AlphaOption::NotPremultiplied, m_ignoreGammaAndColorProfile ? GammaAndColorProfileOption::Ignored : GammaAndColorProfileOption::Applied); 222 220 setDataForPNGDecoderAtIndex(index); 223 221 } -
trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h
r215710 r215729 34 34 35 35 namespace WebCore { 36 37 class PNGImageDecoder;38 39 36 // This class decodes the ICO and CUR image formats. 40 37 class ICOImageDecoder final : public ImageDecoder { 41 38 public: 42 ICOImageDecoder(AlphaOption, GammaAndColorProfileOption); 39 static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 40 { 41 return adoptRef(*new ICOImageDecoder(alphaOption, gammaAndColorProfileOption)); 42 } 43 43 44 virtual ~ICOImageDecoder(); 44 45 … … 76 77 uint32_t m_imageOffset; 77 78 }; 79 80 ICOImageDecoder(AlphaOption, GammaAndColorProfileOption); 78 81 79 82 // Returns true if |a| is a preferable icon entry to |b|. … … 142 145 typedef Vector<std::unique_ptr<BMPImageReader>> BMPReaders; 143 146 BMPReaders m_bmpReaders; 144 typedef Vector< std::unique_ptr<PNGImageDecoder>> PNGDecoders;147 typedef Vector<RefPtr<ImageDecoder>> PNGDecoders; 145 148 PNGDecoders m_pngDecoders; 146 149 -
trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h
r215710 r215729 44 44 class JPEGImageDecoder final : public ImageDecoder { 45 45 public: 46 JPEGImageDecoder(AlphaOption, GammaAndColorProfileOption); 46 static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 47 { 48 return adoptRef(*new JPEGImageDecoder(alphaOption, gammaAndColorProfileOption)); 49 } 50 47 51 virtual ~JPEGImageDecoder(); 48 52 … … 69 73 70 74 private: 75 JPEGImageDecoder(AlphaOption, GammaAndColorProfileOption); 76 71 77 // Decodes the image. If |onlySize| is true, stops decoding after 72 78 // calculating the image size. If decoding fails but there is no more -
trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h
r215710 r215729 38 38 class PNGImageDecoder final : public ImageDecoder { 39 39 public: 40 PNGImageDecoder(AlphaOption, GammaAndColorProfileOption); 40 static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 41 { 42 return adoptRef(*new PNGImageDecoder(alphaOption, gammaAndColorProfileOption)); 43 } 44 41 45 virtual ~PNGImageDecoder(); 42 46 … … 86 90 87 91 private: 92 PNGImageDecoder(AlphaOption, GammaAndColorProfileOption); 93 88 94 // Decodes the image. If |onlySize| is true, stops decoding after 89 95 // calculating the image size. If decoding fails but there is no more -
trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h
r215710 r215729 39 39 class WEBPImageDecoder final : public ImageDecoder { 40 40 public: 41 WEBPImageDecoder(AlphaOption, GammaAndColorProfileOption); 41 static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 42 { 43 return adoptRef(*new WEBPImageDecoder(alphaOption, gammaAndColorProfileOption)); 44 } 45 42 46 virtual ~WEBPImageDecoder(); 43 47 … … 47 51 48 52 private: 53 WEBPImageDecoder(AlphaOption, GammaAndColorProfileOption); 54 49 55 bool decode(bool onlySize); 50 56
Note: See TracChangeset
for help on using the changeset viewer.