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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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: | 64 case LengthTypeREMS: |
65 return "rem"; | 65 return "rem"; |
| 66 case LengthTypeCHS: |
| 67 return "ch"; |
66 } | 68 } |
67 | 69 |
68 ASSERT_NOT_REACHED(); | 70 ASSERT_NOT_REACHED(); |
69 return ""; | 71 return ""; |
70 } | 72 } |
71 | 73 |
72 template<typename CharType> | 74 template<typename CharType> |
73 SVGLengthType stringToLengthType(const CharType*& ptr, const CharType* end) | 75 SVGLengthType stringToLengthType(const CharType*& ptr, const CharType* end) |
74 { | 76 { |
75 if (ptr == end) | 77 if (ptr == end) |
(...skipping 20 matching lines...) Expand all Loading... |
96 if (secondChar == 'm') | 98 if (secondChar == 'm') |
97 type = LengthTypeEMS; | 99 type = LengthTypeEMS; |
98 if (secondChar == 'x') | 100 if (secondChar == 'x') |
99 type = LengthTypeEXS; | 101 type = LengthTypeEXS; |
100 } else if (firstChar == 'r') { | 102 } else if (firstChar == 'r') { |
101 if (secondChar == 'e' && ptr < end) { | 103 if (secondChar == 'e' && ptr < end) { |
102 const CharType thirdChar = *ptr++; | 104 const CharType thirdChar = *ptr++; |
103 if (thirdChar == 'm') | 105 if (thirdChar == 'm') |
104 type = LengthTypeREMS; | 106 type = LengthTypeREMS; |
105 } | 107 } |
106 } else if (firstChar == 'c' && secondChar == 'm') { | 108 } else if (firstChar == 'c') { |
107 type = LengthTypeCM; | 109 if (secondChar == 'h') |
| 110 type = LengthTypeCHS; |
| 111 if (secondChar == 'm') |
| 112 type = LengthTypeCM; |
108 } else if (firstChar == 'm' && secondChar == 'm') { | 113 } else if (firstChar == 'm' && secondChar == 'm') { |
109 type = LengthTypeMM; | 114 type = LengthTypeMM; |
110 } else if (firstChar == 'i' && secondChar == 'n') { | 115 } else if (firstChar == 'i' && secondChar == 'n') { |
111 type = LengthTypeIN; | 116 type = LengthTypeIN; |
112 } else if (isHTMLSpace<CharType>(firstChar) && isHTMLSpace<CharType>(sec
ondChar)) { | 117 } else if (isHTMLSpace<CharType>(firstChar) && isHTMLSpace<CharType>(sec
ondChar)) { |
113 type = LengthTypeNumber; | 118 type = LengthTypeNumber; |
114 } | 119 } |
115 } | 120 } |
116 | 121 |
117 if (!skipOptionalSVGSpaces(ptr, end)) | 122 if (!skipOptionalSVGSpaces(ptr, end)) |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 break; | 309 break; |
305 case CSSPrimitiveValue::CSS_IN: | 310 case CSSPrimitiveValue::CSS_IN: |
306 svgType = LengthTypeIN; | 311 svgType = LengthTypeIN; |
307 break; | 312 break; |
308 case CSSPrimitiveValue::CSS_PT: | 313 case CSSPrimitiveValue::CSS_PT: |
309 svgType = LengthTypePT; | 314 svgType = LengthTypePT; |
310 break; | 315 break; |
311 case CSSPrimitiveValue::CSS_REMS: | 316 case CSSPrimitiveValue::CSS_REMS: |
312 svgType = LengthTypeREMS; | 317 svgType = LengthTypeREMS; |
313 break; | 318 break; |
| 319 case CSSPrimitiveValue::CSS_CHS: |
| 320 svgType = LengthTypeCHS; |
| 321 break; |
314 default: | 322 default: |
315 ASSERT(value->primitiveType() == CSSPrimitiveValue::CSS_PC); | 323 ASSERT(value->primitiveType() == CSSPrimitiveValue::CSS_PC); |
316 svgType = LengthTypePC; | 324 svgType = LengthTypePC; |
317 break; | 325 break; |
318 }; | 326 }; |
319 | 327 |
320 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(); | 328 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(); |
321 length->newValueSpecifiedUnits(svgType, value->getFloatValue()); | 329 length->newValueSpecifiedUnits(svgType, value->getFloatValue()); |
322 return length.release(); | 330 return length.release(); |
323 } | 331 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 break; | 364 break; |
357 case LengthTypePT: | 365 case LengthTypePT: |
358 cssType = CSSPrimitiveValue::CSS_PT; | 366 cssType = CSSPrimitiveValue::CSS_PT; |
359 break; | 367 break; |
360 case LengthTypePC: | 368 case LengthTypePC: |
361 cssType = CSSPrimitiveValue::CSS_PC; | 369 cssType = CSSPrimitiveValue::CSS_PC; |
362 break; | 370 break; |
363 case LengthTypeREMS: | 371 case LengthTypeREMS: |
364 cssType = CSSPrimitiveValue::CSS_REMS; | 372 cssType = CSSPrimitiveValue::CSS_REMS; |
365 break; | 373 break; |
| 374 case LengthTypeCHS: |
| 375 cssType = CSSPrimitiveValue::CSS_CHS; |
| 376 break; |
366 }; | 377 }; |
367 | 378 |
368 return CSSPrimitiveValue::create(length->valueInSpecifiedUnits(), cssType); | 379 return CSSPrimitiveValue::create(length->valueInSpecifiedUnits(), cssType); |
369 } | 380 } |
370 | 381 |
371 SVGLengthMode SVGLength::lengthModeForAnimatedLengthAttribute(const QualifiedNam
e& attrName) | 382 SVGLengthMode SVGLength::lengthModeForAnimatedLengthAttribute(const QualifiedNam
e& attrName) |
372 { | 383 { |
373 typedef HashMap<QualifiedName, SVGLengthMode> LengthModeForLengthAttributeMa
p; | 384 typedef HashMap<QualifiedName, SVGLengthMode> LengthModeForLengthAttributeMa
p; |
374 DEFINE_STATIC_LOCAL(LengthModeForLengthAttributeMap, s_lengthModeMap, ()); | 385 DEFINE_STATIC_LOCAL(LengthModeForLengthAttributeMap, s_lengthModeMap, ()); |
375 | 386 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 { | 420 { |
410 RefPtrWillBeRawPtr<SVGLength> from = passFrom; | 421 RefPtrWillBeRawPtr<SVGLength> from = passFrom; |
411 | 422 |
412 SVGLengthType toType = unitType(); | 423 SVGLengthType toType = unitType(); |
413 SVGLengthType fromType = from->unitType(); | 424 SVGLengthType fromType = from->unitType(); |
414 if ((from->isZero() && isZero()) | 425 if ((from->isZero() && isZero()) |
415 || fromType == LengthTypeUnknown | 426 || fromType == LengthTypeUnknown |
416 || toType == LengthTypeUnknown | 427 || toType == LengthTypeUnknown |
417 || (!from->isZero() && fromType != LengthTypePercentage && toType == Len
gthTypePercentage) | 428 || (!from->isZero() && fromType != LengthTypePercentage && toType == Len
gthTypePercentage) |
418 || (!isZero() && fromType == LengthTypePercentage && toType != LengthTyp
ePercentage) | 429 || (!isZero() && fromType == LengthTypePercentage && toType != LengthTyp
ePercentage) |
419 || (!from->isZero() && !isZero() && (fromType == LengthTypeEMS || fromTy
pe == LengthTypeEXS || fromType == LengthTypeREMS) && fromType != toType)) | 430 || (!from->isZero() && !isZero() && (fromType == LengthTypeEMS || fromTy
pe == LengthTypeEXS || fromType == LengthTypeREMS || fromType == LengthTypeCHS)
&& fromType != toType)) |
420 return clone(); | 431 return clone(); |
421 | 432 |
422 RefPtrWillBeRawPtr<SVGLength> length = create(); | 433 RefPtrWillBeRawPtr<SVGLength> length = create(); |
423 | 434 |
424 if (fromType == LengthTypePercentage || toType == LengthTypePercentage) { | 435 if (fromType == LengthTypePercentage || toType == LengthTypePercentage) { |
425 float fromPercent = from->valueAsPercentage100(); | 436 float fromPercent = from->valueAsPercentage100(); |
426 float toPercent = valueAsPercentage100(); | 437 float toPercent = valueAsPercentage100(); |
427 length->newValueSpecifiedUnits(LengthTypePercentage, blink::blend(fromPe
rcent, toPercent, progress)); | 438 length->newValueSpecifiedUnits(LengthTypePercentage, blink::blend(fromPe
rcent, toPercent, progress)); |
428 return length; | 439 return length; |
429 } | 440 } |
430 | 441 |
431 if (fromType == toType || from->isZero() || isZero() || fromType == LengthTy
peEMS || fromType == LengthTypeEXS || fromType == LengthTypeREMS) { | 442 if (fromType == toType || from->isZero() || isZero() || fromType == LengthTy
peEMS || fromType == LengthTypeEXS || fromType == LengthTypeREMS || fromType ==
LengthTypeCHS) { |
432 float fromValue = from->valueInSpecifiedUnits(); | 443 float fromValue = from->valueInSpecifiedUnits(); |
433 float toValue = valueInSpecifiedUnits(); | 444 float toValue = valueInSpecifiedUnits(); |
434 if (isZero()) | 445 if (isZero()) |
435 length->newValueSpecifiedUnits(fromType, blink::blend(fromValue, toV
alue, progress)); | 446 length->newValueSpecifiedUnits(fromType, blink::blend(fromValue, toV
alue, progress)); |
436 else | 447 else |
437 length->newValueSpecifiedUnits(toType, blink::blend(fromValue, toVal
ue, progress)); | 448 length->newValueSpecifiedUnits(toType, blink::blend(fromValue, toVal
ue, progress)); |
438 return length; | 449 return length; |
439 } | 450 } |
440 | 451 |
441 ASSERT(!isRelative()); | 452 ASSERT(!isRelative()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 484 |
474 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal
ue, SVGElement* contextElement) | 485 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal
ue, SVGElement* contextElement) |
475 { | 486 { |
476 SVGLengthContext lengthContext(contextElement); | 487 SVGLengthContext lengthContext(contextElement); |
477 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); | 488 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); |
478 | 489 |
479 return fabsf(toLength->value(lengthContext) - value(lengthContext)); | 490 return fabsf(toLength->value(lengthContext) - value(lengthContext)); |
480 } | 491 } |
481 | 492 |
482 } | 493 } |
OLD | NEW |