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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 case LengthTypeCM: | 54 case LengthTypeCM: |
55 return "cm"; | 55 return "cm"; |
56 case LengthTypeMM: | 56 case LengthTypeMM: |
57 return "mm"; | 57 return "mm"; |
58 case LengthTypeIN: | 58 case LengthTypeIN: |
59 return "in"; | 59 return "in"; |
60 case LengthTypePT: | 60 case LengthTypePT: |
61 return "pt"; | 61 return "pt"; |
62 case LengthTypePC: | 62 case LengthTypePC: |
63 return "pc"; | 63 return "pc"; |
| 64 case LengthTypeREMS: |
| 65 return "rem"; |
64 } | 66 } |
65 | 67 |
66 ASSERT_NOT_REACHED(); | 68 ASSERT_NOT_REACHED(); |
67 return ""; | 69 return ""; |
68 } | 70 } |
69 | 71 |
70 template<typename CharType> | 72 template<typename CharType> |
71 SVGLengthType stringToLengthType(const CharType*& ptr, const CharType* end) | 73 SVGLengthType stringToLengthType(const CharType*& ptr, const CharType* end) |
72 { | 74 { |
73 if (ptr == end) | 75 if (ptr == end) |
(...skipping 14 matching lines...) Expand all Loading... |
88 type = LengthTypePX; | 90 type = LengthTypePX; |
89 if (secondChar == 't') | 91 if (secondChar == 't') |
90 type = LengthTypePT; | 92 type = LengthTypePT; |
91 if (secondChar == 'c') | 93 if (secondChar == 'c') |
92 type = LengthTypePC; | 94 type = LengthTypePC; |
93 } else if (firstChar == 'e') { | 95 } else if (firstChar == 'e') { |
94 if (secondChar == 'm') | 96 if (secondChar == 'm') |
95 type = LengthTypeEMS; | 97 type = LengthTypeEMS; |
96 if (secondChar == 'x') | 98 if (secondChar == 'x') |
97 type = LengthTypeEXS; | 99 type = LengthTypeEXS; |
| 100 } else if (firstChar == 'r') { |
| 101 if (secondChar == 'e') { |
| 102 const CharType thirdChar = *ptr++; |
| 103 if (thirdChar == 'm') |
| 104 type = LengthTypeREMS; |
| 105 } |
98 } else if (firstChar == 'c' && secondChar == 'm') { | 106 } else if (firstChar == 'c' && secondChar == 'm') { |
99 type = LengthTypeCM; | 107 type = LengthTypeCM; |
100 } else if (firstChar == 'm' && secondChar == 'm') { | 108 } else if (firstChar == 'm' && secondChar == 'm') { |
101 type = LengthTypeMM; | 109 type = LengthTypeMM; |
102 } else if (firstChar == 'i' && secondChar == 'n') { | 110 } else if (firstChar == 'i' && secondChar == 'n') { |
103 type = LengthTypeIN; | 111 type = LengthTypeIN; |
104 } else if (isHTMLSpace<CharType>(firstChar) && isHTMLSpace<CharType>(sec
ondChar)) { | 112 } else if (isHTMLSpace<CharType>(firstChar) && isHTMLSpace<CharType>(sec
ondChar)) { |
105 type = LengthTypeNumber; | 113 type = LengthTypeNumber; |
106 } | 114 } |
107 } | 115 } |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 break; | 301 break; |
294 case CSSPrimitiveValue::CSS_MM: | 302 case CSSPrimitiveValue::CSS_MM: |
295 svgType = LengthTypeMM; | 303 svgType = LengthTypeMM; |
296 break; | 304 break; |
297 case CSSPrimitiveValue::CSS_IN: | 305 case CSSPrimitiveValue::CSS_IN: |
298 svgType = LengthTypeIN; | 306 svgType = LengthTypeIN; |
299 break; | 307 break; |
300 case CSSPrimitiveValue::CSS_PT: | 308 case CSSPrimitiveValue::CSS_PT: |
301 svgType = LengthTypePT; | 309 svgType = LengthTypePT; |
302 break; | 310 break; |
| 311 case CSSPrimitiveValue::CSS_REMS: |
| 312 svgType = LengthTypeREMS; |
| 313 break; |
303 default: | 314 default: |
304 ASSERT(value->primitiveType() == CSSPrimitiveValue::CSS_PC); | 315 ASSERT(value->primitiveType() == CSSPrimitiveValue::CSS_PC); |
305 svgType = LengthTypePC; | 316 svgType = LengthTypePC; |
306 break; | 317 break; |
307 }; | 318 }; |
308 | 319 |
309 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(); | 320 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(); |
310 length->newValueSpecifiedUnits(svgType, value->getFloatValue()); | 321 length->newValueSpecifiedUnits(svgType, value->getFloatValue()); |
311 return length.release(); | 322 return length.release(); |
312 } | 323 } |
(...skipping 29 matching lines...) Expand all Loading... |
342 break; | 353 break; |
343 case LengthTypeIN: | 354 case LengthTypeIN: |
344 cssType = CSSPrimitiveValue::CSS_IN; | 355 cssType = CSSPrimitiveValue::CSS_IN; |
345 break; | 356 break; |
346 case LengthTypePT: | 357 case LengthTypePT: |
347 cssType = CSSPrimitiveValue::CSS_PT; | 358 cssType = CSSPrimitiveValue::CSS_PT; |
348 break; | 359 break; |
349 case LengthTypePC: | 360 case LengthTypePC: |
350 cssType = CSSPrimitiveValue::CSS_PC; | 361 cssType = CSSPrimitiveValue::CSS_PC; |
351 break; | 362 break; |
| 363 case LengthTypeREMS: |
| 364 cssType = CSSPrimitiveValue::CSS_REMS; |
| 365 break; |
352 }; | 366 }; |
353 | 367 |
354 return CSSPrimitiveValue::create(length->valueInSpecifiedUnits(), cssType); | 368 return CSSPrimitiveValue::create(length->valueInSpecifiedUnits(), cssType); |
355 } | 369 } |
356 | 370 |
357 SVGLengthMode SVGLength::lengthModeForAnimatedLengthAttribute(const QualifiedNam
e& attrName) | 371 SVGLengthMode SVGLength::lengthModeForAnimatedLengthAttribute(const QualifiedNam
e& attrName) |
358 { | 372 { |
359 typedef HashMap<QualifiedName, SVGLengthMode> LengthModeForLengthAttributeMa
p; | 373 typedef HashMap<QualifiedName, SVGLengthMode> LengthModeForLengthAttributeMa
p; |
360 DEFINE_STATIC_LOCAL(LengthModeForLengthAttributeMap, s_lengthModeMap, ()); | 374 DEFINE_STATIC_LOCAL(LengthModeForLengthAttributeMap, s_lengthModeMap, ()); |
361 | 375 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 { | 409 { |
396 RefPtrWillBeRawPtr<SVGLength> from = passFrom; | 410 RefPtrWillBeRawPtr<SVGLength> from = passFrom; |
397 | 411 |
398 SVGLengthType toType = unitType(); | 412 SVGLengthType toType = unitType(); |
399 SVGLengthType fromType = from->unitType(); | 413 SVGLengthType fromType = from->unitType(); |
400 if ((from->isZero() && isZero()) | 414 if ((from->isZero() && isZero()) |
401 || fromType == LengthTypeUnknown | 415 || fromType == LengthTypeUnknown |
402 || toType == LengthTypeUnknown | 416 || toType == LengthTypeUnknown |
403 || (!from->isZero() && fromType != LengthTypePercentage && toType == Len
gthTypePercentage) | 417 || (!from->isZero() && fromType != LengthTypePercentage && toType == Len
gthTypePercentage) |
404 || (!isZero() && fromType == LengthTypePercentage && toType != LengthTyp
ePercentage) | 418 || (!isZero() && fromType == LengthTypePercentage && toType != LengthTyp
ePercentage) |
405 || (!from->isZero() && !isZero() && (fromType == LengthTypeEMS || fromTy
pe == LengthTypeEXS) && fromType != toType)) | 419 || (!from->isZero() && !isZero() && (fromType == LengthTypeEMS || fromTy
pe == LengthTypeEXS || fromType == LengthTypeREMS) && fromType != toType)) |
406 return clone(); | 420 return clone(); |
407 | 421 |
408 RefPtrWillBeRawPtr<SVGLength> length = create(); | 422 RefPtrWillBeRawPtr<SVGLength> length = create(); |
409 | 423 |
410 if (fromType == LengthTypePercentage || toType == LengthTypePercentage) { | 424 if (fromType == LengthTypePercentage || toType == LengthTypePercentage) { |
411 float fromPercent = from->valueAsPercentage100(); | 425 float fromPercent = from->valueAsPercentage100(); |
412 float toPercent = valueAsPercentage100(); | 426 float toPercent = valueAsPercentage100(); |
413 length->newValueSpecifiedUnits(LengthTypePercentage, blink::blend(fromPe
rcent, toPercent, progress)); | 427 length->newValueSpecifiedUnits(LengthTypePercentage, blink::blend(fromPe
rcent, toPercent, progress)); |
414 return length; | 428 return length; |
415 } | 429 } |
416 | 430 |
417 if (fromType == toType || from->isZero() || isZero() || fromType == LengthTy
peEMS || fromType == LengthTypeEXS) { | 431 if (fromType == toType || from->isZero() || isZero() || fromType == LengthTy
peEMS || fromType == LengthTypeEXS || fromType == LengthTypeREMS) { |
418 float fromValue = from->valueInSpecifiedUnits(); | 432 float fromValue = from->valueInSpecifiedUnits(); |
419 float toValue = valueInSpecifiedUnits(); | 433 float toValue = valueInSpecifiedUnits(); |
420 if (isZero()) | 434 if (isZero()) |
421 length->newValueSpecifiedUnits(fromType, blink::blend(fromValue, toV
alue, progress)); | 435 length->newValueSpecifiedUnits(fromType, blink::blend(fromValue, toV
alue, progress)); |
422 else | 436 else |
423 length->newValueSpecifiedUnits(toType, blink::blend(fromValue, toVal
ue, progress)); | 437 length->newValueSpecifiedUnits(toType, blink::blend(fromValue, toVal
ue, progress)); |
424 return length; | 438 return length; |
425 } | 439 } |
426 | 440 |
427 ASSERT(!isRelative()); | 441 ASSERT(!isRelative()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 | 473 |
460 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal
ue, SVGElement* contextElement) | 474 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal
ue, SVGElement* contextElement) |
461 { | 475 { |
462 SVGLengthContext lengthContext(contextElement); | 476 SVGLengthContext lengthContext(contextElement); |
463 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); | 477 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); |
464 | 478 |
465 return fabsf(toLength->value(lengthContext) - value(lengthContext)); | 479 return fabsf(toLength->value(lengthContext) - value(lengthContext)); |
466 } | 480 } |
467 | 481 |
468 } | 482 } |
OLD | NEW |