| 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 23 matching lines...) Expand all Loading... |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class ImageResourceClient; | 36 class ImageResourceClient; |
| 37 class FetchRequest; | 37 class FetchRequest; |
| 38 class ResourceFetcher; | 38 class ResourceFetcher; |
| 39 class FloatSize; | 39 class FloatSize; |
| 40 class Length; | 40 class Length; |
| 41 class MemoryCache; | 41 class MemoryCache; |
| 42 class LayoutObject; | 42 class LayoutObject; |
| 43 class SecurityOrigin; | 43 class SecurityOrigin; |
| 44 class SVGImageForContainer; | |
| 45 | 44 |
| 46 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver { | 45 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver { |
| 47 friend class MemoryCache; | 46 friend class MemoryCache; |
| 48 | 47 |
| 49 public: | 48 public: |
| 50 typedef ImageResourceClient ClientType; | 49 typedef ImageResourceClient ClientType; |
| 51 | 50 |
| 52 static ResourcePtr<ImageResource> fetch(FetchRequest&, ResourceFetcher*); | 51 static ResourcePtr<ImageResource> fetch(FetchRequest&, ResourceFetcher*); |
| 53 | 52 |
| 54 ImageResource(blink::Image*); | 53 ImageResource(blink::Image*); |
| 55 // Exposed for testing | 54 // Exposed for testing |
| 56 ImageResource(const ResourceRequest&, blink::Image*); | 55 ImageResource(const ResourceRequest&, blink::Image*); |
| 57 ~ImageResource() override; | 56 ~ImageResource() override; |
| 58 | 57 |
| 59 void load(ResourceFetcher*, const ResourceLoaderOptions&) override; | 58 void load(ResourceFetcher*, const ResourceLoaderOptions&) override; |
| 60 | 59 |
| 61 blink::Image* image(); // Returns the nullImage() if the image is not availa
ble yet. | 60 blink::Image* image(); // Returns the nullImage() if the image is not availa
ble yet. |
| 62 blink::Image* imageForLayoutObject(const LayoutObject*); // Returns the null
Image() if the image is not available yet. | 61 blink::Image* imageForLayoutObject(const LayoutObject*); // Returns the null
Image() if the image is not available yet. |
| 63 bool hasImage() const { return m_image.get(); } | 62 bool hasImage() const { return m_image.get(); } |
| 64 // Side effect: ensures decoded image is in cache, therefore should only be
called when about to draw the image. | 63 // Side effect: ensures decoded image is in cache, therefore should only be
called when about to draw the image. |
| 65 // FIXME: Decoding image on the main thread is expensive, so rather than for
cing decode, consider returning false | 64 // FIXME: Decoding image on the main thread is expensive, so rather than for
cing decode, consider returning false |
| 66 // when image is not decoded yet, as we do in case of deferred decoding. | 65 // when image is not decoded yet, as we do in case of deferred decoding. |
| 67 bool currentFrameKnownToBeOpaque(const LayoutObject*); | 66 bool currentFrameKnownToBeOpaque(const LayoutObject*); |
| 68 | 67 |
| 69 static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor);
// Returns an image and the image's resolution scale factor. | 68 static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor);
// Returns an image and the image's resolution scale factor. |
| 70 bool willPaintBrokenImage() const; | 69 bool willPaintBrokenImage() const; |
| 71 | 70 |
| 72 bool canRender(const LayoutObject& layoutObject, float multiplier) { return
!errorOccurred() && !imageSizeForLayoutObject(&layoutObject, multiplier).isEmpty
(); } | 71 bool canRender(const LayoutObject& layoutObject, float multiplier) { return
!errorOccurred() && !imageSizeForLayoutObject(&layoutObject, multiplier).isEmpty
(); } |
| 73 | 72 |
| 74 void setContainerSizeForLayoutObject(const ImageResourceClient*, const IntSi
ze&, float); | |
| 75 bool usesImageContainerSize() const; | 73 bool usesImageContainerSize() const; |
| 76 bool imageHasRelativeWidth() const; | 74 bool imageHasRelativeWidth() const; |
| 77 bool imageHasRelativeHeight() const; | 75 bool imageHasRelativeHeight() const; |
| 78 // The device pixel ratio we got from the server for this image, or 1.0. | 76 // The device pixel ratio we got from the server for this image, or 1.0. |
| 79 float devicePixelRatioHeaderValue() const { return m_devicePixelRatioHeaderV
alue; } | 77 float devicePixelRatioHeaderValue() const { return m_devicePixelRatioHeaderV
alue; } |
| 80 bool hasDevicePixelRatioHeaderValue() const { return m_hasDevicePixelRatioHe
aderValue; } | 78 bool hasDevicePixelRatioHeaderValue() const { return m_hasDevicePixelRatioHe
aderValue; } |
| 81 | 79 |
| 82 enum SizeType { | 80 enum SizeType { |
| 83 NormalSize, // Report the size of the image associated with a certain la
youtObject | 81 NormalSize, // Report the size of the image associated with a certain la
youtObject |
| 84 IntrinsicSize, // Report the intrinsic size, i.e. ignore whatever has be
en set extrinsically. | 82 IntrinsicSize, // Report the intrinsic size, i.e. ignore whatever has be
en set extrinsically. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 ImageResource(const ResourceRequest&); | 132 ImageResource(const ResourceRequest&); |
| 135 | 133 |
| 136 void clear(); | 134 void clear(); |
| 137 | 135 |
| 138 void setCustomAcceptHeader(); | 136 void setCustomAcceptHeader(); |
| 139 void createImage(); | 137 void createImage(); |
| 140 void updateImage(bool allDataReceived); | 138 void updateImage(bool allDataReceived); |
| 141 void clearImage(); | 139 void clearImage(); |
| 142 // If not null, changeRect is the changed part of the image. | 140 // If not null, changeRect is the changed part of the image. |
| 143 void notifyObservers(const IntRect* changeRect = nullptr); | 141 void notifyObservers(const IntRect* changeRect = nullptr); |
| 144 IntSize svgImageSizeForLayoutObject(const LayoutObject*) const; | |
| 145 blink::Image* svgImageForLayoutObject(const LayoutObject*); | |
| 146 bool loadingMultipartContent() const; | 142 bool loadingMultipartContent() const; |
| 147 | 143 |
| 148 float m_devicePixelRatioHeaderValue; | 144 float m_devicePixelRatioHeaderValue; |
| 149 | 145 |
| 150 typedef HashMap<const ImageResourceClient*, RefPtr<SVGImageForContainer>> Im
ageForContainerMap; | |
| 151 OwnPtr<ImageForContainerMap> m_imageForContainerMap; | |
| 152 | |
| 153 RefPtr<blink::Image> m_image; | 146 RefPtr<blink::Image> m_image; |
| 154 bool m_hasDevicePixelRatioHeaderValue; | 147 bool m_hasDevicePixelRatioHeaderValue; |
| 155 }; | 148 }; |
| 156 | 149 |
| 157 DEFINE_RESOURCE_TYPE_CASTS(Image); | 150 DEFINE_RESOURCE_TYPE_CASTS(Image); |
| 158 | 151 |
| 159 } | 152 } |
| 160 | 153 |
| 161 #endif | 154 #endif |
| OLD | NEW |