Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: Source/core/platform/image-decoders/ico/ICOImageDecoder.cpp

Issue 23464095: WTF::notFound looks too much like a local variable. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 return m_frameSize.isEmpty() ? ImageDecoder::setSize(width, height) : ((IntS ize(width, height) == m_frameSize) || setFailed()); 98 return m_frameSize.isEmpty() ? ImageDecoder::setSize(width, height) : ((IntS ize(width, height) == m_frameSize) || setFailed());
99 } 99 }
100 100
101 size_t ICOImageDecoder::frameCount() 101 size_t ICOImageDecoder::frameCount()
102 { 102 {
103 decode(0, true); 103 decode(0, true);
104 if (m_frameBufferCache.isEmpty()) { 104 if (m_frameBufferCache.isEmpty()) {
105 m_frameBufferCache.resize(m_dirEntries.size()); 105 m_frameBufferCache.resize(m_dirEntries.size());
106 for (size_t i = 0; i < m_dirEntries.size(); ++i) { 106 for (size_t i = 0; i < m_dirEntries.size(); ++i) {
107 m_frameBufferCache[i].setPremultiplyAlpha(m_premultiplyAlpha); 107 m_frameBufferCache[i].setPremultiplyAlpha(m_premultiplyAlpha);
108 m_frameBufferCache[i].setRequiredPreviousFrameIndex(notFound); 108 m_frameBufferCache[i].setRequiredPreviousFrameIndex(kNotFound);
109 } 109 }
110 } 110 }
111 // CAUTION: We must not resize m_frameBufferCache again after this, as 111 // CAUTION: We must not resize m_frameBufferCache again after this, as
112 // decodeAtIndex() may give a BMPImageReader a pointer to one of the 112 // decodeAtIndex() may give a BMPImageReader a pointer to one of the
113 // entries. 113 // entries.
114 return m_frameBufferCache.size(); 114 return m_frameBufferCache.size();
115 } 115 }
116 116
117 ImageFrame* ICOImageDecoder::frameBufferAtIndex(size_t index) 117 ImageFrame* ICOImageDecoder::frameBufferAtIndex(size_t index)
118 { 118 {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 new PNGImageDecoder(m_premultiplyAlpha ? ImageSource::AlphaPremultip lied : ImageSource::AlphaNotPremultiplied, 232 new PNGImageDecoder(m_premultiplyAlpha ? ImageSource::AlphaPremultip lied : ImageSource::AlphaNotPremultiplied,
233 m_ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfile Ignored : ImageSource::GammaAndColorProfileApplied, m_maxDecodedSize)); 233 m_ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfile Ignored : ImageSource::GammaAndColorProfileApplied, m_maxDecodedSize));
234 setDataForPNGDecoderAtIndex(index); 234 setDataForPNGDecoderAtIndex(index);
235 } 235 }
236 // Fail if the size the PNGImageDecoder calculated does not match the size 236 // Fail if the size the PNGImageDecoder calculated does not match the size
237 // in the directory. 237 // in the directory.
238 if (m_pngDecoders[index]->isSizeAvailable() && (m_pngDecoders[index]->size() != dirEntry.m_size)) 238 if (m_pngDecoders[index]->isSizeAvailable() && (m_pngDecoders[index]->size() != dirEntry.m_size))
239 return setFailed(); 239 return setFailed();
240 m_frameBufferCache[index] = *m_pngDecoders[index]->frameBufferAtIndex(0); 240 m_frameBufferCache[index] = *m_pngDecoders[index]->frameBufferAtIndex(0);
241 m_frameBufferCache[index].setPremultiplyAlpha(m_premultiplyAlpha); 241 m_frameBufferCache[index].setPremultiplyAlpha(m_premultiplyAlpha);
242 m_frameBufferCache[index].setRequiredPreviousFrameIndex(notFound); 242 m_frameBufferCache[index].setRequiredPreviousFrameIndex(kNotFound);
243 return !m_pngDecoders[index]->failed() || setFailed(); 243 return !m_pngDecoders[index]->failed() || setFailed();
244 } 244 }
245 245
246 bool ICOImageDecoder::processDirectory() 246 bool ICOImageDecoder::processDirectory()
247 { 247 {
248 // Read directory. 248 // Read directory.
249 ASSERT(!m_decodedOffset); 249 ASSERT(!m_decodedOffset);
250 if (m_data->size() < sizeOfDirectory) 250 if (m_data->size() < sizeOfDirectory)
251 return false; 251 return false;
252 const uint16_t fileType = readUint16(2); 252 const uint16_t fileType = readUint16(2);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // Check if this entry is a BMP or a PNG; we need 4 bytes to check the magic 338 // Check if this entry is a BMP or a PNG; we need 4 bytes to check the magic
339 // number. 339 // number.
340 ASSERT_WITH_SECURITY_IMPLICATION(index < m_dirEntries.size()); 340 ASSERT_WITH_SECURITY_IMPLICATION(index < m_dirEntries.size());
341 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset; 341 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset;
342 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4)) 342 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4))
343 return Unknown; 343 return Unknown;
344 return strncmp(&m_data->data()[imageOffset], "\x89PNG", 4) ? BMP : PNG; 344 return strncmp(&m_data->data()[imageOffset], "\x89PNG", 4) ? BMP : PNG;
345 } 345 }
346 346
347 } 347 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698