OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2007 Apple Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 && m_valueInSpecifiedUnits == other.m_valueInSpecifiedUnits; | 159 && m_valueInSpecifiedUnits == other.m_valueInSpecifiedUnits; |
160 } | 160 } |
161 | 161 |
162 float SVGLength::value(const SVGLengthContext& context) const | 162 float SVGLength::value(const SVGLengthContext& context) const |
163 { | 163 { |
164 return context.convertValueToUserUnits(m_valueInSpecifiedUnits, unitMode(),
unitType()); | 164 return context.convertValueToUserUnits(m_valueInSpecifiedUnits, unitMode(),
unitType()); |
165 } | 165 } |
166 | 166 |
167 void SVGLength::setValue(float value, const SVGLengthContext& context) | 167 void SVGLength::setValue(float value, const SVGLengthContext& context) |
168 { | 168 { |
169 // LengthTypePercentage is represented with 100% = 100.0. Good for accuracy
but could eventually be changed. | |
170 if (m_unitType == LengthTypePercentage) | |
171 value = value / 100; | |
172 | |
173 m_valueInSpecifiedUnits = context.convertValueFromUserUnits(value, unitMode(
), unitType()); | 169 m_valueInSpecifiedUnits = context.convertValueFromUserUnits(value, unitMode(
), unitType()); |
174 } | 170 } |
175 | 171 |
176 void SVGLength::setUnitType(SVGLengthType type) | 172 void SVGLength::setUnitType(SVGLengthType type) |
177 { | 173 { |
178 ASSERT(type != LengthTypeUnknown && type <= LengthTypePC); | 174 ASSERT(type != LengthTypeUnknown && type <= LengthTypePC); |
179 m_unitType = type; | 175 m_unitType = type; |
180 } | 176 } |
181 | 177 |
182 float SVGLength::valueAsPercentage() const | 178 float SVGLength::valueAsPercentage() const |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 458 |
463 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal
ue, SVGElement* contextElement) | 459 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal
ue, SVGElement* contextElement) |
464 { | 460 { |
465 SVGLengthContext lengthContext(contextElement); | 461 SVGLengthContext lengthContext(contextElement); |
466 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); | 462 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); |
467 | 463 |
468 return fabsf(toLength->value(lengthContext) - value(lengthContext)); | 464 return fabsf(toLength->value(lengthContext) - value(lengthContext)); |
469 } | 465 } |
470 | 466 |
471 } | 467 } |
OLD | NEW |