| 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 | |
| 532 image_complete_ = true; | 522 image_complete_ = true; |
| 533 | 523 |
| 534 // Update ImageAnimationPolicy for image_. | 524 // Update ImageAnimationPolicy for image_. |
| 535 if (image_) | 525 if (image_) |
| 536 image_->UpdateImageAnimationPolicy(); | 526 image_->UpdateImageAnimationPolicy(); |
| 537 | 527 |
| 538 UpdateLayoutObject(); | 528 UpdateLayoutObject(); |
| 539 | 529 |
| 540 if (image_ && image_->GetImage() && image_->GetImage()->IsSVGImage()) | 530 if (image_ && image_->GetImage() && image_->GetImage()->IsSVGImage()) |
| 541 ToSVGImage(image_->GetImage()) | 531 ToSVGImage(image_->GetImage()) |
| 542 ->UpdateUseCounters(GetElement()->GetDocument()); | 532 ->UpdateUseCounters(GetElement()->GetDocument()); |
| 543 | 533 |
| 544 if (loading_image_document_) { | 534 if (!has_pending_load_event_) |
| 545 CHECK(!has_pending_load_event_); | |
| 546 return; | 535 return; |
| 547 } | |
| 548 | |
| 549 CHECK(has_pending_load_event_); | |
| 550 | 536 |
| 551 if (resource->ErrorOccurred()) { | 537 if (resource->ErrorOccurred()) { |
| 552 LoadEventSender().CancelEvent(this); | 538 LoadEventSender().CancelEvent(this); |
| 553 has_pending_load_event_ = false; | 539 has_pending_load_event_ = false; |
| 554 | 540 |
| 555 if (resource->GetResourceError().IsAccessCheck()) { | 541 if (resource->GetResourceError().IsAccessCheck()) { |
| 556 CrossSiteOrCSPViolationOccurred( | 542 CrossSiteOrCSPViolationOccurred( |
| 557 AtomicString(resource->GetResourceError().FailingURL())); | 543 AtomicString(resource->GetResourceError().FailingURL())); |
| 558 } | 544 } |
| 559 | 545 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 DCHECK(event_sender == &LoadEventSender() || | 625 DCHECK(event_sender == &LoadEventSender() || |
| 640 event_sender == &ErrorEventSender()); | 626 event_sender == &ErrorEventSender()); |
| 641 const AtomicString& event_type = event_sender->EventType(); | 627 const AtomicString& event_type = event_sender->EventType(); |
| 642 if (event_type == EventTypeNames::load) | 628 if (event_type == EventTypeNames::load) |
| 643 DispatchPendingLoadEvent(); | 629 DispatchPendingLoadEvent(); |
| 644 if (event_type == EventTypeNames::error) | 630 if (event_type == EventTypeNames::error) |
| 645 DispatchPendingErrorEvent(); | 631 DispatchPendingErrorEvent(); |
| 646 } | 632 } |
| 647 | 633 |
| 648 void ImageLoader::DispatchPendingLoadEvent() { | 634 void ImageLoader::DispatchPendingLoadEvent() { |
| 649 CHECK(has_pending_load_event_); | 635 if (!has_pending_load_event_) |
| 636 return; |
| 650 if (!image_) | 637 if (!image_) |
| 651 return; | 638 return; |
| 652 CHECK(image_complete_); | |
| 653 has_pending_load_event_ = false; | 639 has_pending_load_event_ = false; |
| 654 if (GetElement()->GetDocument().GetFrame()) | 640 if (GetElement()->GetDocument().GetFrame()) |
| 655 DispatchLoadEvent(); | 641 DispatchLoadEvent(); |
| 656 | 642 |
| 657 // Only consider updating the protection ref-count of the Element immediately | 643 // Only consider updating the protection ref-count of the Element immediately |
| 658 // before returning from this function as doing so might result in the | 644 // before returning from this function as doing so might result in the |
| 659 // destruction of this ImageLoader. | 645 // destruction of this ImageLoader. |
| 660 UpdatedHasPendingEvent(); | 646 UpdatedHasPendingEvent(); |
| 661 } | 647 } |
| 662 | 648 |
| 663 void ImageLoader::DispatchPendingErrorEvent() { | 649 void ImageLoader::DispatchPendingErrorEvent() { |
| 664 CHECK(has_pending_error_event_); | 650 if (!has_pending_error_event_) |
| 651 return; |
| 665 has_pending_error_event_ = false; | 652 has_pending_error_event_ = false; |
| 666 | 653 |
| 667 if (GetElement()->GetDocument().GetFrame()) | 654 if (GetElement()->GetDocument().GetFrame()) |
| 668 GetElement()->DispatchEvent(Event::Create(EventTypeNames::error)); | 655 GetElement()->DispatchEvent(Event::Create(EventTypeNames::error)); |
| 669 | 656 |
| 670 // Only consider updating the protection ref-count of the Element immediately | 657 // Only consider updating the protection ref-count of the Element immediately |
| 671 // 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 |
| 672 // destruction of this ImageLoader. | 659 // destruction of this ImageLoader. |
| 673 UpdatedHasPendingEvent(); | 660 UpdatedHasPendingEvent(); |
| 674 } | 661 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 690 } | 677 } |
| 691 | 678 |
| 692 void ImageLoader::ElementDidMoveToNewDocument() { | 679 void ImageLoader::ElementDidMoveToNewDocument() { |
| 693 if (load_delay_counter_) | 680 if (load_delay_counter_) |
| 694 load_delay_counter_->DocumentChanged(element_->GetDocument()); | 681 load_delay_counter_->DocumentChanged(element_->GetDocument()); |
| 695 ClearFailedLoadURL(); | 682 ClearFailedLoadURL(); |
| 696 ClearImage(); | 683 ClearImage(); |
| 697 } | 684 } |
| 698 | 685 |
| 699 } // namespace blink | 686 } // namespace blink |
| OLD | NEW |