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 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 RenderObject; |
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 RenderObject*); // 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 bool currentFrameKnownToBeOpaque(const RenderObject*); // Side effect: ensur
es decoded image is in cache, therefore should only be called when about to draw
the image. | 61 bool currentFrameKnownToBeOpaque(const RenderObject*); // Side effect: ensur
es decoded image is in cache, therefore should only be called when about to draw
the image. |
62 | 62 |
63 static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor);
// Returns an image and the image's resolution scale factor. | 63 static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor);
// Returns an image and the image's resolution scale factor. |
64 bool willPaintBrokenImage() const; | 64 bool willPaintBrokenImage() const; |
65 | 65 |
66 bool canRender(const RenderObject& renderer, float multiplier) { return !err
orOccurred() && !imageSizeForRenderer(&renderer, multiplier).isEmpty(); } | 66 bool canRender(const RenderObject& renderer, float multiplier) { return !err
orOccurred() && !imageSizeForRenderer(&renderer, multiplier).isEmpty(); } |
(...skipping 11 matching lines...) Expand all Loading... |
78 IntrinsicSize // Report the intrinsic size, i.e. ignore whatever has bee
n set extrinsically. | 78 IntrinsicSize // Report the intrinsic size, i.e. ignore whatever has bee
n set extrinsically. |
79 }; | 79 }; |
80 // This method takes a zoom multiplier that can be used to increase the natu
ral size of the image by the zoom. | 80 // This method takes a zoom multiplier that can be used to increase the natu
ral size of the image by the zoom. |
81 LayoutSize imageSizeForRenderer(const RenderObject*, float multiplier, SizeT
ype = NormalSize); // returns the size of the complete image. | 81 LayoutSize imageSizeForRenderer(const RenderObject*, float multiplier, SizeT
ype = NormalSize); // returns the size of the complete image. |
82 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei
ght, FloatSize& intrinsicRatio); | 82 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei
ght, FloatSize& intrinsicRatio); |
83 | 83 |
84 static void updateBitmapImages(HashSet<ImageResource*>&, bool redecodeImages
= false); | 84 static void updateBitmapImages(HashSet<ImageResource*>&, bool redecodeImages
= false); |
85 | 85 |
86 bool isAccessAllowed(SecurityOrigin*); | 86 bool isAccessAllowed(SecurityOrigin*); |
87 | 87 |
88 virtual void didAddClient(ResourceClient*) OVERRIDE; | 88 virtual void didAddClient(ResourceClient*) override; |
89 virtual void didRemoveClient(ResourceClient*) OVERRIDE; | 89 virtual void didRemoveClient(ResourceClient*) override; |
90 | 90 |
91 virtual void allClientsRemoved() OVERRIDE; | 91 virtual void allClientsRemoved() override; |
92 | 92 |
93 virtual void appendData(const char*, unsigned) OVERRIDE; | 93 virtual void appendData(const char*, unsigned) override; |
94 virtual void error(Resource::Status) OVERRIDE; | 94 virtual void error(Resource::Status) override; |
95 virtual void responseReceived(const ResourceResponse&) OVERRIDE; | 95 virtual void responseReceived(const ResourceResponse&) override; |
96 virtual void finishOnePart() OVERRIDE; | 96 virtual void finishOnePart() override; |
97 | 97 |
98 // For compatibility, images keep loading even if there are HTTP errors. | 98 // For compatibility, images keep loading even if there are HTTP errors. |
99 virtual bool shouldIgnoreHTTPStatusCodeErrors() const OVERRIDE { return true
; } | 99 virtual bool shouldIgnoreHTTPStatusCodeErrors() const override { return true
; } |
100 | 100 |
101 virtual bool isImage() const OVERRIDE { return true; } | 101 virtual bool isImage() const override { return true; } |
102 virtual bool stillNeedsLoad() const OVERRIDE { return !errorOccurred() && st
atus() == Unknown && !isLoading(); } | 102 virtual bool stillNeedsLoad() const override { return !errorOccurred() && st
atus() == Unknown && !isLoading(); } |
103 | 103 |
104 // ImageObserver | 104 // ImageObserver |
105 virtual void decodedSizeChanged(const blink::Image*, int delta) OVERRIDE; | 105 virtual void decodedSizeChanged(const blink::Image*, int delta) override; |
106 virtual void didDraw(const blink::Image*) OVERRIDE; | 106 virtual void didDraw(const blink::Image*) override; |
107 | 107 |
108 virtual bool shouldPauseAnimation(const blink::Image*) OVERRIDE; | 108 virtual bool shouldPauseAnimation(const blink::Image*) override; |
109 virtual void animationAdvanced(const blink::Image*) OVERRIDE; | 109 virtual void animationAdvanced(const blink::Image*) override; |
110 virtual void changedInRect(const blink::Image*, const IntRect&) OVERRIDE; | 110 virtual void changedInRect(const blink::Image*, const IntRect&) override; |
111 | 111 |
112 protected: | 112 protected: |
113 virtual bool isSafeToUnlock() const OVERRIDE; | 113 virtual bool isSafeToUnlock() const override; |
114 virtual void destroyDecodedDataIfPossible() OVERRIDE; | 114 virtual void destroyDecodedDataIfPossible() override; |
115 | 115 |
116 private: | 116 private: |
117 void clear(); | 117 void clear(); |
118 | 118 |
119 void setCustomAcceptHeader(); | 119 void setCustomAcceptHeader(); |
120 void createImage(); | 120 void createImage(); |
121 void updateImage(bool allDataReceived); | 121 void updateImage(bool allDataReceived); |
122 void clearImage(); | 122 void clearImage(); |
123 // If not null, changeRect is the changed part of the image. | 123 // If not null, changeRect is the changed part of the image. |
124 void notifyObservers(const IntRect* changeRect = 0); | 124 void notifyObservers(const IntRect* changeRect = 0); |
125 | 125 |
126 virtual void switchClientsToRevalidatedResource() OVERRIDE; | 126 virtual void switchClientsToRevalidatedResource() override; |
127 | 127 |
128 typedef pair<IntSize, float> SizeAndZoom; | 128 typedef pair<IntSize, float> SizeAndZoom; |
129 typedef HashMap<const ImageResourceClient*, SizeAndZoom> ContainerSizeReques
ts; | 129 typedef HashMap<const ImageResourceClient*, SizeAndZoom> ContainerSizeReques
ts; |
130 ContainerSizeRequests m_pendingContainerSizeRequests; | 130 ContainerSizeRequests m_pendingContainerSizeRequests; |
131 float m_devicePixelRatioHeaderValue; | 131 float m_devicePixelRatioHeaderValue; |
132 | 132 |
133 RefPtr<blink::Image> m_image; | 133 RefPtr<blink::Image> m_image; |
134 OwnPtr<SVGImageCache> m_svgImageCache; | 134 OwnPtr<SVGImageCache> m_svgImageCache; |
135 bool m_loadingMultipartContent; | 135 bool m_loadingMultipartContent; |
136 bool m_hasDevicePixelRatioHeaderValue; | 136 bool m_hasDevicePixelRatioHeaderValue; |
137 }; | 137 }; |
138 | 138 |
139 DEFINE_RESOURCE_TYPE_CASTS(Image); | 139 DEFINE_RESOURCE_TYPE_CASTS(Image); |
140 | 140 |
141 } | 141 } |
142 | 142 |
143 #endif | 143 #endif |
OLD | NEW |