| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // Called from the task or from updateFromElement to initiate the load. | 133 // Called from the task or from updateFromElement to initiate the load. |
| 134 void DoUpdateFromElement(BypassMainWorldBehavior, | 134 void DoUpdateFromElement(BypassMainWorldBehavior, |
| 135 UpdateFromElementBehavior, | 135 UpdateFromElementBehavior, |
| 136 const KURL&, | 136 const KURL&, |
| 137 ReferrerPolicy = kReferrerPolicyDefault); | 137 ReferrerPolicy = kReferrerPolicyDefault); |
| 138 | 138 |
| 139 virtual void DispatchLoadEvent() = 0; | 139 virtual void DispatchLoadEvent() = 0; |
| 140 virtual void NoImageResourceToLoad() {} | 140 virtual void NoImageResourceToLoad() {} |
| 141 | 141 |
| 142 bool HasPendingEvent() const; | 142 bool HasPendingEvent() const; |
| 143 void UpdatedHasPendingEvent(); | |
| 144 | 143 |
| 145 void DispatchPendingLoadEvent(); | 144 void DispatchPendingLoadEvent(); |
| 146 void DispatchPendingErrorEvent(); | 145 void DispatchPendingErrorEvent(); |
| 147 | 146 |
| 148 LayoutImageResource* GetLayoutImageResource(); | 147 LayoutImageResource* GetLayoutImageResource(); |
| 149 void UpdateLayoutObject(); | 148 void UpdateLayoutObject(); |
| 150 | 149 |
| 151 // Note: SetImage.*() are not a simple setter. | 150 // Note: SetImage.*() are not a simple setter. |
| 152 // Check the implementation to see what they do. | 151 // Check the implementation to see what they do. |
| 153 // TODO(hiroshige): Cleanup these methods. | 152 // TODO(hiroshige): Cleanup these methods. |
| 154 void SetImageForImageDocument(ImageResource*); | 153 void SetImageForImageDocument(ImageResource*); |
| 155 void SetImageWithoutConsideringPendingLoadEvent(ImageResourceContent*); | 154 void SetImageWithoutConsideringPendingLoadEvent(ImageResourceContent*); |
| 156 void UpdateImageState(ImageResourceContent*); | 155 void UpdateImageState(ImageResourceContent*); |
| 157 | 156 |
| 158 void ClearFailedLoadURL(); | 157 void ClearFailedLoadURL(); |
| 159 void DispatchErrorEvent(); | 158 void DispatchErrorEvent(); |
| 160 void CrossSiteOrCSPViolationOccurred(AtomicString); | 159 void CrossSiteOrCSPViolationOccurred(AtomicString); |
| 161 void EnqueueImageLoadingMicroTask(UpdateFromElementBehavior, ReferrerPolicy); | 160 void EnqueueImageLoadingMicroTask(UpdateFromElementBehavior, ReferrerPolicy); |
| 162 | 161 |
| 163 void TimerFired(TimerBase*); | |
| 164 | |
| 165 KURL ImageSourceToKURL(AtomicString) const; | 162 KURL ImageSourceToKURL(AtomicString) const; |
| 166 | 163 |
| 167 // Used to determine whether to immediately initiate the load or to schedule a | 164 // Used to determine whether to immediately initiate the load or to schedule a |
| 168 // microtask. | 165 // microtask. |
| 169 bool ShouldLoadImmediately(const KURL&) const; | 166 bool ShouldLoadImmediately(const KURL&) const; |
| 170 | 167 |
| 171 // For Oilpan, we must run dispose() as a prefinalizer and call | 168 // For Oilpan, we must run dispose() as a prefinalizer and call |
| 172 // m_image->removeClient(this) (and more.) Otherwise, the ImageResource can | 169 // m_image->removeClient(this) (and more.) Otherwise, the ImageResource can |
| 173 // invoke didAddClient() for the ImageLoader that is about to die in the | 170 // invoke didAddClient() for the ImageLoader that is about to die in the |
| 174 // current lazy sweeping, and the didAddClient() can access on-heap objects | 171 // current lazy sweeping, and the didAddClient() can access on-heap objects |
| 175 // that have already been finalized in the current lazy sweeping. | 172 // that have already been finalized in the current lazy sweeping. |
| 176 void Dispose(); | 173 void Dispose(); |
| 177 | 174 |
| 178 Member<Element> element_; | 175 Member<Element> element_; |
| 179 Member<ImageResourceContent> image_; | 176 Member<ImageResourceContent> image_; |
| 180 Member<ImageResource> image_resource_for_image_document_; | 177 Member<ImageResource> image_resource_for_image_document_; |
| 181 // FIXME: Oilpan: We might be able to remove this Persistent hack when | |
| 182 // ImageResourceClient is traceable. | |
| 183 GC_PLUGIN_IGNORE("http://crbug.com/383741") | |
| 184 Persistent<Element> keep_alive_; | |
| 185 | 178 |
| 186 Timer<ImageLoader> deref_element_timer_; | |
| 187 AtomicString failed_load_url_; | 179 AtomicString failed_load_url_; |
| 188 WeakPtr<Task> pending_task_; // owned by Microtask | 180 WeakPtr<Task> pending_task_; // owned by Microtask |
| 189 std::unique_ptr<IncrementLoadEventDelayCount> | 181 std::unique_ptr<IncrementLoadEventDelayCount> |
| 190 delay_until_do_update_from_element_; | 182 delay_until_do_update_from_element_; |
| 191 | 183 |
| 192 // Delaying load event: the timeline should be: | 184 // Delaying load event: the timeline should be: |
| 193 // (0) ImageResource::Fetch() is called. | 185 // (0) ImageResource::Fetch() is called. |
| 194 // (1) ResourceFetcher::StartLoad(): Resource loading is actually started. | 186 // (1) ResourceFetcher::StartLoad(): Resource loading is actually started. |
| 195 // (2) ResourceLoader::DidFinishLoading() etc: | 187 // (2) ResourceLoader::DidFinishLoading() etc: |
| 196 // Resource loading is finished, but SVG document load might be | 188 // Resource loading is finished, but SVG document load might be |
| 197 // incomplete because of asynchronously loaded subresources. | 189 // incomplete because of asynchronously loaded subresources. |
| 198 // (3) ImageNotifyFinished(): Image is completely loaded. | 190 // (3) ImageNotifyFinished(): Image is completely loaded. |
| 199 // and we delay Document load event from (1) to (3): | 191 // and we delay Document load event from (1) to (3): |
| 200 // - |ResourceFetcher::loaders_| delays Document load event from (1) to (2). | 192 // - |ResourceFetcher::loaders_| delays Document load event from (1) to (2). |
| 201 // - |delay_until_image_notify_finished_| delays Document load event from | 193 // - |delay_until_image_notify_finished_| delays Document load event from |
| 202 // the first ImageChanged() (at some time between (1) and (2)) until (3). | 194 // the first ImageChanged() (at some time between (1) and (2)) until (3). |
| 203 // Ideally, we might want to delay Document load event from (1) to (3), | 195 // Ideally, we might want to delay Document load event from (1) to (3), |
| 204 // but currently we piggyback on ImageChanged() because adding a callback | 196 // but currently we piggyback on ImageChanged() because adding a callback |
| 205 // hook at (1) might complicate the code. | 197 // hook at (1) might complicate the code. |
| 206 std::unique_ptr<IncrementLoadEventDelayCount> | 198 std::unique_ptr<IncrementLoadEventDelayCount> |
| 207 delay_until_image_notify_finished_; | 199 delay_until_image_notify_finished_; |
| 208 | 200 |
| 209 // Indicates whether there is a pending task for the load/error event on | 201 // Indicates whether there is a pending task for the load/error event on |
| 210 // EventSender. Will be replaced when EventSender is removed crbug/624697. | 202 // EventSender. Will be replaced when EventSender is removed crbug/624697. |
| 211 bool has_pending_load_event_ : 1; | 203 bool has_pending_load_event_ : 1; |
| 212 bool has_pending_error_event_ : 1; | 204 bool has_pending_error_event_ : 1; |
| 213 | 205 |
| 214 bool image_complete_ : 1; | 206 bool image_complete_ : 1; |
| 215 bool loading_image_document_ : 1; | 207 bool loading_image_document_ : 1; |
| 216 bool element_is_protected_ : 1; | |
| 217 bool suppress_error_events_ : 1; | 208 bool suppress_error_events_ : 1; |
| 218 }; | 209 }; |
| 219 | 210 |
| 220 } // namespace blink | 211 } // namespace blink |
| 221 | 212 |
| 222 #endif | 213 #endif |
| OLD | NEW |