OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CSSStyleImageValue_h | 5 #ifndef CSSStyleImageValue_h |
6 #define CSSStyleImageValue_h | 6 #define CSSStyleImageValue_h |
7 | 7 |
| 8 #include "core/CoreExport.h" |
| 9 #include "core/css/CSSImageValue.h" |
8 #include "core/css/CSSImageValue.h" | 10 #include "core/css/CSSImageValue.h" |
9 #include "core/css/cssom/CSSResourceValue.h" | 11 #include "core/css/cssom/CSSResourceValue.h" |
| 12 #include "core/css/cssom/CSSStyleValue.h" |
10 #include "core/fetch/ImageResource.h" | 13 #include "core/fetch/ImageResource.h" |
| 14 #include "core/html/canvas/CanvasImageSource.h" |
| 15 #include "core/imagebitmap/ImageBitmapSource.h" |
11 #include "core/style/StyleImage.h" | 16 #include "core/style/StyleImage.h" |
12 | 17 |
13 | |
14 namespace blink { | 18 namespace blink { |
15 | 19 |
16 class CORE_EXPORT CSSStyleImageValue : public CSSResourceValue { | 20 class CORE_EXPORT CSSStyleImageValue : public CSSResourceValue, public CanvasIma
geSource { |
17 WTF_MAKE_NONCOPYABLE(CSSStyleImageValue); | 21 WTF_MAKE_NONCOPYABLE(CSSStyleImageValue); |
18 DEFINE_WRAPPERTYPEINFO(); | 22 DEFINE_WRAPPERTYPEINFO(); |
19 public: | 23 public: |
20 virtual ~CSSStyleImageValue() { } | 24 virtual ~CSSStyleImageValue() { } |
21 | 25 |
22 StyleValueType type() const override { return ImageType; } | 26 StyleValueType type() const override { return ImageType; } |
23 | 27 |
24 double intrinsicWidth(bool& isNull); | 28 double intrinsicWidth(bool& isNull) const; |
25 double intrinsicHeight(bool& isNull); | 29 double intrinsicHeight(bool& isNull) const; |
26 double intrinsicRatio(bool& isNull); | 30 double intrinsicRatio(bool& isNull); |
27 | 31 |
| 32 // CanvasImageSource |
| 33 bool isCSSImageValue() const final { return true; } |
| 34 int sourceWidth() final; |
| 35 int sourceHeight() final; |
| 36 bool wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigin) const final |
| 37 { |
| 38 return true; |
| 39 } |
| 40 FloatSize elementSize(const FloatSize& defaultObjectSize) const final; |
| 41 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, AccelerationHi
nt, SnapshotReason, const FloatSize&) const final |
| 42 { |
| 43 return image(); |
| 44 } |
| 45 bool isAccelerated() const override; |
| 46 |
28 DEFINE_INLINE_VIRTUAL_TRACE() | 47 DEFINE_INLINE_VIRTUAL_TRACE() |
29 { | 48 { |
30 visitor->trace(m_imageValue); | 49 visitor->trace(m_imageValue); |
31 CSSStyleValue::trace(visitor); | 50 CSSStyleValue::trace(visitor); |
32 CSSResourceValue::trace(visitor); | 51 CSSResourceValue::trace(visitor); |
33 } | 52 } |
34 | 53 |
35 protected: | 54 protected: |
36 CSSStyleImageValue(const CSSImageValue* imageValue) | 55 CSSStyleImageValue(const CSSImageValue* imageValue) |
37 : m_imageValue(imageValue) | 56 : m_imageValue(imageValue) |
38 { | 57 { |
39 } | 58 } |
40 | 59 |
41 Member<const CSSImageValue> m_imageValue; | 60 Member<const CSSImageValue> m_imageValue; |
42 | 61 |
43 virtual LayoutSize imageLayoutSize() const | 62 virtual LayoutSize imageLayoutSize() const |
44 { | 63 { |
45 DCHECK(!m_imageValue->isCachePending()); | 64 DCHECK(!m_imageValue->isCachePending()); |
46 return m_imageValue->cachedImage()->cachedImage()->imageSize(DoNotRespec
tImageOrientation, 1, ImageResource::IntrinsicSize); | 65 return m_imageValue->cachedImage()->cachedImage()->imageSize(DoNotRespec
tImageOrientation, 1, ImageResource::IntrinsicSize); |
47 } | 66 } |
48 | 67 |
49 virtual bool isCachePending() const { return m_imageValue->isCachePending();
} | 68 virtual bool isCachePending() const { return m_imageValue->isCachePending();
} |
50 | 69 |
51 Resource::Status status() const override | 70 Resource::Status status() const override |
52 { | 71 { |
53 if (isCachePending()) | 72 if (isCachePending()) |
54 return Resource::Status::NotStarted; | 73 return Resource::Status::NotStarted; |
55 return m_imageValue->cachedImage()->cachedImage()->getStatus(); | 74 return m_imageValue->cachedImage()->cachedImage()->getStatus(); |
56 } | 75 } |
| 76 |
| 77 private: |
| 78 PassRefPtr<Image> image() const; |
57 }; | 79 }; |
58 | 80 |
59 } // namespace blink | 81 } // namespace blink |
60 | 82 |
61 #endif // CSSResourceValue_h | 83 #endif // CSSResourceValue_h |
OLD | NEW |