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