| 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 16 matching lines...) Expand all Loading... |
| 27 #include "core/fetch/ResourcePtr.h" | 27 #include "core/fetch/ResourcePtr.h" |
| 28 #include "platform/geometry/IntRect.h" | 28 #include "platform/geometry/IntRect.h" |
| 29 #include "platform/geometry/IntSizeHash.h" | 29 #include "platform/geometry/IntSizeHash.h" |
| 30 #include "platform/geometry/LayoutSize.h" | 30 #include "platform/geometry/LayoutSize.h" |
| 31 #include "platform/graphics/ImageObserver.h" | 31 #include "platform/graphics/ImageObserver.h" |
| 32 #include "wtf/HashMap.h" | 32 #include "wtf/HashMap.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class ImageResourceClient; | 36 class ImageResourceClient; |
| 37 class FetchRequest; |
| 37 class ResourceFetcher; | 38 class ResourceFetcher; |
| 38 class FloatSize; | 39 class FloatSize; |
| 39 class Length; | 40 class Length; |
| 40 class MemoryCache; | 41 class MemoryCache; |
| 41 class LayoutObject; | 42 class LayoutObject; |
| 42 class SecurityOrigin; | 43 class SecurityOrigin; |
| 43 class SVGImageForContainer; | 44 class SVGImageForContainer; |
| 44 | 45 |
| 45 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver { | 46 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver { |
| 46 friend class MemoryCache; | 47 friend class MemoryCache; |
| 47 | 48 |
| 48 public: | 49 public: |
| 49 typedef ImageResourceClient ClientType; | 50 typedef ImageResourceClient ClientType; |
| 50 | 51 |
| 51 ImageResource(const ResourceRequest&); | 52 static ResourcePtr<ImageResource> fetch(FetchRequest&, ResourceFetcher*); |
| 53 |
| 52 ImageResource(blink::Image*); | 54 ImageResource(blink::Image*); |
| 53 // Exposed for testing | 55 // Exposed for testing |
| 54 ImageResource(const ResourceRequest&, blink::Image*); | 56 ImageResource(const ResourceRequest&, blink::Image*); |
| 55 virtual ~ImageResource(); | 57 virtual ~ImageResource(); |
| 56 | 58 |
| 57 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&) override; | 59 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&) override; |
| 58 | 60 |
| 59 blink::Image* image(); // Returns the nullImage() if the image is not availa
ble yet. | 61 blink::Image* image(); // Returns the nullImage() if the image is not availa
ble yet. |
| 60 blink::Image* imageForLayoutObject(const LayoutObject*); // Returns the null
Image() if the image is not available yet. | 62 blink::Image* imageForLayoutObject(const LayoutObject*); // Returns the null
Image() if the image is not available yet. |
| 61 bool hasImage() const { return m_image.get(); } | 63 bool hasImage() const { return m_image.get(); } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 113 |
| 112 virtual bool shouldPauseAnimation(const blink::Image*) override; | 114 virtual bool shouldPauseAnimation(const blink::Image*) override; |
| 113 virtual void animationAdvanced(const blink::Image*) override; | 115 virtual void animationAdvanced(const blink::Image*) override; |
| 114 virtual void changedInRect(const blink::Image*, const IntRect&) override; | 116 virtual void changedInRect(const blink::Image*, const IntRect&) override; |
| 115 | 117 |
| 116 protected: | 118 protected: |
| 117 virtual bool isSafeToUnlock() const override; | 119 virtual bool isSafeToUnlock() const override; |
| 118 virtual void destroyDecodedDataIfPossible() override; | 120 virtual void destroyDecodedDataIfPossible() override; |
| 119 | 121 |
| 120 private: | 122 private: |
| 123 static void preCacheDataURIImage(const FetchRequest&, ResourceFetcher*); |
| 124 |
| 125 class ImageResourceFactory : public ResourceFactory { |
| 126 public: |
| 127 ImageResourceFactory() |
| 128 : ResourceFactory(Resource::Image) { } |
| 129 |
| 130 Resource* create(const ResourceRequest& request, const String&) const ov
erride |
| 131 { |
| 132 return new ImageResource(request); |
| 133 } |
| 134 }; |
| 135 ImageResource(const ResourceRequest&); |
| 136 |
| 121 void clear(); | 137 void clear(); |
| 122 | 138 |
| 123 void setCustomAcceptHeader(); | 139 void setCustomAcceptHeader(); |
| 124 void createImage(); | 140 void createImage(); |
| 125 void updateImage(bool allDataReceived); | 141 void updateImage(bool allDataReceived); |
| 126 void clearImage(); | 142 void clearImage(); |
| 127 // If not null, changeRect is the changed part of the image. | 143 // If not null, changeRect is the changed part of the image. |
| 128 void notifyObservers(const IntRect* changeRect = nullptr); | 144 void notifyObservers(const IntRect* changeRect = nullptr); |
| 129 IntSize svgImageSizeForLayoutObject(const LayoutObject*) const; | 145 IntSize svgImageSizeForLayoutObject(const LayoutObject*) const; |
| 130 blink::Image* svgImageForLayoutObject(const LayoutObject*); | 146 blink::Image* svgImageForLayoutObject(const LayoutObject*); |
| 131 bool loadingMultipartContent() const; | 147 bool loadingMultipartContent() const; |
| 132 | 148 |
| 133 float m_devicePixelRatioHeaderValue; | 149 float m_devicePixelRatioHeaderValue; |
| 134 | 150 |
| 135 typedef HashMap<const ImageResourceClient*, RefPtr<SVGImageForContainer>> Im
ageForContainerMap; | 151 typedef HashMap<const ImageResourceClient*, RefPtr<SVGImageForContainer>> Im
ageForContainerMap; |
| 136 OwnPtr<ImageForContainerMap> m_imageForContainerMap; | 152 OwnPtr<ImageForContainerMap> m_imageForContainerMap; |
| 137 | 153 |
| 138 RefPtr<blink::Image> m_image; | 154 RefPtr<blink::Image> m_image; |
| 139 bool m_hasDevicePixelRatioHeaderValue; | 155 bool m_hasDevicePixelRatioHeaderValue; |
| 140 }; | 156 }; |
| 141 | 157 |
| 142 DEFINE_RESOURCE_TYPE_CASTS(Image); | 158 DEFINE_RESOURCE_TYPE_CASTS(Image); |
| 143 | 159 |
| 144 } | 160 } |
| 145 | 161 |
| 146 #endif | 162 #endif |
| OLD | NEW |