OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
7 | 7 |
8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 Resource::didAddClient(c); | 87 Resource::didAddClient(c); |
88 } | 88 } |
89 | 89 |
90 void ImageResource::didRemoveClient(ResourceClient* c) | 90 void ImageResource::didRemoveClient(ResourceClient* c) |
91 { | 91 { |
92 ASSERT(c); | 92 ASSERT(c); |
93 ASSERT(c->resourceClientType() == ImageResourceClient::expectedType()); | 93 ASSERT(c->resourceClientType() == ImageResourceClient::expectedType()); |
94 | 94 |
95 m_pendingContainerSizeRequests.remove(static_cast<ImageResourceClient*>(c)); | 95 m_pendingContainerSizeRequests.remove(static_cast<ImageResourceClient*>(c)); |
96 if (m_svgImageCache) | 96 if (m_imageCache) |
97 m_svgImageCache->removeClientFromCache(static_cast<ImageResourceClient*>
(c)); | 97 m_imageCache->removeClientFromCache(static_cast<ImageResourceClient*>(c)
); |
98 | 98 |
99 Resource::didRemoveClient(c); | 99 Resource::didRemoveClient(c); |
100 } | 100 } |
101 | 101 |
102 void ImageResource::switchClientsToRevalidatedResource() | 102 void ImageResource::switchClientsToRevalidatedResource() |
103 { | 103 { |
104 ASSERT(resourceToRevalidate()); | 104 ASSERT(resourceToRevalidate()); |
105 ASSERT(resourceToRevalidate()->isImage()); | 105 ASSERT(resourceToRevalidate()->isImage()); |
106 // Pending container size requests need to be transferred to the revalidated
resource. | 106 // Pending container size requests need to be transferred to the revalidated
resource. |
107 if (!m_pendingContainerSizeRequests.isEmpty()) { | 107 if (!m_pendingContainerSizeRequests.isEmpty()) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // Returning the 1x broken image is non-ideal, but we cannot reliably ac
cess the appropriate | 168 // Returning the 1x broken image is non-ideal, but we cannot reliably ac
cess the appropriate |
169 // deviceScaleFactor from here. It is critical that callers use ImageRes
ource::brokenImage() | 169 // deviceScaleFactor from here. It is critical that callers use ImageRes
ource::brokenImage() |
170 // when they need the real, deviceScaleFactor-appropriate broken image i
con. | 170 // when they need the real, deviceScaleFactor-appropriate broken image i
con. |
171 return brokenImage(1).first; | 171 return brokenImage(1).first; |
172 } | 172 } |
173 | 173 |
174 if (!m_image) | 174 if (!m_image) |
175 return WebCore::Image::nullImage(); | 175 return WebCore::Image::nullImage(); |
176 | 176 |
177 if (m_image->isSVGImage()) { | 177 if (m_image->isSVGImage()) { |
178 WebCore::Image* image = m_svgImageCache->imageForRenderer(renderer); | 178 WebCore::Image* image = m_imageCache->imageForRenderer(renderer); |
179 if (image != WebCore::Image::nullImage()) | 179 if (image != WebCore::Image::nullImage()) |
180 return image; | 180 return image; |
181 } | 181 } |
182 | 182 |
183 return m_image.get(); | 183 return m_image.get(); |
184 } | 184 } |
185 | 185 |
186 void ImageResource::setContainerSizeForRenderer(const ImageResourceClient* rende
rer, const IntSize& containerSize, float containerZoom) | 186 void ImageResource::setContainerSizeForRenderer(const ImageResourceClient* rende
rer, const IntSize& containerSize, float containerZoom) |
187 { | 187 { |
188 if (containerSize.isEmpty()) | 188 if (containerSize.isEmpty()) |
189 return; | 189 return; |
190 ASSERT(renderer); | 190 ASSERT(renderer); |
191 ASSERT(containerZoom); | 191 ASSERT(containerZoom); |
192 if (!m_image) { | 192 if (!m_image) { |
193 m_pendingContainerSizeRequests.set(renderer, SizeAndZoom(containerSize,
containerZoom)); | 193 m_pendingContainerSizeRequests.set(renderer, SizeAndZoom(containerSize,
containerZoom)); |
194 return; | 194 return; |
195 } | 195 } |
196 if (!m_image->isSVGImage()) { | |
197 m_image->setContainerSize(containerSize); | |
198 return; | |
199 } | |
200 | 196 |
201 m_svgImageCache->setContainerSizeForRenderer(renderer, containerSize, contai
nerZoom); | 197 m_imageCache->setContainerSizeForRenderer(renderer, containerSize, container
Zoom); |
202 } | 198 } |
203 | 199 |
204 bool ImageResource::usesImageContainerSize() const | 200 bool ImageResource::usesImageContainerSize() const |
205 { | 201 { |
206 if (m_image) | 202 if (m_image) |
207 return m_image->usesContainerSize(); | 203 return m_image->usesContainerSize(); |
208 | 204 |
209 return false; | 205 return false; |
210 } | 206 } |
211 | 207 |
(...skipping 17 matching lines...) Expand all Loading... |
229 { | 225 { |
230 ASSERT(!isPurgeable()); | 226 ASSERT(!isPurgeable()); |
231 | 227 |
232 if (!m_image) | 228 if (!m_image) |
233 return IntSize(); | 229 return IntSize(); |
234 | 230 |
235 LayoutSize imageSize; | 231 LayoutSize imageSize; |
236 | 232 |
237 if (m_image->isBitmapImage() && (renderer && renderer->shouldRespectImageOri
entation() == RespectImageOrientation)) | 233 if (m_image->isBitmapImage() && (renderer && renderer->shouldRespectImageOri
entation() == RespectImageOrientation)) |
238 imageSize = static_cast<BitmapImage*>(m_image.get())->sizeRespectingOrie
ntation(); | 234 imageSize = static_cast<BitmapImage*>(m_image.get())->sizeRespectingOrie
ntation(); |
239 else if (m_image->isSVGImage() && sizeType == NormalSize) | 235 else if (sizeType == NormalSize) |
240 imageSize = m_svgImageCache->imageSizeForRenderer(renderer); | 236 imageSize = m_imageCache->imageSizeForRenderer(renderer); |
241 else | 237 else |
242 imageSize = m_image->size(); | 238 imageSize = m_image->size(); |
243 | 239 |
244 if (multiplier == 1.0f) | 240 if (multiplier == 1.0f) |
245 return imageSize; | 241 return imageSize; |
246 | 242 |
247 // Don't let images that have a width/height >= 1 shrink below 1 when zoomed
. | 243 // Don't let images that have a width/height >= 1 shrink below 1 when zoomed
. |
248 float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier; | 244 float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier; |
249 float heightScale = m_image->hasRelativeHeight() ? 1.0f : multiplier; | 245 float heightScale = m_image->hasRelativeHeight() ? 1.0f : multiplier; |
250 LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0
? 1 : 0); | 246 LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0
? 1 : 0); |
(...skipping 29 matching lines...) Expand all Loading... |
280 DEFINE_STATIC_LOCAL(const AtomicString, acceptWebP, ("image/webp,*/*;q=0.8",
AtomicString::ConstructFromLiteral)); | 276 DEFINE_STATIC_LOCAL(const AtomicString, acceptWebP, ("image/webp,*/*;q=0.8",
AtomicString::ConstructFromLiteral)); |
281 setAccept(acceptWebP); | 277 setAccept(acceptWebP); |
282 } | 278 } |
283 | 279 |
284 inline void ImageResource::createImage() | 280 inline void ImageResource::createImage() |
285 { | 281 { |
286 // Create the image if it doesn't yet exist. | 282 // Create the image if it doesn't yet exist. |
287 if (m_image) | 283 if (m_image) |
288 return; | 284 return; |
289 | 285 |
290 if (m_response.mimeType() == "image/svg+xml") { | 286 if (m_response.mimeType() == "image/svg+xml") |
291 RefPtr<SVGImage> svgImage = SVGImage::create(this); | 287 m_image = SVGImage::create(this); |
292 m_svgImageCache = SVGImageCache::create(svgImage.get()); | 288 else |
293 m_image = svgImage.release(); | |
294 } else { | |
295 m_image = BitmapImage::create(this); | 289 m_image = BitmapImage::create(this); |
296 } | 290 |
| 291 m_imageCache = ImageCache::create(m_image.get()); |
297 | 292 |
298 if (m_image) { | 293 if (m_image) { |
299 // Send queued container size requests. | 294 // Send queued container size requests. |
300 if (m_image->usesContainerSize()) { | 295 if (m_image->usesContainerSize()) { |
301 for (ContainerSizeRequests::iterator it = m_pendingContainerSizeRequ
ests.begin(); it != m_pendingContainerSizeRequests.end(); ++it) | 296 for (ContainerSizeRequests::iterator it = m_pendingContainerSizeRequ
ests.begin(); it != m_pendingContainerSizeRequests.end(); ++it) |
302 setContainerSizeForRenderer(it->key, it->value.first, it->value.
second); | 297 setContainerSizeForRenderer(it->key, it->value.first, it->value.
second); |
303 } | 298 } |
304 m_pendingContainerSizeRequests.clear(); | 299 m_pendingContainerSizeRequests.clear(); |
305 } | 300 } |
306 } | 301 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 437 |
443 bool ImageResource::currentFrameKnownToBeOpaque(const RenderObject* renderer) | 438 bool ImageResource::currentFrameKnownToBeOpaque(const RenderObject* renderer) |
444 { | 439 { |
445 WebCore::Image* image = imageForRenderer(renderer); | 440 WebCore::Image* image = imageForRenderer(renderer); |
446 if (image->isBitmapImage()) | 441 if (image->isBitmapImage()) |
447 image->nativeImageForCurrentFrame(); // force decode | 442 image->nativeImageForCurrentFrame(); // force decode |
448 return image->currentFrameKnownToBeOpaque(); | 443 return image->currentFrameKnownToBeOpaque(); |
449 } | 444 } |
450 | 445 |
451 } // namespace WebCore | 446 } // namespace WebCore |
OLD | NEW |