| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 friend class MemoryCache; | 47 friend class MemoryCache; |
| 48 | 48 |
| 49 public: | 49 public: |
| 50 typedef ImageResourceClient ClientType; | 50 typedef ImageResourceClient ClientType; |
| 51 | 51 |
| 52 static ResourcePtr<ImageResource> fetch(FetchRequest&, ResourceFetcher*); | 52 static ResourcePtr<ImageResource> fetch(FetchRequest&, ResourceFetcher*); |
| 53 | 53 |
| 54 ImageResource(blink::Image*); | 54 ImageResource(blink::Image*); |
| 55 // Exposed for testing | 55 // Exposed for testing |
| 56 ImageResource(const ResourceRequest&, blink::Image*); | 56 ImageResource(const ResourceRequest&, blink::Image*); |
| 57 virtual ~ImageResource(); | 57 ~ImageResource() override; |
| 58 | 58 |
| 59 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&) override; | 59 void load(ResourceFetcher*, const ResourceLoaderOptions&) override; |
| 60 | 60 |
| 61 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. |
| 62 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. |
| 63 bool hasImage() const { return m_image.get(); } | 63 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. | 64 // 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 | 65 // 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. | 66 // when image is not decoded yet, as we do in case of deferred decoding. |
| 67 bool currentFrameKnownToBeOpaque(const LayoutObject*); | 67 bool currentFrameKnownToBeOpaque(const LayoutObject*); |
| 68 | 68 |
| 69 static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor);
// Returns an image and the image's resolution scale factor. | 69 static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor);
// Returns an image and the image's resolution scale factor. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 85 IntrinsicCorrectedToDPR, // Report the intrinsic size corrected to accou
nt for image density. | 85 IntrinsicCorrectedToDPR, // Report the intrinsic size corrected to accou
nt for image density. |
| 86 }; | 86 }; |
| 87 // This method takes a zoom multiplier that can be used to increase the natu
ral size of the image by the zoom. | 87 // This method takes a zoom multiplier that can be used to increase the natu
ral size of the image by the zoom. |
| 88 LayoutSize imageSizeForLayoutObject(const LayoutObject*, float multiplier, S
izeType = NormalSize); // returns the size of the complete image. | 88 LayoutSize imageSizeForLayoutObject(const LayoutObject*, float multiplier, S
izeType = NormalSize); // returns the size of the complete image. |
| 89 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei
ght, FloatSize& intrinsicRatio); | 89 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei
ght, FloatSize& intrinsicRatio); |
| 90 | 90 |
| 91 bool isAccessAllowed(SecurityOrigin*); | 91 bool isAccessAllowed(SecurityOrigin*); |
| 92 | 92 |
| 93 void updateImageAnimationPolicy(); | 93 void updateImageAnimationPolicy(); |
| 94 | 94 |
| 95 virtual void didAddClient(ResourceClient*) override; | 95 void didAddClient(ResourceClient*) override; |
| 96 virtual void didRemoveClient(ResourceClient*) override; | 96 void didRemoveClient(ResourceClient*) override; |
| 97 | 97 |
| 98 virtual void allClientsRemoved() override; | 98 void allClientsRemoved() override; |
| 99 | 99 |
| 100 virtual void appendData(const char*, unsigned) override; | 100 void appendData(const char*, unsigned) override; |
| 101 virtual void error(Resource::Status) override; | 101 void error(Resource::Status) override; |
| 102 virtual void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataCon
sumerHandle>) override; | 102 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan
dle>) override; |
| 103 virtual void finishOnePart() override; | 103 void finishOnePart() override; |
| 104 | 104 |
| 105 // For compatibility, images keep loading even if there are HTTP errors. | 105 // For compatibility, images keep loading even if there are HTTP errors. |
| 106 virtual bool shouldIgnoreHTTPStatusCodeErrors() const override { return true
; } | 106 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } |
| 107 | 107 |
| 108 virtual bool isImage() const override { return true; } | 108 bool isImage() const override { return true; } |
| 109 virtual bool stillNeedsLoad() const override { return !errorOccurred() && st
atus() == Unknown && !isLoading(); } | 109 bool stillNeedsLoad() const override { return !errorOccurred() && status() =
= Unknown && !isLoading(); } |
| 110 | 110 |
| 111 // ImageObserver | 111 // ImageObserver |
| 112 virtual void decodedSizeChanged(const blink::Image*, int delta) override; | 112 void decodedSizeChanged(const blink::Image*, int delta) override; |
| 113 virtual void didDraw(const blink::Image*) override; | 113 void didDraw(const blink::Image*) override; |
| 114 | 114 |
| 115 virtual bool shouldPauseAnimation(const blink::Image*) override; | 115 bool shouldPauseAnimation(const blink::Image*) override; |
| 116 virtual void animationAdvanced(const blink::Image*) override; | 116 void animationAdvanced(const blink::Image*) override; |
| 117 virtual void changedInRect(const blink::Image*, const IntRect&) override; | 117 void changedInRect(const blink::Image*, const IntRect&) override; |
| 118 | 118 |
| 119 protected: | 119 protected: |
| 120 virtual bool isSafeToUnlock() const override; | 120 bool isSafeToUnlock() const override; |
| 121 virtual void destroyDecodedDataIfPossible() override; | 121 void destroyDecodedDataIfPossible() override; |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 static void preCacheDataURIImage(const FetchRequest&, ResourceFetcher*); | 124 static void preCacheDataURIImage(const FetchRequest&, ResourceFetcher*); |
| 125 | 125 |
| 126 class ImageResourceFactory : public ResourceFactory { | 126 class ImageResourceFactory : public ResourceFactory { |
| 127 public: | 127 public: |
| 128 ImageResourceFactory() | 128 ImageResourceFactory() |
| 129 : ResourceFactory(Resource::Image) { } | 129 : ResourceFactory(Resource::Image) { } |
| 130 | 130 |
| 131 Resource* create(const ResourceRequest& request, const String&) const ov
erride | 131 Resource* create(const ResourceRequest& request, const String&) const ov
erride |
| (...skipping 22 matching lines...) Expand all Loading... |
| 154 | 154 |
| 155 RefPtr<blink::Image> m_image; | 155 RefPtr<blink::Image> m_image; |
| 156 bool m_hasDevicePixelRatioHeaderValue; | 156 bool m_hasDevicePixelRatioHeaderValue; |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 DEFINE_RESOURCE_TYPE_CASTS(Image); | 159 DEFINE_RESOURCE_TYPE_CASTS(Image); |
| 160 | 160 |
| 161 } | 161 } |
| 162 | 162 |
| 163 #endif | 163 #endif |
| OLD | NEW |