| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 typedef std::pair<unsigned short, String> StringEntry; | 42 typedef std::pair<unsigned short, String> StringEntry; |
| 43 typedef Vector<StringEntry> StringEntries; | 43 typedef Vector<StringEntry> StringEntries; |
| 44 | 44 |
| 45 // SVGEnumeration does not have a tear-off type. | 45 // SVGEnumeration does not have a tear-off type. |
| 46 typedef void TearOffType; | 46 typedef void TearOffType; |
| 47 typedef unsigned short PrimitiveType; | 47 typedef unsigned short PrimitiveType; |
| 48 | 48 |
| 49 ~SVGEnumerationBase() override; | 49 ~SVGEnumerationBase() override; |
| 50 | 50 |
| 51 unsigned short value() const { return m_value <= maxExposedEnumValue() ? m_v
alue : 0; } | 51 unsigned short value() const { return m_value <= maxExposedEnumValue() ? m_v
alue : 0; } |
| 52 void setValue(unsigned short, ExceptionState&); | 52 void setValue(unsigned short); |
| 53 | 53 |
| 54 // SVGPropertyBase: | 54 // SVGPropertyBase: |
| 55 virtual PassRefPtrWillBeRawPtr<SVGEnumerationBase> clone() const = 0; | 55 virtual PassRefPtrWillBeRawPtr<SVGEnumerationBase> clone() const = 0; |
| 56 PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const String&) con
st override; | 56 PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const String&) con
st override; |
| 57 | 57 |
| 58 String valueAsString() const override; | 58 String valueAsString() const override; |
| 59 void setValueAsString(const String&, ExceptionState&); | 59 void setValueAsString(const String&, ExceptionState&); |
| 60 | 60 |
| 61 void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; | 61 void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; |
| 62 void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned
repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from, PassRefPtrWillBeRawP
tr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDuratio
nValue, SVGElement*) override; | 62 void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned
repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from, PassRefPtrWillBeRawP
tr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDuratio
nValue, SVGElement*) override; |
| 63 float calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> to, SVGEleme
nt*) override; | 63 float calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> to, SVGEleme
nt*) override; |
| 64 | 64 |
| 65 static AnimatedPropertyType classType() { return AnimatedEnumeration; } | 65 static AnimatedPropertyType classType() { return AnimatedEnumeration; } |
| 66 | 66 |
| 67 // Ensure that |SVGAnimatedEnumerationBase::setBaseVal| is used instead of |
SVGAnimatedProperty<SVGEnumerationBase>::setBaseVal|. | 67 static unsigned short valueOfLastEnum(const StringEntries& entries) { return
entries.last().first; } |
| 68 void setValue(unsigned short) { ASSERT_NOT_REACHED(); } | |
| 69 | 68 |
| 70 static unsigned short valueOfLastEnum(const StringEntries& entries) { return
entries.last().first; } | 69 // This is the maximum value that is exposed as an IDL constant on the relev
ant interface. |
| 70 unsigned short maxExposedEnumValue() const { return m_maxExposed; } |
| 71 | 71 |
| 72 protected: | 72 protected: |
| 73 SVGEnumerationBase(unsigned short value, const StringEntries& entries, unsig
ned short maxExposed) | 73 SVGEnumerationBase(unsigned short value, const StringEntries& entries, unsig
ned short maxExposed) |
| 74 : SVGPropertyBase(classType()) | 74 : SVGPropertyBase(classType()) |
| 75 , m_value(value) | 75 , m_value(value) |
| 76 , m_maxExposed(maxExposed) | 76 , m_maxExposed(maxExposed) |
| 77 , m_entries(entries) | 77 , m_entries(entries) |
| 78 { | 78 { |
| 79 } | 79 } |
| 80 | 80 |
| 81 // This is the maximum value of all the internal enumeration values. | 81 // This is the maximum value of all the internal enumeration values. |
| 82 // This assumes that |m_entries| are sorted. | 82 // This assumes that |m_entries| are sorted. |
| 83 unsigned short maxInternalEnumValue() const { return valueOfLastEnum(m_entri
es); } | 83 unsigned short maxInternalEnumValue() const { return valueOfLastEnum(m_entri
es); } |
| 84 | 84 |
| 85 // This is the maximum value that is exposed as an IDL constant on the relev
ant interface. | |
| 86 unsigned short maxExposedEnumValue() const { return m_maxExposed; } | |
| 87 | |
| 88 // Used by SVGMarkerOrientEnumeration. | 85 // Used by SVGMarkerOrientEnumeration. |
| 89 virtual void notifyChange() { } | 86 virtual void notifyChange() { } |
| 90 | 87 |
| 91 unsigned short m_value; | 88 unsigned short m_value; |
| 92 const unsigned short m_maxExposed; | 89 const unsigned short m_maxExposed; |
| 93 const StringEntries& m_entries; | 90 const StringEntries& m_entries; |
| 94 }; | 91 }; |
| 95 typedef SVGEnumerationBase::StringEntries SVGEnumerationStringEntries; | 92 typedef SVGEnumerationBase::StringEntries SVGEnumerationStringEntries; |
| 96 | 93 |
| 97 template<typename Enum> const SVGEnumerationStringEntries& getStaticStringEntrie
s(); | 94 template<typename Enum> const SVGEnumerationStringEntries& getStaticStringEntrie
s(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 protected: | 127 protected: |
| 131 explicit SVGEnumeration(Enum newValue) | 128 explicit SVGEnumeration(Enum newValue) |
| 132 : SVGEnumerationBase(newValue, getStaticStringEntries<Enum>(), getMaxExp
osedEnumValue<Enum>()) | 129 : SVGEnumerationBase(newValue, getStaticStringEntries<Enum>(), getMaxExp
osedEnumValue<Enum>()) |
| 133 { | 130 { |
| 134 } | 131 } |
| 135 }; | 132 }; |
| 136 | 133 |
| 137 } // namespace blink | 134 } // namespace blink |
| 138 | 135 |
| 139 #endif // SVGEnumeration_h | 136 #endif // SVGEnumeration_h |
| OLD | NEW |