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

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

Issue 654253003: Error event shouldn't fire when image is updated on environment changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 ImageLoader::ImageLoader(Element* element) 114 ImageLoader::ImageLoader(Element* element)
115 : m_element(element) 115 : m_element(element)
116 , m_image(0) 116 , m_image(0)
117 , m_derefElementTimer(this, &ImageLoader::timerFired) 117 , m_derefElementTimer(this, &ImageLoader::timerFired)
118 , m_hasPendingLoadEvent(false) 118 , m_hasPendingLoadEvent(false)
119 , m_hasPendingErrorEvent(false) 119 , m_hasPendingErrorEvent(false)
120 , m_imageComplete(true) 120 , m_imageComplete(true)
121 , m_loadingImageDocument(false) 121 , m_loadingImageDocument(false)
122 , m_elementIsProtected(false) 122 , m_elementIsProtected(false)
123 , m_environmentChangeOnly(false)
123 , m_highPriorityClientCount(0) 124 , m_highPriorityClientCount(0)
124 { 125 {
125 WTF_LOG(Timers, "new ImageLoader %p", this); 126 WTF_LOG(Timers, "new ImageLoader %p", this);
126 } 127 }
127 128
128 ImageLoader::~ImageLoader() 129 ImageLoader::~ImageLoader()
129 { 130 {
130 WTF_LOG(Timers, "~ImageLoader %p; m_hasPendingLoadEvent=%d, m_hasPendingErro rEvent=%d", 131 WTF_LOG(Timers, "~ImageLoader %p; m_hasPendingLoadEvent=%d, m_hasPendingErro rEvent=%d",
131 this, m_hasPendingLoadEvent, m_hasPendingErrorEvent); 132 this, m_hasPendingLoadEvent, m_hasPendingErrorEvent);
132 133
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // being queued to fire. Ensure this happens after beforeload is dispatc hed. 302 // being queued to fire. Ensure this happens after beforeload is dispatc hed.
302 if (newImage) 303 if (newImage)
303 newImage->addClient(this); 304 newImage->addClient(this);
304 305
305 if (oldImage) 306 if (oldImage)
306 oldImage->removeClient(this); 307 oldImage->removeClient(this);
307 } else if (updateBehavior == UpdateSizeChanged && m_element->renderer() && m _element->renderer()->isImage()) { 308 } else if (updateBehavior == UpdateSizeChanged && m_element->renderer() && m _element->renderer()->isImage()) {
308 toRenderImage(m_element->renderer())->intrinsicSizeChanged(); 309 toRenderImage(m_element->renderer())->intrinsicSizeChanged();
309 } 310 }
310 311
312 if (updateBehavior == UpdateSizeChanged)
313 m_environmentChangeOnly = true;
Mike West 2014/10/17 14:12:40 You can drop the `if` and just assign the result o
314
311 if (RenderImageResource* imageResource = renderImageResource()) 315 if (RenderImageResource* imageResource = renderImageResource())
312 imageResource->resetAnimation(); 316 imageResource->resetAnimation();
313 317
314 // Only consider updating the protection ref-count of the Element immediatel y before returning 318 // Only consider updating the protection ref-count of the Element immediatel y before returning
315 // from this function as doing so might result in the destruction of this Im ageLoader. 319 // from this function as doing so might result in the destruction of this Im ageLoader.
316 updatedHasPendingEvent(); 320 updatedHasPendingEvent();
317 } 321 }
318 322
319 void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, Lo adType loadType) 323 void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, Lo adType loadType)
320 { 324 {
325 m_environmentChangeOnly = false;
321 AtomicString imageSourceURL = m_element->imageSourceURL(); 326 AtomicString imageSourceURL = m_element->imageSourceURL();
322 327
323 if (updateBehavior == UpdateIgnorePreviousError) 328 if (updateBehavior == UpdateIgnorePreviousError)
324 clearFailedLoadURL(); 329 clearFailedLoadURL();
325 330
326 if (!m_failedLoadURL.isEmpty() && imageSourceURL == m_failedLoadURL) 331 if (!m_failedLoadURL.isEmpty() && imageSourceURL == m_failedLoadURL)
327 return; 332 return;
328 333
329 // If we have a pending task, we have to clear it -- either we're 334 // If we have a pending task, we have to clear it -- either we're
330 // now loading immediately, or we need to reset the task's state. 335 // now loading immediately, or we need to reset the task's state.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 m_imageComplete = true; 384 m_imageComplete = true;
380 updateRenderer(); 385 updateRenderer();
381 386
382 if (!m_hasPendingLoadEvent) 387 if (!m_hasPendingLoadEvent)
383 return; 388 return;
384 389
385 if (resource->errorOccurred()) { 390 if (resource->errorOccurred()) {
386 loadEventSender().cancelEvent(this); 391 loadEventSender().cancelEvent(this);
387 m_hasPendingLoadEvent = false; 392 m_hasPendingLoadEvent = false;
388 393
389 m_hasPendingErrorEvent = true; 394 // The error event should not fire if the image data update is a result of environment change.
390 errorEventSender().dispatchEventSoon(this); 395 // https://html.spec.whatwg.org/multipage/embedded-content.html#the-img- element:the-img-element-55
396 if (!m_environmentChangeOnly) {
397 m_hasPendingErrorEvent = true;
398 errorEventSender().dispatchEventSoon(this);
399 }
391 400
392 // Only consider updating the protection ref-count of the Element immedi ately before returning 401 // Only consider updating the protection ref-count of the Element immedi ately before returning
393 // from this function as doing so might result in the destruction of thi s ImageLoader. 402 // from this function as doing so might result in the destruction of thi s ImageLoader.
394 updatedHasPendingEvent(); 403 updatedHasPendingEvent();
395 return; 404 return;
396 } 405 }
397 if (resource->wasCanceled()) { 406 if (resource->wasCanceled()) {
398 m_hasPendingLoadEvent = false; 407 m_hasPendingLoadEvent = false;
399 // Only consider updating the protection ref-count of the Element immedi ately before returning 408 // Only consider updating the protection ref-count of the Element immedi ately before returning
400 // from this function as doing so might result in the destruction of thi s ImageLoader. 409 // from this function as doing so might result in the destruction of thi s ImageLoader.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 } 580 }
572 581
573 #if ENABLE(OILPAN) 582 #if ENABLE(OILPAN)
574 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() 583 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover()
575 { 584 {
576 m_loader.willRemoveClient(m_client); 585 m_loader.willRemoveClient(m_client);
577 } 586 }
578 #endif 587 #endif
579 588
580 } 589 }
OLDNEW
« Source/core/loader/ImageLoader.h ('K') | « Source/core/loader/ImageLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698