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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 , m_image(image) | 68 , m_image(image) |
69 , m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFir
ed) | 69 , m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFir
ed) |
70 , m_shouldPaintBrokenImage(true) | 70 , m_shouldPaintBrokenImage(true) |
71 { | 71 { |
72 setStatus(Cached); | 72 setStatus(Cached); |
73 setLoading(false); | 73 setLoading(false); |
74 } | 74 } |
75 | 75 |
76 CachedImage::~CachedImage() | 76 CachedImage::~CachedImage() |
77 { | 77 { |
| 78 clearImage(); |
78 } | 79 } |
79 | 80 |
80 void CachedImage::decodedDataDeletionTimerFired(Timer<CachedImage>*) | 81 void CachedImage::decodedDataDeletionTimerFired(Timer<CachedImage>*) |
81 { | 82 { |
82 ASSERT(!hasClients()); | 83 ASSERT(!hasClients()); |
83 destroyDecodedData(); | 84 destroyDecodedData(); |
84 } | 85 } |
85 | 86 |
86 void CachedImage::load(CachedResourceLoader* cachedResourceLoader, const Resourc
eLoaderOptions& options) | 87 void CachedImage::load(CachedResourceLoader* cachedResourceLoader, const Resourc
eLoaderOptions& options) |
87 { | 88 { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 296 |
296 m_shouldPaintBrokenImage = m_loader->frameLoader()->client()->shouldPaintBro
kenImage(m_resourceRequest.url()); | 297 m_shouldPaintBrokenImage = m_loader->frameLoader()->client()->shouldPaintBro
kenImage(m_resourceRequest.url()); |
297 } | 298 } |
298 | 299 |
299 void CachedImage::clear() | 300 void CachedImage::clear() |
300 { | 301 { |
301 destroyDecodedData(); | 302 destroyDecodedData(); |
302 #if ENABLE(SVG) | 303 #if ENABLE(SVG) |
303 m_svgImageCache.clear(); | 304 m_svgImageCache.clear(); |
304 #endif | 305 #endif |
305 m_image = 0; | 306 clearImage(); |
306 setEncodedSize(0); | 307 setEncodedSize(0); |
307 } | 308 } |
308 | 309 |
309 inline void CachedImage::createImage() | 310 inline void CachedImage::createImage() |
310 { | 311 { |
311 // Create the image if it doesn't yet exist. | 312 // Create the image if it doesn't yet exist. |
312 if (m_image) | 313 if (m_image) |
313 return; | 314 return; |
314 #if USE(CG) && !USE(WEBKIT_IMAGE_DECODERS) | 315 #if USE(CG) && !USE(WEBKIT_IMAGE_DECODERS) |
315 if (m_response.mimeType() == "application/pdf") { | 316 if (m_response.mimeType() == "application/pdf") { |
316 m_image = PDFDocumentImage::create(); | 317 m_image = PDFDocumentImage::create(); |
317 return; | 318 return; |
318 } | 319 } |
319 #endif | 320 #endif |
320 #if ENABLE(SVG) | 321 #if ENABLE(SVG) |
321 if (m_response.mimeType() == "image/svg+xml") { | 322 if (m_response.mimeType() == "image/svg+xml") { |
322 RefPtr<SVGImage> svgImage = SVGImage::create(this); | 323 RefPtr<SVGImage> svgImage = SVGImage::create(this); |
323 m_svgImageCache = SVGImageCache::create(svgImage.get()); | 324 m_svgImageCache = SVGImageCache::create(svgImage.get()); |
324 m_image = svgImage.release(); | 325 m_image = svgImage.release(); |
325 return; | 326 return; |
326 } | 327 } |
327 #endif | 328 #endif |
328 m_image = BitmapImage::create(this); | 329 m_image = BitmapImage::create(this); |
329 } | 330 } |
330 | 331 |
| 332 inline void CachedImage::clearImage() |
| 333 { |
| 334 // If our Image has an observer, it's always us so we need to clear the back
pointer |
| 335 // before dropping our reference. |
| 336 if (m_image) |
| 337 m_image->setImageObserver(0); |
| 338 m_image.clear(); |
| 339 } |
| 340 |
331 size_t CachedImage::maximumDecodedImageSize() | 341 size_t CachedImage::maximumDecodedImageSize() |
332 { | 342 { |
333 if (!m_loader || m_loader->reachedTerminalState()) | 343 if (!m_loader || m_loader->reachedTerminalState()) |
334 return 0; | 344 return 0; |
335 Settings* settings = m_loader->frameLoader()->frame()->settings(); | 345 Settings* settings = m_loader->frameLoader()->frame()->settings(); |
336 return settings ? settings->maximumDecodedImageSize() : 0; | 346 return settings ? settings->maximumDecodedImageSize() : 0; |
337 } | 347 } |
338 | 348 |
339 void CachedImage::data(PassRefPtr<SharedBuffer> data, bool allDataReceived) | 349 void CachedImage::data(PassRefPtr<SharedBuffer> data, bool allDataReceived) |
340 { | 350 { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 // We have to update the cached ImageBuffers if the underlying content chang
ed. | 470 // We have to update the cached ImageBuffers if the underlying content chang
ed. |
461 if (image->isSVGImage()) { | 471 if (image->isSVGImage()) { |
462 m_svgImageCache->imageContentChanged(); | 472 m_svgImageCache->imageContentChanged(); |
463 return; | 473 return; |
464 } | 474 } |
465 #endif | 475 #endif |
466 notifyObservers(&rect); | 476 notifyObservers(&rect); |
467 } | 477 } |
468 | 478 |
469 } // namespace WebCore | 479 } // namespace WebCore |
OLD | NEW |