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