| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007, 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 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2010. 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 return point.release(); | 110 return point.release(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 float SVGAngle::value() const | 113 float SVGAngle::value() const |
| 114 { | 114 { |
| 115 switch (m_unitType) { | 115 switch (m_unitType) { |
| 116 case SVG_ANGLETYPE_GRAD: | 116 case SVG_ANGLETYPE_GRAD: |
| 117 return grad2deg(m_valueInSpecifiedUnits); | 117 return grad2deg(m_valueInSpecifiedUnits); |
| 118 case SVG_ANGLETYPE_RAD: | 118 case SVG_ANGLETYPE_RAD: |
| 119 return rad2deg(m_valueInSpecifiedUnits); | 119 return rad2deg(m_valueInSpecifiedUnits); |
| 120 case SVG_ANGLETYPE_TURN: |
| 121 return turn2deg(m_valueInSpecifiedUnits); |
| 120 case SVG_ANGLETYPE_UNSPECIFIED: | 122 case SVG_ANGLETYPE_UNSPECIFIED: |
| 121 case SVG_ANGLETYPE_UNKNOWN: | 123 case SVG_ANGLETYPE_UNKNOWN: |
| 122 case SVG_ANGLETYPE_DEG: | 124 case SVG_ANGLETYPE_DEG: |
| 123 return m_valueInSpecifiedUnits; | 125 return m_valueInSpecifiedUnits; |
| 124 } | 126 } |
| 125 | 127 |
| 126 ASSERT_NOT_REACHED(); | 128 ASSERT_NOT_REACHED(); |
| 127 return 0; | 129 return 0; |
| 128 } | 130 } |
| 129 | 131 |
| 130 void SVGAngle::setValue(float value) | 132 void SVGAngle::setValue(float value) |
| 131 { | 133 { |
| 132 switch (m_unitType) { | 134 switch (m_unitType) { |
| 133 case SVG_ANGLETYPE_GRAD: | 135 case SVG_ANGLETYPE_GRAD: |
| 134 m_valueInSpecifiedUnits = deg2grad(value); | 136 m_valueInSpecifiedUnits = deg2grad(value); |
| 135 break; | 137 break; |
| 136 case SVG_ANGLETYPE_RAD: | 138 case SVG_ANGLETYPE_RAD: |
| 137 m_valueInSpecifiedUnits = deg2rad(value); | 139 m_valueInSpecifiedUnits = deg2rad(value); |
| 138 break; | 140 break; |
| 141 case SVG_ANGLETYPE_TURN: |
| 142 m_valueInSpecifiedUnits = deg2turn(value); |
| 143 break; |
| 139 case SVG_ANGLETYPE_UNSPECIFIED: | 144 case SVG_ANGLETYPE_UNSPECIFIED: |
| 140 case SVG_ANGLETYPE_UNKNOWN: | 145 case SVG_ANGLETYPE_UNKNOWN: |
| 141 case SVG_ANGLETYPE_DEG: | 146 case SVG_ANGLETYPE_DEG: |
| 142 m_valueInSpecifiedUnits = value; | 147 m_valueInSpecifiedUnits = value; |
| 143 break; | 148 break; |
| 144 } | 149 } |
| 145 m_orientType->setEnumValue(SVGMarkerOrientAngle); | 150 m_orientType->setEnumValue(SVGMarkerOrientAngle); |
| 146 } | 151 } |
| 147 | 152 |
| 148 template<typename CharType> | 153 template<typename CharType> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 161 const CharType secondChar = *ptr++; | 166 const CharType secondChar = *ptr++; |
| 162 const CharType thirdChar = *ptr++; | 167 const CharType thirdChar = *ptr++; |
| 163 if (firstChar == 'd' && secondChar == 'e' && thirdChar == 'g') { | 168 if (firstChar == 'd' && secondChar == 'e' && thirdChar == 'g') { |
| 164 type = SVGAngle::SVG_ANGLETYPE_DEG; | 169 type = SVGAngle::SVG_ANGLETYPE_DEG; |
| 165 } else if (firstChar == 'r' && secondChar == 'a' && thirdChar == 'd') { | 170 } else if (firstChar == 'r' && secondChar == 'a' && thirdChar == 'd') { |
| 166 type = SVGAngle::SVG_ANGLETYPE_RAD; | 171 type = SVGAngle::SVG_ANGLETYPE_RAD; |
| 167 } else if (ptr != end) { | 172 } else if (ptr != end) { |
| 168 const CharType fourthChar = *ptr++; | 173 const CharType fourthChar = *ptr++; |
| 169 if (firstChar == 'g' && secondChar == 'r' && thirdChar == 'a' && fou
rthChar == 'd') | 174 if (firstChar == 'g' && secondChar == 'r' && thirdChar == 'a' && fou
rthChar == 'd') |
| 170 type = SVGAngle::SVG_ANGLETYPE_GRAD; | 175 type = SVGAngle::SVG_ANGLETYPE_GRAD; |
| 176 else if (firstChar == 't' && secondChar == 'u' && thirdChar == 'r' &
& fourthChar == 'n') |
| 177 type = SVGAngle::SVG_ANGLETYPE_TURN; |
| 171 } | 178 } |
| 172 } | 179 } |
| 173 | 180 |
| 174 if (!skipOptionalSVGSpaces(ptr, end)) | 181 if (!skipOptionalSVGSpaces(ptr, end)) |
| 175 return type; | 182 return type; |
| 176 | 183 |
| 177 return SVGAngle::SVG_ANGLETYPE_UNKNOWN; | 184 return SVGAngle::SVG_ANGLETYPE_UNKNOWN; |
| 178 } | 185 } |
| 179 | 186 |
| 180 String SVGAngle::valueAsString() const | 187 String SVGAngle::valueAsString() const |
| 181 { | 188 { |
| 182 switch (m_unitType) { | 189 switch (m_unitType) { |
| 183 case SVG_ANGLETYPE_DEG: { | 190 case SVG_ANGLETYPE_DEG: { |
| 184 DEFINE_STATIC_LOCAL(String, degString, ("deg")); | 191 DEFINE_STATIC_LOCAL(String, degString, ("deg")); |
| 185 return String::number(m_valueInSpecifiedUnits) + degString; | 192 return String::number(m_valueInSpecifiedUnits) + degString; |
| 186 } | 193 } |
| 187 case SVG_ANGLETYPE_RAD: { | 194 case SVG_ANGLETYPE_RAD: { |
| 188 DEFINE_STATIC_LOCAL(String, radString, ("rad")); | 195 DEFINE_STATIC_LOCAL(String, radString, ("rad")); |
| 189 return String::number(m_valueInSpecifiedUnits) + radString; | 196 return String::number(m_valueInSpecifiedUnits) + radString; |
| 190 } | 197 } |
| 191 case SVG_ANGLETYPE_GRAD: { | 198 case SVG_ANGLETYPE_GRAD: { |
| 192 DEFINE_STATIC_LOCAL(String, gradString, ("grad")); | 199 DEFINE_STATIC_LOCAL(String, gradString, ("grad")); |
| 193 return String::number(m_valueInSpecifiedUnits) + gradString; | 200 return String::number(m_valueInSpecifiedUnits) + gradString; |
| 194 } | 201 } |
| 202 case SVG_ANGLETYPE_TURN: { |
| 203 DEFINE_STATIC_LOCAL(String, turnString, ("turn")); |
| 204 return String::number(m_valueInSpecifiedUnits) + turnString; |
| 205 } |
| 195 case SVG_ANGLETYPE_UNSPECIFIED: | 206 case SVG_ANGLETYPE_UNSPECIFIED: |
| 196 case SVG_ANGLETYPE_UNKNOWN: | 207 case SVG_ANGLETYPE_UNKNOWN: |
| 197 return String::number(m_valueInSpecifiedUnits); | 208 return String::number(m_valueInSpecifiedUnits); |
| 198 } | 209 } |
| 199 | 210 |
| 200 ASSERT_NOT_REACHED(); | 211 ASSERT_NOT_REACHED(); |
| 201 return String(); | 212 return String(); |
| 202 } | 213 } |
| 203 | 214 |
| 204 template<typename CharType> | 215 template<typename CharType> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 { | 267 { |
| 257 if (m_unitType == SVG_ANGLETYPE_UNKNOWN) { | 268 if (m_unitType == SVG_ANGLETYPE_UNKNOWN) { |
| 258 exceptionState.throwDOMException(NotSupportedError, "Cannot convert from
unknown or invalid units."); | 269 exceptionState.throwDOMException(NotSupportedError, "Cannot convert from
unknown or invalid units."); |
| 259 return; | 270 return; |
| 260 } | 271 } |
| 261 | 272 |
| 262 if (unitType == m_unitType) | 273 if (unitType == m_unitType) |
| 263 return; | 274 return; |
| 264 | 275 |
| 265 switch (m_unitType) { | 276 switch (m_unitType) { |
| 277 case SVG_ANGLETYPE_TURN: |
| 278 switch (unitType) { |
| 279 case SVG_ANGLETYPE_GRAD: |
| 280 m_valueInSpecifiedUnits = turn2grad(m_valueInSpecifiedUnits); |
| 281 break; |
| 282 case SVG_ANGLETYPE_UNSPECIFIED: |
| 283 case SVG_ANGLETYPE_DEG: |
| 284 m_valueInSpecifiedUnits = turn2deg(m_valueInSpecifiedUnits); |
| 285 break; |
| 286 case SVG_ANGLETYPE_RAD: |
| 287 m_valueInSpecifiedUnits = deg2rad(turn2deg(m_valueInSpecifiedUnits))
; |
| 288 break; |
| 289 case SVG_ANGLETYPE_TURN: |
| 290 case SVG_ANGLETYPE_UNKNOWN: |
| 291 ASSERT_NOT_REACHED(); |
| 292 break; |
| 293 } |
| 294 break; |
| 266 case SVG_ANGLETYPE_RAD: | 295 case SVG_ANGLETYPE_RAD: |
| 267 switch (unitType) { | 296 switch (unitType) { |
| 268 case SVG_ANGLETYPE_GRAD: | 297 case SVG_ANGLETYPE_GRAD: |
| 269 m_valueInSpecifiedUnits = rad2grad(m_valueInSpecifiedUnits); | 298 m_valueInSpecifiedUnits = rad2grad(m_valueInSpecifiedUnits); |
| 270 break; | 299 break; |
| 271 case SVG_ANGLETYPE_UNSPECIFIED: | 300 case SVG_ANGLETYPE_UNSPECIFIED: |
| 272 case SVG_ANGLETYPE_DEG: | 301 case SVG_ANGLETYPE_DEG: |
| 273 m_valueInSpecifiedUnits = rad2deg(m_valueInSpecifiedUnits); | 302 m_valueInSpecifiedUnits = rad2deg(m_valueInSpecifiedUnits); |
| 274 break; | 303 break; |
| 304 case SVG_ANGLETYPE_TURN: |
| 305 m_valueInSpecifiedUnits = deg2turn(rad2deg(m_valueInSpecifiedUnits))
; |
| 306 break; |
| 275 case SVG_ANGLETYPE_RAD: | 307 case SVG_ANGLETYPE_RAD: |
| 276 case SVG_ANGLETYPE_UNKNOWN: | 308 case SVG_ANGLETYPE_UNKNOWN: |
| 277 ASSERT_NOT_REACHED(); | 309 ASSERT_NOT_REACHED(); |
| 278 break; | 310 break; |
| 279 } | 311 } |
| 280 break; | 312 break; |
| 281 case SVG_ANGLETYPE_GRAD: | 313 case SVG_ANGLETYPE_GRAD: |
| 282 switch (unitType) { | 314 switch (unitType) { |
| 283 case SVG_ANGLETYPE_RAD: | 315 case SVG_ANGLETYPE_RAD: |
| 284 m_valueInSpecifiedUnits = grad2rad(m_valueInSpecifiedUnits); | 316 m_valueInSpecifiedUnits = grad2rad(m_valueInSpecifiedUnits); |
| 285 break; | 317 break; |
| 286 case SVG_ANGLETYPE_UNSPECIFIED: | 318 case SVG_ANGLETYPE_UNSPECIFIED: |
| 287 case SVG_ANGLETYPE_DEG: | 319 case SVG_ANGLETYPE_DEG: |
| 288 m_valueInSpecifiedUnits = grad2deg(m_valueInSpecifiedUnits); | 320 m_valueInSpecifiedUnits = grad2deg(m_valueInSpecifiedUnits); |
| 289 break; | 321 break; |
| 322 case SVG_ANGLETYPE_TURN: |
| 323 m_valueInSpecifiedUnits = grad2turn(m_valueInSpecifiedUnits); |
| 324 break; |
| 290 case SVG_ANGLETYPE_GRAD: | 325 case SVG_ANGLETYPE_GRAD: |
| 291 case SVG_ANGLETYPE_UNKNOWN: | 326 case SVG_ANGLETYPE_UNKNOWN: |
| 292 ASSERT_NOT_REACHED(); | 327 ASSERT_NOT_REACHED(); |
| 293 break; | 328 break; |
| 294 } | 329 } |
| 295 break; | 330 break; |
| 296 case SVG_ANGLETYPE_UNSPECIFIED: | 331 case SVG_ANGLETYPE_UNSPECIFIED: |
| 297 // Spec: For angles, a unitless value is treated the same as if degrees
were specified. | 332 // Spec: For angles, a unitless value is treated the same as if degrees
were specified. |
| 298 case SVG_ANGLETYPE_DEG: | 333 case SVG_ANGLETYPE_DEG: |
| 299 switch (unitType) { | 334 switch (unitType) { |
| 300 case SVG_ANGLETYPE_RAD: | 335 case SVG_ANGLETYPE_RAD: |
| 301 m_valueInSpecifiedUnits = deg2rad(m_valueInSpecifiedUnits); | 336 m_valueInSpecifiedUnits = deg2rad(m_valueInSpecifiedUnits); |
| 302 break; | 337 break; |
| 303 case SVG_ANGLETYPE_GRAD: | 338 case SVG_ANGLETYPE_GRAD: |
| 304 m_valueInSpecifiedUnits = deg2grad(m_valueInSpecifiedUnits); | 339 m_valueInSpecifiedUnits = deg2grad(m_valueInSpecifiedUnits); |
| 305 break; | 340 break; |
| 341 case SVG_ANGLETYPE_TURN: |
| 342 m_valueInSpecifiedUnits = deg2turn(m_valueInSpecifiedUnits); |
| 343 break; |
| 306 case SVG_ANGLETYPE_UNSPECIFIED: | 344 case SVG_ANGLETYPE_UNSPECIFIED: |
| 345 case SVG_ANGLETYPE_DEG: |
| 307 break; | 346 break; |
| 308 case SVG_ANGLETYPE_DEG: | |
| 309 case SVG_ANGLETYPE_UNKNOWN: | 347 case SVG_ANGLETYPE_UNKNOWN: |
| 310 ASSERT_NOT_REACHED(); | 348 ASSERT_NOT_REACHED(); |
| 311 break; | 349 break; |
| 312 } | 350 } |
| 313 break; | 351 break; |
| 314 case SVG_ANGLETYPE_UNKNOWN: | 352 case SVG_ANGLETYPE_UNKNOWN: |
| 315 ASSERT_NOT_REACHED(); | 353 ASSERT_NOT_REACHED(); |
| 316 break; | 354 break; |
| 317 } | 355 } |
| 318 | 356 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 | 427 |
| 390 void SVGAngle::orientTypeChanged() | 428 void SVGAngle::orientTypeChanged() |
| 391 { | 429 { |
| 392 if (orientType()->enumValue() == SVGMarkerOrientAuto) { | 430 if (orientType()->enumValue() == SVGMarkerOrientAuto) { |
| 393 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; | 431 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; |
| 394 m_valueInSpecifiedUnits = 0; | 432 m_valueInSpecifiedUnits = 0; |
| 395 } | 433 } |
| 396 } | 434 } |
| 397 | 435 |
| 398 } | 436 } |
| OLD | NEW |