Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserv ed. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserv ed. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 if (m_image) | 115 if (m_image) |
| 116 m_image->removeClient(this); | 116 m_image->removeClient(this); |
| 117 | 117 |
| 118 ASSERT(m_hasPendingLoadEvent || !loadEventSender().hasPendingEvents(this)); | 118 ASSERT(m_hasPendingLoadEvent || !loadEventSender().hasPendingEvents(this)); |
| 119 if (m_hasPendingLoadEvent) | 119 if (m_hasPendingLoadEvent) |
| 120 loadEventSender().cancelEvent(this); | 120 loadEventSender().cancelEvent(this); |
| 121 | 121 |
| 122 ASSERT(m_hasPendingErrorEvent || !errorEventSender().hasPendingEvents(this)) ; | 122 ASSERT(m_hasPendingErrorEvent || !errorEventSender().hasPendingEvents(this)) ; |
| 123 if (m_hasPendingErrorEvent) | 123 if (m_hasPendingErrorEvent) |
| 124 errorEventSender().cancelEvent(this); | 124 errorEventSender().cancelEvent(this); |
| 125 } | |
| 125 | 126 |
| 126 // If the ImageLoader is being destroyed but it is still protecting its imag e-loading Element, | 127 void ImageLoader::trace(Visitor* visitor) |
| 127 // remove that protection here. | 128 { |
| 128 if (m_elementIsProtected) | 129 visitor->trace(m_element); |
| 129 m_element->deref(); | |
|
haraken
2014/06/10 04:15:13
Shall we add an ASSERT like this?
ASSERT(!m_ele
| |
| 130 } | 130 } |
| 131 | 131 |
| 132 void ImageLoader::setImage(ImageResource* newImage) | 132 void ImageLoader::setImage(ImageResource* newImage) |
| 133 { | 133 { |
| 134 setImageWithoutConsideringPendingLoadEvent(newImage); | 134 setImageWithoutConsideringPendingLoadEvent(newImage); |
| 135 | 135 |
| 136 // Only consider updating the protection ref-count of the Element immediatel y before returning | 136 // Only consider updating the protection ref-count of the Element immediatel y before returning |
| 137 // from this function as doing so might result in the destruction of this Im ageLoader. | 137 // from this function as doing so might result in the destruction of this Im ageLoader. |
| 138 updatedHasPendingEvent(); | 138 updatedHasPendingEvent(); |
| 139 } | 139 } |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 // If such an Element wishes for the load to stop when removed from the DOM it needs to stop the ImageLoader explicitly. | 409 // If such an Element wishes for the load to stop when removed from the DOM it needs to stop the ImageLoader explicitly. |
| 410 bool wasProtected = m_elementIsProtected; | 410 bool wasProtected = m_elementIsProtected; |
| 411 m_elementIsProtected = m_hasPendingLoadEvent || m_hasPendingErrorEvent; | 411 m_elementIsProtected = m_hasPendingLoadEvent || m_hasPendingErrorEvent; |
| 412 if (wasProtected == m_elementIsProtected) | 412 if (wasProtected == m_elementIsProtected) |
| 413 return; | 413 return; |
| 414 | 414 |
| 415 if (m_elementIsProtected) { | 415 if (m_elementIsProtected) { |
| 416 if (m_derefElementTimer.isActive()) | 416 if (m_derefElementTimer.isActive()) |
| 417 m_derefElementTimer.stop(); | 417 m_derefElementTimer.stop(); |
| 418 else | 418 else |
| 419 m_element->ref(); | 419 m_keepAlive = m_element; |
| 420 } else { | 420 } else { |
| 421 ASSERT(!m_derefElementTimer.isActive()); | 421 ASSERT(!m_derefElementTimer.isActive()); |
| 422 m_derefElementTimer.startOneShot(0, FROM_HERE); | 422 m_derefElementTimer.startOneShot(0, FROM_HERE); |
| 423 } | 423 } |
| 424 } | 424 } |
| 425 | 425 |
| 426 void ImageLoader::timerFired(Timer<ImageLoader>*) | 426 void ImageLoader::timerFired(Timer<ImageLoader>*) |
| 427 { | 427 { |
| 428 m_element->deref(); | 428 m_keepAlive.clear(); |
| 429 } | 429 } |
| 430 | 430 |
| 431 void ImageLoader::dispatchPendingEvent(ImageEventSender* eventSender) | 431 void ImageLoader::dispatchPendingEvent(ImageEventSender* eventSender) |
| 432 { | 432 { |
| 433 ASSERT(eventSender == &loadEventSender() || eventSender == &errorEventSender ()); | 433 ASSERT(eventSender == &loadEventSender() || eventSender == &errorEventSender ()); |
| 434 const AtomicString& eventType = eventSender->eventType(); | 434 const AtomicString& eventType = eventSender->eventType(); |
| 435 if (eventType == EventTypeNames::load) | 435 if (eventType == EventTypeNames::load) |
| 436 dispatchPendingLoadEvent(); | 436 dispatchPendingLoadEvent(); |
| 437 if (eventType == EventTypeNames::error) | 437 if (eventType == EventTypeNames::error) |
| 438 dispatchPendingErrorEvent(); | 438 dispatchPendingErrorEvent(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 } | 539 } |
| 540 | 540 |
| 541 #if ENABLE(OILPAN) | 541 #if ENABLE(OILPAN) |
| 542 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() | 542 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() |
| 543 { | 543 { |
| 544 m_loader.willRemoveClient(m_client); | 544 m_loader.willRemoveClient(m_client); |
| 545 } | 545 } |
| 546 #endif | 546 #endif |
| 547 | 547 |
| 548 } | 548 } |
| OLD | NEW |