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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 if (isHTMLPictureElement(element()->parentNode()) || !element()->fastGet
Attribute(HTMLNames::srcsetAttr).isNull()) | 290 if (isHTMLPictureElement(element()->parentNode()) || !element()->fastGet
Attribute(HTMLNames::srcsetAttr).isNull()) |
291 resourceRequest.setRequestContext(WebURLRequest::RequestContextImage
Set); | 291 resourceRequest.setRequestContext(WebURLRequest::RequestContextImage
Set); |
292 FetchRequest request(resourceRequest, element()->localName(), resourceLo
aderOptions); | 292 FetchRequest request(resourceRequest, element()->localName(), resourceLo
aderOptions); |
293 configureRequest(request, bypassBehavior, *m_element, document.clientHin
tsPreferences()); | 293 configureRequest(request, bypassBehavior, *m_element, document.clientHin
tsPreferences()); |
294 | 294 |
295 newImage = ImageResource::fetch(request, document.fetcher()); | 295 newImage = ImageResource::fetch(request, document.fetcher()); |
296 | 296 |
297 if (!newImage && !pageIsBeingDismissed(&document)) { | 297 if (!newImage && !pageIsBeingDismissed(&document)) { |
298 crossSiteOrCSPViolationOccurred(imageSourceURL); | 298 crossSiteOrCSPViolationOccurred(imageSourceURL); |
299 dispatchErrorEvent(); | 299 dispatchErrorEvent(); |
| 300 dispatchLoadendEventSoon(); |
300 } else { | 301 } else { |
301 clearFailedLoadURL(); | 302 clearFailedLoadURL(); |
302 } | 303 } |
303 } else { | 304 } else { |
304 if (!imageSourceURL.isNull()) { | 305 if (!imageSourceURL.isNull()) { |
305 // Fire an error event if the url string is not empty, but the KURL
is. | 306 // Fire an error event if the url string is not empty, but the KURL
is. |
306 dispatchErrorEvent(); | 307 dispatchErrorEvent(); |
| 308 dispatchLoadendEventSoon(); |
307 } | 309 } |
308 noImageResourceToLoad(); | 310 noImageResourceToLoad(); |
309 } | 311 } |
310 | 312 |
311 ImageResource* oldImage = m_image.get(); | 313 ImageResource* oldImage = m_image.get(); |
312 if (updateBehavior == UpdateSizeChanged && m_element->layoutObject() && m_el
ement->layoutObject()->isImage() && newImage == oldImage) { | 314 if (updateBehavior == UpdateSizeChanged && m_element->layoutObject() && m_el
ement->layoutObject()->isImage() && newImage == oldImage) { |
313 toLayoutImage(m_element->layoutObject())->intrinsicSizeChanged(); | 315 toLayoutImage(m_element->layoutObject())->intrinsicSizeChanged(); |
314 } else { | 316 } else { |
315 if (m_hasPendingLoadEvent) { | 317 if (m_hasPendingLoadEvent) { |
316 loadEventSender().cancelEvent(this); | 318 loadEventSender().cancelEvent(this); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 } | 542 } |
541 | 543 |
542 void ImageLoader::timerFired(TimerBase*) | 544 void ImageLoader::timerFired(TimerBase*) |
543 { | 545 { |
544 m_keepAlive.clear(); | 546 m_keepAlive.clear(); |
545 } | 547 } |
546 | 548 |
547 void ImageLoader::dispatchPendingEvent(ImageEventSender* eventSender) | 549 void ImageLoader::dispatchPendingEvent(ImageEventSender* eventSender) |
548 { | 550 { |
549 RESOURCE_LOADING_DVLOG(1) << "ImageLoader::dispatchPendingEvent " << this; | 551 RESOURCE_LOADING_DVLOG(1) << "ImageLoader::dispatchPendingEvent " << this; |
550 ASSERT(eventSender == &loadEventSender() || eventSender == &errorEventSender
()); | |
551 const AtomicString& eventType = eventSender->eventType(); | 552 const AtomicString& eventType = eventSender->eventType(); |
552 if (eventType == EventTypeNames::load) | 553 if (eventType == EventTypeNames::load) |
553 dispatchPendingLoadEvent(); | 554 dispatchPendingLoadEvent(); |
554 if (eventType == EventTypeNames::error) | 555 if (eventType == EventTypeNames::error) |
555 dispatchPendingErrorEvent(); | 556 dispatchPendingErrorEvent(); |
| 557 if (eventType == EventTypeNames::loadend) |
| 558 dispatchPendingLoadendEvent(); |
556 } | 559 } |
557 | 560 |
558 void ImageLoader::dispatchPendingLoadEvent() | 561 void ImageLoader::dispatchPendingLoadEvent() |
559 { | 562 { |
560 if (!m_hasPendingLoadEvent) | 563 if (!m_hasPendingLoadEvent) |
561 return; | 564 return; |
562 if (!m_image) | 565 if (!m_image) |
563 return; | 566 return; |
564 m_hasPendingLoadEvent = false; | 567 m_hasPendingLoadEvent = false; |
565 if (element()->document().frame()) | 568 if (element()->document().frame()) |
(...skipping 11 matching lines...) Expand all Loading... |
577 m_hasPendingErrorEvent = false; | 580 m_hasPendingErrorEvent = false; |
578 | 581 |
579 if (element()->document().frame()) | 582 if (element()->document().frame()) |
580 element()->dispatchEvent(Event::create(EventTypeNames::error)); | 583 element()->dispatchEvent(Event::create(EventTypeNames::error)); |
581 | 584 |
582 // Only consider updating the protection ref-count of the Element immediatel
y before returning | 585 // Only consider updating the protection ref-count of the Element immediatel
y before returning |
583 // from this function as doing so might result in the destruction of this Im
ageLoader. | 586 // from this function as doing so might result in the destruction of this Im
ageLoader. |
584 updatedHasPendingEvent(); | 587 updatedHasPendingEvent(); |
585 } | 588 } |
586 | 589 |
| 590 void ImageLoader::dispatchPendingLoadendEvent() |
| 591 { |
| 592 if (element()->document().frame()) { |
| 593 dispatchLoadendEvent(); |
| 594 } |
| 595 |
| 596 updatedHasPendingEvent(); |
| 597 } |
| 598 |
587 bool ImageLoader::getImageAnimationPolicy(ImageAnimationPolicy& policy) | 599 bool ImageLoader::getImageAnimationPolicy(ImageAnimationPolicy& policy) |
588 { | 600 { |
589 if (!element()->document().settings()) | 601 if (!element()->document().settings()) |
590 return false; | 602 return false; |
591 | 603 |
592 policy = element()->document().settings()->imageAnimationPolicy(); | 604 policy = element()->document().settings()->imageAnimationPolicy(); |
593 return true; | 605 return true; |
594 } | 606 } |
595 | 607 |
596 void ImageLoader::dispatchPendingLoadEvents() | 608 void ImageLoader::dispatchPendingLoadEvents() |
597 { | 609 { |
598 loadEventSender().dispatchPendingEvents(); | 610 loadEventSender().dispatchPendingEvents(); |
599 } | 611 } |
600 | 612 |
601 void ImageLoader::dispatchPendingErrorEvents() | 613 void ImageLoader::dispatchPendingErrorEvents() |
602 { | 614 { |
603 errorEventSender().dispatchPendingEvents(); | 615 errorEventSender().dispatchPendingEvents(); |
604 } | 616 } |
605 | 617 |
606 void ImageLoader::elementDidMoveToNewDocument() | 618 void ImageLoader::elementDidMoveToNewDocument() |
607 { | 619 { |
608 if (m_loadDelayCounter) | 620 if (m_loadDelayCounter) |
609 m_loadDelayCounter->documentChanged(m_element->document()); | 621 m_loadDelayCounter->documentChanged(m_element->document()); |
610 clearFailedLoadURL(); | 622 clearFailedLoadURL(); |
611 setImage(0); | 623 setImage(0); |
612 } | 624 } |
613 | 625 |
614 } // namespace blink | 626 } // namespace blink |
OLD | NEW |