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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 void reloadIfLoFi(ResourceFetcher*); | 94 void reloadIfLoFi(ResourceFetcher*); |
94 | 95 |
95 void didAddClient(ResourceClient*) override; | 96 void didAddClient(ResourceClient*) override; |
96 void didRemoveClient(ResourceClient*) override; | 97 void didRemoveClient(ResourceClient*) override; |
97 | 98 |
98 void allClientsRemoved() override; | 99 void allClientsRemoved() override; |
99 | 100 |
100 void appendData(const char*, size_t) override; | 101 void appendData(const char*, size_t) override; |
101 void error(Resource::Status) override; | 102 void error(Resource::Status) override; |
102 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan
dle>) override; | 103 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan
dle>) override; |
103 void finishOnePart() override; | 104 void finish() override; |
104 | 105 |
105 // For compatibility, images keep loading even if there are HTTP errors. | 106 // For compatibility, images keep loading even if there are HTTP errors. |
106 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } | 107 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } |
107 | 108 |
108 bool isImage() const override { return true; } | 109 bool isImage() const override { return true; } |
109 bool stillNeedsLoad() const override { return !errorOccurred() && getStatus(
) == Unknown && !isLoading(); } | 110 bool stillNeedsLoad() const override { return !errorOccurred() && getStatus(
) == Unknown && !isLoading(); } |
110 | 111 |
111 // ImageObserver | 112 // ImageObserver |
112 void decodedSizeChanged(const blink::Image*, int delta) override; | 113 void decodedSizeChanged(const blink::Image*, int delta) override; |
113 void didDraw(const blink::Image*) override; | 114 void didDraw(const blink::Image*) override; |
114 | 115 |
115 bool shouldPauseAnimation(const blink::Image*) override; | 116 bool shouldPauseAnimation(const blink::Image*) override; |
116 void animationAdvanced(const blink::Image*) override; | 117 void animationAdvanced(const blink::Image*) override; |
117 void changedInRect(const blink::Image*, const IntRect&) override; | 118 void changedInRect(const blink::Image*, const IntRect&) override; |
118 | 119 |
| 120 // MultipartImageResourceParser::Client |
| 121 void onePartInMultipartReceived(const ResourceResponse&, bool isFirstPart) f
inal; |
| 122 void multipartDataReceived(const char*, size_t) final; |
| 123 |
119 DECLARE_VIRTUAL_TRACE(); | 124 DECLARE_VIRTUAL_TRACE(); |
120 | 125 |
121 protected: | 126 protected: |
122 bool isSafeToUnlock() const override; | 127 bool isSafeToUnlock() const override; |
123 void destroyDecodedDataIfPossible() override; | 128 void destroyDecodedDataIfPossible() override; |
124 void destroyDecodedDataForFailedRevalidation() override; | 129 void destroyDecodedDataForFailedRevalidation() override; |
125 | 130 |
126 private: | 131 private: |
127 explicit ImageResource(blink::Image*); | 132 explicit ImageResource(blink::Image*); |
128 ImageResource(const ResourceRequest&, blink::Image*); | 133 ImageResource(const ResourceRequest&, blink::Image*); |
(...skipping 11 matching lines...) Expand all Loading... |
140 ImageResource(const ResourceRequest&); | 145 ImageResource(const ResourceRequest&); |
141 | 146 |
142 void clear(); | 147 void clear(); |
143 | 148 |
144 void setCustomAcceptHeader(); | 149 void setCustomAcceptHeader(); |
145 void createImage(); | 150 void createImage(); |
146 void updateImage(bool allDataReceived); | 151 void updateImage(bool allDataReceived); |
147 void clearImage(); | 152 void clearImage(); |
148 // If not null, changeRect is the changed part of the image. | 153 // If not null, changeRect is the changed part of the image. |
149 void notifyObservers(const IntRect* changeRect = nullptr); | 154 void notifyObservers(const IntRect* changeRect = nullptr); |
150 bool loadingMultipartContent() const; | |
151 | 155 |
152 float m_devicePixelRatioHeaderValue; | 156 float m_devicePixelRatioHeaderValue; |
153 | 157 |
| 158 PersistentWillBeMember<MultipartImageResourceParser> m_multipartParser; |
154 RefPtr<blink::Image> m_image; | 159 RefPtr<blink::Image> m_image; |
155 bool m_hasDevicePixelRatioHeaderValue; | 160 bool m_hasDevicePixelRatioHeaderValue; |
156 }; | 161 }; |
157 | 162 |
158 DEFINE_RESOURCE_TYPE_CASTS(Image); | 163 DEFINE_RESOURCE_TYPE_CASTS(Image); |
159 | 164 |
160 } // namespace blink | 165 } // namespace blink |
161 | 166 |
162 #endif | 167 #endif |
OLD | NEW |