OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv
ed. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 case CSS_VALUE_ID: | 483 case CSS_VALUE_ID: |
484 break; | 484 break; |
485 } | 485 } |
486 m_primitiveUnitType = 0; | 486 m_primitiveUnitType = 0; |
487 if (m_hasCachedCSSText) { | 487 if (m_hasCachedCSSText) { |
488 cssTextCache().remove(this); | 488 cssTextCache().remove(this); |
489 m_hasCachedCSSText = false; | 489 m_hasCachedCSSText = false; |
490 } | 490 } |
491 } | 491 } |
492 | 492 |
493 double CSSPrimitiveValue::computeSeconds() | 493 double CSSPrimitiveValue::computeSeconds() const |
494 { | 494 { |
495 ASSERT(isTime() || (isCalculated() && cssCalcValue()->category() == CalcTime
)); | 495 ASSERT(isTime() || (isCalculated() && cssCalcValue()->category() == CalcTime
)); |
496 UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->pr
imitiveType() : type(); | 496 UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->pr
imitiveType() : type(); |
497 if (currentType == CSS_S) | 497 if (currentType == CSS_S) |
498 return getDoubleValue(); | 498 return getDoubleValue(); |
499 if (currentType == CSS_MS) | 499 if (currentType == CSS_MS) |
500 return getDoubleValue() / 1000; | 500 return getDoubleValue() / 1000; |
501 ASSERT_NOT_REACHED(); | 501 ASSERT_NOT_REACHED(); |
502 return 0; | 502 return 0; |
503 } | 503 } |
(...skipping 10 matching lines...) Expand all Loading... |
514 case CSS_GRAD: | 514 case CSS_GRAD: |
515 return grad2deg(getDoubleValue()); | 515 return grad2deg(getDoubleValue()); |
516 case CSS_TURN: | 516 case CSS_TURN: |
517 return turn2deg(getDoubleValue()); | 517 return turn2deg(getDoubleValue()); |
518 default: | 518 default: |
519 ASSERT_NOT_REACHED(); | 519 ASSERT_NOT_REACHED(); |
520 return 0; | 520 return 0; |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 template<> int CSSPrimitiveValue::computeLength(const CSSToLengthConversionData&
conversionData) | 524 template<> int CSSPrimitiveValue::computeLength(const CSSToLengthConversionData&
conversionData) const |
525 { | 525 { |
526 return roundForImpreciseConversion<int>(computeLengthDouble(conversionData))
; | 526 return roundForImpreciseConversion<int>(computeLengthDouble(conversionData))
; |
527 } | 527 } |
528 | 528 |
529 template<> unsigned CSSPrimitiveValue::computeLength(const CSSToLengthConversion
Data& conversionData) | 529 template<> unsigned CSSPrimitiveValue::computeLength(const CSSToLengthConversion
Data& conversionData) const |
530 { | 530 { |
531 return roundForImpreciseConversion<unsigned>(computeLengthDouble(conversionD
ata)); | 531 return roundForImpreciseConversion<unsigned>(computeLengthDouble(conversionD
ata)); |
532 } | 532 } |
533 | 533 |
534 template<> Length CSSPrimitiveValue::computeLength(const CSSToLengthConversionDa
ta& conversionData) | 534 template<> Length CSSPrimitiveValue::computeLength(const CSSToLengthConversionDa
ta& conversionData) const |
535 { | 535 { |
536 return Length(clampToCSSLengthRange(computeLengthDouble(conversionData)), Fi
xed); | 536 return Length(clampToCSSLengthRange(computeLengthDouble(conversionData)), Fi
xed); |
537 } | 537 } |
538 | 538 |
539 template<> short CSSPrimitiveValue::computeLength(const CSSToLengthConversionDat
a& conversionData) | 539 template<> short CSSPrimitiveValue::computeLength(const CSSToLengthConversionDat
a& conversionData) const |
540 { | 540 { |
541 return roundForImpreciseConversion<short>(computeLengthDouble(conversionData
)); | 541 return roundForImpreciseConversion<short>(computeLengthDouble(conversionData
)); |
542 } | 542 } |
543 | 543 |
544 template<> unsigned short CSSPrimitiveValue::computeLength(const CSSToLengthConv
ersionData& conversionData) | 544 template<> unsigned short CSSPrimitiveValue::computeLength(const CSSToLengthConv
ersionData& conversionData) const |
545 { | 545 { |
546 return roundForImpreciseConversion<unsigned short>(computeLengthDouble(conve
rsionData)); | 546 return roundForImpreciseConversion<unsigned short>(computeLengthDouble(conve
rsionData)); |
547 } | 547 } |
548 | 548 |
549 template<> float CSSPrimitiveValue::computeLength(const CSSToLengthConversionDat
a& conversionData) | 549 template<> float CSSPrimitiveValue::computeLength(const CSSToLengthConversionDat
a& conversionData) const |
550 { | 550 { |
551 return static_cast<float>(computeLengthDouble(conversionData)); | 551 return static_cast<float>(computeLengthDouble(conversionData)); |
552 } | 552 } |
553 | 553 |
554 template<> double CSSPrimitiveValue::computeLength(const CSSToLengthConversionDa
ta& conversionData) | 554 template<> double CSSPrimitiveValue::computeLength(const CSSToLengthConversionDa
ta& conversionData) const |
555 { | 555 { |
556 return computeLengthDouble(conversionData); | 556 return computeLengthDouble(conversionData); |
557 } | 557 } |
558 | 558 |
559 double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c
onversionData) | 559 double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c
onversionData) const |
560 { | 560 { |
561 // The logic in this function is duplicated in MediaValues::computeLength | 561 // The logic in this function is duplicated in MediaValues::computeLength |
562 // because MediaValues::computeLength needs nearly identical logic, but we h
aven't found a way to make | 562 // because MediaValues::computeLength needs nearly identical logic, but we h
aven't found a way to make |
563 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases)
without hurting performance. | 563 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases)
without hurting performance. |
564 if (type() == CSS_CALC) | 564 if (type() == CSS_CALC) |
565 return value().calc->computeLengthPx(conversionData); | 565 return value().calc->computeLengthPx(conversionData); |
566 | 566 |
567 double factor; | 567 double factor; |
568 | 568 |
569 switch (primitiveType()) { | 569 switch (primitiveType()) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 case CSS_KHZ: | 698 case CSS_KHZ: |
699 factor = 1000; | 699 factor = 1000; |
700 break; | 700 break; |
701 default: | 701 default: |
702 break; | 702 break; |
703 } | 703 } |
704 | 704 |
705 return factor; | 705 return factor; |
706 } | 706 } |
707 | 707 |
708 Length CSSPrimitiveValue::convertToLength(const CSSToLengthConversionData& conve
rsionData) | 708 Length CSSPrimitiveValue::convertToLength(const CSSToLengthConversionData& conve
rsionData) const |
709 { | 709 { |
710 if (isLength()) | 710 if (isLength()) |
711 return computeLength<Length>(conversionData); | 711 return computeLength<Length>(conversionData); |
712 if (isPercentage()) | 712 if (isPercentage()) |
713 return Length(getDoubleValue(), Percent); | 713 return Length(getDoubleValue(), Percent); |
714 ASSERT(isCalculated()); | 714 ASSERT(isCalculated()); |
715 return Length(cssCalcValue()->toCalcValue(conversionData)); | 715 return Length(cssCalcValue()->toCalcValue(conversionData)); |
716 } | 716 } |
717 | 717 |
718 double CSSPrimitiveValue::getDoubleValue() const | 718 double CSSPrimitiveValue::getDoubleValue() const |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 visitor->trace(m_value.shape); | 1160 visitor->trace(m_value.shape); |
1161 break; | 1161 break; |
1162 default: | 1162 default: |
1163 break; | 1163 break; |
1164 } | 1164 } |
1165 #endif | 1165 #endif |
1166 CSSValueObject::traceAfterDispatch(visitor); | 1166 CSSValueObject::traceAfterDispatch(visitor); |
1167 } | 1167 } |
1168 | 1168 |
1169 } // namespace blink | 1169 } // namespace blink |
OLD | NEW |