OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/loader/resource/ImageResourceContent.h" | 5 #include "core/loader/resource/ImageResourceContent.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "core/loader/resource/ImageResource.h" | 9 #include "core/loader/resource/ImageResource.h" |
10 #include "core/loader/resource/ImageResourceInfo.h" | 10 #include "core/loader/resource/ImageResourceInfo.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 public ImageResourceInfo { | 28 public ImageResourceInfo { |
29 USING_GARBAGE_COLLECTED_MIXIN(NullImageResourceInfo); | 29 USING_GARBAGE_COLLECTED_MIXIN(NullImageResourceInfo); |
30 | 30 |
31 public: | 31 public: |
32 NullImageResourceInfo() {} | 32 NullImageResourceInfo() {} |
33 | 33 |
34 DEFINE_INLINE_VIRTUAL_TRACE() { ImageResourceInfo::trace(visitor); } | 34 DEFINE_INLINE_VIRTUAL_TRACE() { ImageResourceInfo::trace(visitor); } |
35 | 35 |
36 private: | 36 private: |
37 const KURL& url() const override { return m_url; } | 37 const KURL& url() const override { return m_url; } |
38 bool isSchedulingReload() const override { return false; } | |
39 bool hasDevicePixelRatioHeaderValue() const override { return false; } | 38 bool hasDevicePixelRatioHeaderValue() const override { return false; } |
40 float devicePixelRatioHeaderValue() const override { return 1.0; } | 39 float devicePixelRatioHeaderValue() const override { return 1.0; } |
41 const ResourceResponse& response() const override { return m_response; } | 40 const ResourceResponse& response() const override { return m_response; } |
42 ResourceStatus getStatus() const override { return ResourceStatus::Cached; } | 41 ResourceStatus getStatus() const override { return ResourceStatus::Cached; } |
43 bool shouldShowPlaceholder() const override { return false; } | 42 bool shouldShowPlaceholder() const override { return false; } |
44 bool isCacheValidator() const override { return false; } | 43 bool isCacheValidator() const override { return false; } |
45 bool schedulingReloadOrShouldReloadBrokenPlaceholder() const override { | |
46 return false; | |
47 } | |
48 bool isAccessAllowed( | 44 bool isAccessAllowed( |
49 SecurityOrigin*, | 45 SecurityOrigin*, |
50 DoesCurrentFrameHaveSingleSecurityOrigin) const override { | 46 DoesCurrentFrameHaveSingleSecurityOrigin) const override { |
51 return true; | 47 return true; |
52 } | 48 } |
53 bool hasCacheControlNoStoreHeader() const override { return false; } | 49 bool hasCacheControlNoStoreHeader() const override { return false; } |
54 const ResourceError& resourceError() const override { return m_error; } | 50 const ResourceError& resourceError() const override { return m_error; } |
55 | 51 |
56 void setDecodedSize(size_t) override {} | 52 void setDecodedSize(size_t) override {} |
57 void willAddClientOrObserver() override {} | 53 void willAddClientOrObserver() override {} |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 104 |
109 m_observers.add(observer); | 105 m_observers.add(observer); |
110 | 106 |
111 if (m_info->isCacheValidator()) | 107 if (m_info->isCacheValidator()) |
112 return; | 108 return; |
113 | 109 |
114 if (m_image && !m_image->isNull()) { | 110 if (m_image && !m_image->isNull()) { |
115 observer->imageChanged(this); | 111 observer->imageChanged(this); |
116 } | 112 } |
117 | 113 |
118 if (isLoaded() && m_observers.contains(observer) && | 114 if (isLoaded() && m_observers.contains(observer)) { |
119 !m_info->schedulingReloadOrShouldReloadBrokenPlaceholder()) { | |
120 markObserverFinished(observer); | 115 markObserverFinished(observer); |
121 observer->imageNotifyFinished(this); | 116 observer->imageNotifyFinished(this); |
122 } | 117 } |
123 } | 118 } |
124 | 119 |
125 void ImageResourceContent::removeObserver(ImageResourceObserver* observer) { | 120 void ImageResourceContent::removeObserver(ImageResourceObserver* observer) { |
126 DCHECK(observer); | 121 DCHECK(observer); |
127 | 122 |
128 auto it = m_observers.find(observer); | 123 auto it = m_observers.find(observer); |
129 if (it != m_observers.end()) { | 124 if (it != m_observers.end()) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 NotifyFinishOption notifyingFinishOption, | 257 NotifyFinishOption notifyingFinishOption, |
263 const IntRect* changeRect) { | 258 const IntRect* changeRect) { |
264 for (auto* observer : m_finishedObservers.asVector()) { | 259 for (auto* observer : m_finishedObservers.asVector()) { |
265 if (m_finishedObservers.contains(observer)) | 260 if (m_finishedObservers.contains(observer)) |
266 observer->imageChanged(this, changeRect); | 261 observer->imageChanged(this, changeRect); |
267 } | 262 } |
268 for (auto* observer : m_observers.asVector()) { | 263 for (auto* observer : m_observers.asVector()) { |
269 if (m_observers.contains(observer)) { | 264 if (m_observers.contains(observer)) { |
270 observer->imageChanged(this, changeRect); | 265 observer->imageChanged(this, changeRect); |
271 if (notifyingFinishOption == ShouldNotifyFinish && | 266 if (notifyingFinishOption == ShouldNotifyFinish && |
272 m_observers.contains(observer) && | 267 m_observers.contains(observer)) { |
273 !m_info->schedulingReloadOrShouldReloadBrokenPlaceholder()) { | |
274 markObserverFinished(observer); | 268 markObserverFinished(observer); |
275 observer->imageNotifyFinished(this); | 269 observer->imageNotifyFinished(this); |
276 } | 270 } |
277 } | 271 } |
278 } | 272 } |
279 } | 273 } |
280 | 274 |
281 PassRefPtr<Image> ImageResourceContent::createImage() { | 275 PassRefPtr<Image> ImageResourceContent::createImage() { |
282 if (m_info->response().mimeType() == "image/svg+xml") | 276 if (m_info->response().mimeType() == "image/svg+xml") |
283 return SVGImage::create(this); | 277 return SVGImage::create(this); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 | 471 |
478 const ResourceResponse& ImageResourceContent::response() const { | 472 const ResourceResponse& ImageResourceContent::response() const { |
479 return m_info->response(); | 473 return m_info->response(); |
480 } | 474 } |
481 | 475 |
482 const ResourceError& ImageResourceContent::resourceError() const { | 476 const ResourceError& ImageResourceContent::resourceError() const { |
483 return m_info->resourceError(); | 477 return m_info->resourceError(); |
484 } | 478 } |
485 | 479 |
486 } // namespace blink | 480 } // namespace blink |
OLD | NEW |