Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp

Issue 2897533002: Make ImageObserver::AsyncLoadCompleted() called asynchronously (Closed)
Patch Set: Reflect kinuko's comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/svg/graphics/SVGImage.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org>
3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 12 matching lines...) Expand all
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "core/svg/graphics/SVGImage.h" 28 #include "core/svg/graphics/SVGImage.h"
29 29
30 #include "core/animation/DocumentAnimations.h" 30 #include "core/animation/DocumentAnimations.h"
31 #include "core/animation/DocumentTimeline.h" 31 #include "core/animation/DocumentTimeline.h"
32 #include "core/dom/NodeTraversal.h" 32 #include "core/dom/NodeTraversal.h"
33 #include "core/dom/TaskRunnerHelper.h"
33 #include "core/dom/shadow/FlatTreeTraversal.h" 34 #include "core/dom/shadow/FlatTreeTraversal.h"
34 #include "core/frame/FrameView.h" 35 #include "core/frame/FrameView.h"
35 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
36 #include "core/frame/LocalFrameClient.h" 37 #include "core/frame/LocalFrameClient.h"
37 #include "core/frame/Settings.h" 38 #include "core/frame/Settings.h"
38 #include "core/layout/LayoutView.h" 39 #include "core/layout/LayoutView.h"
39 #include "core/layout/svg/LayoutSVGRoot.h" 40 #include "core/layout/svg/LayoutSVGRoot.h"
40 #include "core/loader/FrameLoadRequest.h" 41 #include "core/loader/FrameLoadRequest.h"
41 #include "core/paint/FloatClipRecorder.h" 42 #include "core/paint/FloatClipRecorder.h"
42 #include "core/paint/TransformRecorder.h" 43 #include "core/paint/TransformRecorder.h"
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 } 634 }
634 635
635 void SVGImage::LoadCompleted() { 636 void SVGImage::LoadCompleted() {
636 switch (load_state_) { 637 switch (load_state_) {
637 case kInDataChanged: 638 case kInDataChanged:
638 load_state_ = kLoadCompleted; 639 load_state_ = kLoadCompleted;
639 break; 640 break;
640 641
641 case kWaitingForAsyncLoadCompletion: 642 case kWaitingForAsyncLoadCompletion:
642 load_state_ = kLoadCompleted; 643 load_state_ = kLoadCompleted;
643 if (GetImageObserver()) 644
644 GetImageObserver()->AsyncLoadCompleted(this); 645 // Because LoadCompleted() is called synchronously from
646 // Document::ImplicitClose(), we defer AsyncLoadCompleted() to avoid
647 // potential bugs and timing dependencies around ImplicitClose() and
648 // to make LoadEventFinished() true when AsyncLoadCompleted() is called.
649 TaskRunnerHelper::Get(TaskType::kUnspecedLoading,
650 ToLocalFrame(page_->MainFrame()))
651 ->PostTask(BLINK_FROM_HERE,
652 WTF::Bind(&SVGImage::NotifyAsyncLoadCompleted,
653 RefPtr<SVGImage>(this)));
645 break; 654 break;
646 655
647 case kDataChangedNotStarted: 656 case kDataChangedNotStarted:
648 case kLoadCompleted: 657 case kLoadCompleted:
649 CHECK(false); 658 CHECK(false);
650 break; 659 break;
651 } 660 }
652 } 661 }
653 662
663 void SVGImage::NotifyAsyncLoadCompleted() {
664 if (GetImageObserver())
665 GetImageObserver()->AsyncLoadCompleted(this);
666 }
667
654 Image::SizeAvailability SVGImage::DataChanged(bool all_data_received) { 668 Image::SizeAvailability SVGImage::DataChanged(bool all_data_received) {
655 TRACE_EVENT0("blink", "SVGImage::dataChanged"); 669 TRACE_EVENT0("blink", "SVGImage::dataChanged");
656 670
657 // Don't do anything if is an empty image. 671 // Don't do anything if is an empty image.
658 if (!Data()->size()) 672 if (!Data()->size())
659 return kSizeAvailable; 673 return kSizeAvailable;
660 674
661 if (!all_data_received) 675 if (!all_data_received)
662 return page_ ? kSizeAvailable : kSizeUnavailable; 676 return page_ ? kSizeAvailable : kSizeUnavailable;
663 677
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 773
760 NOTREACHED(); 774 NOTREACHED();
761 return kSizeAvailable; 775 return kSizeAvailable;
762 } 776 }
763 777
764 String SVGImage::FilenameExtension() const { 778 String SVGImage::FilenameExtension() const {
765 return "svg"; 779 return "svg";
766 } 780 }
767 781
768 } // namespace blink 782 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/graphics/SVGImage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698