Chromium Code Reviews| 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; } | |
|
Nate Chapin
2016/03/01 19:02:15
This is only used for ASSERTs in ImageResource. Ma
yhirano
2016/03/01 19:43:23
Done.
| |
| 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 |
| 104 void appendData(const char*, size_t) override; | 107 void appendData(const char*, size_t) override; |
| 105 void error(Resource::Status) override; | 108 void error(Resource::Status) override; |
| 106 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan dle>) override; | 109 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan dle>) override; |
| 107 void finishOnePart() override; | 110 void finish() override; |
| 108 | 111 |
| 109 // For compatibility, images keep loading even if there are HTTP errors. | 112 // For compatibility, images keep loading even if there are HTTP errors. |
| 110 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } | 113 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } |
| 111 | 114 |
| 112 bool isImage() const override { return true; } | 115 bool isImage() const override { return true; } |
| 113 bool stillNeedsLoad() const override { return !errorOccurred() && getStatus( ) == Unknown && !isLoading(); } | 116 bool stillNeedsLoad() const override { return !errorOccurred() && getStatus( ) == Unknown && !isLoading(); } |
| 114 | 117 |
| 115 // ImageObserver | 118 // ImageObserver |
| 116 void decodedSizeChanged(const blink::Image*, int delta) override; | 119 void decodedSizeChanged(const blink::Image*, int delta) override; |
| 117 void didDraw(const blink::Image*) override; | 120 void didDraw(const blink::Image*) override; |
| 118 | 121 |
| 119 bool shouldPauseAnimation(const blink::Image*) override; | 122 bool shouldPauseAnimation(const blink::Image*) override; |
| 120 void animationAdvanced(const blink::Image*) override; | 123 void animationAdvanced(const blink::Image*) override; |
| 121 void changedInRect(const blink::Image*, const IntRect&) override; | 124 void changedInRect(const blink::Image*, const IntRect&) override; |
| 122 | 125 |
| 126 // MultipartImageResourceParser::Client | |
| 127 void onePartInMultipartReceived(const ResourceResponse&, bool isFirstPart) f inal; | |
| 128 void multipartDataReceived(const char*, size_t) final; | |
| 129 | |
| 123 DECLARE_VIRTUAL_TRACE(); | 130 DECLARE_VIRTUAL_TRACE(); |
| 124 | 131 |
| 125 protected: | 132 protected: |
| 126 bool isSafeToUnlock() const override; | 133 bool isSafeToUnlock() const override; |
| 127 void destroyDecodedDataIfPossible() override; | 134 void destroyDecodedDataIfPossible() override; |
| 128 void destroyDecodedDataForFailedRevalidation() override; | 135 void destroyDecodedDataForFailedRevalidation() override; |
| 129 | 136 |
| 130 private: | 137 private: |
| 131 explicit ImageResource(blink::Image*); | 138 explicit ImageResource(blink::Image*); |
| 132 ImageResource(const ResourceRequest&, blink::Image*); | 139 ImageResource(const ResourceRequest&, blink::Image*); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 144 ImageResource(const ResourceRequest&); | 151 ImageResource(const ResourceRequest&); |
| 145 | 152 |
| 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 |