| OLD | NEW |
| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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); | 183 m_image->removeClient(this); |
| 184 m_image->removeObserver(this); |
| 184 m_image = nullptr; | 185 m_image = nullptr; |
| 185 } | 186 } |
| 186 | 187 |
| 187 #if !ENABLE(OILPAN) | 188 #if !ENABLE(OILPAN) |
| 188 ASSERT(m_hasPendingLoadEvent || !loadEventSender().hasPendingEvents(this)); | 189 ASSERT(m_hasPendingLoadEvent || !loadEventSender().hasPendingEvents(this)); |
| 189 if (m_hasPendingLoadEvent) | 190 if (m_hasPendingLoadEvent) |
| 190 loadEventSender().cancelEvent(this); | 191 loadEventSender().cancelEvent(this); |
| 191 | 192 |
| 192 ASSERT(m_hasPendingErrorEvent || !errorEventSender().hasPendingEvents(this))
; | 193 ASSERT(m_hasPendingErrorEvent || !errorEventSender().hasPendingEvents(this))
; |
| 193 if (m_hasPendingErrorEvent) | 194 if (m_hasPendingErrorEvent) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 218 m_image = newImage; | 219 m_image = newImage; |
| 219 if (m_hasPendingLoadEvent) { | 220 if (m_hasPendingLoadEvent) { |
| 220 loadEventSender().cancelEvent(this); | 221 loadEventSender().cancelEvent(this); |
| 221 m_hasPendingLoadEvent = false; | 222 m_hasPendingLoadEvent = false; |
| 222 } | 223 } |
| 223 if (m_hasPendingErrorEvent) { | 224 if (m_hasPendingErrorEvent) { |
| 224 errorEventSender().cancelEvent(this); | 225 errorEventSender().cancelEvent(this); |
| 225 m_hasPendingErrorEvent = false; | 226 m_hasPendingErrorEvent = false; |
| 226 } | 227 } |
| 227 m_imageComplete = true; | 228 m_imageComplete = true; |
| 228 if (newImage) | 229 if (newImage) { |
| 229 newImage->addClient(this); | 230 newImage->addClient(this); |
| 230 if (oldImage) | 231 newImage->addObserver(this); |
| 232 } |
| 233 if (oldImage) { |
| 231 oldImage->removeClient(this); | 234 oldImage->removeClient(this); |
| 235 oldImage->removeObserver(this); |
| 236 } |
| 232 } | 237 } |
| 233 | 238 |
| 234 if (LayoutImageResource* imageResource = layoutImageResource()) | 239 if (LayoutImageResource* imageResource = layoutImageResource()) |
| 235 imageResource->resetAnimation(); | 240 imageResource->resetAnimation(); |
| 236 } | 241 } |
| 237 | 242 |
| 238 static void configureRequest(FetchRequest& request, ImageLoader::BypassMainWorld
Behavior bypassBehavior, Element& element, const ClientHintsPreferences& clientH
intsPreferences) | 243 static void configureRequest(FetchRequest& request, ImageLoader::BypassMainWorld
Behavior bypassBehavior, Element& element, const ClientHintsPreferences& clientH
intsPreferences) |
| 239 { | 244 { |
| 240 if (bypassBehavior == ImageLoader::BypassMainWorldCSP) | 245 if (bypassBehavior == ImageLoader::BypassMainWorldCSP) |
| 241 request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); | 246 request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 m_hasPendingErrorEvent = false; | 365 m_hasPendingErrorEvent = false; |
| 361 } | 366 } |
| 362 | 367 |
| 363 m_image = newImage; | 368 m_image = newImage; |
| 364 m_hasPendingLoadEvent = newImage; | 369 m_hasPendingLoadEvent = newImage; |
| 365 m_imageComplete = !newImage; | 370 m_imageComplete = !newImage; |
| 366 | 371 |
| 367 updateLayoutObject(); | 372 updateLayoutObject(); |
| 368 // If newImage exists and is cached, addClient() will result in the load
event | 373 // If newImage exists and is cached, addClient() will result in the load
event |
| 369 // being queued to fire. Ensure this happens after beforeload is dispatc
hed. | 374 // being queued to fire. Ensure this happens after beforeload is dispatc
hed. |
| 370 if (newImage) | 375 if (newImage) { |
| 371 newImage->addClient(this); | 376 newImage->addClient(this); |
| 372 | 377 newImage->addObserver(this); |
| 373 if (oldImage) | 378 } |
| 379 if (oldImage) { |
| 374 oldImage->removeClient(this); | 380 oldImage->removeClient(this); |
| 381 oldImage->removeObserver(this); |
| 382 } |
| 375 } | 383 } |
| 376 | 384 |
| 377 if (LayoutImageResource* imageResource = layoutImageResource()) | 385 if (LayoutImageResource* imageResource = layoutImageResource()) |
| 378 imageResource->resetAnimation(); | 386 imageResource->resetAnimation(); |
| 379 | 387 |
| 380 // Only consider updating the protection ref-count of the Element immediatel
y before returning | 388 // Only consider updating the protection ref-count of the Element immediatel
y before returning |
| 381 // from this function as doing so might result in the destruction of this Im
ageLoader. | 389 // from this function as doing so might result in the destruction of this Im
ageLoader. |
| 382 updatedHasPendingEvent(); | 390 updatedHasPendingEvent(); |
| 383 } | 391 } |
| 384 | 392 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 402 | 410 |
| 403 KURL url = imageSourceToKURL(imageSourceURL); | 411 KURL url = imageSourceToKURL(imageSourceURL); |
| 404 if (shouldLoadImmediately(url)) { | 412 if (shouldLoadImmediately(url)) { |
| 405 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior, referrerPol
icy); | 413 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior, referrerPol
icy); |
| 406 return; | 414 return; |
| 407 } | 415 } |
| 408 // Allow the idiom "img.src=''; img.src='.." to clear down the image before | 416 // Allow the idiom "img.src=''; img.src='.." to clear down the image before |
| 409 // an asynchronous load completes. | 417 // an asynchronous load completes. |
| 410 if (imageSourceURL.isEmpty()) { | 418 if (imageSourceURL.isEmpty()) { |
| 411 ImageResource* image = m_image.get(); | 419 ImageResource* image = m_image.get(); |
| 412 if (image) | 420 if (image) { |
| 413 image->removeClient(this); | 421 image->removeClient(this); |
| 422 image->removeObserver(this); |
| 423 } |
| 414 m_image = nullptr; | 424 m_image = nullptr; |
| 415 } | 425 } |
| 416 | 426 |
| 417 // Don't load images for inactive documents. We don't want to slow down the | 427 // Don't load images for inactive documents. We don't want to slow down the |
| 418 // raw HTML parsing case by loading images we don't intend to display. | 428 // raw HTML parsing case by loading images we don't intend to display. |
| 419 Document& document = m_element->document(); | 429 Document& document = m_element->document(); |
| 420 if (document.isActive()) | 430 if (document.isActive()) |
| 421 enqueueImageLoadingMicroTask(updateBehavior, referrerPolicy); | 431 enqueueImageLoadingMicroTask(updateBehavior, referrerPolicy); |
| 422 } | 432 } |
| 423 | 433 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 m_hasPendingErrorEvent = false; | 608 m_hasPendingErrorEvent = false; |
| 599 | 609 |
| 600 if (element()->document().frame()) | 610 if (element()->document().frame()) |
| 601 element()->dispatchEvent(Event::create(EventTypeNames::error)); | 611 element()->dispatchEvent(Event::create(EventTypeNames::error)); |
| 602 | 612 |
| 603 // Only consider updating the protection ref-count of the Element immediatel
y before returning | 613 // Only consider updating the protection ref-count of the Element immediatel
y before returning |
| 604 // from this function as doing so might result in the destruction of this Im
ageLoader. | 614 // from this function as doing so might result in the destruction of this Im
ageLoader. |
| 605 updatedHasPendingEvent(); | 615 updatedHasPendingEvent(); |
| 606 } | 616 } |
| 607 | 617 |
| 608 bool ImageLoader::getImageAnimationPolicy(ImageResource*, ImageAnimationPolicy&
policy) | 618 bool ImageLoader::getImageAnimationPolicy(ImageAnimationPolicy& policy) |
| 609 { | 619 { |
| 610 if (!element()->document().settings()) | 620 if (!element()->document().settings()) |
| 611 return false; | 621 return false; |
| 612 | 622 |
| 613 policy = element()->document().settings()->imageAnimationPolicy(); | 623 policy = element()->document().settings()->imageAnimationPolicy(); |
| 614 return true; | 624 return true; |
| 615 } | 625 } |
| 616 | 626 |
| 617 void ImageLoader::dispatchPendingLoadEvents() | 627 void ImageLoader::dispatchPendingLoadEvents() |
| 618 { | 628 { |
| 619 loadEventSender().dispatchPendingEvents(); | 629 loadEventSender().dispatchPendingEvents(); |
| 620 } | 630 } |
| 621 | 631 |
| 622 void ImageLoader::dispatchPendingErrorEvents() | 632 void ImageLoader::dispatchPendingErrorEvents() |
| 623 { | 633 { |
| 624 errorEventSender().dispatchPendingEvents(); | 634 errorEventSender().dispatchPendingEvents(); |
| 625 } | 635 } |
| 626 | 636 |
| 627 void ImageLoader::elementDidMoveToNewDocument() | 637 void ImageLoader::elementDidMoveToNewDocument() |
| 628 { | 638 { |
| 629 if (m_loadDelayCounter) | 639 if (m_loadDelayCounter) |
| 630 m_loadDelayCounter->documentChanged(m_element->document()); | 640 m_loadDelayCounter->documentChanged(m_element->document()); |
| 631 clearFailedLoadURL(); | 641 clearFailedLoadURL(); |
| 632 setImage(0); | 642 setImage(0); |
| 633 } | 643 } |
| 634 | 644 |
| 635 } // namespace blink | 645 } // namespace blink |
| OLD | NEW |