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 15 matching lines...) Expand all Loading... |
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 SVGNumber_h | 31 #ifndef SVGNumber_h |
32 #define SVGNumber_h | 32 #define SVGNumber_h |
33 | 33 |
34 #include "bindings/v8/ExceptionMessages.h" | 34 #include "bindings/v8/ExceptionMessages.h" |
35 #include "bindings/v8/ExceptionStatePlaceholder.h" | 35 #include "bindings/v8/ExceptionStatePlaceholder.h" |
36 #include "core/svg/properties/NewSVGProperty.h" | 36 #include "core/svg/properties/SVGProperty.h" |
37 | 37 |
38 namespace WebCore { | 38 namespace WebCore { |
39 | 39 |
40 class SVGNumberTearOff; | 40 class SVGNumberTearOff; |
41 | 41 |
42 class SVGNumber : public NewSVGPropertyBase { | 42 class SVGNumber : public SVGPropertyBase { |
43 public: | 43 public: |
44 // SVGNumber has a tear-off type, but SVGAnimatedNumber uses primitive type. | 44 // SVGNumber has a tear-off type, but SVGAnimatedNumber uses primitive type. |
45 typedef SVGNumberTearOff TearOffType; | 45 typedef SVGNumberTearOff TearOffType; |
46 typedef float PrimitiveType; | 46 typedef float PrimitiveType; |
47 | 47 |
48 static PassRefPtr<SVGNumber> create(float value = 0.0f) | 48 static PassRefPtr<SVGNumber> create(float value = 0.0f) |
49 { | 49 { |
50 return adoptRef(new SVGNumber(value)); | 50 return adoptRef(new SVGNumber(value)); |
51 } | 51 } |
52 | 52 |
53 virtual PassRefPtr<SVGNumber> clone() const; | 53 virtual PassRefPtr<SVGNumber> clone() const; |
54 virtual PassRefPtr<NewSVGPropertyBase> cloneForAnimation(const String&) cons
t OVERRIDE; | 54 virtual PassRefPtr<SVGPropertyBase> cloneForAnimation(const String&) const O
VERRIDE; |
55 | 55 |
56 float value() const { return m_value; } | 56 float value() const { return m_value; } |
57 void setValue(float value) { m_value = value; } | 57 void setValue(float value) { m_value = value; } |
58 | 58 |
59 virtual String valueAsString() const OVERRIDE; | 59 virtual String valueAsString() const OVERRIDE; |
60 virtual void setValueAsString(const String&, ExceptionState&); | 60 virtual 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*
contextElement) OVERRIDE; | 63 virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage,
unsigned repeatCount, PassRefPtr<SVGPropertyBase> from, PassRefPtr<SVGPropertyBa
se> to, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextE
lement) OVERRIDE; |
64 virtual float calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGElemen
t* contextElement) OVERRIDE; | 64 virtual float calculateDistance(PassRefPtr<SVGPropertyBase> to, SVGElement*
contextElement) OVERRIDE; |
65 | 65 |
66 static AnimatedPropertyType classType() { return AnimatedNumber; } | 66 static AnimatedPropertyType classType() { return AnimatedNumber; } |
67 | 67 |
68 protected: | 68 protected: |
69 explicit SVGNumber(float); | 69 explicit SVGNumber(float); |
70 | 70 |
71 template<typename CharType> | 71 template<typename CharType> |
72 bool parse(const CharType*& ptr, const CharType* end); | 72 bool parse(const CharType*& ptr, const CharType* end); |
73 | 73 |
74 float m_value; | 74 float m_value; |
75 }; | 75 }; |
76 | 76 |
77 inline PassRefPtr<SVGNumber> toSVGNumber(PassRefPtr<NewSVGPropertyBase> passBase
) | 77 inline PassRefPtr<SVGNumber> toSVGNumber(PassRefPtr<SVGPropertyBase> passBase) |
78 { | 78 { |
79 RefPtr<NewSVGPropertyBase> base = passBase; | 79 RefPtr<SVGPropertyBase> base = passBase; |
80 ASSERT(base->type() == SVGNumber::classType()); | 80 ASSERT(base->type() == SVGNumber::classType()); |
81 return static_pointer_cast<SVGNumber>(base.release()); | 81 return static_pointer_cast<SVGNumber>(base.release()); |
82 } | 82 } |
83 | 83 |
84 // SVGNumber which also accepts percentage as its value. | 84 // SVGNumber which also accepts percentage as its value. |
85 // This is used for <stop> "offset" | 85 // This is used for <stop> "offset" |
86 // Spec: http://www.w3.org/TR/SVG11/pservers.html#GradientStops | 86 // Spec: http://www.w3.org/TR/SVG11/pservers.html#GradientStops |
87 // offset = "<number> | <percentage>" | 87 // offset = "<number> | <percentage>" |
88 class SVGNumberAcceptPercentage FINAL : public SVGNumber { | 88 class SVGNumberAcceptPercentage FINAL : public SVGNumber { |
89 public: | 89 public: |
90 static PassRefPtr<SVGNumberAcceptPercentage> create(float value = 0) | 90 static PassRefPtr<SVGNumberAcceptPercentage> create(float value = 0) |
91 { | 91 { |
92 return adoptRef(new SVGNumberAcceptPercentage(value)); | 92 return adoptRef(new SVGNumberAcceptPercentage(value)); |
93 } | 93 } |
94 | 94 |
95 virtual PassRefPtr<SVGNumber> clone() const OVERRIDE; | 95 virtual PassRefPtr<SVGNumber> clone() const OVERRIDE; |
96 virtual void setValueAsString(const String&, ExceptionState&) OVERRIDE; | 96 virtual void setValueAsString(const String&, ExceptionState&) OVERRIDE; |
97 | 97 |
98 private: | 98 private: |
99 SVGNumberAcceptPercentage(float value); | 99 SVGNumberAcceptPercentage(float value); |
100 }; | 100 }; |
101 | 101 |
102 } // namespace WebCore | 102 } // namespace WebCore |
103 | 103 |
104 #endif // SVGNumber_h | 104 #endif // SVGNumber_h |
OLD | NEW |