| 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 WebCore { | 34 namespace WebCore { |
| 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 : 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(WebCore::Image*); | 51 ImageResource(WebCore::Image*); |
| 52 virtual ~ImageResource(); | 52 virtual ~ImageResource(); |
| 53 | 53 |
| 54 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&); | 54 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&) OVERRIDE; |
| 55 | 55 |
| 56 WebCore::Image* image(); // Returns the nullImage() if the image is not avai
lable yet. | 56 WebCore::Image* image(); // Returns the nullImage() if the image is not avai
lable yet. |
| 57 WebCore::Image* imageForRenderer(const RenderObject*); // Returns the nullIm
age() if the image is not available yet. | 57 WebCore::Image* imageForRenderer(const RenderObject*); // Returns the nullIm
age() if the image is not available yet. |
| 58 bool hasImage() const { return m_image.get(); } | 58 bool hasImage() const { return m_image.get(); } |
| 59 bool currentFrameKnownToBeOpaque(const RenderObject*); // Side effect: ensur
es decoded image is in cache, therefore should only be called when about to draw
the image. | 59 bool currentFrameKnownToBeOpaque(const RenderObject*); // Side effect: ensur
es decoded image is in cache, therefore should only be called when about to draw
the image. |
| 60 | 60 |
| 61 static std::pair<WebCore::Image*, float> brokenImage(float deviceScaleFactor
); // Returns an image and the image's resolution scale factor. | 61 static std::pair<WebCore::Image*, float> brokenImage(float deviceScaleFactor
); // Returns an image and the image's resolution scale factor. |
| 62 bool willPaintBrokenImage() const; | 62 bool willPaintBrokenImage() const; |
| 63 | 63 |
| 64 bool canRender(const RenderObject* renderer, float multiplier) { return !err
orOccurred() && !imageSizeForRenderer(renderer, multiplier).isEmpty(); } | 64 bool canRender(const RenderObject* renderer, float multiplier) { return !err
orOccurred() && !imageSizeForRenderer(renderer, multiplier).isEmpty(); } |
| 65 | 65 |
| 66 void setContainerSizeForRenderer(const ImageResourceClient*, const IntSize&,
float); | 66 void setContainerSizeForRenderer(const ImageResourceClient*, const IntSize&,
float); |
| 67 bool usesImageContainerSize() const; | 67 bool usesImageContainerSize() const; |
| 68 bool imageHasRelativeWidth() const; | 68 bool imageHasRelativeWidth() const; |
| 69 bool imageHasRelativeHeight() const; | 69 bool imageHasRelativeHeight() const; |
| 70 // The device pixel ratio we got from the server for this image, or 1.0. | 70 // The device pixel ratio we got from the server for this image, or 1.0. |
| 71 float devicePixelRatioHeaderValue() const { return m_devicePixelRatioHeaderV
alue; } | 71 float devicePixelRatioHeaderValue() const { return m_devicePixelRatioHeaderV
alue; } |
| 72 bool hasDevicePixelRatioHeaderValue() const { return m_hasDevicePixelRatioHe
aderValue; } | 72 bool hasDevicePixelRatioHeaderValue() const { return m_hasDevicePixelRatioHe
aderValue; } |
| 73 | 73 |
| 74 enum SizeType { | 74 enum SizeType { |
| 75 NormalSize, // Report the size of the image associated with a certain re
nderer | 75 NormalSize, // Report the size of the image associated with a certain re
nderer |
| 76 IntrinsicSize // Report the intrinsic size, i.e. ignore whatever has bee
n set extrinsically. | 76 IntrinsicSize // Report the intrinsic size, i.e. ignore whatever has bee
n set extrinsically. |
| 77 }; | 77 }; |
| 78 // This method takes a zoom multiplier that can be used to increase the natu
ral size of the image by the zoom. | 78 // This method takes a zoom multiplier that can be used to increase the natu
ral size of the image by the zoom. |
| 79 LayoutSize imageSizeForRenderer(const RenderObject*, float multiplier, SizeT
ype = NormalSize); // returns the size of the complete image. | 79 LayoutSize imageSizeForRenderer(const RenderObject*, float multiplier, SizeT
ype = NormalSize); // returns the size of the complete image. |
| 80 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei
ght, FloatSize& intrinsicRatio); | 80 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei
ght, FloatSize& intrinsicRatio); |
| 81 | 81 |
| 82 bool isAccessAllowed(SecurityOrigin*); | 82 bool isAccessAllowed(SecurityOrigin*); |
| 83 | 83 |
| 84 virtual void didAddClient(ResourceClient*); | 84 virtual void didAddClient(ResourceClient*) OVERRIDE; |
| 85 virtual void didRemoveClient(ResourceClient*); | 85 virtual void didRemoveClient(ResourceClient*) OVERRIDE; |
| 86 | 86 |
| 87 virtual void allClientsRemoved(); | 87 virtual void allClientsRemoved() OVERRIDE; |
| 88 virtual void destroyDecodedData(); | 88 virtual void destroyDecodedData() OVERRIDE; |
| 89 | 89 |
| 90 virtual void appendData(const char*, int) OVERRIDE; | 90 virtual void appendData(const char*, int) OVERRIDE; |
| 91 virtual void error(Resource::Status); | 91 virtual void error(Resource::Status) OVERRIDE; |
| 92 virtual void responseReceived(const ResourceResponse&); | 92 virtual void responseReceived(const ResourceResponse&) OVERRIDE; |
| 93 virtual void finishOnePart() OVERRIDE; | 93 virtual void finishOnePart() OVERRIDE; |
| 94 | 94 |
| 95 // For compatibility, images keep loading even if there are HTTP errors. | 95 // For compatibility, images keep loading even if there are HTTP errors. |
| 96 virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return true; } | 96 virtual bool shouldIgnoreHTTPStatusCodeErrors() const OVERRIDE { return true
; } |
| 97 | 97 |
| 98 virtual bool isImage() const { return true; } | 98 virtual bool isImage() const OVERRIDE { return true; } |
| 99 virtual bool stillNeedsLoad() const OVERRIDE { return !errorOccurred() && st
atus() == Unknown && !isLoading(); } | 99 virtual bool stillNeedsLoad() const OVERRIDE { return !errorOccurred() && st
atus() == Unknown && !isLoading(); } |
| 100 | 100 |
| 101 // ImageObserver | 101 // ImageObserver |
| 102 virtual void decodedSizeChanged(const WebCore::Image*, int delta); | 102 virtual void decodedSizeChanged(const WebCore::Image*, int delta) OVERRIDE; |
| 103 virtual void didDraw(const WebCore::Image*); | 103 virtual void didDraw(const WebCore::Image*) OVERRIDE; |
| 104 | 104 |
| 105 virtual bool shouldPauseAnimation(const WebCore::Image*); | 105 virtual bool shouldPauseAnimation(const WebCore::Image*) OVERRIDE; |
| 106 virtual void animationAdvanced(const WebCore::Image*); | 106 virtual void animationAdvanced(const WebCore::Image*) OVERRIDE; |
| 107 virtual void changedInRect(const WebCore::Image*, const IntRect&); | 107 virtual void changedInRect(const WebCore::Image*, const IntRect&) OVERRIDE; |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 void clear(); | 110 void clear(); |
| 111 | 111 |
| 112 void setCustomAcceptHeader(); | 112 void setCustomAcceptHeader(); |
| 113 void createImage(); | 113 void createImage(); |
| 114 void updateImage(bool allDataReceived); | 114 void updateImage(bool allDataReceived); |
| 115 void clearImage(); | 115 void clearImage(); |
| 116 // If not null, changeRect is the changed part of the image. | 116 // If not null, changeRect is the changed part of the image. |
| 117 void notifyObservers(const IntRect* changeRect = 0); | 117 void notifyObservers(const IntRect* changeRect = 0); |
| 118 | 118 |
| 119 virtual void switchClientsToRevalidatedResource() OVERRIDE; | 119 virtual void switchClientsToRevalidatedResource() OVERRIDE; |
| 120 | 120 |
| 121 typedef pair<IntSize, float> SizeAndZoom; | 121 typedef pair<IntSize, float> SizeAndZoom; |
| 122 typedef HashMap<const ImageResourceClient*, SizeAndZoom> ContainerSizeReques
ts; | 122 typedef HashMap<const ImageResourceClient*, SizeAndZoom> ContainerSizeReques
ts; |
| 123 ContainerSizeRequests m_pendingContainerSizeRequests; | 123 ContainerSizeRequests m_pendingContainerSizeRequests; |
| 124 float m_devicePixelRatioHeaderValue; | 124 float m_devicePixelRatioHeaderValue; |
| 125 | 125 |
| 126 RefPtr<WebCore::Image> m_image; | 126 RefPtr<WebCore::Image> m_image; |
| 127 OwnPtr<SVGImageCache> m_svgImageCache; | 127 OwnPtr<SVGImageCache> m_svgImageCache; |
| 128 bool m_loadingMultipartContent; | 128 bool m_loadingMultipartContent; |
| 129 bool m_hasDevicePixelRatioHeaderValue; | 129 bool m_hasDevicePixelRatioHeaderValue; |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 DEFINE_RESOURCE_TYPE_CASTS(Image); | 132 DEFINE_RESOURCE_TYPE_CASTS(Image); |
| 133 | 133 |
| 134 } | 134 } |
| 135 | 135 |
| 136 #endif | 136 #endif |
| OLD | NEW |