| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // SVGEnumeration does not have a tear-off type. | 44 // SVGEnumeration does not have a tear-off type. |
| 45 typedef void TearOffType; | 45 typedef void TearOffType; |
| 46 typedef unsigned short PrimitiveType; | 46 typedef unsigned short PrimitiveType; |
| 47 | 47 |
| 48 ~SVGEnumerationBase() override; | 48 ~SVGEnumerationBase() override; |
| 49 | 49 |
| 50 unsigned short value() const { return m_value <= maxExposedEnumValue() ? m_v
alue : 0; } | 50 unsigned short value() const { return m_value <= maxExposedEnumValue() ? m_v
alue : 0; } |
| 51 void setValue(unsigned short); | 51 void setValue(unsigned short); |
| 52 | 52 |
| 53 // SVGPropertyBase: | 53 // SVGPropertyBase: |
| 54 virtual PassRefPtrWillBeRawPtr<SVGEnumerationBase> clone() const = 0; | 54 virtual RawPtr<SVGEnumerationBase> clone() const = 0; |
| 55 PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const String&) con
st override; | 55 RawPtr<SVGPropertyBase> cloneForAnimation(const String&) const override; |
| 56 | 56 |
| 57 String valueAsString() const override; | 57 String valueAsString() const override; |
| 58 SVGParsingError setValueAsString(const String&); | 58 SVGParsingError setValueAsString(const String&); |
| 59 | 59 |
| 60 void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; | 60 void add(RawPtr<SVGPropertyBase>, SVGElement*) override; |
| 61 void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned
repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from, PassRefPtrWillBeRawP
tr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDuratio
nValue, SVGElement*) override; | 61 void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned
repeatCount, RawPtr<SVGPropertyBase> from, RawPtr<SVGPropertyBase> to, RawPtr<S
VGPropertyBase> toAtEndOfDurationValue, SVGElement*) override; |
| 62 float calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> to, SVGEleme
nt*) override; | 62 float calculateDistance(RawPtr<SVGPropertyBase> to, SVGElement*) override; |
| 63 | 63 |
| 64 static AnimatedPropertyType classType() { return AnimatedEnumeration; } | 64 static AnimatedPropertyType classType() { return AnimatedEnumeration; } |
| 65 | 65 |
| 66 static unsigned short valueOfLastEnum(const StringEntries& entries) { return
entries.last().first; } | 66 static unsigned short valueOfLastEnum(const StringEntries& entries) { return
entries.last().first; } |
| 67 | 67 |
| 68 // This is the maximum value that is exposed as an IDL constant on the relev
ant interface. | 68 // This is the maximum value that is exposed as an IDL constant on the relev
ant interface. |
| 69 unsigned short maxExposedEnumValue() const { return m_maxExposed; } | 69 unsigned short maxExposedEnumValue() const { return m_maxExposed; } |
| 70 | 70 |
| 71 protected: | 71 protected: |
| 72 SVGEnumerationBase(unsigned short value, const StringEntries& entries, unsig
ned short maxExposed) | 72 SVGEnumerationBase(unsigned short value, const StringEntries& entries, unsig
ned short maxExposed) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 92 | 92 |
| 93 template<typename Enum> const SVGEnumerationStringEntries& getStaticStringEntrie
s(); | 93 template<typename Enum> const SVGEnumerationStringEntries& getStaticStringEntrie
s(); |
| 94 template<typename Enum> unsigned short getMaxExposedEnumValue() | 94 template<typename Enum> unsigned short getMaxExposedEnumValue() |
| 95 { | 95 { |
| 96 return SVGEnumerationBase::valueOfLastEnum(getStaticStringEntries<Enum>()); | 96 return SVGEnumerationBase::valueOfLastEnum(getStaticStringEntries<Enum>()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 template<typename Enum> | 99 template<typename Enum> |
| 100 class SVGEnumeration : public SVGEnumerationBase { | 100 class SVGEnumeration : public SVGEnumerationBase { |
| 101 public: | 101 public: |
| 102 static PassRefPtrWillBeRawPtr<SVGEnumeration<Enum>> create(Enum newValue) | 102 static RawPtr<SVGEnumeration<Enum>> create(Enum newValue) |
| 103 { | 103 { |
| 104 return adoptRefWillBeNoop(new SVGEnumeration<Enum>(newValue)); | 104 return new SVGEnumeration<Enum>(newValue); |
| 105 } | 105 } |
| 106 | 106 |
| 107 ~SVGEnumeration() override {} | 107 ~SVGEnumeration() override {} |
| 108 | 108 |
| 109 PassRefPtrWillBeRawPtr<SVGEnumerationBase> clone() const override | 109 RawPtr<SVGEnumerationBase> clone() const override |
| 110 { | 110 { |
| 111 return create(enumValue()); | 111 return create(enumValue()); |
| 112 } | 112 } |
| 113 | 113 |
| 114 Enum enumValue() const | 114 Enum enumValue() const |
| 115 { | 115 { |
| 116 ASSERT(m_value <= maxInternalEnumValue()); | 116 ASSERT(m_value <= maxInternalEnumValue()); |
| 117 return static_cast<Enum>(m_value); | 117 return static_cast<Enum>(m_value); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void setEnumValue(Enum value) | 120 void setEnumValue(Enum value) |
| 121 { | 121 { |
| 122 m_value = value; | 122 m_value = value; |
| 123 notifyChange(); | 123 notifyChange(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 protected: | 126 protected: |
| 127 explicit SVGEnumeration(Enum newValue) | 127 explicit SVGEnumeration(Enum newValue) |
| 128 : SVGEnumerationBase(newValue, getStaticStringEntries<Enum>(), getMaxExp
osedEnumValue<Enum>()) | 128 : SVGEnumerationBase(newValue, getStaticStringEntries<Enum>(), getMaxExp
osedEnumValue<Enum>()) |
| 129 { | 129 { |
| 130 } | 130 } |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 } // namespace blink | 133 } // namespace blink |
| 134 | 134 |
| 135 #endif // SVGEnumeration_h | 135 #endif // SVGEnumeration_h |
| OLD | NEW |