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, 2009 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2009 Apple Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 template<typename T> class EventSender; | 57 template<typename T> class EventSender; |
58 typedef EventSender<ImageLoader> ImageEventSender; | 58 typedef EventSender<ImageLoader> ImageEventSender; |
59 | 59 |
60 class ImageLoader : public NoBaseWillBeGarbageCollectedFinalized<ImageLoader>, p
ublic ImageResourceClient { | 60 class ImageLoader : public NoBaseWillBeGarbageCollectedFinalized<ImageLoader>, p
ublic ImageResourceClient { |
61 public: | 61 public: |
62 explicit ImageLoader(Element*); | 62 explicit ImageLoader(Element*); |
63 virtual ~ImageLoader(); | 63 virtual ~ImageLoader(); |
64 void trace(Visitor*); | 64 void trace(Visitor*); |
65 | 65 |
66 enum LoadType { | |
67 LoadNormally, | |
68 ForceLoadImmediately | |
69 }; | |
70 | |
71 enum UpdateFromElementBehavior { | 66 enum UpdateFromElementBehavior { |
72 // This should be the update behavior when the element is attached to a
document, or when DOM mutations trigger a new load. | 67 // This should be the update behavior when the element is attached to a
document, or when DOM mutations trigger a new load. |
73 // Starts loading if a load hasn't already been started. | 68 // Starts loading if a load hasn't already been started. |
74 UpdateNormal, | 69 UpdateNormal, |
75 // This should be the update behavior when the resource was changed (via
'src', 'srcset' or 'sizes'). | 70 // This should be the update behavior when the resource was changed (via
'src', 'srcset' or 'sizes'). |
76 // Starts a new load even if a previous load of the same resource have f
ailed, to match Firefox's behavior. | 71 // Starts a new load even if a previous load of the same resource have f
ailed, to match Firefox's behavior. |
77 // FIXME - Verify that this is the right behavior according to the spec. | 72 // FIXME - Verify that this is the right behavior according to the spec. |
78 UpdateIgnorePreviousError, | 73 UpdateIgnorePreviousError, |
79 // This forces the image to update its intrinsic size, even if the image
source has not changed. | 74 // This forces the image to update its intrinsic size, even if the image
source has not changed. |
80 UpdateSizeChanged | 75 UpdateSizeChanged |
81 }; | 76 }; |
82 | 77 |
83 enum BypassMainWorldBehavior { | 78 enum BypassMainWorldBehavior { |
84 BypassMainWorldCSP, | 79 BypassMainWorldCSP, |
85 DoNotBypassMainWorldCSP | 80 DoNotBypassMainWorldCSP |
86 }; | 81 }; |
87 | 82 |
88 void updateFromElement(UpdateFromElementBehavior = UpdateNormal, LoadType =
LoadNormally); | 83 void updateFromElement(UpdateFromElementBehavior = UpdateNormal); |
89 | 84 |
90 void elementDidMoveToNewDocument(); | 85 void elementDidMoveToNewDocument(); |
91 | 86 |
92 Element* element() const { return m_element; } | 87 Element* element() const { return m_element; } |
93 bool imageComplete() const | 88 bool imageComplete() const |
94 { | 89 { |
95 return m_imageComplete && !m_pendingTask; | 90 return m_imageComplete && !m_pendingTask; |
96 } | 91 } |
97 | 92 |
98 ImageResource* image() const { return m_image.get(); } | 93 ImageResource* image() const { return m_image.get(); } |
(...skipping 18 matching lines...) Expand all Loading... |
117 virtual void notifyFinished(Resource*) OVERRIDE; | 112 virtual void notifyFinished(Resource*) OVERRIDE; |
118 | 113 |
119 private: | 114 private: |
120 class Task; | 115 class Task; |
121 | 116 |
122 // Called from the task or from updateFromElement to initiate the load. | 117 // Called from the task or from updateFromElement to initiate the load. |
123 void doUpdateFromElement(BypassMainWorldBehavior, UpdateFromElementBehavior)
; | 118 void doUpdateFromElement(BypassMainWorldBehavior, UpdateFromElementBehavior)
; |
124 | 119 |
125 virtual void dispatchLoadEvent() = 0; | 120 virtual void dispatchLoadEvent() = 0; |
126 virtual String sourceURI(const AtomicString&) const = 0; | 121 virtual String sourceURI(const AtomicString&) const = 0; |
| 122 virtual void noImageResourceToLoad() { }; |
127 | 123 |
128 void updatedHasPendingEvent(); | 124 void updatedHasPendingEvent(); |
129 | 125 |
130 void dispatchPendingLoadEvent(); | 126 void dispatchPendingLoadEvent(); |
131 void dispatchPendingErrorEvent(); | 127 void dispatchPendingErrorEvent(); |
132 | 128 |
133 RenderImageResource* renderImageResource(); | 129 RenderImageResource* renderImageResource(); |
134 void updateRenderer(); | 130 void updateRenderer(); |
135 | 131 |
136 void setImageWithoutConsideringPendingLoadEvent(ImageResource*); | 132 void setImageWithoutConsideringPendingLoadEvent(ImageResource*); |
137 void sourceImageChanged(); | 133 void sourceImageChanged(); |
138 void clearFailedLoadURL(); | 134 void clearFailedLoadURL(); |
139 void crossSiteOrCSPViolationOccured(AtomicString); | 135 void crossSiteOrCSPViolationOccured(AtomicString); |
140 void enqueueImageLoadingMicroTask(UpdateFromElementBehavior); | 136 void enqueueImageLoadingMicroTask(UpdateFromElementBehavior); |
141 static ResourcePtr<ImageResource> createImageResourceForImageDocument(Docume
nt&, FetchRequest&); | 137 static ResourcePtr<ImageResource> createImageResourceForImageDocument(Docume
nt&, FetchRequest&); |
142 | 138 |
143 void timerFired(Timer<ImageLoader>*); | 139 void timerFired(Timer<ImageLoader>*); |
144 | 140 |
145 KURL imageSourceToKURL(AtomicString) const; | 141 KURL imageSourceToKURL(AtomicString) const; |
146 | 142 |
147 // Used to determine whether to immediately initiate the load | 143 // Used to determine whether to immediately initiate the load |
148 // or to schedule a microtask. | 144 // or to schedule a microtask. |
149 bool shouldLoadImmediately(const KURL&, LoadType) const; | 145 bool shouldLoadImmediately(const KURL&) const; |
150 | 146 |
151 void willRemoveClient(ImageLoaderClient&); | 147 void willRemoveClient(ImageLoaderClient&); |
152 | 148 |
153 RawPtrWillBeMember<Element> m_element; | 149 RawPtrWillBeMember<Element> m_element; |
154 ResourcePtr<ImageResource> m_image; | 150 ResourcePtr<ImageResource> m_image; |
155 // FIXME: Oilpan: We might be able to remove this Persistent hack when | 151 // FIXME: Oilpan: We might be able to remove this Persistent hack when |
156 // ImageResourceClient is traceable. | 152 // ImageResourceClient is traceable. |
157 GC_PLUGIN_IGNORE("http://crbug.com/383741") | 153 GC_PLUGIN_IGNORE("http://crbug.com/383741") |
158 RefPtrWillBePersistent<Element> m_keepAlive; | 154 RefPtrWillBePersistent<Element> m_keepAlive; |
159 #if ENABLE(OILPAN) | 155 #if ENABLE(OILPAN) |
(...skipping 25 matching lines...) Expand all Loading... |
185 bool m_hasPendingErrorEvent : 1; | 181 bool m_hasPendingErrorEvent : 1; |
186 bool m_imageComplete : 1; | 182 bool m_imageComplete : 1; |
187 bool m_loadingImageDocument : 1; | 183 bool m_loadingImageDocument : 1; |
188 bool m_elementIsProtected : 1; | 184 bool m_elementIsProtected : 1; |
189 unsigned m_highPriorityClientCount; | 185 unsigned m_highPriorityClientCount; |
190 }; | 186 }; |
191 | 187 |
192 } | 188 } |
193 | 189 |
194 #endif | 190 #endif |
OLD | NEW |