Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Side by Side Diff: Source/core/loader/ImageLoader.cpp

Issue 1047563002: Fire load event for an image even if it was the last image we loaded successfully. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 if (updateBehavior == UpdateSizeChanged && m_element->layoutObject() && m_el ement->layoutObject()->isImage() && newImage == oldImage) {
Yoav Weiss 2015/04/02 07:52:10 Hmm, I'm not sure that's the cleanest way to do th
rhogan 2015/04/02 18:15:16 It's not material for the test cases added by my C
293 sourceImageChanged(); 293 toLayoutImage(m_element->layoutObject())->intrinsicSizeChanged();
294 } else {
295 if (newImage != oldImage)
296 sourceImageChanged();
294 297
295 if (m_hasPendingLoadEvent) { 298 if (m_hasPendingLoadEvent) {
296 loadEventSender().cancelEvent(this); 299 loadEventSender().cancelEvent(this);
297 m_hasPendingLoadEvent = false; 300 m_hasPendingLoadEvent = false;
298 } 301 }
299 302
300 // Cancel error events that belong to the previous load, which is now ca ncelled by changing the src attribute. 303 // 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 304 // 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. 305 // 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. 306 // 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) { 307 if (m_hasPendingErrorEvent && newImage) {
305 errorEventSender().cancelEvent(this); 308 errorEventSender().cancelEvent(this);
306 m_hasPendingErrorEvent = false; 309 m_hasPendingErrorEvent = false;
307 } 310 }
308 311
309 m_image = newImage; 312 m_image = newImage;
310 m_hasPendingLoadEvent = newImage; 313 m_hasPendingLoadEvent = newImage;
311 m_imageComplete = !newImage; 314 m_imageComplete = !newImage;
312 315
313 updateRenderer(); 316 updateRenderer();
314 // If newImage exists and is cached, addClient() will result in the load event 317 // 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. 318 // being queued to fire. Ensure this happens after beforeload is dispatc hed.
316 if (newImage) 319 if (newImage)
317 newImage->addClient(this); 320 newImage->addClient(this);
318 321
319 if (oldImage) 322 if (oldImage)
320 oldImage->removeClient(this); 323 oldImage->removeClient(this);
Jimmy Jo 2016/04/28 13:02:33 I have a question. If newImage and oldImage are eq
321 } else if (updateBehavior == UpdateSizeChanged && m_element->layoutObject() && m_element->layoutObject()->isImage()) {
322 toLayoutImage(m_element->layoutObject())->intrinsicSizeChanged();
323 } 324 }
324 325
325 if (LayoutImageResource* imageResource = layoutImageResource()) 326 if (LayoutImageResource* imageResource = layoutImageResource())
326 imageResource->resetAnimation(); 327 imageResource->resetAnimation();
327 328
328 // Only consider updating the protection ref-count of the Element immediatel y before returning 329 // 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. 330 // from this function as doing so might result in the destruction of this Im ageLoader.
330 updatedHasPendingEvent(); 331 updatedHasPendingEvent();
331 } 332 }
332 333
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 #endif 595 #endif
595 } 596 }
596 597
597 #if ENABLE(OILPAN) 598 #if ENABLE(OILPAN)
598 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() 599 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover()
599 { 600 {
600 m_loader.willRemoveClient(m_client); 601 m_loader.willRemoveClient(m_client);
601 } 602 }
602 #endif 603 #endif
603 } 604 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698