| 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 16 matching lines...) Expand all Loading... |
| 27 #include "core/fetch/Resource.h" | 27 #include "core/fetch/Resource.h" |
| 28 #include "platform/geometry/IntRect.h" | 28 #include "platform/geometry/IntRect.h" |
| 29 #include "platform/geometry/IntSizeHash.h" | 29 #include "platform/geometry/IntSizeHash.h" |
| 30 #include "platform/geometry/LayoutSize.h" | 30 #include "platform/geometry/LayoutSize.h" |
| 31 #include "platform/graphics/ImageObserver.h" | 31 #include "platform/graphics/ImageObserver.h" |
| 32 #include "platform/graphics/ImageOrientation.h" | 32 #include "platform/graphics/ImageOrientation.h" |
| 33 #include "wtf/HashMap.h" | 33 #include "wtf/HashMap.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 class ImageResourceClient; | |
| 38 class FetchRequest; | 37 class FetchRequest; |
| 39 class ResourceFetcher; | |
| 40 class FloatSize; | 38 class FloatSize; |
| 39 class ImageResourceObserver; |
| 41 class Length; | 40 class Length; |
| 42 class MemoryCache; | 41 class MemoryCache; |
| 42 class ResourceClient; |
| 43 class ResourceFetcher; |
| 43 class SecurityOrigin; | 44 class SecurityOrigin; |
| 44 | 45 |
| 45 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver { | 46 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver { |
| 46 friend class MemoryCache; | 47 friend class MemoryCache; |
| 47 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageResource); | 48 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageResource); |
| 48 public: | 49 public: |
| 49 using ClientType = ImageResourceClient; | 50 using ClientType = ResourceClient; |
| 50 | 51 |
| 51 static PassRefPtrWillBeRawPtr<ImageResource> fetch(FetchRequest&, ResourceFe
tcher*); | 52 static PassRefPtrWillBeRawPtr<ImageResource> fetch(FetchRequest&, ResourceFe
tcher*); |
| 52 | 53 |
| 53 static PassRefPtrWillBeRawPtr<ImageResource> create(blink::Image* image) | 54 static PassRefPtrWillBeRawPtr<ImageResource> create(blink::Image* image) |
| 54 { | 55 { |
| 55 return adoptRefWillBeNoop(new ImageResource(image)); | 56 return adoptRefWillBeNoop(new ImageResource(image)); |
| 56 } | 57 } |
| 57 | 58 |
| 58 // Exposed for testing | 59 // Exposed for testing |
| 59 static PassRefPtrWillBeRawPtr<ImageResource> create(const ResourceRequest& r
equest, blink::Image* image) | 60 static PassRefPtrWillBeRawPtr<ImageResource> create(const ResourceRequest& r
equest, blink::Image* image) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 90 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei
ght, FloatSize& intrinsicRatio); | 91 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei
ght, FloatSize& intrinsicRatio); |
| 91 | 92 |
| 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 void didAddClient(ResourceClient*) override; | 101 void addObserver(ImageResourceObserver*); |
| 101 void didRemoveClient(ResourceClient*) override; | 102 void removeObserver(ImageResourceObserver*); |
| 103 |
| 104 ResourcePriority priorityFromClients() override; |
| 102 | 105 |
| 103 void allClientsRemoved() override; | 106 void allClientsRemoved() override; |
| 104 | 107 |
| 105 void appendData(const char*, size_t) override; | 108 void appendData(const char*, size_t) override; |
| 106 void error(Resource::Status) override; | 109 void error(Resource::Status) override; |
| 107 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan
dle>) override; | 110 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan
dle>) override; |
| 108 void finishOnePart() override; | 111 void finishOnePart() override; |
| 109 | 112 |
| 110 // For compatibility, images keep loading even if there are HTTP errors. | 113 // For compatibility, images keep loading even if there are HTTP errors. |
| 111 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } | 114 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 void updateImage(bool allDataReceived); | 154 void updateImage(bool allDataReceived); |
| 152 void clearImage(); | 155 void clearImage(); |
| 153 // If not null, changeRect is the changed part of the image. | 156 // If not null, changeRect is the changed part of the image. |
| 154 void notifyObservers(const IntRect* changeRect = nullptr); | 157 void notifyObservers(const IntRect* changeRect = nullptr); |
| 155 bool loadingMultipartContent() const; | 158 bool loadingMultipartContent() const; |
| 156 | 159 |
| 157 float m_devicePixelRatioHeaderValue; | 160 float m_devicePixelRatioHeaderValue; |
| 158 | 161 |
| 159 RefPtr<blink::Image> m_image; | 162 RefPtr<blink::Image> m_image; |
| 160 bool m_hasDevicePixelRatioHeaderValue; | 163 bool m_hasDevicePixelRatioHeaderValue; |
| 164 HashCountedSet<ImageResourceObserver*> m_observers; |
| 161 }; | 165 }; |
| 162 | 166 |
| 163 DEFINE_RESOURCE_TYPE_CASTS(Image); | 167 DEFINE_RESOURCE_TYPE_CASTS(Image); |
| 164 | 168 |
| 165 } // namespace blink | 169 } // namespace blink |
| 166 | 170 |
| 167 #endif | 171 #endif |
| OLD | NEW |