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. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 public: | 58 public: |
| 59 using ClientType = ResourceClient; | 59 using ClientType = ResourceClient; |
| 60 | 60 |
| 61 static ImageResource* fetch(FetchRequest&, ResourceFetcher*); | 61 static ImageResource* fetch(FetchRequest&, ResourceFetcher*); |
| 62 | 62 |
| 63 static ImageResource* create(blink::Image* image) { | 63 static ImageResource* create(blink::Image* image) { |
| 64 return new ImageResource(image, ResourceLoaderOptions()); | 64 return new ImageResource(image, ResourceLoaderOptions()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 static ImageResource* create(const ResourceRequest& request) { | 67 static ImageResource* create(const ResourceRequest& request) { |
| 68 return new ImageResource(request, ResourceLoaderOptions()); | 68 return new ImageResource(request, ResourceLoaderOptions(), false); |
| 69 } | 69 } |
| 70 | 70 |
| 71 ~ImageResource() override; | 71 ~ImageResource() override; |
| 72 | 72 |
| 73 blink::Image* | 73 blink::Image* |
| 74 getImage(); // Returns the nullImage() if the image is not available yet. | 74 getImage(); // Returns the nullImage() if the image is not available yet. |
| 75 bool hasImage() const { return m_image.get(); } | 75 bool hasImage() const { return m_image.get(); } |
| 76 | 76 |
| 77 static std::pair<blink::Image*, float> brokenImage( | 77 static std::pair<blink::Image*, float> brokenImage( |
| 78 float deviceScaleFactor); // Returns an image and the image's resolution | 78 float deviceScaleFactor); // Returns an image and the image's resolution |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 101 // natural size of the image by the zoom. | 101 // natural size of the image by the zoom. |
| 102 LayoutSize imageSize( | 102 LayoutSize imageSize( |
| 103 RespectImageOrientationEnum shouldRespectImageOrientation, | 103 RespectImageOrientationEnum shouldRespectImageOrientation, |
| 104 float multiplier, | 104 float multiplier, |
| 105 SizeType = IntrinsicSize); | 105 SizeType = IntrinsicSize); |
| 106 | 106 |
| 107 bool isAccessAllowed(SecurityOrigin*); | 107 bool isAccessAllowed(SecurityOrigin*); |
| 108 | 108 |
| 109 void updateImageAnimationPolicy(); | 109 void updateImageAnimationPolicy(); |
| 110 | 110 |
| 111 // If this ImageResource has the Lo-Fi response headers, reload it with the | 111 // If this ImageResource has the Lo-Fi response headers or is a placeholder, |
| 112 // Lo-Fi state set to off and bypassing the cache. | 112 // reload the full original image with the Lo-Fi state set to off and |
| 113 void reloadIfLoFi(ResourceFetcher*); | 113 // optionally bypassing the cache. |
| 114 void reloadIfLoFi(ResourceFetcher*, bool bypassCache = true); | |
|
Stephen Chennney
2016/10/17 18:09:17
Rename this to reloadIfLoFiOrPlaceholder.
sclittle
2016/10/18 00:54:11
Done.
| |
| 114 | 115 |
| 115 void didAddClient(ResourceClient*) override; | 116 void didAddClient(ResourceClient*) override; |
| 116 | 117 |
| 117 void addObserver(ImageResourceObserver*); | 118 void addObserver(ImageResourceObserver*); |
| 118 void removeObserver(ImageResourceObserver*); | 119 void removeObserver(ImageResourceObserver*); |
| 119 | 120 |
| 120 ResourcePriority priorityFromObservers() override; | 121 ResourcePriority priorityFromObservers() override; |
| 121 | 122 |
| 122 void allClientsAndObserversRemoved() override; | 123 void allClientsAndObserversRemoved() override; |
| 123 | 124 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 138 void didDraw(const blink::Image*) override; | 139 void didDraw(const blink::Image*) override; |
| 139 | 140 |
| 140 bool shouldPauseAnimation(const blink::Image*) override; | 141 bool shouldPauseAnimation(const blink::Image*) override; |
| 141 void animationAdvanced(const blink::Image*) override; | 142 void animationAdvanced(const blink::Image*) override; |
| 142 void changedInRect(const blink::Image*, const IntRect&) override; | 143 void changedInRect(const blink::Image*, const IntRect&) override; |
| 143 | 144 |
| 144 // MultipartImageResourceParser::Client | 145 // MultipartImageResourceParser::Client |
| 145 void onePartInMultipartReceived(const ResourceResponse&) final; | 146 void onePartInMultipartReceived(const ResourceResponse&) final; |
| 146 void multipartDataReceived(const char*, size_t) final; | 147 void multipartDataReceived(const char*, size_t) final; |
| 147 | 148 |
| 149 bool isPlaceholder() const { return m_isPlaceholder; } | |
| 150 bool shouldReloadBrokenPlaceholder() const { | |
| 151 return m_isPlaceholder && willPaintBrokenImage(); | |
| 152 } | |
| 153 | |
| 148 DECLARE_VIRTUAL_TRACE(); | 154 DECLARE_VIRTUAL_TRACE(); |
| 149 | 155 |
| 150 private: | 156 private: |
| 151 explicit ImageResource(blink::Image*, const ResourceLoaderOptions&); | 157 explicit ImageResource(blink::Image*, const ResourceLoaderOptions&); |
| 152 | 158 |
| 153 enum class MultipartParsingState : uint8_t { | 159 enum class MultipartParsingState : uint8_t { |
| 154 WaitingForFirstPart, | 160 WaitingForFirstPart, |
| 155 ParsingFirstPart, | 161 ParsingFirstPart, |
| 156 FinishedParsingFirstPart, | 162 FinishedParsingFirstPart, |
| 157 }; | 163 }; |
| 158 | 164 |
| 159 class ImageResourceFactory : public ResourceFactory { | 165 class ImageResourceFactory; |
| 160 public: | |
| 161 ImageResourceFactory() : ResourceFactory(Resource::Image) {} | |
| 162 | 166 |
| 163 Resource* create(const ResourceRequest& request, | 167 ImageResource(const ResourceRequest&, |
| 164 const ResourceLoaderOptions& options, | 168 const ResourceLoaderOptions&, |
| 165 const String&) const override { | 169 bool isPlaceholder); |
| 166 return new ImageResource(request, options); | |
| 167 } | |
| 168 }; | |
| 169 ImageResource(const ResourceRequest&, const ResourceLoaderOptions&); | |
| 170 | 170 |
| 171 bool hasClientsOrObservers() const override { | 171 bool hasClientsOrObservers() const override { |
| 172 return Resource::hasClientsOrObservers() || !m_observers.isEmpty() || | 172 return Resource::hasClientsOrObservers() || !m_observers.isEmpty() || |
| 173 !m_finishedObservers.isEmpty(); | 173 !m_finishedObservers.isEmpty(); |
| 174 } | 174 } |
| 175 void clear(); | 175 void clear(); |
| 176 | 176 |
| 177 void createImage(); | 177 void createImage(); |
| 178 void updateImage(bool allDataReceived); | 178 void updateImage(bool allDataReceived); |
| 179 void updateImageAndClearBuffer(); | 179 void updateImageAndClearBuffer(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 198 RefPtr<blink::Image> m_image; | 198 RefPtr<blink::Image> m_image; |
| 199 MultipartParsingState m_multipartParsingState = | 199 MultipartParsingState m_multipartParsingState = |
| 200 MultipartParsingState::WaitingForFirstPart; | 200 MultipartParsingState::WaitingForFirstPart; |
| 201 bool m_hasDevicePixelRatioHeaderValue; | 201 bool m_hasDevicePixelRatioHeaderValue; |
| 202 HashCountedSet<ImageResourceObserver*> m_observers; | 202 HashCountedSet<ImageResourceObserver*> m_observers; |
| 203 HashCountedSet<ImageResourceObserver*> m_finishedObservers; | 203 HashCountedSet<ImageResourceObserver*> m_finishedObservers; |
| 204 | 204 |
| 205 // Indicates if the ImageResource is currently scheduling a reload, e.g. | 205 // Indicates if the ImageResource is currently scheduling a reload, e.g. |
| 206 // because reloadIfLoFi() was called. | 206 // because reloadIfLoFi() was called. |
| 207 bool m_isSchedulingReload; | 207 bool m_isSchedulingReload; |
| 208 | |
| 209 // Indicates if this ImageResource is either attempting to load a placeholder | |
| 210 // image, or is a (possibly broken) placeholder image. | |
| 211 bool m_isPlaceholder; | |
| 208 }; | 212 }; |
| 209 | 213 |
| 210 DEFINE_RESOURCE_TYPE_CASTS(Image); | 214 DEFINE_RESOURCE_TYPE_CASTS(Image); |
| 211 | 215 |
| 212 } // namespace blink | 216 } // namespace blink |
| 213 | 217 |
| 214 #endif | 218 #endif |
| OLD | NEW |