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. |
11 | 11 |
12 This library is distributed in the hope that it will be useful, | 12 This library is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 Library General Public License for more details. | 15 Library General Public License for more details. |
16 | 16 |
17 You should have received a copy of the GNU Library General Public License | 17 You should have received a copy of the GNU Library General Public License |
18 along with this library; see the file COPYING.LIB. If not, write to | 18 along with this library; see the file COPYING.LIB. If not, write to |
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 Boston, MA 02110-1301, USA. | 20 Boston, MA 02110-1301, USA. |
21 */ | 21 */ |
22 | 22 |
23 #ifndef ImageResource_h | 23 #ifndef ImageResource_h |
24 #define ImageResource_h | 24 #define ImageResource_h |
25 | 25 |
26 #include "core/CoreExport.h" | 26 #include "core/CoreExport.h" |
27 #include "core/fetch/MultipartImageResourceParser.h" | |
27 #include "core/fetch/Resource.h" | 28 #include "core/fetch/Resource.h" |
28 #include "platform/geometry/IntRect.h" | 29 #include "platform/geometry/IntRect.h" |
29 #include "platform/geometry/IntSizeHash.h" | 30 #include "platform/geometry/IntSizeHash.h" |
30 #include "platform/geometry/LayoutSize.h" | 31 #include "platform/geometry/LayoutSize.h" |
31 #include "platform/graphics/ImageObserver.h" | 32 #include "platform/graphics/ImageObserver.h" |
32 #include "platform/graphics/ImageOrientation.h" | 33 #include "platform/graphics/ImageOrientation.h" |
33 #include "wtf/HashMap.h" | 34 #include "wtf/HashMap.h" |
34 | 35 |
35 namespace blink { | 36 namespace blink { |
36 | 37 |
37 class ImageResourceClient; | 38 class ImageResourceClient; |
38 class FetchRequest; | 39 class FetchRequest; |
39 class ResourceFetcher; | 40 class ResourceFetcher; |
40 class FloatSize; | 41 class FloatSize; |
41 class Length; | 42 class Length; |
42 class MemoryCache; | 43 class MemoryCache; |
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, p ublic MultipartImageResourceParser::Client { |
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 = ImageResourceClient; |
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)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 void computeIntrinsicDimensions(FloatSize& intrinsicSize, FloatSize& intrins icRatio); | 90 void computeIntrinsicDimensions(FloatSize& intrinsicSize, FloatSize& intrins icRatio); |
90 | 91 |
91 bool isAccessAllowed(SecurityOrigin*); | 92 bool isAccessAllowed(SecurityOrigin*); |
92 | 93 |
93 void updateImageAnimationPolicy(); | 94 void updateImageAnimationPolicy(); |
94 | 95 |
95 // If this ImageResource has the Lo-Fi response headers, reload it with | 96 // If this ImageResource has the Lo-Fi response headers, reload it with |
96 // the Lo-Fi state set to off and bypassing the cache. | 97 // the Lo-Fi state set to off and bypassing the cache. |
97 void reloadIfLoFi(ResourceFetcher*); | 98 void reloadIfLoFi(ResourceFetcher*); |
98 | 99 |
100 bool isMultipartImage() const { return m_multipartParser; } | |
hiroshige
2016/02/26 19:03:35
nit optional: I think this corresponds to loadingM
yhirano
2016/02/27 02:03:20
The original name contained "loading" and the impl
| |
101 | |
99 void didAddClient(ResourceClient*) override; | 102 void didAddClient(ResourceClient*) override; |
100 void didRemoveClient(ResourceClient*) override; | 103 void didRemoveClient(ResourceClient*) override; |
101 | 104 |
102 void allClientsRemoved() override; | 105 void allClientsRemoved() override; |
103 | 106 |
107 void appendData(const char*, size_t) override; | |
104 void error(Resource::Status) override; | 108 void error(Resource::Status) override; |
105 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan dle>) override; | 109 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan dle>) override; |
106 void finishOnePart() override; | 110 void finish() override; |
107 | 111 |
108 // For compatibility, images keep loading even if there are HTTP errors. | 112 // For compatibility, images keep loading even if there are HTTP errors. |
109 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } | 113 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } |
110 | 114 |
111 bool isImage() const override { return true; } | 115 bool isImage() const override { return true; } |
112 bool stillNeedsLoad() const override { return !errorOccurred() && status() = = Unknown && !isLoading(); } | 116 bool stillNeedsLoad() const override { return !errorOccurred() && status() = = Unknown && !isLoading(); } |
113 | 117 |
114 // ImageObserver | 118 // ImageObserver |
115 void decodedSizeChanged(const blink::Image*, int delta) override; | 119 void decodedSizeChanged(const blink::Image*, int delta) override; |
116 void didDraw(const blink::Image*) override; | 120 void didDraw(const blink::Image*) override; |
117 | 121 |
118 bool shouldPauseAnimation(const blink::Image*) override; | 122 bool shouldPauseAnimation(const blink::Image*) override; |
119 void animationAdvanced(const blink::Image*) override; | 123 void animationAdvanced(const blink::Image*) override; |
120 void changedInRect(const blink::Image*, const IntRect&) override; | 124 void changedInRect(const blink::Image*, const IntRect&) override; |
121 | 125 |
126 // MultipartImageResourceParser::Client | |
127 void didReceiveResponse(const ResourceResponse&, bool isFirstPart) final; | |
128 void didReceiveData(const char*, size_t) final; | |
129 | |
122 DECLARE_VIRTUAL_TRACE(); | 130 DECLARE_VIRTUAL_TRACE(); |
123 | 131 |
124 protected: | 132 protected: |
125 bool isSafeToUnlock() const override; | 133 bool isSafeToUnlock() const override; |
126 void destroyDecodedDataIfPossible() override; | 134 void destroyDecodedDataIfPossible() override; |
127 void destroyDecodedDataForFailedRevalidation() override; | 135 void destroyDecodedDataForFailedRevalidation() override; |
128 | 136 |
129 private: | 137 private: |
130 explicit ImageResource(blink::Image*); | 138 explicit ImageResource(blink::Image*); |
131 ImageResource(const ResourceRequest&, blink::Image*); | 139 ImageResource(const ResourceRequest&, blink::Image*); |
132 | 140 |
133 class ImageResourceFactory : public ResourceFactory { | 141 class ImageResourceFactory : public ResourceFactory { |
134 public: | 142 public: |
135 ImageResourceFactory() | 143 ImageResourceFactory() |
136 : ResourceFactory(Resource::Image) { } | 144 : ResourceFactory(Resource::Image) { } |
137 | 145 |
138 PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest& request, const String&) const override | 146 PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest& request, const String&) const override |
139 { | 147 { |
140 return adoptRefWillBeNoop(new ImageResource(request)); | 148 return adoptRefWillBeNoop(new ImageResource(request)); |
141 } | 149 } |
142 }; | 150 }; |
143 ImageResource(const ResourceRequest&); | 151 ImageResource(const ResourceRequest&); |
144 | 152 |
145 void appendDataInternal(const char*, size_t) override; | |
146 void clear(); | 153 void clear(); |
147 | 154 |
148 void setCustomAcceptHeader(); | 155 void setCustomAcceptHeader(); |
149 void createImage(); | 156 void createImage(); |
150 void updateImage(bool allDataReceived); | 157 void updateImage(bool allDataReceived); |
151 void clearImage(); | 158 void clearImage(); |
152 // If not null, changeRect is the changed part of the image. | 159 // If not null, changeRect is the changed part of the image. |
153 void notifyObservers(const IntRect* changeRect = nullptr); | 160 void notifyObservers(const IntRect* changeRect = nullptr); |
154 bool loadingMultipartContent() const; | |
155 | 161 |
156 float m_devicePixelRatioHeaderValue; | 162 float m_devicePixelRatioHeaderValue; |
157 | 163 |
164 PersistentWillBeMember<MultipartImageResourceParser> m_multipartParser; | |
158 RefPtr<blink::Image> m_image; | 165 RefPtr<blink::Image> m_image; |
159 bool m_hasDevicePixelRatioHeaderValue; | 166 bool m_hasDevicePixelRatioHeaderValue; |
160 }; | 167 }; |
161 | 168 |
162 DEFINE_RESOURCE_TYPE_CASTS(Image); | 169 DEFINE_RESOURCE_TYPE_CASTS(Image); |
163 | 170 |
164 } // namespace blink | 171 } // namespace blink |
165 | 172 |
166 #endif | 173 #endif |
OLD | NEW |