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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 | 88 |
| 89 // For compatibility, images keep loading even if there are HTTP errors. | 89 // For compatibility, images keep loading even if there are HTTP errors. |
| 90 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } | 90 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } |
| 91 | 91 |
| 92 bool isImage() const override { return true; } | 92 bool isImage() const override { return true; } |
| 93 | 93 |
| 94 // MultipartImageResourceParser::Client | 94 // MultipartImageResourceParser::Client |
| 95 void onePartInMultipartReceived(const ResourceResponse&) final; | 95 void onePartInMultipartReceived(const ResourceResponse&) final; |
| 96 void multipartDataReceived(const char*, size_t) final; | 96 void multipartDataReceived(const char*, size_t) final; |
| 97 | 97 |
| 98 // Used by tests. | 98 bool shouldShowPlaceholder() const; |
| 99 bool isPlaceholder() const { return m_isPlaceholder; } | |
| 100 | 99 |
| 101 DECLARE_VIRTUAL_TRACE(); | 100 DECLARE_VIRTUAL_TRACE(); |
| 102 | 101 |
| 103 private: | 102 private: |
| 104 enum class MultipartParsingState : uint8_t { | 103 enum class MultipartParsingState : uint8_t { |
| 105 WaitingForFirstPart, | 104 WaitingForFirstPart, |
| 106 ParsingFirstPart, | 105 ParsingFirstPart, |
| 107 FinishedParsingFirstPart, | 106 FinishedParsingFirstPart, |
| 108 }; | 107 }; |
| 109 | 108 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 128 ImageResourceContent::UpdateImageOption, | 127 ImageResourceContent::UpdateImageOption, |
| 129 bool allDataReceived); | 128 bool allDataReceived); |
| 130 | 129 |
| 131 void checkNotify() override; | 130 void checkNotify() override; |
| 132 | 131 |
| 133 void destroyDecodedDataIfPossible() override; | 132 void destroyDecodedDataIfPossible() override; |
| 134 void destroyDecodedDataForFailedRevalidation() override; | 133 void destroyDecodedDataForFailedRevalidation() override; |
| 135 | 134 |
| 136 void flushImageIfNeeded(TimerBase*); | 135 void flushImageIfNeeded(TimerBase*); |
| 137 | 136 |
| 138 bool shouldReloadBrokenPlaceholder() const { | 137 bool shouldReloadBrokenPlaceholder() const; |
| 139 return m_isPlaceholder && willPaintBrokenImage(); | |
| 140 } | |
| 141 | |
| 142 bool willPaintBrokenImage() const; | |
| 143 | 138 |
| 144 Member<ImageResourceContent> m_content; | 139 Member<ImageResourceContent> m_content; |
| 145 | 140 |
| 146 // TODO(hiroshige): move |m_devicePixelRatioHeaderValue| and | 141 // TODO(hiroshige): move |m_devicePixelRatioHeaderValue| and |
| 147 // |m_hasDevicePixelRatioHeaderValue| to ImageResourceContent and update | 142 // |m_hasDevicePixelRatioHeaderValue| to ImageResourceContent and update |
| 148 // it via ImageResourceContent::updateImage(). | 143 // it via ImageResourceContent::updateImage(). |
| 149 float m_devicePixelRatioHeaderValue; | 144 float m_devicePixelRatioHeaderValue; |
| 150 | 145 |
| 151 Member<MultipartImageResourceParser> m_multipartParser; | 146 Member<MultipartImageResourceParser> m_multipartParser; |
| 152 MultipartParsingState m_multipartParsingState = | 147 MultipartParsingState m_multipartParsingState = |
| 153 MultipartParsingState::WaitingForFirstPart; | 148 MultipartParsingState::WaitingForFirstPart; |
| 154 bool m_hasDevicePixelRatioHeaderValue; | 149 bool m_hasDevicePixelRatioHeaderValue; |
| 155 | 150 |
| 156 // Indicates if the ImageResource is currently scheduling a reload, e.g. | 151 // Indicates if the ImageResource is currently scheduling a reload, e.g. |
| 157 // because reloadIfLoFi() was called. | 152 // because reloadIfLoFi() was called. |
| 158 bool m_isSchedulingReload; | 153 bool m_isSchedulingReload; |
| 159 | 154 |
| 160 // Indicates if this ImageResource is either attempting to load a placeholder | 155 // Indicates if this ImageResource is either attempting to load a placeholder |
| 161 // image, or is a (possibly broken) placeholder image. | 156 // image, or is a (possibly broken) placeholder image. |
| 162 bool m_isPlaceholder; | 157 enum PlaceholderOption { |
|
yhirano
2017/02/13 11:36:57
enum class?
hiroshige
2017/02/23 20:52:38
Done.
| |
| 158 // Do not show or reload placeholder. | |
| 159 DoNotReloadPlaceholder, | |
| 160 | |
| 161 // Do not show placeholder, reload only when decode error occurs. | |
| 162 ReloadPlaceholderOnDecodeError, | |
| 163 | |
| 164 // Show placeholder and reload. | |
| 165 ShowAndReloadPlaceholderAlways, | |
| 166 }; | |
| 167 PlaceholderOption m_placeholderOption; | |
| 163 | 168 |
| 164 Timer<ImageResource> m_flushTimer; | 169 Timer<ImageResource> m_flushTimer; |
| 165 double m_lastFlushTime = 0.; | 170 double m_lastFlushTime = 0.; |
| 166 }; | 171 }; |
| 167 | 172 |
| 168 DEFINE_RESOURCE_TYPE_CASTS(Image); | 173 DEFINE_RESOURCE_TYPE_CASTS(Image); |
| 169 | 174 |
| 170 } // namespace blink | 175 } // namespace blink |
| 171 | 176 |
| 172 #endif | 177 #endif |
| OLD | NEW |