Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 22 | 22 |
| 23 #ifndef ImageResource_h | 23 #ifndef ImageResource_h |
| 24 #define ImageResource_h | 24 #define ImageResource_h |
| 25 | 25 |
| 26 #include "core/CoreExport.h" | 26 #include "core/CoreExport.h" |
| 27 #include "core/fetch/ResourcePtr.h" | 27 #include "core/fetch/ResourcePtr.h" |
| 28 #include "platform/geometry/IntRect.h" | 28 #include "platform/geometry/IntRect.h" |
| 29 #include "platform/geometry/IntSizeHash.h" | 29 #include "platform/geometry/IntSizeHash.h" |
| 30 #include "platform/geometry/LayoutSize.h" | 30 #include "platform/geometry/LayoutSize.h" |
| 31 #include "platform/graphics/ImageObserver.h" | 31 #include "platform/graphics/ImageObserver.h" |
| 32 #include "platform/graphics/ImageOrientation.h" | |
| 32 #include "wtf/HashMap.h" | 33 #include "wtf/HashMap.h" |
| 33 | 34 |
| 34 namespace blink { | 35 namespace blink { |
| 35 | 36 |
| 36 class ImageResourceClient; | 37 class ImageResourceClient; |
| 37 class FetchRequest; | 38 class FetchRequest; |
| 38 class ResourceFetcher; | 39 class ResourceFetcher; |
| 39 class FloatSize; | 40 class FloatSize; |
| 40 class Length; | 41 class Length; |
| 41 class MemoryCache; | 42 class MemoryCache; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 61 bool hasImage() const { return m_image.get(); } | 62 bool hasImage() const { return m_image.get(); } |
| 62 // 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. |
| 63 // 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 |
| 64 // 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. |
| 65 bool currentFrameKnownToBeOpaque(const LayoutObject*); | 66 bool currentFrameKnownToBeOpaque(const LayoutObject*); |
| 66 | 67 |
| 67 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. |
| 68 bool willPaintBrokenImage() const; | 69 bool willPaintBrokenImage() const; |
| 69 | 70 |
| 70 // Assumes that image rotation or scale doesn't effect the image size being empty or not. | 71 // Assumes that image rotation or scale doesn't effect the image size being empty or not. |
| 71 bool canRender() { return !errorOccurred() && !imageSizeForLayoutObject(null ptr, 1).isEmpty(); } | 72 bool canRender() { return !errorOccurred() && !imageSize(DoNotRespectImageOr ientation, 1).isEmpty(); } |
|
Yoav Weiss
2015/11/24 10:29:07
It adds an extra call, but it might be better to h
davve
2015/11/24 13:33:33
fetch/ shouldn't depend on the rest of core/ (see
| |
| 72 | 73 |
| 73 bool usesImageContainerSize() const; | 74 bool usesImageContainerSize() const; |
| 74 bool imageHasRelativeWidth() const; | 75 bool imageHasRelativeWidth() const; |
| 75 bool imageHasRelativeHeight() const; | 76 bool imageHasRelativeHeight() const; |
| 76 // The device pixel ratio we got from the server for this image, or 1.0. | 77 // The device pixel ratio we got from the server for this image, or 1.0. |
| 77 float devicePixelRatioHeaderValue() const { return m_devicePixelRatioHeaderV alue; } | 78 float devicePixelRatioHeaderValue() const { return m_devicePixelRatioHeaderV alue; } |
| 78 bool hasDevicePixelRatioHeaderValue() const { return m_hasDevicePixelRatioHe aderValue; } | 79 bool hasDevicePixelRatioHeaderValue() const { return m_hasDevicePixelRatioHe aderValue; } |
| 79 | 80 |
| 80 enum SizeType { | 81 enum SizeType { |
| 81 IntrinsicSize, // Report the intrinsic size. | 82 IntrinsicSize, // Report the intrinsic size. |
| 82 IntrinsicCorrectedToDPR, // Report the intrinsic size corrected to accou nt for image density. | 83 IntrinsicCorrectedToDPR, // Report the intrinsic size corrected to accou nt for image density. |
| 83 }; | 84 }; |
| 84 // This method takes a zoom multiplier that can be used to increase the natu ral size of the image by the zoom. | 85 // This method takes a zoom multiplier that can be used to increase the natu ral size of the image by the zoom. |
| 85 LayoutSize imageSizeForLayoutObject(const LayoutObject*, float multiplier, S izeType = IntrinsicSize); // returns the size of the complete image. | 86 LayoutSize imageSize(RespectImageOrientationEnum shouldRespectImageOrientati on, float multiplier, SizeType = IntrinsicSize); |
| 86 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei ght, FloatSize& intrinsicRatio); | 87 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei ght, FloatSize& intrinsicRatio); |
| 87 | 88 |
| 88 bool isAccessAllowed(SecurityOrigin*); | 89 bool isAccessAllowed(SecurityOrigin*); |
| 89 | 90 |
| 90 void updateImageAnimationPolicy(); | 91 void updateImageAnimationPolicy(); |
| 91 | 92 |
| 92 void didAddClient(ResourceClient*) override; | 93 void didAddClient(ResourceClient*) override; |
| 93 void didRemoveClient(ResourceClient*) override; | 94 void didRemoveClient(ResourceClient*) override; |
| 94 | 95 |
| 95 void allClientsRemoved() override; | 96 void allClientsRemoved() override; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 | 146 |
| 146 RefPtr<blink::Image> m_image; | 147 RefPtr<blink::Image> m_image; |
| 147 bool m_hasDevicePixelRatioHeaderValue; | 148 bool m_hasDevicePixelRatioHeaderValue; |
| 148 }; | 149 }; |
| 149 | 150 |
| 150 DEFINE_RESOURCE_TYPE_CASTS(Image); | 151 DEFINE_RESOURCE_TYPE_CASTS(Image); |
| 151 | 152 |
| 152 } | 153 } |
| 153 | 154 |
| 154 #endif | 155 #endif |
| OLD | NEW |