Chromium Code Reviews| 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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 } | 503 } |
| 504 | 504 |
| 505 void ImageLoader::ImageNotifyFinished(ImageResourceContent* resource) { | 505 void ImageLoader::ImageNotifyFinished(ImageResourceContent* resource) { |
| 506 RESOURCE_LOADING_DVLOG(1) | 506 RESOURCE_LOADING_DVLOG(1) |
| 507 << "ImageLoader::imageNotifyFinished " << this | 507 << "ImageLoader::imageNotifyFinished " << this |
| 508 << "; has_pending_load_event_=" << has_pending_load_event_; | 508 << "; has_pending_load_event_=" << has_pending_load_event_; |
| 509 | 509 |
| 510 DCHECK(failed_load_url_.IsEmpty()); | 510 DCHECK(failed_load_url_.IsEmpty()); |
| 511 DCHECK_EQ(resource, image_.Get()); | 511 DCHECK_EQ(resource, image_.Get()); |
| 512 | 512 |
| 513 // TODO(hiroshige): Turn the CHECK()s to DCHECK()s before going to beta. | |
| 514 if (loading_image_document_) | |
| 515 CHECK(image_complete_); | |
|
yhirano
2017/05/10 06:44:04
Just to confirm: This is based on the fact that Im
hiroshige
2017/05/10 17:05:44
Yes, and SetImage() sets image_ to non-null but im
| |
| 516 else | |
| 517 CHECK(!image_complete_); | |
| 518 | |
| 513 image_complete_ = true; | 519 image_complete_ = true; |
| 514 | 520 |
| 515 // Update ImageAnimationPolicy for image_. | 521 // Update ImageAnimationPolicy for image_. |
| 516 if (image_) | 522 if (image_) |
| 517 image_->UpdateImageAnimationPolicy(); | 523 image_->UpdateImageAnimationPolicy(); |
| 518 | 524 |
| 519 UpdateLayoutObject(); | 525 UpdateLayoutObject(); |
| 520 | 526 |
| 521 if (image_ && image_->GetImage() && image_->GetImage()->IsSVGImage()) | 527 if (image_ && image_->GetImage() && image_->GetImage()->IsSVGImage()) |
| 522 ToSVGImage(image_->GetImage()) | 528 ToSVGImage(image_->GetImage()) |
| 523 ->UpdateUseCounters(GetElement()->GetDocument()); | 529 ->UpdateUseCounters(GetElement()->GetDocument()); |
| 524 | 530 |
| 525 if (!has_pending_load_event_) | 531 if (loading_image_document_) { |
| 532 CHECK(!has_pending_load_event_); | |
| 526 return; | 533 return; |
| 534 } | |
| 535 | |
| 536 CHECK(has_pending_load_event_); | |
| 527 | 537 |
| 528 if (resource->ErrorOccurred()) { | 538 if (resource->ErrorOccurred()) { |
| 529 LoadEventSender().CancelEvent(this); | 539 LoadEventSender().CancelEvent(this); |
| 530 has_pending_load_event_ = false; | 540 has_pending_load_event_ = false; |
| 531 | 541 |
| 532 if (resource->GetResourceError().IsAccessCheck()) { | 542 if (resource->GetResourceError().IsAccessCheck()) { |
| 533 CrossSiteOrCSPViolationOccurred( | 543 CrossSiteOrCSPViolationOccurred( |
| 534 AtomicString(resource->GetResourceError().FailingURL())); | 544 AtomicString(resource->GetResourceError().FailingURL())); |
| 535 } | 545 } |
| 536 | 546 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 616 DCHECK(event_sender == &LoadEventSender() || | 626 DCHECK(event_sender == &LoadEventSender() || |
| 617 event_sender == &ErrorEventSender()); | 627 event_sender == &ErrorEventSender()); |
| 618 const AtomicString& event_type = event_sender->EventType(); | 628 const AtomicString& event_type = event_sender->EventType(); |
| 619 if (event_type == EventTypeNames::load) | 629 if (event_type == EventTypeNames::load) |
| 620 DispatchPendingLoadEvent(); | 630 DispatchPendingLoadEvent(); |
| 621 if (event_type == EventTypeNames::error) | 631 if (event_type == EventTypeNames::error) |
| 622 DispatchPendingErrorEvent(); | 632 DispatchPendingErrorEvent(); |
| 623 } | 633 } |
| 624 | 634 |
| 625 void ImageLoader::DispatchPendingLoadEvent() { | 635 void ImageLoader::DispatchPendingLoadEvent() { |
| 626 if (!has_pending_load_event_) | 636 CHECK(has_pending_load_event_); |
| 627 return; | |
| 628 if (!image_) | 637 if (!image_) |
| 629 return; | 638 return; |
| 639 CHECK(image_complete_); | |
| 630 has_pending_load_event_ = false; | 640 has_pending_load_event_ = false; |
| 631 if (GetElement()->GetDocument().GetFrame()) | 641 if (GetElement()->GetDocument().GetFrame()) |
| 632 DispatchLoadEvent(); | 642 DispatchLoadEvent(); |
| 633 | 643 |
| 634 // Only consider updating the protection ref-count of the Element immediately | 644 // Only consider updating the protection ref-count of the Element immediately |
| 635 // before returning from this function as doing so might result in the | 645 // before returning from this function as doing so might result in the |
| 636 // destruction of this ImageLoader. | 646 // destruction of this ImageLoader. |
| 637 UpdatedHasPendingEvent(); | 647 UpdatedHasPendingEvent(); |
| 638 } | 648 } |
| 639 | 649 |
| 640 void ImageLoader::DispatchPendingErrorEvent() { | 650 void ImageLoader::DispatchPendingErrorEvent() { |
| 641 if (!has_pending_error_event_) | 651 if (!has_pending_error_event_) |
|
yhirano
2017/05/10 06:44:04
Should this be consistent with the corresponding s
hiroshige
2017/05/10 22:43:37
Done, and trying on bots.
| |
| 642 return; | 652 return; |
| 643 has_pending_error_event_ = false; | 653 has_pending_error_event_ = false; |
| 644 | 654 |
| 645 if (GetElement()->GetDocument().GetFrame()) | 655 if (GetElement()->GetDocument().GetFrame()) |
| 646 GetElement()->DispatchEvent(Event::Create(EventTypeNames::error)); | 656 GetElement()->DispatchEvent(Event::Create(EventTypeNames::error)); |
| 647 | 657 |
| 648 // Only consider updating the protection ref-count of the Element immediately | 658 // Only consider updating the protection ref-count of the Element immediately |
| 649 // before returning from this function as doing so might result in the | 659 // before returning from this function as doing so might result in the |
| 650 // destruction of this ImageLoader. | 660 // destruction of this ImageLoader. |
| 651 UpdatedHasPendingEvent(); | 661 UpdatedHasPendingEvent(); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 668 } | 678 } |
| 669 | 679 |
| 670 void ImageLoader::ElementDidMoveToNewDocument() { | 680 void ImageLoader::ElementDidMoveToNewDocument() { |
| 671 if (load_delay_counter_) | 681 if (load_delay_counter_) |
| 672 load_delay_counter_->DocumentChanged(element_->GetDocument()); | 682 load_delay_counter_->DocumentChanged(element_->GetDocument()); |
| 673 ClearFailedLoadURL(); | 683 ClearFailedLoadURL(); |
| 674 ClearImage(); | 684 ClearImage(); |
| 675 } | 685 } |
| 676 | 686 |
| 677 } // namespace blink | 687 } // namespace blink |
| OLD | NEW |