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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 return (dirEntry.m_imageOffset + dirEntry.m_byteSize) <= m_data->size(); | 91 return (dirEntry.m_imageOffset + dirEntry.m_byteSize) <= m_data->size(); |
92 } | 92 } |
93 | 93 |
94 bool ICOImageDecoder::setFailed() { | 94 bool ICOImageDecoder::setFailed() { |
95 m_bmpReaders.clear(); | 95 m_bmpReaders.clear(); |
96 m_pngDecoders.clear(); | 96 m_pngDecoders.clear(); |
97 return ImageDecoder::setFailed(); | 97 return ImageDecoder::setFailed(); |
98 } | 98 } |
99 | 99 |
100 bool ICOImageDecoder::hotSpot(IntPoint& hotSpot) const { | 100 bool ICOImageDecoder::hotSpot(IntPoint& hotSpot) const { |
101 // When unspecified, the default frame is always frame 0. This is consistent w
ith | 101 // When unspecified, the default frame is always frame 0. This is consistent |
102 // BitmapImage where currentFrame() starts at 0 and only increases when animat
ion is | 102 // with BitmapImage, where currentFrame() starts at 0 and only increases when |
103 // requested. | 103 // animation is requested. |
104 return hotSpotAtIndex(0, hotSpot); | 104 return hotSpotAtIndex(0, hotSpot); |
105 } | 105 } |
106 | 106 |
107 bool ICOImageDecoder::hotSpotAtIndex(size_t index, IntPoint& hotSpot) const { | 107 bool ICOImageDecoder::hotSpotAtIndex(size_t index, IntPoint& hotSpot) const { |
108 if (index >= m_dirEntries.size() || m_fileType != CURSOR) | 108 if (index >= m_dirEntries.size() || m_fileType != CURSOR) |
109 return false; | 109 return false; |
110 | 110 |
111 hotSpot = m_dirEntries[index].m_hotSpot; | 111 hotSpot = m_dirEntries[index].m_hotSpot; |
112 return true; | 112 return true; |
113 } | 113 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 ASSERT_WITH_SECURITY_IMPLICATION(index < m_dirEntries.size()); | 327 ASSERT_WITH_SECURITY_IMPLICATION(index < m_dirEntries.size()); |
328 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset; | 328 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset; |
329 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4)) | 329 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4)) |
330 return Unknown; | 330 return Unknown; |
331 char buffer[4]; | 331 char buffer[4]; |
332 const char* data = m_fastReader.getConsecutiveData(imageOffset, 4, buffer); | 332 const char* data = m_fastReader.getConsecutiveData(imageOffset, 4, buffer); |
333 return strncmp(data, "\x89PNG", 4) ? BMP : PNG; | 333 return strncmp(data, "\x89PNG", 4) ? BMP : PNG; |
334 } | 334 } |
335 | 335 |
336 } // namespace blink | 336 } // namespace blink |
OLD | NEW |