OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef SVGEnumeration_h | 31 #ifndef SVGEnumeration_h |
32 #define SVGEnumeration_h | 32 #define SVGEnumeration_h |
33 | 33 |
34 #include "core/svg/properties/NewSVGProperty.h" | 34 #include "core/svg/properties/SVGProperty.h" |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
38 class SVGEnumerationBase : public NewSVGPropertyBase { | 38 class SVGEnumerationBase : public SVGPropertyBase { |
39 public: | 39 public: |
40 typedef std::pair<unsigned short, String> StringEntry; | 40 typedef std::pair<unsigned short, String> StringEntry; |
41 typedef Vector<StringEntry> StringEntries; | 41 typedef Vector<StringEntry> StringEntries; |
42 | 42 |
43 // SVGEnumeration does not have a tear-off type. | 43 // SVGEnumeration does not have a tear-off type. |
44 typedef void TearOffType; | 44 typedef void TearOffType; |
45 typedef unsigned short PrimitiveType; | 45 typedef unsigned short PrimitiveType; |
46 | 46 |
47 virtual ~SVGEnumerationBase(); | 47 virtual ~SVGEnumerationBase(); |
48 | 48 |
49 unsigned short value() const { return m_value; } | 49 unsigned short value() const { return m_value; } |
50 void setValue(unsigned short, ExceptionState&); | 50 void setValue(unsigned short, ExceptionState&); |
51 | 51 |
52 // This assumes that |m_entries| are sorted. | 52 // This assumes that |m_entries| are sorted. |
53 unsigned short maxEnumValue() const { return m_entries.last().first; } | 53 unsigned short maxEnumValue() const { return m_entries.last().first; } |
54 | 54 |
55 // NewSVGPropertyBase: | 55 // SVGPropertyBase: |
56 virtual PassRefPtr<SVGEnumerationBase> clone() const = 0; | 56 virtual PassRefPtr<SVGEnumerationBase> clone() const = 0; |
57 virtual PassRefPtr<NewSVGPropertyBase> cloneForAnimation(const String&) cons
t OVERRIDE; | 57 virtual PassRefPtr<SVGPropertyBase> cloneForAnimation(const String&) const O
VERRIDE; |
58 | 58 |
59 virtual String valueAsString() const OVERRIDE; | 59 virtual String valueAsString() const OVERRIDE; |
60 void setValueAsString(const String&, ExceptionState&); | 60 void setValueAsString(const String&, ExceptionState&); |
61 | 61 |
62 virtual void add(PassRefPtr<NewSVGPropertyBase>, SVGElement*) OVERRIDE; | 62 virtual void add(PassRefPtr<SVGPropertyBase>, SVGElement*) OVERRIDE; |
63 virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage,
unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> from, PassRefPtr<NewSVGProp
ertyBase> to, PassRefPtr<NewSVGPropertyBase> toAtEndOfDurationValue, SVGElement*
) OVERRIDE; | 63 virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage,
unsigned repeatCount, PassRefPtr<SVGPropertyBase> from, PassRefPtr<SVGPropertyBa
se> to, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*) OVERRID
E; |
64 virtual float calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGElemen
t*) OVERRIDE; | 64 virtual float calculateDistance(PassRefPtr<SVGPropertyBase> to, SVGElement*)
OVERRIDE; |
65 | 65 |
66 static AnimatedPropertyType classType() { return AnimatedEnumeration; } | 66 static AnimatedPropertyType classType() { return AnimatedEnumeration; } |
67 | 67 |
68 // Ensure that |SVGAnimatedEnumerationBase::setBaseVal| is used instead of |
NewSVGAnimatedProperty<SVGEnumerationBase>::setBaseVal|. | 68 // Ensure that |SVGAnimatedEnumerationBase::setBaseVal| is used instead of |
SVGAnimatedProperty<SVGEnumerationBase>::setBaseVal|. |
69 void setValue(unsigned short) { ASSERT_NOT_REACHED(); } | 69 void setValue(unsigned short) { ASSERT_NOT_REACHED(); } |
70 | 70 |
71 protected: | 71 protected: |
72 SVGEnumerationBase(unsigned short value, const StringEntries& entries) | 72 SVGEnumerationBase(unsigned short value, const StringEntries& entries) |
73 : NewSVGPropertyBase(classType()) | 73 : SVGPropertyBase(classType()) |
74 , m_value(value) | 74 , m_value(value) |
75 , m_entries(entries) | 75 , m_entries(entries) |
76 { | 76 { |
77 } | 77 } |
78 | 78 |
79 // Used by SVGMarkerOrientEnumeration. | 79 // Used by SVGMarkerOrientEnumeration. |
80 virtual void notifyChange() { } | 80 virtual void notifyChange() { } |
81 | 81 |
82 unsigned short m_value; | 82 unsigned short m_value; |
83 const StringEntries& m_entries; | 83 const StringEntries& m_entries; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 protected: | 118 protected: |
119 explicit SVGEnumeration(Enum newValue) | 119 explicit SVGEnumeration(Enum newValue) |
120 : SVGEnumerationBase(newValue, getStaticStringEntries<Enum>()) | 120 : SVGEnumerationBase(newValue, getStaticStringEntries<Enum>()) |
121 { | 121 { |
122 } | 122 } |
123 }; | 123 }; |
124 | 124 |
125 } // namespace WebCore | 125 } // namespace WebCore |
126 | 126 |
127 #endif // SVGEnumeration_h | 127 #endif // SVGEnumeration_h |
OLD | NEW |