| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 SVGLengthType fromType = from.unitType(); | 107 SVGLengthType fromType = from.unitType(); |
| 108 if ((from.isZero() && isZero()) | 108 if ((from.isZero() && isZero()) |
| 109 || fromType == LengthTypeUnknown | 109 || fromType == LengthTypeUnknown |
| 110 || toType == LengthTypeUnknown | 110 || toType == LengthTypeUnknown |
| 111 || (!from.isZero() && fromType != LengthTypePercentage && toType ==
LengthTypePercentage) | 111 || (!from.isZero() && fromType != LengthTypePercentage && toType ==
LengthTypePercentage) |
| 112 || (!isZero() && fromType == LengthTypePercentage && toType != Lengt
hTypePercentage) | 112 || (!isZero() && fromType == LengthTypePercentage && toType != Lengt
hTypePercentage) |
| 113 || (!from.isZero() && !isZero() && (fromType == LengthTypeEMS || fro
mType == LengthTypeEXS) && fromType != toType)) | 113 || (!from.isZero() && !isZero() && (fromType == LengthTypeEMS || fro
mType == LengthTypeEXS) && fromType != toType)) |
| 114 return *this; | 114 return *this; |
| 115 | 115 |
| 116 SVGLength length; | 116 SVGLength length; |
| 117 TrackExceptionState es; | 117 TrackExceptionState exceptionState; |
| 118 | 118 |
| 119 if (fromType == LengthTypePercentage || toType == LengthTypePercentage)
{ | 119 if (fromType == LengthTypePercentage || toType == LengthTypePercentage)
{ |
| 120 float fromPercent = from.valueAsPercentage() * 100; | 120 float fromPercent = from.valueAsPercentage() * 100; |
| 121 float toPercent = valueAsPercentage() * 100; | 121 float toPercent = valueAsPercentage() * 100; |
| 122 length.newValueSpecifiedUnits(LengthTypePercentage, WebCore::blend(f
romPercent, toPercent, progress), es); | 122 length.newValueSpecifiedUnits(LengthTypePercentage, WebCore::blend(f
romPercent, toPercent, progress), exceptionState); |
| 123 if (es.hadException()) | 123 if (exceptionState.hadException()) |
| 124 return SVGLength(); | 124 return SVGLength(); |
| 125 return length; | 125 return length; |
| 126 } | 126 } |
| 127 | 127 |
| 128 if (fromType == toType || from.isZero() || isZero() || fromType == Lengt
hTypeEMS || fromType == LengthTypeEXS) { | 128 if (fromType == toType || from.isZero() || isZero() || fromType == Lengt
hTypeEMS || fromType == LengthTypeEXS) { |
| 129 float fromValue = from.valueInSpecifiedUnits(); | 129 float fromValue = from.valueInSpecifiedUnits(); |
| 130 float toValue = valueInSpecifiedUnits(); | 130 float toValue = valueInSpecifiedUnits(); |
| 131 if (isZero()) | 131 if (isZero()) |
| 132 length.newValueSpecifiedUnits(fromType, WebCore::blend(fromValue
, toValue, progress), es); | 132 length.newValueSpecifiedUnits(fromType, WebCore::blend(fromValue
, toValue, progress), exceptionState); |
| 133 else | 133 else |
| 134 length.newValueSpecifiedUnits(toType, WebCore::blend(fromValue,
toValue, progress), es); | 134 length.newValueSpecifiedUnits(toType, WebCore::blend(fromValue,
toValue, progress), exceptionState); |
| 135 if (es.hadException()) | 135 if (exceptionState.hadException()) |
| 136 return SVGLength(); | 136 return SVGLength(); |
| 137 return length; | 137 return length; |
| 138 } | 138 } |
| 139 | 139 |
| 140 ASSERT(!isRelative()); | 140 ASSERT(!isRelative()); |
| 141 ASSERT(!from.isRelative()); | 141 ASSERT(!from.isRelative()); |
| 142 | 142 |
| 143 SVGLengthContext nonRelativeLengthContext(0); | 143 SVGLengthContext nonRelativeLengthContext(0); |
| 144 float fromValueInUserUnits = nonRelativeLengthContext.convertValueToUser
Units(from.valueInSpecifiedUnits(), from.unitMode(), fromType, es); | 144 float fromValueInUserUnits = nonRelativeLengthContext.convertValueToUser
Units(from.valueInSpecifiedUnits(), from.unitMode(), fromType, exceptionState); |
| 145 if (es.hadException()) | 145 if (exceptionState.hadException()) |
| 146 return SVGLength(); | 146 return SVGLength(); |
| 147 | 147 |
| 148 float fromValue = nonRelativeLengthContext.convertValueFromUserUnits(fro
mValueInUserUnits, unitMode(), toType, es); | 148 float fromValue = nonRelativeLengthContext.convertValueFromUserUnits(fro
mValueInUserUnits, unitMode(), toType, exceptionState); |
| 149 if (es.hadException()) | 149 if (exceptionState.hadException()) |
| 150 return SVGLength(); | 150 return SVGLength(); |
| 151 | 151 |
| 152 float toValue = valueInSpecifiedUnits(); | 152 float toValue = valueInSpecifiedUnits(); |
| 153 length.newValueSpecifiedUnits(toType, WebCore::blend(fromValue, toValue,
progress), es); | 153 length.newValueSpecifiedUnits(toType, WebCore::blend(fromValue, toValue,
progress), exceptionState); |
| 154 | 154 |
| 155 if (es.hadException()) | 155 if (exceptionState.hadException()) |
| 156 return SVGLength(); | 156 return SVGLength(); |
| 157 return length; | 157 return length; |
| 158 } | 158 } |
| 159 | 159 |
| 160 private: | 160 private: |
| 161 float m_valueInSpecifiedUnits; | 161 float m_valueInSpecifiedUnits; |
| 162 unsigned int m_unit; | 162 unsigned int m_unit; |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 template<> | 165 template<> |
| 166 struct SVGPropertyTraits<SVGLength> { | 166 struct SVGPropertyTraits<SVGLength> { |
| 167 static SVGLength initialValue() { return SVGLength(); } | 167 static SVGLength initialValue() { return SVGLength(); } |
| 168 static String toString(const SVGLength& type) { return type.valueAsString();
} | 168 static String toString(const SVGLength& type) { return type.valueAsString();
} |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 | 171 |
| 172 } // namespace WebCore | 172 } // namespace WebCore |
| 173 | 173 |
| 174 #endif // SVGLength_h | 174 #endif // SVGLength_h |
| OLD | NEW |