| 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 24 matching lines...) Expand all Loading... |
| 35 namespace WebCore { | 35 namespace WebCore { |
| 36 | 36 |
| 37 static inline unsigned int storeUnit(SVGLengthMode mode, SVGLengthType type) | 37 static inline unsigned int storeUnit(SVGLengthMode mode, SVGLengthType type) |
| 38 { | 38 { |
| 39 return (mode << 4) | type; | 39 return (mode << 4) | type; |
| 40 } | 40 } |
| 41 | 41 |
| 42 static inline SVGLengthMode extractMode(unsigned int unit) | 42 static inline SVGLengthMode extractMode(unsigned int unit) |
| 43 { | 43 { |
| 44 unsigned int mode = unit >> 4; | 44 unsigned int mode = unit >> 4; |
| 45 return static_cast<SVGLengthMode>(mode); | 45 return toSVGLengthMode(mode); |
| 46 } | 46 } |
| 47 | 47 |
| 48 static inline SVGLengthType extractType(unsigned int unit) | 48 static inline SVGLengthType extractType(unsigned int unit) |
| 49 { | 49 { |
| 50 unsigned int mode = unit >> 4; | 50 unsigned int mode = unit >> 4; |
| 51 unsigned int type = unit ^ (mode << 4); | 51 unsigned int type = unit ^ (mode << 4); |
| 52 return static_cast<SVGLengthType>(type); | 52 return toSVGLengthType(type); |
| 53 } | 53 } |
| 54 | 54 |
| 55 static inline String lengthTypeToString(SVGLengthType type) | 55 static inline String lengthTypeToString(SVGLengthType type) |
| 56 { | 56 { |
| 57 switch (type) { | 57 switch (type) { |
| 58 case LengthTypeUnknown: | 58 case LengthTypeUnknown: |
| 59 case LengthTypeNumber: | 59 case LengthTypeNumber: |
| 60 return ""; | 60 return ""; |
| 61 case LengthTypePercentage: | 61 case LengthTypePercentage: |
| 62 return "%"; | 62 return "%"; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 return String::number(m_valueInSpecifiedUnits) + lengthTypeToString(extractT
ype(m_unit)); | 259 return String::number(m_valueInSpecifiedUnits) + lengthTypeToString(extractT
ype(m_unit)); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void SVGLength::newValueSpecifiedUnits(unsigned short type, float value, Excepti
onState& es) | 262 void SVGLength::newValueSpecifiedUnits(unsigned short type, float value, Excepti
onState& es) |
| 263 { | 263 { |
| 264 if (type == LengthTypeUnknown || type > LengthTypePC) { | 264 if (type == LengthTypeUnknown || type > LengthTypePC) { |
| 265 es.throwDOMException(NotSupportedError); | 265 es.throwDOMException(NotSupportedError); |
| 266 return; | 266 return; |
| 267 } | 267 } |
| 268 | 268 |
| 269 m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type)); | 269 m_unit = storeUnit(extractMode(m_unit), toSVGLengthType(type)); |
| 270 m_valueInSpecifiedUnits = value; | 270 m_valueInSpecifiedUnits = value; |
| 271 } | 271 } |
| 272 | 272 |
| 273 void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGLengthCont
ext& context, ExceptionState& es) | 273 void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGLengthCont
ext& context, ExceptionState& es) |
| 274 { | 274 { |
| 275 if (type == LengthTypeUnknown || type > LengthTypePC) { | 275 if (type == LengthTypeUnknown || type > LengthTypePC) { |
| 276 es.throwDOMException(NotSupportedError); | 276 es.throwDOMException(NotSupportedError); |
| 277 return; | 277 return; |
| 278 } | 278 } |
| 279 | 279 |
| 280 float valueInUserUnits = value(context, es); | 280 float valueInUserUnits = value(context, es); |
| 281 if (es.hadException()) | 281 if (es.hadException()) |
| 282 return; | 282 return; |
| 283 | 283 |
| 284 unsigned int originalUnitAndType = m_unit; | 284 unsigned int originalUnitAndType = m_unit; |
| 285 m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type)); | 285 m_unit = storeUnit(extractMode(m_unit), toSVGLengthType(type)); |
| 286 setValue(valueInUserUnits, context, es); | 286 setValue(valueInUserUnits, context, es); |
| 287 if (!es.hadException()) | 287 if (!es.hadException()) |
| 288 return; | 288 return; |
| 289 | 289 |
| 290 // Eventually restore old unit and type | 290 // Eventually restore old unit and type |
| 291 m_unit = originalUnitAndType; | 291 m_unit = originalUnitAndType; |
| 292 } | 292 } |
| 293 | 293 |
| 294 SVGLength SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue* value) | 294 SVGLength SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue* value) |
| 295 { | 295 { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 s_lengthModeMap.set(SVGNames::startOffsetAttr, LengthModeWidth); | 415 s_lengthModeMap.set(SVGNames::startOffsetAttr, LengthModeWidth); |
| 416 } | 416 } |
| 417 | 417 |
| 418 if (s_lengthModeMap.contains(attrName)) | 418 if (s_lengthModeMap.contains(attrName)) |
| 419 return s_lengthModeMap.get(attrName); | 419 return s_lengthModeMap.get(attrName); |
| 420 | 420 |
| 421 return LengthModeOther; | 421 return LengthModeOther; |
| 422 } | 422 } |
| 423 | 423 |
| 424 } | 424 } |
| OLD | NEW |