| 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 | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights |
| 5 * reserved. | 5 * reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 } | 512 } |
| 513 | 513 |
| 514 void ImageLoader::ImageNotifyFinished(ImageResourceContent* resource) { | 514 void ImageLoader::ImageNotifyFinished(ImageResourceContent* resource) { |
| 515 RESOURCE_LOADING_DVLOG(1) | 515 RESOURCE_LOADING_DVLOG(1) |
| 516 << "ImageLoader::imageNotifyFinished " << this | 516 << "ImageLoader::imageNotifyFinished " << this |
| 517 << "; has_pending_load_event_=" << has_pending_load_event_; | 517 << "; has_pending_load_event_=" << has_pending_load_event_; |
| 518 | 518 |
| 519 DCHECK(failed_load_url_.IsEmpty()); | 519 DCHECK(failed_load_url_.IsEmpty()); |
| 520 DCHECK_EQ(resource, image_.Get()); | 520 DCHECK_EQ(resource, image_.Get()); |
| 521 | 521 |
| 522 // |has_pending_load_event_| is always false and |image_complete_| is |
| 523 // always true for entire ImageDocument loading for historical reason. |
| 524 // DoUpdateFromElement() is not called and SetImageForImageDocument() |
| 525 // is called instead for ImageDocument loading. |
| 526 // TODO(hiroshige): Turn the CHECK()s to DCHECK()s before going to beta. |
| 527 if (loading_image_document_) |
| 528 CHECK(image_complete_); |
| 529 else |
| 530 CHECK(!image_complete_); |
| 531 |
| 522 image_complete_ = true; | 532 image_complete_ = true; |
| 523 | 533 |
| 524 // Update ImageAnimationPolicy for image_. | 534 // Update ImageAnimationPolicy for image_. |
| 525 if (image_) | 535 if (image_) |
| 526 image_->UpdateImageAnimationPolicy(); | 536 image_->UpdateImageAnimationPolicy(); |
| 527 | 537 |
| 528 UpdateLayoutObject(); | 538 UpdateLayoutObject(); |
| 529 | 539 |
| 530 if (image_ && image_->GetImage() && image_->GetImage()->IsSVGImage()) | 540 if (image_ && image_->GetImage() && image_->GetImage()->IsSVGImage()) |
| 531 ToSVGImage(image_->GetImage()) | 541 ToSVGImage(image_->GetImage()) |
| 532 ->UpdateUseCounters(GetElement()->GetDocument()); | 542 ->UpdateUseCounters(GetElement()->GetDocument()); |
| 533 | 543 |
| 534 if (!has_pending_load_event_) | 544 if (loading_image_document_) { |
| 545 CHECK(!has_pending_load_event_); |
| 535 return; | 546 return; |
| 547 } |
| 548 |
| 549 CHECK(has_pending_load_event_); |
| 536 | 550 |
| 537 if (resource->ErrorOccurred()) { | 551 if (resource->ErrorOccurred()) { |
| 538 LoadEventSender().CancelEvent(this); | 552 LoadEventSender().CancelEvent(this); |
| 539 has_pending_load_event_ = false; | 553 has_pending_load_event_ = false; |
| 540 | 554 |
| 541 if (resource->GetResourceError().IsAccessCheck()) { | 555 if (resource->GetResourceError().IsAccessCheck()) { |
| 542 CrossSiteOrCSPViolationOccurred( | 556 CrossSiteOrCSPViolationOccurred( |
| 543 AtomicString(resource->GetResourceError().FailingURL())); | 557 AtomicString(resource->GetResourceError().FailingURL())); |
| 544 } | 558 } |
| 545 | 559 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 DCHECK(event_sender == &LoadEventSender() || | 639 DCHECK(event_sender == &LoadEventSender() || |
| 626 event_sender == &ErrorEventSender()); | 640 event_sender == &ErrorEventSender()); |
| 627 const AtomicString& event_type = event_sender->EventType(); | 641 const AtomicString& event_type = event_sender->EventType(); |
| 628 if (event_type == EventTypeNames::load) | 642 if (event_type == EventTypeNames::load) |
| 629 DispatchPendingLoadEvent(); | 643 DispatchPendingLoadEvent(); |
| 630 if (event_type == EventTypeNames::error) | 644 if (event_type == EventTypeNames::error) |
| 631 DispatchPendingErrorEvent(); | 645 DispatchPendingErrorEvent(); |
| 632 } | 646 } |
| 633 | 647 |
| 634 void ImageLoader::DispatchPendingLoadEvent() { | 648 void ImageLoader::DispatchPendingLoadEvent() { |
| 635 if (!has_pending_load_event_) | 649 CHECK(has_pending_load_event_); |
| 636 return; | |
| 637 if (!image_) | 650 if (!image_) |
| 638 return; | 651 return; |
| 652 CHECK(image_complete_); |
| 639 has_pending_load_event_ = false; | 653 has_pending_load_event_ = false; |
| 640 if (GetElement()->GetDocument().GetFrame()) | 654 if (GetElement()->GetDocument().GetFrame()) |
| 641 DispatchLoadEvent(); | 655 DispatchLoadEvent(); |
| 642 | 656 |
| 643 // Only consider updating the protection ref-count of the Element immediately | 657 // Only consider updating the protection ref-count of the Element immediately |
| 644 // before returning from this function as doing so might result in the | 658 // before returning from this function as doing so might result in the |
| 645 // destruction of this ImageLoader. | 659 // destruction of this ImageLoader. |
| 646 UpdatedHasPendingEvent(); | 660 UpdatedHasPendingEvent(); |
| 647 } | 661 } |
| 648 | 662 |
| 649 void ImageLoader::DispatchPendingErrorEvent() { | 663 void ImageLoader::DispatchPendingErrorEvent() { |
| 650 if (!has_pending_error_event_) | 664 CHECK(has_pending_error_event_); |
| 651 return; | |
| 652 has_pending_error_event_ = false; | 665 has_pending_error_event_ = false; |
| 653 | 666 |
| 654 if (GetElement()->GetDocument().GetFrame()) | 667 if (GetElement()->GetDocument().GetFrame()) |
| 655 GetElement()->DispatchEvent(Event::Create(EventTypeNames::error)); | 668 GetElement()->DispatchEvent(Event::Create(EventTypeNames::error)); |
| 656 | 669 |
| 657 // Only consider updating the protection ref-count of the Element immediately | 670 // Only consider updating the protection ref-count of the Element immediately |
| 658 // before returning from this function as doing so might result in the | 671 // before returning from this function as doing so might result in the |
| 659 // destruction of this ImageLoader. | 672 // destruction of this ImageLoader. |
| 660 UpdatedHasPendingEvent(); | 673 UpdatedHasPendingEvent(); |
| 661 } | 674 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 677 } | 690 } |
| 678 | 691 |
| 679 void ImageLoader::ElementDidMoveToNewDocument() { | 692 void ImageLoader::ElementDidMoveToNewDocument() { |
| 680 if (load_delay_counter_) | 693 if (load_delay_counter_) |
| 681 load_delay_counter_->DocumentChanged(element_->GetDocument()); | 694 load_delay_counter_->DocumentChanged(element_->GetDocument()); |
| 682 ClearFailedLoadURL(); | 695 ClearFailedLoadURL(); |
| 683 ClearImage(); | 696 ClearImage(); |
| 684 } | 697 } |
| 685 | 698 |
| 686 } // namespace blink | 699 } // namespace blink |
| OLD | NEW |