OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 13 matching lines...) Expand all Loading... |
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
27 * SUCH DAMAGE. | 27 * SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #ifndef ClipPathOperation_h | 30 #ifndef ClipPathOperation_h |
31 #define ClipPathOperation_h | 31 #define ClipPathOperation_h |
32 | 32 |
33 #include "core/style/BasicShapes.h" | 33 #include "core/style/BasicShapes.h" |
| 34 #include "core/svg/SVGElementProxy.h" |
34 #include "platform/graphics/Path.h" | 35 #include "platform/graphics/Path.h" |
35 #include "wtf/PtrUtil.h" | 36 #include "wtf/PtrUtil.h" |
36 #include "wtf/RefCounted.h" | 37 #include "wtf/RefCounted.h" |
37 #include "wtf/text/WTFString.h" | 38 #include "wtf/text/WTFString.h" |
38 #include <memory> | 39 #include <memory> |
39 | 40 |
40 namespace blink { | 41 namespace blink { |
41 | 42 |
| 43 class SVGElement; |
| 44 class SVGResourceClient; |
| 45 class TreeScope; |
| 46 |
42 class ClipPathOperation : public RefCounted<ClipPathOperation> { | 47 class ClipPathOperation : public RefCounted<ClipPathOperation> { |
43 public: | 48 public: |
44 enum OperationType { REFERENCE, SHAPE }; | 49 enum OperationType { REFERENCE, SHAPE }; |
45 | 50 |
46 virtual ~ClipPathOperation() {} | 51 virtual ~ClipPathOperation() {} |
47 | 52 |
48 virtual bool operator==(const ClipPathOperation&) const = 0; | 53 virtual bool operator==(const ClipPathOperation&) const = 0; |
49 bool operator!=(const ClipPathOperation& o) const { return !(*this == o); } | 54 bool operator!=(const ClipPathOperation& o) const { return !(*this == o); } |
50 | 55 |
51 virtual OperationType type() const = 0; | 56 virtual OperationType type() const = 0; |
52 bool isSameType(const ClipPathOperation& o) const { | 57 bool isSameType(const ClipPathOperation& o) const { |
53 return o.type() == type(); | 58 return o.type() == type(); |
54 } | 59 } |
55 | 60 |
56 protected: | 61 protected: |
57 ClipPathOperation() {} | 62 ClipPathOperation() {} |
58 }; | 63 }; |
59 | 64 |
60 class ReferenceClipPathOperation final : public ClipPathOperation { | 65 class ReferenceClipPathOperation final : public ClipPathOperation { |
61 public: | 66 public: |
62 static PassRefPtr<ReferenceClipPathOperation> create( | 67 static PassRefPtr<ReferenceClipPathOperation> create( |
63 const String& url, | 68 const String& url, |
64 const AtomicString& fragment) { | 69 SVGElementProxy& elementProxy) { |
65 return adoptRef(new ReferenceClipPathOperation(url, fragment)); | 70 return adoptRef(new ReferenceClipPathOperation(url, elementProxy)); |
66 } | 71 } |
67 | 72 |
| 73 void addClient(SVGResourceClient*); |
| 74 void removeClient(SVGResourceClient*); |
| 75 |
| 76 SVGElement* findElement(TreeScope&) const; |
| 77 |
68 const String& url() const { return m_url; } | 78 const String& url() const { return m_url; } |
69 const AtomicString& fragment() const { return m_fragment; } | |
70 | 79 |
71 private: | 80 private: |
72 bool operator==(const ClipPathOperation& o) const override { | 81 bool operator==(const ClipPathOperation&) const override; |
73 return isSameType(o) && | |
74 m_url == static_cast<const ReferenceClipPathOperation&>(o).m_url; | |
75 } | |
76 OperationType type() const override { return REFERENCE; } | 82 OperationType type() const override { return REFERENCE; } |
77 | 83 |
78 ReferenceClipPathOperation(const String& url, const AtomicString& fragment) | 84 ReferenceClipPathOperation(const String& url, SVGElementProxy& elementProxy) |
79 : m_url(url), m_fragment(fragment) {} | 85 : m_elementProxy(&elementProxy), m_url(url) {} |
80 | 86 |
| 87 Persistent<SVGElementProxy> m_elementProxy; |
81 String m_url; | 88 String m_url; |
82 AtomicString m_fragment; | |
83 }; | 89 }; |
84 | 90 |
85 DEFINE_TYPE_CASTS(ReferenceClipPathOperation, | 91 DEFINE_TYPE_CASTS(ReferenceClipPathOperation, |
86 ClipPathOperation, | 92 ClipPathOperation, |
87 op, | 93 op, |
88 op->type() == ClipPathOperation::REFERENCE, | 94 op->type() == ClipPathOperation::REFERENCE, |
89 op.type() == ClipPathOperation::REFERENCE); | 95 op.type() == ClipPathOperation::REFERENCE); |
90 | 96 |
91 class ShapeClipPathOperation final : public ClipPathOperation { | 97 class ShapeClipPathOperation final : public ClipPathOperation { |
92 public: | 98 public: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 return false; | 134 return false; |
129 BasicShape* otherShape = toShapeClipPathOperation(o).m_shape.get(); | 135 BasicShape* otherShape = toShapeClipPathOperation(o).m_shape.get(); |
130 if (!m_shape.get() || !otherShape) | 136 if (!m_shape.get() || !otherShape) |
131 return static_cast<bool>(m_shape.get()) == static_cast<bool>(otherShape); | 137 return static_cast<bool>(m_shape.get()) == static_cast<bool>(otherShape); |
132 return *m_shape == *otherShape; | 138 return *m_shape == *otherShape; |
133 } | 139 } |
134 | 140 |
135 } // namespace blink | 141 } // namespace blink |
136 | 142 |
137 #endif // ClipPathOperation_h | 143 #endif // ClipPathOperation_h |
OLD | NEW |