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 20 matching lines...) Expand all Loading... |
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 ResourceFetcher; | 37 class ResourceFetcher; |
38 class FloatSize; | 38 class FloatSize; |
39 class Length; | 39 class Length; |
40 class MemoryCache; | 40 class MemoryCache; |
41 class RenderObject; | 41 class LayoutObject; |
42 class SecurityOrigin; | 42 class SecurityOrigin; |
43 | 43 |
44 class ImageResource final : public Resource, public ImageObserver { | 44 class ImageResource final : public Resource, public ImageObserver { |
45 friend class MemoryCache; | 45 friend class MemoryCache; |
46 | 46 |
47 public: | 47 public: |
48 typedef ImageResourceClient ClientType; | 48 typedef ImageResourceClient ClientType; |
49 | 49 |
50 ImageResource(const ResourceRequest&); | 50 ImageResource(const ResourceRequest&); |
51 ImageResource(blink::Image*); | 51 ImageResource(blink::Image*); |
52 // Exposed for testing | 52 // Exposed for testing |
53 ImageResource(const ResourceRequest&, blink::Image*); | 53 ImageResource(const ResourceRequest&, blink::Image*); |
54 virtual ~ImageResource(); | 54 virtual ~ImageResource(); |
55 | 55 |
56 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&) override; | 56 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&) override; |
57 | 57 |
58 blink::Image* image(); // Returns the nullImage() if the image is not availa
ble yet. | 58 blink::Image* image(); // Returns the nullImage() if the image is not availa
ble yet. |
59 blink::Image* imageForRenderer(const RenderObject*); // Returns the nullImag
e() if the image is not available yet. | 59 blink::Image* imageForRenderer(const LayoutObject*); // Returns the nullImag
e() if the image is not available yet. |
60 bool hasImage() const { return m_image.get(); } | 60 bool hasImage() const { return m_image.get(); } |
61 // Side effect: ensures decoded image is in cache, therefore should only be
called when about to draw the image. | 61 // Side effect: ensures decoded image is in cache, therefore should only be
called when about to draw the image. |
62 // FIXME: Decoding image on the main thread is expensive, so rather than for
cing decode, consider returning false | 62 // FIXME: Decoding image on the main thread is expensive, so rather than for
cing decode, consider returning false |
63 // when image is not decoded yet, as we do in case of deferred decoding. | 63 // when image is not decoded yet, as we do in case of deferred decoding. |
64 bool currentFrameKnownToBeOpaque(const RenderObject*); | 64 bool currentFrameKnownToBeOpaque(const LayoutObject*); |
65 | 65 |
66 static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor);
// Returns an image and the image's resolution scale factor. | 66 static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor);
// Returns an image and the image's resolution scale factor. |
67 bool willPaintBrokenImage() const; | 67 bool willPaintBrokenImage() const; |
68 | 68 |
69 bool canRender(const RenderObject& renderer, float multiplier) { return !err
orOccurred() && !imageSizeForRenderer(&renderer, multiplier).isEmpty(); } | 69 bool canRender(const LayoutObject& renderer, float multiplier) { return !err
orOccurred() && !imageSizeForRenderer(&renderer, multiplier).isEmpty(); } |
70 | 70 |
71 void setContainerSizeForRenderer(const ImageResourceClient*, const IntSize&,
float); | 71 void setContainerSizeForRenderer(const ImageResourceClient*, const IntSize&,
float); |
72 bool usesImageContainerSize() const; | 72 bool usesImageContainerSize() const; |
73 bool imageHasRelativeWidth() const; | 73 bool imageHasRelativeWidth() const; |
74 bool imageHasRelativeHeight() const; | 74 bool imageHasRelativeHeight() const; |
75 // The device pixel ratio we got from the server for this image, or 1.0. | 75 // The device pixel ratio we got from the server for this image, or 1.0. |
76 float devicePixelRatioHeaderValue() const { return m_devicePixelRatioHeaderV
alue; } | 76 float devicePixelRatioHeaderValue() const { return m_devicePixelRatioHeaderV
alue; } |
77 bool hasDevicePixelRatioHeaderValue() const { return m_hasDevicePixelRatioHe
aderValue; } | 77 bool hasDevicePixelRatioHeaderValue() const { return m_hasDevicePixelRatioHe
aderValue; } |
78 | 78 |
79 enum SizeType { | 79 enum SizeType { |
80 NormalSize, // Report the size of the image associated with a certain re
nderer | 80 NormalSize, // Report the size of the image associated with a certain re
nderer |
81 IntrinsicSize // Report the intrinsic size, i.e. ignore whatever has bee
n set extrinsically. | 81 IntrinsicSize // Report the intrinsic size, i.e. ignore whatever has bee
n set extrinsically. |
82 }; | 82 }; |
83 // This method takes a zoom multiplier that can be used to increase the natu
ral size of the image by the zoom. | 83 // This method takes a zoom multiplier that can be used to increase the natu
ral size of the image by the zoom. |
84 LayoutSize imageSizeForRenderer(const RenderObject*, float multiplier, SizeT
ype = NormalSize); // returns the size of the complete image. | 84 LayoutSize imageSizeForRenderer(const LayoutObject*, float multiplier, SizeT
ype = NormalSize); // returns the size of the complete image. |
85 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei
ght, FloatSize& intrinsicRatio); | 85 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei
ght, FloatSize& intrinsicRatio); |
86 | 86 |
87 static void updateBitmapImages(HashSet<ImageResource*>&, bool redecodeImages
= false); | 87 static void updateBitmapImages(HashSet<ImageResource*>&, bool redecodeImages
= false); |
88 | 88 |
89 bool isAccessAllowed(ExecutionContext*, SecurityOrigin*); | 89 bool isAccessAllowed(ExecutionContext*, SecurityOrigin*); |
90 | 90 |
91 void updateImageAnimationPolicy(); | 91 void updateImageAnimationPolicy(); |
92 | 92 |
93 virtual void didAddClient(ResourceClient*) override; | 93 virtual void didAddClient(ResourceClient*) override; |
94 virtual void didRemoveClient(ResourceClient*) override; | 94 virtual void didRemoveClient(ResourceClient*) override; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 OwnPtr<SVGImageCache> m_svgImageCache; | 139 OwnPtr<SVGImageCache> m_svgImageCache; |
140 bool m_loadingMultipartContent; | 140 bool m_loadingMultipartContent; |
141 bool m_hasDevicePixelRatioHeaderValue; | 141 bool m_hasDevicePixelRatioHeaderValue; |
142 }; | 142 }; |
143 | 143 |
144 DEFINE_RESOURCE_TYPE_CASTS(Image); | 144 DEFINE_RESOURCE_TYPE_CASTS(Image); |
145 | 145 |
146 } | 146 } |
147 | 147 |
148 #endif | 148 #endif |
OLD | NEW |