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 25 matching lines...) Expand all Loading... |
86 LayoutSize imageSize(RespectImageOrientationEnum shouldRespectImageOrientati
on, float multiplier, SizeType = IntrinsicSize); | 87 LayoutSize imageSize(RespectImageOrientationEnum shouldRespectImageOrientati
on, float multiplier, SizeType = IntrinsicSize); |
87 | 88 |
88 bool isAccessAllowed(SecurityOrigin*); | 89 bool isAccessAllowed(SecurityOrigin*); |
89 | 90 |
90 void updateImageAnimationPolicy(); | 91 void updateImageAnimationPolicy(); |
91 | 92 |
92 // If this ImageResource has the Lo-Fi response headers, reload it with | 93 // If this ImageResource has the Lo-Fi response headers, reload it with |
93 // the Lo-Fi state set to off and bypassing the cache. | 94 // the Lo-Fi state set to off and bypassing the cache. |
94 void reloadIfLoFi(ResourceFetcher*); | 95 void reloadIfLoFi(ResourceFetcher*); |
95 | 96 |
96 void didAddClient(ResourceClient*) override; | 97 void addObserver(ImageResourceObserver*); |
97 void didRemoveClient(ResourceClient*) override; | 98 void removeObserver(ImageResourceObserver*); |
| 99 bool hasClientsOrObservers() const override { return Resource::hasClientsOrO
bservers() || !m_observers.isEmpty(); } |
98 | 100 |
99 void allClientsRemoved() override; | 101 ResourcePriority priorityFromObservers() override; |
| 102 |
| 103 void allClientsAndObserversRemoved() override; |
100 | 104 |
101 void appendData(const char*, size_t) override; | 105 void appendData(const char*, size_t) override; |
102 void error(Resource::Status) override; | 106 void error(Resource::Status) override; |
103 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan
dle>) override; | 107 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan
dle>) override; |
104 void finish() override; | 108 void finish() override; |
105 | 109 |
106 // For compatibility, images keep loading even if there are HTTP errors. | 110 // For compatibility, images keep loading even if there are HTTP errors. |
107 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } | 111 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } |
108 | 112 |
109 bool isImage() const override { return true; } | 113 bool isImage() const override { return true; } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 void updateImage(bool allDataReceived); | 155 void updateImage(bool allDataReceived); |
152 void clearImage(); | 156 void clearImage(); |
153 // If not null, changeRect is the changed part of the image. | 157 // If not null, changeRect is the changed part of the image. |
154 void notifyObservers(const IntRect* changeRect = nullptr); | 158 void notifyObservers(const IntRect* changeRect = nullptr); |
155 | 159 |
156 float m_devicePixelRatioHeaderValue; | 160 float m_devicePixelRatioHeaderValue; |
157 | 161 |
158 PersistentWillBeMember<MultipartImageResourceParser> m_multipartParser; | 162 PersistentWillBeMember<MultipartImageResourceParser> m_multipartParser; |
159 RefPtr<blink::Image> m_image; | 163 RefPtr<blink::Image> m_image; |
160 bool m_hasDevicePixelRatioHeaderValue; | 164 bool m_hasDevicePixelRatioHeaderValue; |
| 165 HashCountedSet<ImageResourceObserver*> m_observers; |
161 }; | 166 }; |
162 | 167 |
163 DEFINE_RESOURCE_TYPE_CASTS(Image); | 168 DEFINE_RESOURCE_TYPE_CASTS(Image); |
164 | 169 |
165 } // namespace blink | 170 } // namespace blink |
166 | 171 |
167 #endif | 172 #endif |
OLD | NEW |