| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool ICOImageDecoder::SetSize(unsigned width, unsigned height) { | 77 bool ICOImageDecoder::SetSize(unsigned width, unsigned height) { |
| 78 // The size calculated inside the BMPImageReader had better match the one in | 78 // The size calculated inside the BMPImageReader had better match the one in |
| 79 // the icon directory. | 79 // the icon directory. |
| 80 return frame_size_.IsEmpty() | 80 return frame_size_.IsEmpty() |
| 81 ? ImageDecoder::SetSize(width, height) | 81 ? ImageDecoder::SetSize(width, height) |
| 82 : ((IntSize(width, height) == frame_size_) || SetFailed()); | 82 : ((IntSize(width, height) == frame_size_) || SetFailed()); |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool ICOImageDecoder::FrameIsCompleteAtIndex(size_t index) const { | 85 bool ICOImageDecoder::FrameIsReceivedAtIndex(size_t index) const { |
| 86 if (index >= dir_entries_.size()) | 86 if (index >= dir_entries_.size()) |
| 87 return false; | 87 return false; |
| 88 const IconDirectoryEntry& dir_entry = dir_entries_[index]; | 88 const IconDirectoryEntry& dir_entry = dir_entries_[index]; |
| 89 return (dir_entry.image_offset_ + dir_entry.byte_size_) <= data_->size(); | 89 return (dir_entry.image_offset_ + dir_entry.byte_size_) <= data_->size(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool ICOImageDecoder::SetFailed() { | 92 bool ICOImageDecoder::SetFailed() { |
| 93 bmp_readers_.clear(); | 93 bmp_readers_.clear(); |
| 94 png_decoders_.clear(); | 94 png_decoders_.clear(); |
| 95 return ImageDecoder::SetFailed(); | 95 return ImageDecoder::SetFailed(); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 SECURITY_DCHECK(index < dir_entries_.size()); | 331 SECURITY_DCHECK(index < dir_entries_.size()); |
| 332 const uint32_t image_offset = dir_entries_[index].image_offset_; | 332 const uint32_t image_offset = dir_entries_[index].image_offset_; |
| 333 if ((image_offset > data_->size()) || ((data_->size() - image_offset) < 4)) | 333 if ((image_offset > data_->size()) || ((data_->size() - image_offset) < 4)) |
| 334 return kUnknown; | 334 return kUnknown; |
| 335 char buffer[4]; | 335 char buffer[4]; |
| 336 const char* data = fast_reader_.GetConsecutiveData(image_offset, 4, buffer); | 336 const char* data = fast_reader_.GetConsecutiveData(image_offset, 4, buffer); |
| 337 return strncmp(data, "\x89PNG", 4) ? BMP : PNG; | 337 return strncmp(data, "\x89PNG", 4) ? BMP : PNG; |
| 338 } | 338 } |
| 339 | 339 |
| 340 } // namespace blink | 340 } // namespace blink |
| OLD | NEW |