| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 { | 61 { |
| 62 for (const auto& entry : m_entries) { | 62 for (const auto& entry : m_entries) { |
| 63 if (m_value == entry.first) | 63 if (m_value == entry.first) |
| 64 return entry.second; | 64 return entry.second; |
| 65 } | 65 } |
| 66 | 66 |
| 67 ASSERT(m_value < maxInternalEnumValue()); | 67 ASSERT(m_value < maxInternalEnumValue()); |
| 68 return emptyString(); | 68 return emptyString(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void SVGEnumerationBase::setValue(unsigned short value, ExceptionState& exceptio
nState) | 71 void SVGEnumerationBase::setValue(unsigned short value) |
| 72 { | 72 { |
| 73 if (!value) { | |
| 74 exceptionState.throwTypeError("The enumeration value provided is 0, whic
h is not settable."); | |
| 75 return; | |
| 76 } | |
| 77 | |
| 78 if (value > maxExposedEnumValue()) { | |
| 79 exceptionState.throwTypeError("The enumeration value provided (" + Strin
g::number(value) + ") is larger than the largest allowed value (" + String::numb
er(maxExposedEnumValue()) + ")."); | |
| 80 return; | |
| 81 } | |
| 82 | |
| 83 m_value = value; | 73 m_value = value; |
| 84 notifyChange(); | 74 notifyChange(); |
| 85 } | 75 } |
| 86 | 76 |
| 87 void SVGEnumerationBase::setValueAsString(const String& string, ExceptionState&
exceptionState) | 77 void SVGEnumerationBase::setValueAsString(const String& string, ExceptionState&
exceptionState) |
| 88 { | 78 { |
| 89 for (const auto& entry : m_entries) { | 79 for (const auto& entry : m_entries) { |
| 90 if (string == entry.second) { | 80 if (string == entry.second) { |
| 91 // 0 corresponds to _UNKNOWN enumeration values, and should not be s
ettable. | 81 // 0 corresponds to _UNKNOWN enumeration values, and should not be s
ettable. |
| 92 ASSERT(entry.first); | 82 ASSERT(entry.first); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 114 animationElement->animateDiscreteType<unsigned short>(percentage, fromEnumer
ation, toEnumeration, m_value); | 104 animationElement->animateDiscreteType<unsigned short>(percentage, fromEnumer
ation, toEnumeration, m_value); |
| 115 } | 105 } |
| 116 | 106 |
| 117 float SVGEnumerationBase::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBa
se>, SVGElement*) | 107 float SVGEnumerationBase::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBa
se>, SVGElement*) |
| 118 { | 108 { |
| 119 // No paced animations for boolean. | 109 // No paced animations for boolean. |
| 120 return -1; | 110 return -1; |
| 121 } | 111 } |
| 122 | 112 |
| 123 } | 113 } |
| OLD | NEW |