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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 } | 282 } |
| 283 } else { | 283 } else { |
| 284 if (!imageSourceURL.isNull()) { | 284 if (!imageSourceURL.isNull()) { |
| 285 // Fire an error event if the url string is not empty, but the KURL is. | 285 // Fire an error event if the url string is not empty, but the KURL is. |
| 286 dispatchErrorEvent(); | 286 dispatchErrorEvent(); |
| 287 } | 287 } |
| 288 noImageResourceToLoad(); | 288 noImageResourceToLoad(); |
| 289 } | 289 } |
| 290 | 290 |
| 291 ImageResource* oldImage = m_image.get(); | 291 ImageResource* oldImage = m_image.get(); |
| 292 if (newImage != oldImage) { | 292 bool resizingToViewport = updateBehavior == UpdateSizeChanged && m_element-> layoutObject() && m_element->layoutObject()->isImage(); |
| 293 sourceImageChanged(); | 293 bool selectedNewImage = newImage != oldImage; |
|
esprehn
2015/03/31 00:34:54
I would just inline the newImage != oldImage check
| |
| 294 if (resizingToViewport && !selectedNewImage) { | |
|
esprehn
2015/03/31 00:34:54
I might add a method like isLayoutImage()
and the
rhogan
2015/03/31 19:03:19
Mm, I passed on this. Hope that's OK.
| |
| 295 toLayoutImage(m_element->layoutObject())->intrinsicSizeChanged(); | |
| 296 } else { | |
| 297 if (selectedNewImage) | |
| 298 sourceImageChanged(); | |
| 294 | 299 |
| 295 if (m_hasPendingLoadEvent) { | 300 if (m_hasPendingLoadEvent) { |
| 296 loadEventSender().cancelEvent(this); | 301 loadEventSender().cancelEvent(this); |
| 297 m_hasPendingLoadEvent = false; | 302 m_hasPendingLoadEvent = false; |
| 298 } | 303 } |
| 299 | 304 |
| 300 // Cancel error events that belong to the previous load, which is now ca ncelled by changing the src attribute. | 305 // Cancel error events that belong to the previous load, which is now ca ncelled by changing the src attribute. |
| 301 // If newImage is null and m_hasPendingErrorEvent is true, we know the e rror event has been just posted by | 306 // If newImage is null and m_hasPendingErrorEvent is true, we know the e rror event has been just posted by |
| 302 // this load and we should not cancel the event. | 307 // this load and we should not cancel the event. |
| 303 // FIXME: If both previous load and this one got blocked with an error, we can receive one error event instead of two. | 308 // FIXME: If both previous load and this one got blocked with an error, we can receive one error event instead of two. |
| 304 if (m_hasPendingErrorEvent && newImage) { | 309 if (m_hasPendingErrorEvent && newImage) { |
| 305 errorEventSender().cancelEvent(this); | 310 errorEventSender().cancelEvent(this); |
| 306 m_hasPendingErrorEvent = false; | 311 m_hasPendingErrorEvent = false; |
| 307 } | 312 } |
| 308 | 313 |
| 309 m_image = newImage; | 314 m_image = newImage; |
| 310 m_hasPendingLoadEvent = newImage; | 315 m_hasPendingLoadEvent = newImage; |
| 311 m_imageComplete = !newImage; | 316 m_imageComplete = !newImage; |
| 312 | 317 |
| 313 updateRenderer(); | 318 updateRenderer(); |
| 314 // If newImage exists and is cached, addClient() will result in the load event | 319 // If newImage exists and is cached, addClient() will result in the load event |
| 315 // being queued to fire. Ensure this happens after beforeload is dispatc hed. | 320 // being queued to fire. Ensure this happens after beforeload is dispatc hed. |
| 316 if (newImage) | 321 if (newImage) |
| 317 newImage->addClient(this); | 322 newImage->addClient(this); |
| 318 | 323 |
| 319 if (oldImage) | 324 if (oldImage) |
| 320 oldImage->removeClient(this); | 325 oldImage->removeClient(this); |
| 321 } else if (updateBehavior == UpdateSizeChanged && m_element->layoutObject() && m_element->layoutObject()->isImage()) { | |
| 322 toLayoutImage(m_element->layoutObject())->intrinsicSizeChanged(); | |
| 323 } | 326 } |
| 324 | 327 |
| 325 if (LayoutImageResource* imageResource = layoutImageResource()) | 328 if (LayoutImageResource* imageResource = layoutImageResource()) |
| 326 imageResource->resetAnimation(); | 329 imageResource->resetAnimation(); |
| 327 | 330 |
| 328 // Only consider updating the protection ref-count of the Element immediatel y before returning | 331 // Only consider updating the protection ref-count of the Element immediatel y before returning |
| 329 // from this function as doing so might result in the destruction of this Im ageLoader. | 332 // from this function as doing so might result in the destruction of this Im ageLoader. |
| 330 updatedHasPendingEvent(); | 333 updatedHasPendingEvent(); |
| 331 } | 334 } |
| 332 | 335 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 #endif | 597 #endif |
| 595 } | 598 } |
| 596 | 599 |
| 597 #if ENABLE(OILPAN) | 600 #if ENABLE(OILPAN) |
| 598 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() | 601 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() |
| 599 { | 602 { |
| 600 m_loader.willRemoveClient(m_client); | 603 m_loader.willRemoveClient(m_client); |
| 601 } | 604 } |
| 602 #endif | 605 #endif |
| 603 } | 606 } |
| OLD | NEW |