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

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

Issue 1844603002: Make ImageLoader non-ResourceClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/loader/ImageLoader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 { 173 {
174 WTF_LOG(Timers, "~ImageLoader %p; m_hasPendingLoadEvent=%d, m_hasPendingErro rEvent=%d", 174 WTF_LOG(Timers, "~ImageLoader %p; m_hasPendingLoadEvent=%d, m_hasPendingErro rEvent=%d",
175 this, m_hasPendingLoadEvent, m_hasPendingErrorEvent); 175 this, m_hasPendingLoadEvent, m_hasPendingErrorEvent);
176 176
177 #if !ENABLE(OILPAN) 177 #if !ENABLE(OILPAN)
178 if (m_pendingTask) 178 if (m_pendingTask)
179 m_pendingTask->clearLoader(); 179 m_pendingTask->clearLoader();
180 #endif 180 #endif
181 181
182 if (m_image) { 182 if (m_image) {
183 m_image->removeClient(this);
184 m_image->removeObserver(this); 183 m_image->removeObserver(this);
185 m_image = nullptr; 184 m_image = nullptr;
186 } 185 }
187 186
188 #if !ENABLE(OILPAN) 187 #if !ENABLE(OILPAN)
189 ASSERT(m_hasPendingLoadEvent || !loadEventSender().hasPendingEvents(this)); 188 ASSERT(m_hasPendingLoadEvent || !loadEventSender().hasPendingEvents(this));
190 if (m_hasPendingLoadEvent) 189 if (m_hasPendingLoadEvent)
191 loadEventSender().cancelEvent(this); 190 loadEventSender().cancelEvent(this);
192 191
193 ASSERT(m_hasPendingErrorEvent || !errorEventSender().hasPendingEvents(this)) ; 192 ASSERT(m_hasPendingErrorEvent || !errorEventSender().hasPendingEvents(this)) ;
(...skipping 26 matching lines...) Expand all
220 if (m_hasPendingLoadEvent) { 219 if (m_hasPendingLoadEvent) {
221 loadEventSender().cancelEvent(this); 220 loadEventSender().cancelEvent(this);
222 m_hasPendingLoadEvent = false; 221 m_hasPendingLoadEvent = false;
223 } 222 }
224 if (m_hasPendingErrorEvent) { 223 if (m_hasPendingErrorEvent) {
225 errorEventSender().cancelEvent(this); 224 errorEventSender().cancelEvent(this);
226 m_hasPendingErrorEvent = false; 225 m_hasPendingErrorEvent = false;
227 } 226 }
228 m_imageComplete = true; 227 m_imageComplete = true;
229 if (newImage) { 228 if (newImage) {
230 newImage->addClient(this);
231 newImage->addObserver(this); 229 newImage->addObserver(this);
232 } 230 }
233 if (oldImage) { 231 if (oldImage) {
234 oldImage->removeClient(this);
235 oldImage->removeObserver(this); 232 oldImage->removeObserver(this);
236 } 233 }
237 } 234 }
238 235
239 if (LayoutImageResource* imageResource = layoutImageResource()) 236 if (LayoutImageResource* imageResource = layoutImageResource())
240 imageResource->resetAnimation(); 237 imageResource->resetAnimation();
241 } 238 }
242 239
243 static void configureRequest(FetchRequest& request, ImageLoader::BypassMainWorld Behavior bypassBehavior, Element& element, const ClientHintsPreferences& clientH intsPreferences) 240 static void configureRequest(FetchRequest& request, ImageLoader::BypassMainWorld Behavior bypassBehavior, Element& element, const ClientHintsPreferences& clientH intsPreferences)
244 { 241 {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 if (m_hasPendingErrorEvent && newImage) { 360 if (m_hasPendingErrorEvent && newImage) {
364 errorEventSender().cancelEvent(this); 361 errorEventSender().cancelEvent(this);
365 m_hasPendingErrorEvent = false; 362 m_hasPendingErrorEvent = false;
366 } 363 }
367 364
368 m_image = newImage; 365 m_image = newImage;
369 m_hasPendingLoadEvent = newImage; 366 m_hasPendingLoadEvent = newImage;
370 m_imageComplete = !newImage; 367 m_imageComplete = !newImage;
371 368
372 updateLayoutObject(); 369 updateLayoutObject();
373 // If newImage exists and is cached, addClient() will result in the load event 370 // If newImage exists and is cached, addObserver() will result in the lo ad event
374 // being queued to fire. Ensure this happens after beforeload is dispatc hed. 371 // being queued to fire. Ensure this happens after beforeload is dispatc hed.
375 if (newImage) { 372 if (newImage) {
376 newImage->addClient(this);
377 newImage->addObserver(this); 373 newImage->addObserver(this);
378 } 374 }
379 if (oldImage) { 375 if (oldImage) {
380 oldImage->removeClient(this);
381 oldImage->removeObserver(this); 376 oldImage->removeObserver(this);
382 } 377 }
383 } 378 }
384 379
385 if (LayoutImageResource* imageResource = layoutImageResource()) 380 if (LayoutImageResource* imageResource = layoutImageResource())
386 imageResource->resetAnimation(); 381 imageResource->resetAnimation();
387 382
388 // Only consider updating the protection ref-count of the Element immediatel y before returning 383 // Only consider updating the protection ref-count of the Element immediatel y before returning
389 // from this function as doing so might result in the destruction of this Im ageLoader. 384 // from this function as doing so might result in the destruction of this Im ageLoader.
390 updatedHasPendingEvent(); 385 updatedHasPendingEvent();
(...skipping 20 matching lines...) Expand all
411 KURL url = imageSourceToKURL(imageSourceURL); 406 KURL url = imageSourceToKURL(imageSourceURL);
412 if (shouldLoadImmediately(url)) { 407 if (shouldLoadImmediately(url)) {
413 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior, referrerPol icy); 408 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior, referrerPol icy);
414 return; 409 return;
415 } 410 }
416 // Allow the idiom "img.src=''; img.src='.." to clear down the image before 411 // Allow the idiom "img.src=''; img.src='.." to clear down the image before
417 // an asynchronous load completes. 412 // an asynchronous load completes.
418 if (imageSourceURL.isEmpty()) { 413 if (imageSourceURL.isEmpty()) {
419 ImageResource* image = m_image.get(); 414 ImageResource* image = m_image.get();
420 if (image) { 415 if (image) {
421 image->removeClient(this);
422 image->removeObserver(this); 416 image->removeObserver(this);
423 } 417 }
424 m_image = nullptr; 418 m_image = nullptr;
425 } 419 }
426 420
427 // Don't load images for inactive documents. We don't want to slow down the 421 // Don't load images for inactive documents. We don't want to slow down the
428 // raw HTML parsing case by loading images we don't intend to display. 422 // raw HTML parsing case by loading images we don't intend to display.
429 Document& document = m_element->document(); 423 Document& document = m_element->document();
430 if (document.isActive()) 424 if (document.isActive())
431 enqueueImageLoadingMicroTask(updateBehavior, referrerPolicy); 425 enqueueImageLoadingMicroTask(updateBehavior, referrerPolicy);
(...skipping 24 matching lines...) Expand all
456 // We force any image loads which might require alt content through the asyn chronous path so that we can add the shadow DOM 450 // We force any image loads which might require alt content through the asyn chronous path so that we can add the shadow DOM
457 // for the alt-text content when style recalc is over and DOM mutation is al lowed again. 451 // for the alt-text content when style recalc is over and DOM mutation is al lowed again.
458 if (!url.isNull()) { 452 if (!url.isNull()) {
459 Resource* resource = memoryCache()->resourceForURL(url, m_element->docum ent().fetcher()->getCacheIdentifier()); 453 Resource* resource = memoryCache()->resourceForURL(url, m_element->docum ent().fetcher()->getCacheIdentifier());
460 if (resource && !resource->errorOccurred()) 454 if (resource && !resource->errorOccurred())
461 return true; 455 return true;
462 } 456 }
463 return (m_loadingImageDocument || isHTMLObjectElement(m_element) || isHTMLEm bedElement(m_element) || url.protocolIsData()); 457 return (m_loadingImageDocument || isHTMLObjectElement(m_element) || isHTMLEm bedElement(m_element) || url.protocolIsData());
464 } 458 }
465 459
466 void ImageLoader::notifyFinished(Resource* resource) 460 void ImageLoader::imageNotifyFinished(ImageResource* resource)
467 { 461 {
468 WTF_LOG(Timers, "ImageLoader::notifyFinished %p; m_hasPendingLoadEvent=%d", 462 WTF_LOG(Timers, "ImageLoader::imageNotifyFinished %p; m_hasPendingLoadEvent= %d",
469 this, m_hasPendingLoadEvent); 463 this, m_hasPendingLoadEvent);
470 464
471 ASSERT(m_failedLoadURL.isEmpty()); 465 ASSERT(m_failedLoadURL.isEmpty());
472 ASSERT(resource == m_image.get()); 466 ASSERT(resource == m_image.get());
473 467
474 m_imageComplete = true; 468 m_imageComplete = true;
475 469
476 // Update ImageAnimationPolicy for m_image. 470 // Update ImageAnimationPolicy for m_image.
477 if (m_image) 471 if (m_image)
478 m_image->updateImageAnimationPolicy(); 472 m_image->updateImageAnimationPolicy();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 630
637 void ImageLoader::elementDidMoveToNewDocument() 631 void ImageLoader::elementDidMoveToNewDocument()
638 { 632 {
639 if (m_loadDelayCounter) 633 if (m_loadDelayCounter)
640 m_loadDelayCounter->documentChanged(m_element->document()); 634 m_loadDelayCounter->documentChanged(m_element->document());
641 clearFailedLoadURL(); 635 clearFailedLoadURL();
642 setImage(0); 636 setImage(0);
643 } 637 }
644 638
645 } // namespace blink 639 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/ImageLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698