| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 public ImageResourceObserver { | 49 public ImageResourceObserver { |
| 50 USING_PRE_FINALIZER(ImageLoader, dispose); | 50 USING_PRE_FINALIZER(ImageLoader, dispose); |
| 51 | 51 |
| 52 public: | 52 public: |
| 53 explicit ImageLoader(Element*); | 53 explicit ImageLoader(Element*); |
| 54 ~ImageLoader() override; | 54 ~ImageLoader() override; |
| 55 | 55 |
| 56 DECLARE_TRACE(); | 56 DECLARE_TRACE(); |
| 57 | 57 |
| 58 enum UpdateFromElementBehavior { | 58 enum UpdateFromElementBehavior { |
| 59 // This should be the update behavior when the element is attached to a docu
ment, or when DOM mutations trigger a new load. | 59 // This should be the update behavior when the element is attached to a |
| 60 // Starts loading if a load hasn't already been started. | 60 // document, or when DOM mutations trigger a new load. Starts loading if a |
| 61 // load hasn't already been started. |
| 61 UpdateNormal, | 62 UpdateNormal, |
| 62 // This should be the update behavior when the resource was changed (via 'sr
c', 'srcset' or 'sizes'). | 63 // This should be the update behavior when the resource was changed (via |
| 63 // Starts a new load even if a previous load of the same resource have faile
d, to match Firefox's behavior. | 64 // 'src', 'srcset' or 'sizes'). Starts a new load even if a previous load of |
| 65 // the same resource have failed, to match Firefox's behavior. |
| 64 // FIXME - Verify that this is the right behavior according to the spec. | 66 // FIXME - Verify that this is the right behavior according to the spec. |
| 65 UpdateIgnorePreviousError, | 67 UpdateIgnorePreviousError, |
| 66 // This forces the image to update its intrinsic size, even if the image sou
rce has not changed. | 68 // This forces the image to update its intrinsic size, even if the image |
| 69 // source has not changed. |
| 67 UpdateSizeChanged, | 70 UpdateSizeChanged, |
| 68 // This force the image to refetch and reload the image source, even if it h
as not changed. | 71 // This force the image to refetch and reload the image source, even if it |
| 72 // has not changed. |
| 69 UpdateForcedReload | 73 UpdateForcedReload |
| 70 }; | 74 }; |
| 71 | 75 |
| 72 enum BypassMainWorldBehavior { BypassMainWorldCSP, DoNotBypassMainWorldCSP }; | 76 enum BypassMainWorldBehavior { BypassMainWorldCSP, DoNotBypassMainWorldCSP }; |
| 73 | 77 |
| 74 void updateFromElement(UpdateFromElementBehavior = UpdateNormal, | 78 void updateFromElement(UpdateFromElementBehavior = UpdateNormal, |
| 75 ReferrerPolicy = ReferrerPolicyDefault); | 79 ReferrerPolicy = ReferrerPolicyDefault); |
| 76 | 80 |
| 77 void elementDidMoveToNewDocument(); | 81 void elementDidMoveToNewDocument(); |
| 78 | 82 |
| 79 Element* element() const { return m_element; } | 83 Element* element() const { return m_element; } |
| 80 bool imageComplete() const { return m_imageComplete && !m_pendingTask; } | 84 bool imageComplete() const { return m_imageComplete && !m_pendingTask; } |
| 81 | 85 |
| 82 ImageResource* image() const { return m_image.get(); } | 86 ImageResource* image() const { return m_image.get(); } |
| 83 void setImage( | 87 // Cancels pending load events, and doesn't dispatch new ones. |
| 84 ImageResource*); // Cancels pending load events, and doesn't dispatch new
ones. | 88 void setImage(ImageResource*); |
| 85 | 89 |
| 86 bool isLoadingImageDocument() { return m_loadingImageDocument; } | 90 bool isLoadingImageDocument() { return m_loadingImageDocument; } |
| 87 void setLoadingImageDocument() { m_loadingImageDocument = true; } | 91 void setLoadingImageDocument() { m_loadingImageDocument = true; } |
| 88 | 92 |
| 89 bool hasPendingActivity() const { | 93 bool hasPendingActivity() const { |
| 90 return m_hasPendingLoadEvent || m_hasPendingErrorEvent || m_pendingTask; | 94 return m_hasPendingLoadEvent || m_hasPendingErrorEvent || m_pendingTask; |
| 91 } | 95 } |
| 92 | 96 |
| 93 bool hasPendingError() const { return m_hasPendingErrorEvent; } | 97 bool hasPendingError() const { return m_hasPendingErrorEvent; } |
| 94 | 98 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 void setImageWithoutConsideringPendingLoadEvent(ImageResource*); | 131 void setImageWithoutConsideringPendingLoadEvent(ImageResource*); |
| 128 void clearFailedLoadURL(); | 132 void clearFailedLoadURL(); |
| 129 void dispatchErrorEvent(); | 133 void dispatchErrorEvent(); |
| 130 void crossSiteOrCSPViolationOccurred(AtomicString); | 134 void crossSiteOrCSPViolationOccurred(AtomicString); |
| 131 void enqueueImageLoadingMicroTask(UpdateFromElementBehavior, ReferrerPolicy); | 135 void enqueueImageLoadingMicroTask(UpdateFromElementBehavior, ReferrerPolicy); |
| 132 | 136 |
| 133 void timerFired(TimerBase*); | 137 void timerFired(TimerBase*); |
| 134 | 138 |
| 135 KURL imageSourceToKURL(AtomicString) const; | 139 KURL imageSourceToKURL(AtomicString) const; |
| 136 | 140 |
| 137 // Used to determine whether to immediately initiate the load | 141 // Used to determine whether to immediately initiate the load or to schedule a |
| 138 // or to schedule a microtask. | 142 // microtask. |
| 139 bool shouldLoadImmediately(const KURL&) const; | 143 bool shouldLoadImmediately(const KURL&) const; |
| 140 | 144 |
| 141 // For Oilpan, we must run dispose() as a prefinalizer and call | 145 // For Oilpan, we must run dispose() as a prefinalizer and call |
| 142 // m_image->removeClient(this) (and more.) Otherwise, the ImageResource can in
voke | 146 // m_image->removeClient(this) (and more.) Otherwise, the ImageResource can |
| 143 // didAddClient() for the ImageLoader that is about to die in the current | 147 // invoke didAddClient() for the ImageLoader that is about to die in the |
| 144 // lazy sweeping, and the didAddClient() can access on-heap objects that | 148 // current lazy sweeping, and the didAddClient() can access on-heap objects |
| 145 // have already been finalized in the current lazy sweeping. | 149 // that have already been finalized in the current lazy sweeping. |
| 146 void dispose(); | 150 void dispose(); |
| 147 | 151 |
| 148 Member<Element> m_element; | 152 Member<Element> m_element; |
| 149 Member<ImageResource> m_image; | 153 Member<ImageResource> m_image; |
| 150 // FIXME: Oilpan: We might be able to remove this Persistent hack when | 154 // FIXME: Oilpan: We might be able to remove this Persistent hack when |
| 151 // ImageResourceClient is traceable. | 155 // ImageResourceClient is traceable. |
| 152 GC_PLUGIN_IGNORE("http://crbug.com/383741") | 156 GC_PLUGIN_IGNORE("http://crbug.com/383741") |
| 153 Persistent<Element> m_keepAlive; | 157 Persistent<Element> m_keepAlive; |
| 154 | 158 |
| 155 Timer<ImageLoader> m_derefElementTimer; | 159 Timer<ImageLoader> m_derefElementTimer; |
| 156 AtomicString m_failedLoadURL; | 160 AtomicString m_failedLoadURL; |
| 157 WeakPtr<Task> m_pendingTask; // owned by Microtask | 161 WeakPtr<Task> m_pendingTask; // owned by Microtask |
| 158 std::unique_ptr<IncrementLoadEventDelayCount> m_loadDelayCounter; | 162 std::unique_ptr<IncrementLoadEventDelayCount> m_loadDelayCounter; |
| 159 bool m_hasPendingLoadEvent : 1; | 163 bool m_hasPendingLoadEvent : 1; |
| 160 bool m_hasPendingErrorEvent : 1; | 164 bool m_hasPendingErrorEvent : 1; |
| 161 bool m_imageComplete : 1; | 165 bool m_imageComplete : 1; |
| 162 bool m_loadingImageDocument : 1; | 166 bool m_loadingImageDocument : 1; |
| 163 bool m_elementIsProtected : 1; | 167 bool m_elementIsProtected : 1; |
| 164 bool m_suppressErrorEvents : 1; | 168 bool m_suppressErrorEvents : 1; |
| 165 }; | 169 }; |
| 166 | 170 |
| 167 } // namespace blink | 171 } // namespace blink |
| 168 | 172 |
| 169 #endif | 173 #endif |
| OLD | NEW |