| 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 27 matching lines...) Expand all Loading... |
| 38 class FetchRequest; | 38 class FetchRequest; |
| 39 class FloatSize; | 39 class FloatSize; |
| 40 class ImageResourceObserver; | 40 class ImageResourceObserver; |
| 41 class MemoryCache; | 41 class MemoryCache; |
| 42 class ResourceClient; | 42 class ResourceClient; |
| 43 class ResourceFetcher; | 43 class ResourceFetcher; |
| 44 class SecurityOrigin; | 44 class SecurityOrigin; |
| 45 | 45 |
| 46 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver, p
ublic MultipartImageResourceParser::Client { | 46 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver, p
ublic MultipartImageResourceParser::Client { |
| 47 friend class MemoryCache; | 47 friend class MemoryCache; |
| 48 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageResource); | 48 USING_GARBAGE_COLLECTED_MIXIN(ImageResource); |
| 49 public: | 49 public: |
| 50 using ClientType = ResourceClient; | 50 using ClientType = ResourceClient; |
| 51 | 51 |
| 52 static PassRefPtrWillBeRawPtr<ImageResource> fetch(FetchRequest&, ResourceFe
tcher*); | 52 static RawPtr<ImageResource> fetch(FetchRequest&, ResourceFetcher*); |
| 53 | 53 |
| 54 static PassRefPtrWillBeRawPtr<ImageResource> create(blink::Image* image) | 54 static RawPtr<ImageResource> create(blink::Image* image) |
| 55 { | 55 { |
| 56 return adoptRefWillBeNoop(new ImageResource(image, ResourceLoaderOptions
())); | 56 return new ImageResource(image, ResourceLoaderOptions()); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Exposed for testing | 59 // Exposed for testing |
| 60 static PassRefPtrWillBeRawPtr<ImageResource> create(const ResourceRequest& r
equest, blink::Image* image) | 60 static RawPtr<ImageResource> create(const ResourceRequest& request, blink::I
mage* image) |
| 61 { | 61 { |
| 62 return adoptRefWillBeNoop(new ImageResource(request, image, ResourceLoad
erOptions())); | 62 return new ImageResource(request, image, ResourceLoaderOptions()); |
| 63 } | 63 } |
| 64 | 64 |
| 65 ~ImageResource() override; | 65 ~ImageResource() override; |
| 66 | 66 |
| 67 blink::Image* getImage(); // Returns the nullImage() if the image is not ava
ilable yet. | 67 blink::Image* getImage(); // Returns the nullImage() if the image is not ava
ilable yet. |
| 68 bool hasImage() const { return m_image.get(); } | 68 bool hasImage() const { return m_image.get(); } |
| 69 | 69 |
| 70 static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor);
// Returns an image and the image's resolution scale factor. | 70 static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor);
// Returns an image and the image's resolution scale factor. |
| 71 bool willPaintBrokenImage() const; | 71 bool willPaintBrokenImage() const; |
| 72 | 72 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 WaitingForFirstPart, | 136 WaitingForFirstPart, |
| 137 ParsingFirstPart, | 137 ParsingFirstPart, |
| 138 FinishedParsingFirstPart, | 138 FinishedParsingFirstPart, |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 class ImageResourceFactory : public ResourceFactory { | 141 class ImageResourceFactory : public ResourceFactory { |
| 142 public: | 142 public: |
| 143 ImageResourceFactory() | 143 ImageResourceFactory() |
| 144 : ResourceFactory(Resource::Image) { } | 144 : ResourceFactory(Resource::Image) { } |
| 145 | 145 |
| 146 PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest& request,
const ResourceLoaderOptions& options, const String&) const override | 146 RawPtr<Resource> create(const ResourceRequest& request, const ResourceLo
aderOptions& options, const String&) const override |
| 147 { | 147 { |
| 148 return adoptRefWillBeNoop(new ImageResource(request, options)); | 148 return new ImageResource(request, options); |
| 149 } | 149 } |
| 150 }; | 150 }; |
| 151 ImageResource(const ResourceRequest&, const ResourceLoaderOptions&); | 151 ImageResource(const ResourceRequest&, const ResourceLoaderOptions&); |
| 152 | 152 |
| 153 void clear(); | 153 void clear(); |
| 154 | 154 |
| 155 void setCustomAcceptHeader(); | 155 void setCustomAcceptHeader(); |
| 156 void createImage(); | 156 void createImage(); |
| 157 void updateImage(bool allDataReceived); | 157 void updateImage(bool allDataReceived); |
| 158 void clearImage(); | 158 void clearImage(); |
| 159 // If not null, changeRect is the changed part of the image. | 159 // If not null, changeRect is the changed part of the image. |
| 160 void notifyObservers(bool isNotifyingFinish, const IntRect* changeRect = nul
lptr); | 160 void notifyObservers(bool isNotifyingFinish, const IntRect* changeRect = nul
lptr); |
| 161 void notifyObserver(ImageResourceObserver*, bool isNotifyingFinish, const In
tRect* changeRect = nullptr); | 161 void notifyObserver(ImageResourceObserver*, bool isNotifyingFinish, const In
tRect* changeRect = nullptr); |
| 162 | 162 |
| 163 float m_devicePixelRatioHeaderValue; | 163 float m_devicePixelRatioHeaderValue; |
| 164 | 164 |
| 165 PersistentWillBeMember<MultipartImageResourceParser> m_multipartParser; | 165 Member<MultipartImageResourceParser> m_multipartParser; |
| 166 RefPtr<blink::Image> m_image; | 166 RefPtr<blink::Image> m_image; |
| 167 MultipartParsingState m_multipartParsingState = MultipartParsingState::Waiti
ngForFirstPart; | 167 MultipartParsingState m_multipartParsingState = MultipartParsingState::Waiti
ngForFirstPart; |
| 168 bool m_hasDevicePixelRatioHeaderValue; | 168 bool m_hasDevicePixelRatioHeaderValue; |
| 169 HashCountedSet<ImageResourceObserver*> m_observers; | 169 HashCountedSet<ImageResourceObserver*> m_observers; |
| 170 HashCountedSet<ImageResourceObserver*> m_finishedObservers; | 170 HashCountedSet<ImageResourceObserver*> m_finishedObservers; |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 DEFINE_RESOURCE_TYPE_CASTS(Image); | 173 DEFINE_RESOURCE_TYPE_CASTS(Image); |
| 174 | 174 |
| 175 } // namespace blink | 175 } // namespace blink |
| 176 | 176 |
| 177 #endif | 177 #endif |
| OLD | NEW |