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

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

Issue 1047803005: Allow the "img.src='';img.src='.." idiom to clear down images immediately. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 if (m_pendingTask) { 346 if (m_pendingTask) {
347 m_pendingTask->clearLoader(); 347 m_pendingTask->clearLoader();
348 m_pendingTask.clear(); 348 m_pendingTask.clear();
349 } 349 }
350 350
351 KURL url = imageSourceToKURL(imageSourceURL); 351 KURL url = imageSourceToKURL(imageSourceURL);
352 if (shouldLoadImmediately(url)) { 352 if (shouldLoadImmediately(url)) {
353 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior); 353 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior);
354 return; 354 return;
355 } 355 }
356 // Allow the idiom "img.src=''; img.src='.." to clear down the image before
357 // an asynchronous load completes.
358 if (imageSourceURL.isEmpty()) {
359 ImageResource* image = m_image.get();
360 if (image)
361 image->removeClient(this);
362 m_image = nullptr;
363 }
356 enqueueImageLoadingMicroTask(updateBehavior); 364 enqueueImageLoadingMicroTask(updateBehavior);
357 } 365 }
358 366
359 KURL ImageLoader::imageSourceToKURL(AtomicString imageSourceURL) const 367 KURL ImageLoader::imageSourceToKURL(AtomicString imageSourceURL) const
360 { 368 {
361 KURL url; 369 KURL url;
362 370
363 // Don't load images for inactive documents. We don't want to slow down the 371 // Don't load images for inactive documents. We don't want to slow down the
364 // raw HTML parsing case by loading images we don't intend to display. 372 // raw HTML parsing case by loading images we don't intend to display.
365 Document& document = m_element->document(); 373 Document& document = m_element->document();
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 #endif 602 #endif
595 } 603 }
596 604
597 #if ENABLE(OILPAN) 605 #if ENABLE(OILPAN)
598 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() 606 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover()
599 { 607 {
600 m_loader.willRemoveClient(m_client); 608 m_loader.willRemoveClient(m_client);
601 } 609 }
602 #endif 610 #endif
603 } 611 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698