From 5cd0c28d91b88a67cfb1eba75348e8002610460d Mon Sep 17 00:00:00 2001 From: Andrew Osmond Date: Sat, 22 Jul 2017 07:50:32 -0400 Subject: [PATCH] Bug 1315554 - Part 8. Allow DecoderFactory::CreateDecoderForICOResource to create metadata decoders. r=tnikkel --- image/DecoderFactory.cpp | 8 +++++--- image/DecoderFactory.h | 4 ++++ image/decoders/nsICODecoder.cpp | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/image/DecoderFactory.cpp b/image/DecoderFactory.cpp index 9570fe125f80..5dc71ab13ded 100644 --- a/image/DecoderFactory.cpp +++ b/image/DecoderFactory.cpp @@ -236,6 +236,7 @@ DecoderFactory::CreateMetadataDecoder(DecoderType aType, DecoderFactory::CreateDecoderForICOResource(DecoderType aType, SourceBufferIterator&& aIterator, NotNull aICODecoder, + bool aIsMetadataDecode, const Maybe& aExpectedSize, const Maybe& aDataOffset /* = Nothing() */) @@ -261,10 +262,11 @@ DecoderFactory::CreateDecoderForICOResource(DecoderType aType, MOZ_ASSERT(decoder); // Initialize the decoder, copying settings from @aICODecoder. - MOZ_ASSERT(!aICODecoder->IsMetadataDecode()); - decoder->SetMetadataDecode(aICODecoder->IsMetadataDecode()); + decoder->SetMetadataDecode(aIsMetadataDecode); decoder->SetIterator(Forward(aIterator)); - decoder->SetOutputSize(aICODecoder->OutputSize()); + if (!aIsMetadataDecode) { + decoder->SetOutputSize(aICODecoder->OutputSize()); + } if (aExpectedSize) { decoder->SetExpectedSize(*aExpectedSize); } diff --git a/image/DecoderFactory.h b/image/DecoderFactory.h index 0386a7b44ca0..9ce5d43192c4 100644 --- a/image/DecoderFactory.h +++ b/image/DecoderFactory.h @@ -127,6 +127,9 @@ public: * resource decoder, so the two decoders will have the * same decoder flags, surface flags, target size, and * other parameters. + * @param aIsMetadataDecode Indicates whether or not this decoder is for + * metadata or not. Independent of the state of the + * parent decoder. * @param aExpectedSize The expected size of the resource from the ICO header. * @param aDataOffset If @aType is BMP, specifies the offset at which data * begins in the BMP resource. Must be Some() if and only @@ -136,6 +139,7 @@ public: CreateDecoderForICOResource(DecoderType aType, SourceBufferIterator&& aIterator, NotNull aICODecoder, + bool aIsMetadataDecode, const Maybe& aExpectedSize, const Maybe& aDataOffset = Nothing()); diff --git a/image/decoders/nsICODecoder.cpp b/image/decoders/nsICODecoder.cpp index e0b0c08cdc89..fe5ec14bab98 100644 --- a/image/decoders/nsICODecoder.cpp +++ b/image/decoders/nsICODecoder.cpp @@ -277,6 +277,7 @@ nsICODecoder::SniffResource(const char* aData) DecoderFactory::CreateDecoderForICOResource(DecoderType::PNG, Move(containedIterator), WrapNotNull(this), + false, Some(GetRealSize())); // Read in the rest of the PNG unbuffered. @@ -339,6 +340,7 @@ nsICODecoder::ReadBIH(const char* aData) DecoderFactory::CreateDecoderForICOResource(DecoderType::BMP, Move(containedIterator), WrapNotNull(this), + false, Some(GetRealSize()), Some(dataOffset));