OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 if (!m_pngDecoders[index]) { | 211 if (!m_pngDecoders[index]) { |
212 AlphaOption alphaOption = | 212 AlphaOption alphaOption = |
213 m_premultiplyAlpha ? AlphaPremultiplied : AlphaNotPremultiplied; | 213 m_premultiplyAlpha ? AlphaPremultiplied : AlphaNotPremultiplied; |
214 m_pngDecoders[index] = WTF::wrapUnique( | 214 m_pngDecoders[index] = WTF::wrapUnique( |
215 new PNGImageDecoder(alphaOption, m_colorBehavior, m_maxDecodedBytes, | 215 new PNGImageDecoder(alphaOption, m_colorBehavior, m_maxDecodedBytes, |
216 dirEntry.m_imageOffset)); | 216 dirEntry.m_imageOffset)); |
217 setDataForPNGDecoderAtIndex(index); | 217 setDataForPNGDecoderAtIndex(index); |
218 } | 218 } |
219 // Fail if the size the PNGImageDecoder calculated does not match the size | 219 // Fail if the size the PNGImageDecoder calculated does not match the size |
220 // in the directory. | 220 // in the directory. |
221 if (m_pngDecoders[index]->isSizeAvailable() && | 221 auto& pngDecoder = m_pngDecoders[index]; |
Peter Kasting
2017/03/17 21:37:05
I would prefer "auto* pngDecoder = m_pngDecoders[i
scroggo_chromium
2017/03/20 13:26:42
Done.
| |
222 (m_pngDecoders[index]->size() != dirEntry.m_size)) | 222 if (pngDecoder->isSizeAvailable() && pngDecoder->size() != dirEntry.m_size) |
Peter Kasting
2017/03/17 21:37:05
If isSizeAvailable() is false, should we really fa
scroggo_chromium
2017/03/20 13:26:42
We only fail here if the size is available and it
Peter Kasting
2017/03/20 20:42:15
Hmm:
(a) I misread the new code, and
(b) I think t
scroggo_chromium
2017/03/21 16:03:30
Sgtm. I'd prefer to make this a separate change.
scroggo_chromium
2017/03/21 16:16:52
Uploaded https://codereview.chromium.org/276130300
| |
223 return setFailed(); | 223 return setFailed(); |
224 m_frameBufferCache[index] = *m_pngDecoders[index]->frameBufferAtIndex(0); | 224 if (const auto* frame = pngDecoder->frameBufferAtIndex(0)) { |
225 m_frameBufferCache[index].setPremultiplyAlpha(m_premultiplyAlpha); | 225 m_frameBufferCache[index] = *frame; |
226 return !m_pngDecoders[index]->failed() || setFailed(); | 226 m_frameBufferCache[index].setPremultiplyAlpha(m_premultiplyAlpha); |
scroggo_chromium
2017/03/17 17:50:34
I don't see how this line is necessary. AFAICT, th
Peter Kasting
2017/03/17 21:37:05
I would just remove it now. I think this is an ar
scroggo_chromium
2017/03/20 13:26:42
Done.
| |
227 } | |
228 return !pngDecoder->failed() || setFailed(); | |
227 } | 229 } |
228 | 230 |
229 bool ICOImageDecoder::processDirectory() { | 231 bool ICOImageDecoder::processDirectory() { |
230 // Read directory. | 232 // Read directory. |
231 DCHECK(!m_decodedOffset); | 233 DCHECK(!m_decodedOffset); |
232 if (m_data->size() < sizeOfDirectory) | 234 if (m_data->size() < sizeOfDirectory) |
233 return false; | 235 return false; |
234 const uint16_t fileType = readUint16(2); | 236 const uint16_t fileType = readUint16(2); |
235 m_dirEntriesCount = readUint16(4); | 237 m_dirEntriesCount = readUint16(4); |
236 m_decodedOffset = sizeOfDirectory; | 238 m_decodedOffset = sizeOfDirectory; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 SECURITY_DCHECK(index < m_dirEntries.size()); | 327 SECURITY_DCHECK(index < m_dirEntries.size()); |
326 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset; | 328 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset; |
327 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4)) | 329 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4)) |
328 return Unknown; | 330 return Unknown; |
329 char buffer[4]; | 331 char buffer[4]; |
330 const char* data = m_fastReader.getConsecutiveData(imageOffset, 4, buffer); | 332 const char* data = m_fastReader.getConsecutiveData(imageOffset, 4, buffer); |
331 return strncmp(data, "\x89PNG", 4) ? BMP : PNG; | 333 return strncmp(data, "\x89PNG", 4) ? BMP : PNG; |
332 } | 334 } |
333 | 335 |
334 } // namespace blink | 336 } // namespace blink |
OLD | NEW |