| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org> | 3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org> |
| 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 5 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 6 | 6 |
| 7 This library is free software; you can redistribute it and/or | 7 This library is free software; you can redistribute it and/or |
| 8 modify it under the terms of the GNU Library General Public | 8 modify it under the terms of the GNU Library General Public |
| 9 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
| 10 version 2 of the License, or (at your option) any later version. | 10 version 2 of the License, or (at your option) any later version. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "core/fetch/Resource.h" | 28 #include "core/fetch/Resource.h" |
| 29 #include "platform/geometry/IntRect.h" | 29 #include "platform/geometry/IntRect.h" |
| 30 #include "platform/geometry/IntSizeHash.h" | 30 #include "platform/geometry/IntSizeHash.h" |
| 31 #include "platform/geometry/LayoutSize.h" | 31 #include "platform/geometry/LayoutSize.h" |
| 32 #include "platform/graphics/ImageObserver.h" | 32 #include "platform/graphics/ImageObserver.h" |
| 33 #include "platform/graphics/ImageOrientation.h" | 33 #include "platform/graphics/ImageOrientation.h" |
| 34 #include "wtf/HashMap.h" | 34 #include "wtf/HashMap.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 class ImageResourceClient; | |
| 39 class FetchRequest; | 38 class FetchRequest; |
| 40 class ResourceFetcher; | |
| 41 class FloatSize; | 39 class FloatSize; |
| 40 class ImageResourceObserver; |
| 42 class Length; | 41 class Length; |
| 43 class MemoryCache; | 42 class MemoryCache; |
| 43 class ResourceClient; |
| 44 class ResourceFetcher; |
| 44 class SecurityOrigin; | 45 class SecurityOrigin; |
| 45 | 46 |
| 46 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver, p
ublic MultipartImageResourceParser::Client { | 47 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver, p
ublic MultipartImageResourceParser::Client { |
| 47 friend class MemoryCache; | 48 friend class MemoryCache; |
| 48 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageResource); | 49 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageResource); |
| 49 public: | 50 public: |
| 50 using ClientType = ImageResourceClient; | 51 using ClientType = ResourceClient; |
| 51 | 52 |
| 52 static PassRefPtrWillBeRawPtr<ImageResource> fetch(FetchRequest&, ResourceFe
tcher*); | 53 static PassRefPtrWillBeRawPtr<ImageResource> fetch(FetchRequest&, ResourceFe
tcher*); |
| 53 | 54 |
| 54 static PassRefPtrWillBeRawPtr<ImageResource> create(blink::Image* image) | 55 static PassRefPtrWillBeRawPtr<ImageResource> create(blink::Image* image) |
| 55 { | 56 { |
| 56 return adoptRefWillBeNoop(new ImageResource(image)); | 57 return adoptRefWillBeNoop(new ImageResource(image)); |
| 57 } | 58 } |
| 58 | 59 |
| 59 // Exposed for testing | 60 // Exposed for testing |
| 60 static PassRefPtrWillBeRawPtr<ImageResource> create(const ResourceRequest& r
equest, blink::Image* image) | 61 static PassRefPtrWillBeRawPtr<ImageResource> create(const ResourceRequest& r
equest, blink::Image* image) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 bool isAccessAllowed(SecurityOrigin*); | 93 bool isAccessAllowed(SecurityOrigin*); |
| 93 | 94 |
| 94 void updateImageAnimationPolicy(); | 95 void updateImageAnimationPolicy(); |
| 95 | 96 |
| 96 // If this ImageResource has the Lo-Fi response headers, reload it with | 97 // If this ImageResource has the Lo-Fi response headers, reload it with |
| 97 // the Lo-Fi state set to off and bypassing the cache. | 98 // the Lo-Fi state set to off and bypassing the cache. |
| 98 void reloadIfLoFi(ResourceFetcher*); | 99 void reloadIfLoFi(ResourceFetcher*); |
| 99 | 100 |
| 100 bool isMultipartImage() const { return m_multipartParser; } | 101 bool isMultipartImage() const { return m_multipartParser; } |
| 101 | 102 |
| 102 void didAddClient(ResourceClient*) override; | 103 void addObserver(ImageResourceObserver*); |
| 103 void didRemoveClient(ResourceClient*) override; | 104 void removeObserver(ImageResourceObserver*); |
| 105 bool hasClientsOrObservers() const override { return Resource::hasClientsOrO
bservers() || !m_observers.isEmpty(); } |
| 104 | 106 |
| 105 void allClientsRemoved() override; | 107 ResourcePriority priorityFromObservers() override; |
| 108 |
| 109 void allClientsAndObserversRemoved() override; |
| 106 | 110 |
| 107 void appendData(const char*, size_t) override; | 111 void appendData(const char*, size_t) override; |
| 108 void error(Resource::Status) override; | 112 void error(Resource::Status) override; |
| 109 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan
dle>) override; | 113 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan
dle>) override; |
| 110 void finish() override; | 114 void finish() override; |
| 111 | 115 |
| 112 // For compatibility, images keep loading even if there are HTTP errors. | 116 // For compatibility, images keep loading even if there are HTTP errors. |
| 113 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } | 117 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } |
| 114 | 118 |
| 115 bool isImage() const override { return true; } | 119 bool isImage() const override { return true; } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 void updateImage(bool allDataReceived); | 161 void updateImage(bool allDataReceived); |
| 158 void clearImage(); | 162 void clearImage(); |
| 159 // If not null, changeRect is the changed part of the image. | 163 // If not null, changeRect is the changed part of the image. |
| 160 void notifyObservers(const IntRect* changeRect = nullptr); | 164 void notifyObservers(const IntRect* changeRect = nullptr); |
| 161 | 165 |
| 162 float m_devicePixelRatioHeaderValue; | 166 float m_devicePixelRatioHeaderValue; |
| 163 | 167 |
| 164 PersistentWillBeMember<MultipartImageResourceParser> m_multipartParser; | 168 PersistentWillBeMember<MultipartImageResourceParser> m_multipartParser; |
| 165 RefPtr<blink::Image> m_image; | 169 RefPtr<blink::Image> m_image; |
| 166 bool m_hasDevicePixelRatioHeaderValue; | 170 bool m_hasDevicePixelRatioHeaderValue; |
| 171 HashCountedSet<ImageResourceObserver*> m_observers; |
| 167 }; | 172 }; |
| 168 | 173 |
| 169 DEFINE_RESOURCE_TYPE_CASTS(Image); | 174 DEFINE_RESOURCE_TYPE_CASTS(Image); |
| 170 | 175 |
| 171 } // namespace blink | 176 } // namespace blink |
| 172 | 177 |
| 173 #endif | 178 #endif |
| OLD | NEW |