OLD | NEW |
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 Loading... |
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 bool SVGImage::IsInSVGImage(const Node* node) { | 114 bool SVGImage::IsInSVGImage(const Node* node) { |
114 DCHECK(node); | 115 DCHECK(node); |
115 | 116 |
116 Page* page = node->GetDocument().GetPage(); | 117 Page* page = node->GetDocument().GetPage(); |
117 if (!page) | 118 if (!page) |
118 return false; | 119 return false; |
119 | 120 |
120 return page->GetChromeClient().IsSVGImageChromeClient(); | 121 return page->GetChromeClient().IsSVGImageChromeClient(); |
121 } | 122 } |
122 | 123 |
| 124 void SVGImage::CheckLoaded() const { |
| 125 CHECK(page_); |
| 126 |
| 127 LocalFrame* frame = ToLocalFrame(page_->MainFrame()); |
| 128 |
| 129 CHECK(frame->GetDocument()->LoadEventFinished()); |
| 130 } |
| 131 |
123 bool SVGImage::CurrentFrameHasSingleSecurityOrigin() const { | 132 bool SVGImage::CurrentFrameHasSingleSecurityOrigin() const { |
124 if (!page_) | 133 if (!page_) |
125 return true; | 134 return true; |
126 | 135 |
127 LocalFrame* frame = ToLocalFrame(page_->MainFrame()); | 136 LocalFrame* frame = ToLocalFrame(page_->MainFrame()); |
128 | 137 |
129 CHECK(frame->GetDocument()->LoadEventFinished()); | 138 CheckLoaded(); |
130 | 139 |
131 SVGSVGElement* root_element = | 140 SVGSVGElement* root_element = |
132 frame->GetDocument()->AccessSVGExtensions().rootElement(); | 141 frame->GetDocument()->AccessSVGExtensions().rootElement(); |
133 if (!root_element) | 142 if (!root_element) |
134 return true; | 143 return true; |
135 | 144 |
136 // Don't allow foreignObject elements or images that are not known to be | 145 // Don't allow foreignObject elements or images that are not known to be |
137 // single-origin since these can leak cross-origin information. | 146 // single-origin since these can leak cross-origin information. |
138 for (Node* node = root_element; node; node = FlatTreeTraversal::Next(*node)) { | 147 for (Node* node = root_element; node; node = FlatTreeTraversal::Next(*node)) { |
139 if (isSVGForeignObjectElement(*node)) | 148 if (isSVGForeignObjectElement(*node)) |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 } | 642 } |
634 | 643 |
635 void SVGImage::LoadCompleted() { | 644 void SVGImage::LoadCompleted() { |
636 switch (load_state_) { | 645 switch (load_state_) { |
637 case kInDataChanged: | 646 case kInDataChanged: |
638 load_state_ = kLoadCompleted; | 647 load_state_ = kLoadCompleted; |
639 break; | 648 break; |
640 | 649 |
641 case kWaitingForAsyncLoadCompletion: | 650 case kWaitingForAsyncLoadCompletion: |
642 load_state_ = kLoadCompleted; | 651 load_state_ = kLoadCompleted; |
643 if (GetImageObserver()) | 652 if (GetImageObserver()) { |
644 GetImageObserver()->AsyncLoadCompleted(this); | 653 TaskRunnerHelper::Get(TaskType::kDOMManipulation, |
| 654 ToLocalFrame(page_->MainFrame())->GetDocument()) |
| 655 ->PostTask( |
| 656 BLINK_FROM_HERE, |
| 657 WTF::Bind(&ImageObserver::AsyncLoadCompleted, |
| 658 WeakPersistent<ImageObserver>(GetImageObserver()), |
| 659 RefPtr<SVGImage>(this))); |
| 660 } |
645 break; | 661 break; |
646 | 662 |
647 case kDataChangedNotStarted: | 663 case kDataChangedNotStarted: |
648 case kLoadCompleted: | 664 case kLoadCompleted: |
649 CHECK(false); | 665 CHECK(false); |
650 break; | 666 break; |
651 } | 667 } |
652 } | 668 } |
653 | 669 |
654 Image::SizeAvailability SVGImage::DataChanged(bool all_data_received) { | 670 Image::SizeAvailability SVGImage::DataChanged(bool all_data_received) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 | 775 |
760 NOTREACHED(); | 776 NOTREACHED(); |
761 return kSizeAvailable; | 777 return kSizeAvailable; |
762 } | 778 } |
763 | 779 |
764 String SVGImage::FilenameExtension() const { | 780 String SVGImage::FilenameExtension() const { |
765 return "svg"; | 781 return "svg"; |
766 } | 782 } |
767 | 783 |
768 } // namespace blink | 784 } // namespace blink |
OLD | NEW |