| 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 SVGResourceClient; |
| 44 |
| 42 class ClipPathOperation : public RefCounted<ClipPathOperation> { | 45 class ClipPathOperation : public RefCounted<ClipPathOperation> { |
| 43 public: | 46 public: |
| 44 enum OperationType { REFERENCE, SHAPE }; | 47 enum OperationType { REFERENCE, SHAPE }; |
| 45 | 48 |
| 46 virtual ~ClipPathOperation() {} | 49 virtual ~ClipPathOperation() {} |
| 47 | 50 |
| 48 virtual bool operator==(const ClipPathOperation&) const = 0; | 51 virtual bool operator==(const ClipPathOperation&) const = 0; |
| 49 bool operator!=(const ClipPathOperation& o) const { return !(*this == o); } | 52 bool operator!=(const ClipPathOperation& o) const { return !(*this == o); } |
| 50 | 53 |
| 51 virtual OperationType type() const = 0; | 54 virtual OperationType type() const = 0; |
| 52 bool isSameType(const ClipPathOperation& o) const { | 55 bool isSameType(const ClipPathOperation& o) const { |
| 53 return o.type() == type(); | 56 return o.type() == type(); |
| 54 } | 57 } |
| 55 | 58 |
| 56 protected: | 59 protected: |
| 57 ClipPathOperation() {} | 60 ClipPathOperation() {} |
| 58 }; | 61 }; |
| 59 | 62 |
| 60 class ReferenceClipPathOperation final : public ClipPathOperation { | 63 class ReferenceClipPathOperation final : public ClipPathOperation { |
| 61 public: | 64 public: |
| 62 static PassRefPtr<ReferenceClipPathOperation> create( | 65 static PassRefPtr<ReferenceClipPathOperation> create( |
| 63 const String& url, | 66 const String& url, |
| 64 const AtomicString& fragment) { | 67 SVGElementProxy& elementProxy) { |
| 65 return adoptRef(new ReferenceClipPathOperation(url, fragment)); | 68 return adoptRef(new ReferenceClipPathOperation(url, elementProxy)); |
| 66 } | 69 } |
| 67 | 70 |
| 71 void addClient(SVGResourceClient*); |
| 72 void removeClient(SVGResourceClient*); |
| 73 |
| 74 SVGElementProxy& elementProxy() const { return *m_elementProxy; } |
| 75 |
| 68 const String& url() const { return m_url; } | 76 const String& url() const { return m_url; } |
| 69 const AtomicString& fragment() const { return m_fragment; } | |
| 70 | 77 |
| 71 private: | 78 private: |
| 72 bool operator==(const ClipPathOperation& o) const override { | 79 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; } | 80 OperationType type() const override { return REFERENCE; } |
| 77 | 81 |
| 78 ReferenceClipPathOperation(const String& url, const AtomicString& fragment) | 82 ReferenceClipPathOperation(const String& url, SVGElementProxy& elementProxy) |
| 79 : m_url(url), m_fragment(fragment) {} | 83 : m_elementProxy(&elementProxy), m_url(url) {} |
| 80 | 84 |
| 85 Persistent<SVGElementProxy> m_elementProxy; |
| 81 String m_url; | 86 String m_url; |
| 82 AtomicString m_fragment; | |
| 83 }; | 87 }; |
| 84 | 88 |
| 85 DEFINE_TYPE_CASTS(ReferenceClipPathOperation, | 89 DEFINE_TYPE_CASTS(ReferenceClipPathOperation, |
| 86 ClipPathOperation, | 90 ClipPathOperation, |
| 87 op, | 91 op, |
| 88 op->type() == ClipPathOperation::REFERENCE, | 92 op->type() == ClipPathOperation::REFERENCE, |
| 89 op.type() == ClipPathOperation::REFERENCE); | 93 op.type() == ClipPathOperation::REFERENCE); |
| 90 | 94 |
| 91 class ShapeClipPathOperation final : public ClipPathOperation { | 95 class ShapeClipPathOperation final : public ClipPathOperation { |
| 92 public: | 96 public: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 return false; | 132 return false; |
| 129 BasicShape* otherShape = toShapeClipPathOperation(o).m_shape.get(); | 133 BasicShape* otherShape = toShapeClipPathOperation(o).m_shape.get(); |
| 130 if (!m_shape.get() || !otherShape) | 134 if (!m_shape.get() || !otherShape) |
| 131 return static_cast<bool>(m_shape.get()) == static_cast<bool>(otherShape); | 135 return static_cast<bool>(m_shape.get()) == static_cast<bool>(otherShape); |
| 132 return *m_shape == *otherShape; | 136 return *m_shape == *otherShape; |
| 133 } | 137 } |
| 134 | 138 |
| 135 } // namespace blink | 139 } // namespace blink |
| 136 | 140 |
| 137 #endif // ClipPathOperation_h | 141 #endif // ClipPathOperation_h |
| OLD | NEW |