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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 return result; | 698 return result; |
699 } | 699 } |
700 | 700 |
701 double CSSPrimitiveValue::getDoubleValue() const | 701 double CSSPrimitiveValue::getDoubleValue() const |
702 { | 702 { |
703 return m_primitiveUnitType != CSS_CALC ? m_value.num : m_value.calc->doubleV
alue(); | 703 return m_primitiveUnitType != CSS_CALC ? m_value.num : m_value.calc->doubleV
alue(); |
704 } | 704 } |
705 | 705 |
706 CSSPrimitiveValue::UnitTypes CSSPrimitiveValue::canonicalUnitTypeForCategory(Uni
tCategory category) | 706 CSSPrimitiveValue::UnitTypes CSSPrimitiveValue::canonicalUnitTypeForCategory(Uni
tCategory category) |
707 { | 707 { |
708 // The canonical unit type is chosen according to the way BisonCSSParser::va
lidUnit() chooses the default unit | 708 // The canonical unit type is chosen according to the way CSSParser::validUn
it() |
709 // in each category (based on unitflags). | 709 // chooses the default unit in each category (based on unitflags). |
710 switch (category) { | 710 switch (category) { |
711 case UNumber: | 711 case UNumber: |
712 return CSS_NUMBER; | 712 return CSS_NUMBER; |
713 case ULength: | 713 case ULength: |
714 return CSS_PX; | 714 return CSS_PX; |
715 case UPercent: | 715 case UPercent: |
716 return CSS_UNKNOWN; // Cannot convert between numbers and percent. | 716 return CSS_UNKNOWN; // Cannot convert between numbers and percent. |
717 case UTime: | 717 case UTime: |
718 return CSS_MS; | 718 return CSS_MS; |
719 case UAngle: | 719 case UAngle: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 return false; | 752 return false; |
753 | 753 |
754 if (targetCategory == UNumber) { | 754 if (targetCategory == UNumber) { |
755 // We interpret conversion to CSS_NUMBER as conversion to a canonical un
it in this value's category. | 755 // We interpret conversion to CSS_NUMBER as conversion to a canonical un
it in this value's category. |
756 targetUnitType = canonicalUnitTypeForCategory(sourceCategory); | 756 targetUnitType = canonicalUnitTypeForCategory(sourceCategory); |
757 if (targetUnitType == CSS_UNKNOWN) | 757 if (targetUnitType == CSS_UNKNOWN) |
758 return false; | 758 return false; |
759 } | 759 } |
760 | 760 |
761 if (sourceUnitType == CSS_NUMBER) { | 761 if (sourceUnitType == CSS_NUMBER) { |
762 // We interpret conversion from CSS_NUMBER in the same way as BisonCSSPa
rser::validUnit() while using non-strict mode. | 762 // We interpret conversion from CSS_NUMBER in the same way as |
| 763 // CSSParser::validUnit() while using non-strict mode. |
763 sourceUnitType = canonicalUnitTypeForCategory(targetCategory); | 764 sourceUnitType = canonicalUnitTypeForCategory(targetCategory); |
764 if (sourceUnitType == CSS_UNKNOWN) | 765 if (sourceUnitType == CSS_UNKNOWN) |
765 return false; | 766 return false; |
766 } | 767 } |
767 | 768 |
768 double convertedValue = getDoubleValue(); | 769 double convertedValue = getDoubleValue(); |
769 | 770 |
770 // First convert the value from m_primitiveUnitType to canonical type. | 771 // First convert the value from m_primitiveUnitType to canonical type. |
771 double factor = conversionToCanonicalUnitsScaleFactor(sourceUnitType); | 772 double factor = conversionToCanonicalUnitsScaleFactor(sourceUnitType); |
772 convertedValue *= factor; | 773 convertedValue *= factor; |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 return m_value.parserOperator == other.m_value.parserOperator; | 1301 return m_value.parserOperator == other.m_value.parserOperator; |
1301 case CSS_CALC: | 1302 case CSS_CALC: |
1302 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 1303 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); |
1303 case CSS_SHAPE: | 1304 case CSS_SHAPE: |
1304 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); | 1305 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); |
1305 } | 1306 } |
1306 return false; | 1307 return false; |
1307 } | 1308 } |
1308 | 1309 |
1309 } // namespace WebCore | 1310 } // namespace WebCore |
OLD | NEW |