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 |
66 enum UpdateFromElementBehavior { | 71 enum UpdateFromElementBehavior { |
67 // This should be the update behavior when the element is attached to a
document, or when DOM mutations trigger a new load. | 72 // This should be the update behavior when the element is attached to a
document, or when DOM mutations trigger a new load. |
68 // Starts loading if a load hasn't already been started. | 73 // Starts loading if a load hasn't already been started. |
69 UpdateNormal, | 74 UpdateNormal, |
70 // This should be the update behavior when the resource was changed (via
'src', 'srcset' or 'sizes'). | 75 // This should be the update behavior when the resource was changed (via
'src', 'srcset' or 'sizes'). |
71 // Starts a new load even if a previous load of the same resource have f
ailed, to match Firefox's behavior. | 76 // Starts a new load even if a previous load of the same resource have f
ailed, to match Firefox's behavior. |
72 // FIXME - Verify that this is the right behavior according to the spec. | 77 // FIXME - Verify that this is the right behavior according to the spec. |
73 UpdateIgnorePreviousError, | 78 UpdateIgnorePreviousError, |
74 // This forces the image to update its intrinsic size, even if the image
source has not changed. | 79 // This forces the image to update its intrinsic size, even if the image
source has not changed. |
75 UpdateSizeChanged | 80 UpdateSizeChanged |
76 }; | 81 }; |
77 | 82 |
78 enum BypassMainWorldBehavior { | 83 enum BypassMainWorldBehavior { |
79 BypassMainWorldCSP, | 84 BypassMainWorldCSP, |
80 DoNotBypassMainWorldCSP | 85 DoNotBypassMainWorldCSP |
81 }; | 86 }; |
82 | 87 |
83 void updateFromElement(UpdateFromElementBehavior = UpdateNormal); | 88 void updateFromElement(UpdateFromElementBehavior = UpdateNormal, LoadType =
LoadNormally); |
84 | 89 |
85 void elementDidMoveToNewDocument(); | 90 void elementDidMoveToNewDocument(); |
86 | 91 |
87 Element* element() const { return m_element; } | 92 Element* element() const { return m_element; } |
88 bool imageComplete() const | 93 bool imageComplete() const |
89 { | 94 { |
90 return m_imageComplete && !m_pendingTask; | 95 return m_imageComplete && !m_pendingTask; |
91 } | 96 } |
92 | 97 |
93 ImageResource* image() const { return m_image.get(); } | 98 ImageResource* image() const { return m_image.get(); } |
(...skipping 18 matching lines...) Expand all Loading... |
112 virtual void notifyFinished(Resource*) override; | 117 virtual void notifyFinished(Resource*) override; |
113 | 118 |
114 private: | 119 private: |
115 class Task; | 120 class Task; |
116 | 121 |
117 // Called from the task or from updateFromElement to initiate the load. | 122 // Called from the task or from updateFromElement to initiate the load. |
118 void doUpdateFromElement(BypassMainWorldBehavior, UpdateFromElementBehavior)
; | 123 void doUpdateFromElement(BypassMainWorldBehavior, UpdateFromElementBehavior)
; |
119 | 124 |
120 virtual void dispatchLoadEvent() = 0; | 125 virtual void dispatchLoadEvent() = 0; |
121 virtual String sourceURI(const AtomicString&) const = 0; | 126 virtual String sourceURI(const AtomicString&) const = 0; |
122 virtual void noImageResourceToLoad() { }; | |
123 | 127 |
124 void updatedHasPendingEvent(); | 128 void updatedHasPendingEvent(); |
125 | 129 |
126 void dispatchPendingLoadEvent(); | 130 void dispatchPendingLoadEvent(); |
127 void dispatchPendingErrorEvent(); | 131 void dispatchPendingErrorEvent(); |
128 | 132 |
129 RenderImageResource* renderImageResource(); | 133 RenderImageResource* renderImageResource(); |
130 void updateRenderer(); | 134 void updateRenderer(); |
131 | 135 |
132 void setImageWithoutConsideringPendingLoadEvent(ImageResource*); | 136 void setImageWithoutConsideringPendingLoadEvent(ImageResource*); |
133 void sourceImageChanged(); | 137 void sourceImageChanged(); |
134 void clearFailedLoadURL(); | 138 void clearFailedLoadURL(); |
135 void crossSiteOrCSPViolationOccured(AtomicString); | 139 void crossSiteOrCSPViolationOccured(AtomicString); |
136 void enqueueImageLoadingMicroTask(UpdateFromElementBehavior); | 140 void enqueueImageLoadingMicroTask(UpdateFromElementBehavior); |
137 static ResourcePtr<ImageResource> createImageResourceForImageDocument(Docume
nt&, FetchRequest&); | 141 static ResourcePtr<ImageResource> createImageResourceForImageDocument(Docume
nt&, FetchRequest&); |
138 | 142 |
139 void timerFired(Timer<ImageLoader>*); | 143 void timerFired(Timer<ImageLoader>*); |
140 | 144 |
141 KURL imageSourceToKURL(AtomicString) const; | 145 KURL imageSourceToKURL(AtomicString) const; |
142 | 146 |
143 // Used to determine whether to immediately initiate the load | 147 // Used to determine whether to immediately initiate the load |
144 // or to schedule a microtask. | 148 // or to schedule a microtask. |
145 bool shouldLoadImmediately(const KURL&) const; | 149 bool shouldLoadImmediately(const KURL&, LoadType) const; |
146 | 150 |
147 void willRemoveClient(ImageLoaderClient&); | 151 void willRemoveClient(ImageLoaderClient&); |
148 | 152 |
149 RawPtrWillBeMember<Element> m_element; | 153 RawPtrWillBeMember<Element> m_element; |
150 ResourcePtr<ImageResource> m_image; | 154 ResourcePtr<ImageResource> m_image; |
151 // FIXME: Oilpan: We might be able to remove this Persistent hack when | 155 // FIXME: Oilpan: We might be able to remove this Persistent hack when |
152 // ImageResourceClient is traceable. | 156 // ImageResourceClient is traceable. |
153 GC_PLUGIN_IGNORE("http://crbug.com/383741") | 157 GC_PLUGIN_IGNORE("http://crbug.com/383741") |
154 RefPtrWillBePersistent<Element> m_keepAlive; | 158 RefPtrWillBePersistent<Element> m_keepAlive; |
155 #if ENABLE(OILPAN) | 159 #if ENABLE(OILPAN) |
(...skipping 25 matching lines...) Expand all Loading... |
181 bool m_hasPendingErrorEvent : 1; | 185 bool m_hasPendingErrorEvent : 1; |
182 bool m_imageComplete : 1; | 186 bool m_imageComplete : 1; |
183 bool m_loadingImageDocument : 1; | 187 bool m_loadingImageDocument : 1; |
184 bool m_elementIsProtected : 1; | 188 bool m_elementIsProtected : 1; |
185 unsigned m_highPriorityClientCount; | 189 unsigned m_highPriorityClientCount; |
186 }; | 190 }; |
187 | 191 |
188 } | 192 } |
189 | 193 |
190 #endif | 194 #endif |
OLD | NEW |