| 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 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 #include "core/svg/SVGEnumeration.h" | 31 #include "core/svg/SVGEnumeration.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ExceptionState.h" | |
| 34 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | |
| 35 #include "core/dom/ExceptionCode.h" | |
| 36 #include "core/svg/SVGAnimationElement.h" | 33 #include "core/svg/SVGAnimationElement.h" |
| 37 | 34 |
| 38 namespace blink { | 35 namespace blink { |
| 39 | 36 |
| 40 DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGEnumerationBase); | 37 DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGEnumerationBase); |
| 41 | 38 |
| 42 SVGEnumerationBase::~SVGEnumerationBase() | 39 SVGEnumerationBase::~SVGEnumerationBase() |
| 43 { | 40 { |
| 44 } | 41 } |
| 45 | 42 |
| 46 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGEnumerationBase::cloneForAnimation(co
nst String& value) const | 43 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGEnumerationBase::cloneForAnimation(co
nst String& value) const |
| 47 { | 44 { |
| 48 RefPtrWillBeRawPtr<SVGEnumerationBase> svgEnumeration = clone(); | 45 RefPtrWillBeRawPtr<SVGEnumerationBase> svgEnumeration = clone(); |
| 49 svgEnumeration->setValueAsString(value, IGNORE_EXCEPTION); | 46 svgEnumeration->setValueAsString(value); |
| 50 return svgEnumeration.release(); | 47 return svgEnumeration.release(); |
| 51 } | 48 } |
| 52 | 49 |
| 53 String SVGEnumerationBase::valueAsString() const | 50 String SVGEnumerationBase::valueAsString() const |
| 54 { | 51 { |
| 55 for (const auto& entry : m_entries) { | 52 for (const auto& entry : m_entries) { |
| 56 if (m_value == entry.first) | 53 if (m_value == entry.first) |
| 57 return entry.second; | 54 return entry.second; |
| 58 } | 55 } |
| 59 | 56 |
| 60 ASSERT(m_value < maxInternalEnumValue()); | 57 ASSERT(m_value < maxInternalEnumValue()); |
| 61 return emptyString(); | 58 return emptyString(); |
| 62 } | 59 } |
| 63 | 60 |
| 64 void SVGEnumerationBase::setValue(unsigned short value) | 61 void SVGEnumerationBase::setValue(unsigned short value) |
| 65 { | 62 { |
| 66 m_value = value; | 63 m_value = value; |
| 67 notifyChange(); | 64 notifyChange(); |
| 68 } | 65 } |
| 69 | 66 |
| 70 void SVGEnumerationBase::setValueAsString(const String& string, ExceptionState&
exceptionState) | 67 SVGParsingError SVGEnumerationBase::setValueAsString(const String& string) |
| 71 { | 68 { |
| 72 for (const auto& entry : m_entries) { | 69 for (const auto& entry : m_entries) { |
| 73 if (string == entry.second) { | 70 if (string == entry.second) { |
| 74 // 0 corresponds to _UNKNOWN enumeration values, and should not be s
ettable. | 71 // 0 corresponds to _UNKNOWN enumeration values, and should not be s
ettable. |
| 75 ASSERT(entry.first); | 72 ASSERT(entry.first); |
| 76 m_value = entry.first; | 73 m_value = entry.first; |
| 77 notifyChange(); | 74 notifyChange(); |
| 78 return; | 75 return NoError; |
| 79 } | 76 } |
| 80 } | 77 } |
| 81 | 78 |
| 82 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + stri
ng + "') is invalid."); | |
| 83 notifyChange(); | 79 notifyChange(); |
| 80 return ParsingAttributeFailedError; |
| 84 } | 81 } |
| 85 | 82 |
| 86 void SVGEnumerationBase::add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement
*) | 83 void SVGEnumerationBase::add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement
*) |
| 87 { | 84 { |
| 88 ASSERT_NOT_REACHED(); | 85 ASSERT_NOT_REACHED(); |
| 89 } | 86 } |
| 90 | 87 |
| 91 void SVGEnumerationBase::calculateAnimatedValue(SVGAnimationElement* animationEl
ement, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropert
yBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<
SVGPropertyBase>, SVGElement*) | 88 void SVGEnumerationBase::calculateAnimatedValue(SVGAnimationElement* animationEl
ement, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropert
yBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<
SVGPropertyBase>, SVGElement*) |
| 92 { | 89 { |
| 93 ASSERT(animationElement); | 90 ASSERT(animationElement); |
| 94 unsigned short fromEnumeration = animationElement->animationMode() == ToAnim
ation ? m_value : toSVGEnumerationBase(from)->value(); | 91 unsigned short fromEnumeration = animationElement->animationMode() == ToAnim
ation ? m_value : toSVGEnumerationBase(from)->value(); |
| 95 unsigned short toEnumeration = toSVGEnumerationBase(to)->value(); | 92 unsigned short toEnumeration = toSVGEnumerationBase(to)->value(); |
| 96 | 93 |
| 97 animationElement->animateDiscreteType<unsigned short>(percentage, fromEnumer
ation, toEnumeration, m_value); | 94 animationElement->animateDiscreteType<unsigned short>(percentage, fromEnumer
ation, toEnumeration, m_value); |
| 98 } | 95 } |
| 99 | 96 |
| 100 float SVGEnumerationBase::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBa
se>, SVGElement*) | 97 float SVGEnumerationBase::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBa
se>, SVGElement*) |
| 101 { | 98 { |
| 102 // No paced animations for boolean. | 99 // No paced animations for boolean. |
| 103 return -1; | 100 return -1; |
| 104 } | 101 } |
| 105 | 102 |
| 106 } | 103 } |
| OLD | NEW |