diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-02-12 01:25:43 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-02-12 01:25:43 +0100 |
commit | 263d8500ce68b279a2d055c322f0ab3eab634989 (patch) | |
tree | 9f258c3d6186346dc4435427ce6565ec376efd5d /image/decoders | |
parent | b06821da15b7ab2573cd18aea8048b94266e3a97 (diff) | |
parent | 8beab28bfff78ccefc8677c5bdddd6f60c544600 (diff) | |
download | UXP-263d8500ce68b279a2d055c322f0ab3eab634989.tar UXP-263d8500ce68b279a2d055c322f0ab3eab634989.tar.gz UXP-263d8500ce68b279a2d055c322f0ab3eab634989.tar.lz UXP-263d8500ce68b279a2d055c322f0ab3eab634989.tar.xz UXP-263d8500ce68b279a2d055c322f0ab3eab634989.zip |
Merge branch 'master' into Pale_Moon-release
# Conflicts:
# application/palemoon/components/preferences/advanced.xul
# application/palemoon/config/version.txt
# modules/libpref/init/all.js
Diffstat (limited to 'image/decoders')
-rw-r--r-- | image/decoders/nsBMPDecoder.cpp | 17 | ||||
-rw-r--r-- | image/decoders/nsBMPDecoder.h | 6 | ||||
-rw-r--r-- | image/decoders/nsWebPDecoder.cpp | 4 |
3 files changed, 22 insertions, 5 deletions
diff --git a/image/decoders/nsBMPDecoder.cpp b/image/decoders/nsBMPDecoder.cpp index 42bb3486a..fc79c223d 100644 --- a/image/decoders/nsBMPDecoder.cpp +++ b/image/decoders/nsBMPDecoder.cpp @@ -185,9 +185,11 @@ nsBMPDecoder::nsBMPDecoder(RasterImage* aImage, State aState, size_t aLength) { } -// Constructor for normal BMP files. -nsBMPDecoder::nsBMPDecoder(RasterImage* aImage) - : nsBMPDecoder(aImage, State::FILE_HEADER, FILE_HEADER_LENGTH) +// Constructor for normal BMP files or from the clipboard. +nsBMPDecoder::nsBMPDecoder(RasterImage* aImage, bool aForClipboard) + : nsBMPDecoder(aImage, + aForClipboard ? State::CLIPBOARD_HEADER : State::FILE_HEADER, + aForClipboard ? BIHSIZE_FIELD_LENGTH : FILE_HEADER_LENGTH) { } @@ -455,6 +457,7 @@ nsBMPDecoder::DoDecode(SourceBufferIterator& aIterator, IResumable* aOnResume) [=](State aState, const char* aData, size_t aLength) { switch (aState) { case State::FILE_HEADER: return ReadFileHeader(aData, aLength); + case State::CLIPBOARD_HEADER: return ReadClipboardHeader(aData, aLength); case State::INFO_HEADER_SIZE: return ReadInfoHeaderSize(aData, aLength); case State::INFO_HEADER_REST: return ReadInfoHeaderRest(aData, aLength); case State::BITFIELDS: return ReadBitfields(aData, aLength); @@ -488,6 +491,14 @@ nsBMPDecoder::ReadFileHeader(const char* aData, size_t aLength) return Transition::To(State::INFO_HEADER_SIZE, BIHSIZE_FIELD_LENGTH); } +LexerTransition<nsBMPDecoder::State> +nsBMPDecoder::ReadClipboardHeader(const char* aData, size_t aLength) +{ + // With the clipboard, the data offset is the header length. + mH.mDataOffset = LittleEndian::readUint32(aData); + return ReadInfoHeaderSize(aData, aLength); +} + // We read the info header in two steps: (a) read the mBIHSize field to // determine how long the header is; (b) read the rest of the header. LexerTransition<nsBMPDecoder::State> diff --git a/image/decoders/nsBMPDecoder.h b/image/decoders/nsBMPDecoder.h index 0cf2af689..258381649 100644 --- a/image/decoders/nsBMPDecoder.h +++ b/image/decoders/nsBMPDecoder.h @@ -152,6 +152,7 @@ private: enum class State { FILE_HEADER, + CLIPBOARD_HEADER, INFO_HEADER_SIZE, INFO_HEADER_REST, BITFIELDS, @@ -164,8 +165,8 @@ private: RLE_ABSOLUTE }; - // This is the constructor used for normal BMP images. - explicit nsBMPDecoder(RasterImage* aImage); + // This is the constructor used for normal and clipboard BMP images. + explicit nsBMPDecoder(RasterImage* aImage, bool aForClipboard = false); // This is the constructor used for BMP resources in ICO images. nsBMPDecoder(RasterImage* aImage, uint32_t aDataOffset); @@ -180,6 +181,7 @@ private: void FinishRow(); LexerTransition<State> ReadFileHeader(const char* aData, size_t aLength); + LexerTransition<State> ReadClipboardHeader(const char* aData, size_t aLength); LexerTransition<State> ReadInfoHeaderSize(const char* aData, size_t aLength); LexerTransition<State> ReadInfoHeaderRest(const char* aData, size_t aLength); LexerTransition<State> ReadBitfields(const char* aData, size_t aLength); diff --git a/image/decoders/nsWebPDecoder.cpp b/image/decoders/nsWebPDecoder.cpp index 4f3cc8b2a..3181e3a3a 100644 --- a/image/decoders/nsWebPDecoder.cpp +++ b/image/decoders/nsWebPDecoder.cpp @@ -144,6 +144,10 @@ nsWebPDecoder::UpdateBuffer(SourceBufferIterator& aIterator, switch (aState) { case SourceBufferIterator::READY: + if(!aIterator.IsContiguous()) { + //We need to buffer. This should be rare, but expensive. + break; + } if (!mData) { // For as long as we hold onto an iterator, we know the data pointers // to the chunks cannot change underneath us, so save the pointer to |