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

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

Issue 1697713002: [WIP] ImageResourceClient->ImageResourceObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 m_image = newImage; 237 m_image = newImage;
238 if (m_hasPendingLoadEvent) { 238 if (m_hasPendingLoadEvent) {
239 loadEventSender().cancelEvent(this); 239 loadEventSender().cancelEvent(this);
240 m_hasPendingLoadEvent = false; 240 m_hasPendingLoadEvent = false;
241 } 241 }
242 if (m_hasPendingErrorEvent) { 242 if (m_hasPendingErrorEvent) {
243 errorEventSender().cancelEvent(this); 243 errorEventSender().cancelEvent(this);
244 m_hasPendingErrorEvent = false; 244 m_hasPendingErrorEvent = false;
245 } 245 }
246 m_imageComplete = true; 246 m_imageComplete = true;
247 if (newImage) 247 if (newImage) {
248 newImage->addClient(this); 248 newImage->addClient(this);
249 if (oldImage) 249 newImage->addObserver(this);
250 }
251 if (oldImage) {
250 oldImage->removeClient(this); 252 oldImage->removeClient(this);
253 oldImage->removeObserver(this);
254 }
251 } 255 }
252 256
253 if (LayoutImageResource* imageResource = layoutImageResource()) 257 if (LayoutImageResource* imageResource = layoutImageResource())
254 imageResource->resetAnimation(); 258 imageResource->resetAnimation();
255 } 259 }
256 260
257 static void configureRequest(FetchRequest& request, ImageLoader::BypassMainWorld Behavior bypassBehavior, Element& element, const ClientHintsPreferences& clientH intsPreferences) 261 static void configureRequest(FetchRequest& request, ImageLoader::BypassMainWorld Behavior bypassBehavior, Element& element, const ClientHintsPreferences& clientH intsPreferences)
258 { 262 {
259 if (bypassBehavior == ImageLoader::BypassMainWorldCSP) 263 if (bypassBehavior == ImageLoader::BypassMainWorldCSP)
260 request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); 264 request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 m_hasPendingErrorEvent = false; 387 m_hasPendingErrorEvent = false;
384 } 388 }
385 389
386 m_image = newImage; 390 m_image = newImage;
387 m_hasPendingLoadEvent = newImage; 391 m_hasPendingLoadEvent = newImage;
388 m_imageComplete = !newImage; 392 m_imageComplete = !newImage;
389 393
390 updateLayoutObject(); 394 updateLayoutObject();
391 // If newImage exists and is cached, addClient() will result in the load event 395 // If newImage exists and is cached, addClient() will result in the load event
392 // being queued to fire. Ensure this happens after beforeload is dispatc hed. 396 // being queued to fire. Ensure this happens after beforeload is dispatc hed.
393 if (newImage) 397 if (newImage) {
394 newImage->addClient(this); 398 newImage->addClient(this);
395 399 newImage->addObserver(this);
396 if (oldImage) 400 }
401 if (oldImage) {
397 oldImage->removeClient(this); 402 oldImage->removeClient(this);
403 oldImage->removeObserver(this);
404 }
398 } 405 }
399 406
400 if (LayoutImageResource* imageResource = layoutImageResource()) 407 if (LayoutImageResource* imageResource = layoutImageResource())
401 imageResource->resetAnimation(); 408 imageResource->resetAnimation();
402 409
403 // Only consider updating the protection ref-count of the Element immediatel y before returning 410 // Only consider updating the protection ref-count of the Element immediatel y before returning
404 // from this function as doing so might result in the destruction of this Im ageLoader. 411 // from this function as doing so might result in the destruction of this Im ageLoader.
405 updatedHasPendingEvent(); 412 updatedHasPendingEvent();
406 } 413 }
407 414
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 memoryCache()->updateDecodedResource(m_image.get(), UpdateForPropert yChange, MemoryCacheLiveResourcePriorityLow); 653 memoryCache()->updateDecodedResource(m_image.get(), UpdateForPropert yChange, MemoryCacheLiveResourcePriorityLow);
647 } 654 }
648 } 655 }
649 656
650 void ImageLoader::removeClient(ImageLoaderClient* client) 657 void ImageLoader::removeClient(ImageLoaderClient* client)
651 { 658 {
652 willRemoveClient(*client); 659 willRemoveClient(*client);
653 m_clients.remove(client); 660 m_clients.remove(client);
654 } 661 }
655 662
656 bool ImageLoader::getImageAnimationPolicy(ImageResource*, ImageAnimationPolicy& policy) 663 bool ImageLoader::getImageAnimationPolicy(ImageAnimationPolicy& policy)
657 { 664 {
658 if (!element()->document().settings()) 665 if (!element()->document().settings())
659 return false; 666 return false;
660 667
661 policy = element()->document().settings()->imageAnimationPolicy(); 668 policy = element()->document().settings()->imageAnimationPolicy();
662 return true; 669 return true;
663 } 670 }
664 671
665 void ImageLoader::dispatchPendingLoadEvents() 672 void ImageLoader::dispatchPendingLoadEvents()
666 { 673 {
(...skipping 15 matching lines...) Expand all
682 689
683 void ImageLoader::sourceImageChanged() 690 void ImageLoader::sourceImageChanged()
684 { 691 {
685 for (auto& client : m_clients) { 692 for (auto& client : m_clients) {
686 ImageLoaderClient* handle = client; 693 ImageLoaderClient* handle = client;
687 handle->notifyImageSourceChanged(); 694 handle->notifyImageSourceChanged();
688 } 695 }
689 } 696 }
690 697
691 } // namespace blink 698 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698