| 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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 // We do not apply the zoom factor when we are computing the value of the fo
nt-size property. The zooming | 615 // We do not apply the zoom factor when we are computing the value of the fo
nt-size property. The zooming |
| 616 // for font sizes is much more complicated, since we have to worry about enf
orcing the minimum font size preference | 616 // for font sizes is much more complicated, since we have to worry about enf
orcing the minimum font size preference |
| 617 // as well as enforcing the implicit "smart minimum." | 617 // as well as enforcing the implicit "smart minimum." |
| 618 double result = getDoubleValue() * factor; | 618 double result = getDoubleValue() * factor; |
| 619 if (computingFontSize || isFontRelativeLength()) | 619 if (computingFontSize || isFontRelativeLength()) |
| 620 return result; | 620 return result; |
| 621 | 621 |
| 622 return result * multiplier; | 622 return result * multiplier; |
| 623 } | 623 } |
| 624 | 624 |
| 625 void CSSPrimitiveValue::setFloatValue(unsigned short, double, ExceptionState& es
) | 625 void CSSPrimitiveValue::setFloatValue(unsigned short, double, ExceptionState& ex
ceptionState) |
| 626 { | 626 { |
| 627 // Keeping values immutable makes optimizations easier and allows sharing of
the primitive value objects. | 627 // Keeping values immutable makes optimizations easier and allows sharing of
the primitive value objects. |
| 628 // No other engine supports mutating style through this API. Computed style
is always read-only anyway. | 628 // No other engine supports mutating style through this API. Computed style
is always read-only anyway. |
| 629 // Supporting setter would require making primitive value copy-on-write and
taking care of style invalidation. | 629 // Supporting setter would require making primitive value copy-on-write and
taking care of style invalidation. |
| 630 es.throwUninformativeAndGenericDOMException(NoModificationAllowedError); | 630 exceptionState.throwUninformativeAndGenericDOMException(NoModificationAllowe
dError); |
| 631 } | 631 } |
| 632 | 632 |
| 633 double CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(unsigned short u
nitType) | 633 double CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(unsigned short u
nitType) |
| 634 { | 634 { |
| 635 double factor = 1.0; | 635 double factor = 1.0; |
| 636 // FIXME: the switch can be replaced by an array of scale factors. | 636 // FIXME: the switch can be replaced by an array of scale factors. |
| 637 switch (unitType) { | 637 switch (unitType) { |
| 638 // These are "canonical" units in their respective categories. | 638 // These are "canonical" units in their respective categories. |
| 639 case CSS_PX: | 639 case CSS_PX: |
| 640 case CSS_DEG: | 640 case CSS_DEG: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 case CSS_KHZ: | 675 case CSS_KHZ: |
| 676 factor = 1000; | 676 factor = 1000; |
| 677 break; | 677 break; |
| 678 default: | 678 default: |
| 679 break; | 679 break; |
| 680 } | 680 } |
| 681 | 681 |
| 682 return factor; | 682 return factor; |
| 683 } | 683 } |
| 684 | 684 |
| 685 double CSSPrimitiveValue::getDoubleValue(unsigned short unitType, ExceptionState
& es) const | 685 double CSSPrimitiveValue::getDoubleValue(unsigned short unitType, ExceptionState
& exceptionState) const |
| 686 { | 686 { |
| 687 double result = 0; | 687 double result = 0; |
| 688 bool success = getDoubleValueInternal(static_cast<UnitTypes>(unitType), &res
ult); | 688 bool success = getDoubleValueInternal(static_cast<UnitTypes>(unitType), &res
ult); |
| 689 if (!success) { | 689 if (!success) { |
| 690 es.throwUninformativeAndGenericDOMException(InvalidAccessError); | 690 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr
or); |
| 691 return 0.0; | 691 return 0.0; |
| 692 } | 692 } |
| 693 | 693 |
| 694 return result; | 694 return result; |
| 695 } | 695 } |
| 696 | 696 |
| 697 double CSSPrimitiveValue::getDoubleValue(unsigned short unitType) const | 697 double CSSPrimitiveValue::getDoubleValue(unsigned short unitType) const |
| 698 { | 698 { |
| 699 double result = 0; | 699 double result = 0; |
| 700 getDoubleValueInternal(static_cast<UnitTypes>(unitType), &result); | 700 getDoubleValueInternal(static_cast<UnitTypes>(unitType), &result); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 convertedValue *= factor; | 775 convertedValue *= factor; |
| 776 | 776 |
| 777 // Now convert from canonical type to the target unitType. | 777 // Now convert from canonical type to the target unitType. |
| 778 factor = conversionToCanonicalUnitsScaleFactor(targetUnitType); | 778 factor = conversionToCanonicalUnitsScaleFactor(targetUnitType); |
| 779 convertedValue /= factor; | 779 convertedValue /= factor; |
| 780 | 780 |
| 781 *result = convertedValue; | 781 *result = convertedValue; |
| 782 return true; | 782 return true; |
| 783 } | 783 } |
| 784 | 784 |
| 785 void CSSPrimitiveValue::setStringValue(unsigned short, const String&, ExceptionS
tate& es) | 785 void CSSPrimitiveValue::setStringValue(unsigned short, const String&, ExceptionS
tate& exceptionState) |
| 786 { | 786 { |
| 787 // Keeping values immutable makes optimizations easier and allows sharing of
the primitive value objects. | 787 // Keeping values immutable makes optimizations easier and allows sharing of
the primitive value objects. |
| 788 // No other engine supports mutating style through this API. Computed style
is always read-only anyway. | 788 // No other engine supports mutating style through this API. Computed style
is always read-only anyway. |
| 789 // Supporting setter would require making primitive value copy-on-write and
taking care of style invalidation. | 789 // Supporting setter would require making primitive value copy-on-write and
taking care of style invalidation. |
| 790 es.throwUninformativeAndGenericDOMException(NoModificationAllowedError); | 790 exceptionState.throwUninformativeAndGenericDOMException(NoModificationAllowe
dError); |
| 791 } | 791 } |
| 792 | 792 |
| 793 String CSSPrimitiveValue::getStringValue(ExceptionState& es) const | 793 String CSSPrimitiveValue::getStringValue(ExceptionState& exceptionState) const |
| 794 { | 794 { |
| 795 switch (m_primitiveUnitType) { | 795 switch (m_primitiveUnitType) { |
| 796 case CSS_STRING: | 796 case CSS_STRING: |
| 797 case CSS_ATTR: | 797 case CSS_ATTR: |
| 798 case CSS_URI: | 798 case CSS_URI: |
| 799 case CSS_VARIABLE_NAME: | 799 case CSS_VARIABLE_NAME: |
| 800 return m_value.string; | 800 return m_value.string; |
| 801 case CSS_VALUE_ID: | 801 case CSS_VALUE_ID: |
| 802 return valueName(m_value.valueID); | 802 return valueName(m_value.valueID); |
| 803 case CSS_PROPERTY_ID: | 803 case CSS_PROPERTY_ID: |
| 804 return propertyName(m_value.propertyID); | 804 return propertyName(m_value.propertyID); |
| 805 default: | 805 default: |
| 806 es.throwUninformativeAndGenericDOMException(InvalidAccessError); | 806 exceptionState.throwUninformativeAndGenericDOMException(InvalidAcces
sError); |
| 807 break; | 807 break; |
| 808 } | 808 } |
| 809 | 809 |
| 810 return String(); | 810 return String(); |
| 811 } | 811 } |
| 812 | 812 |
| 813 String CSSPrimitiveValue::getStringValue() const | 813 String CSSPrimitiveValue::getStringValue() const |
| 814 { | 814 { |
| 815 switch (m_primitiveUnitType) { | 815 switch (m_primitiveUnitType) { |
| 816 case CSS_STRING: | 816 case CSS_STRING: |
| 817 case CSS_ATTR: | 817 case CSS_ATTR: |
| 818 case CSS_URI: | 818 case CSS_URI: |
| 819 case CSS_VARIABLE_NAME: | 819 case CSS_VARIABLE_NAME: |
| 820 return m_value.string; | 820 return m_value.string; |
| 821 case CSS_VALUE_ID: | 821 case CSS_VALUE_ID: |
| 822 return valueName(m_value.valueID); | 822 return valueName(m_value.valueID); |
| 823 case CSS_PROPERTY_ID: | 823 case CSS_PROPERTY_ID: |
| 824 return propertyName(m_value.propertyID); | 824 return propertyName(m_value.propertyID); |
| 825 default: | 825 default: |
| 826 break; | 826 break; |
| 827 } | 827 } |
| 828 | 828 |
| 829 return String(); | 829 return String(); |
| 830 } | 830 } |
| 831 | 831 |
| 832 Counter* CSSPrimitiveValue::getCounterValue(ExceptionState& es) const | 832 Counter* CSSPrimitiveValue::getCounterValue(ExceptionState& exceptionState) cons
t |
| 833 { | 833 { |
| 834 if (m_primitiveUnitType != CSS_COUNTER) { | 834 if (m_primitiveUnitType != CSS_COUNTER) { |
| 835 es.throwUninformativeAndGenericDOMException(InvalidAccessError); | 835 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr
or); |
| 836 return 0; | 836 return 0; |
| 837 } | 837 } |
| 838 | 838 |
| 839 return m_value.counter; | 839 return m_value.counter; |
| 840 } | 840 } |
| 841 | 841 |
| 842 Rect* CSSPrimitiveValue::getRectValue(ExceptionState& es) const | 842 Rect* CSSPrimitiveValue::getRectValue(ExceptionState& exceptionState) const |
| 843 { | 843 { |
| 844 if (m_primitiveUnitType != CSS_RECT) { | 844 if (m_primitiveUnitType != CSS_RECT) { |
| 845 es.throwUninformativeAndGenericDOMException(InvalidAccessError); | 845 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr
or); |
| 846 return 0; | 846 return 0; |
| 847 } | 847 } |
| 848 | 848 |
| 849 return m_value.rect; | 849 return m_value.rect; |
| 850 } | 850 } |
| 851 | 851 |
| 852 Quad* CSSPrimitiveValue::getQuadValue(ExceptionState& es) const | 852 Quad* CSSPrimitiveValue::getQuadValue(ExceptionState& exceptionState) const |
| 853 { | 853 { |
| 854 if (m_primitiveUnitType != CSS_QUAD) { | 854 if (m_primitiveUnitType != CSS_QUAD) { |
| 855 es.throwUninformativeAndGenericDOMException(InvalidAccessError); | 855 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr
or); |
| 856 return 0; | 856 return 0; |
| 857 } | 857 } |
| 858 | 858 |
| 859 return m_value.quad; | 859 return m_value.quad; |
| 860 } | 860 } |
| 861 | 861 |
| 862 PassRefPtr<RGBColor> CSSPrimitiveValue::getRGBColorValue(ExceptionState& es) con
st | 862 PassRefPtr<RGBColor> CSSPrimitiveValue::getRGBColorValue(ExceptionState& excepti
onState) const |
| 863 { | 863 { |
| 864 if (m_primitiveUnitType != CSS_RGBCOLOR) { | 864 if (m_primitiveUnitType != CSS_RGBCOLOR) { |
| 865 es.throwUninformativeAndGenericDOMException(InvalidAccessError); | 865 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr
or); |
| 866 return 0; | 866 return 0; |
| 867 } | 867 } |
| 868 | 868 |
| 869 // FIMXE: This should not return a new object for each invocation. | 869 // FIMXE: This should not return a new object for each invocation. |
| 870 return RGBColor::create(m_value.rgbcolor); | 870 return RGBColor::create(m_value.rgbcolor); |
| 871 } | 871 } |
| 872 | 872 |
| 873 Pair* CSSPrimitiveValue::getPairValue(ExceptionState& es) const | 873 Pair* CSSPrimitiveValue::getPairValue(ExceptionState& exceptionState) const |
| 874 { | 874 { |
| 875 if (m_primitiveUnitType != CSS_PAIR) { | 875 if (m_primitiveUnitType != CSS_PAIR) { |
| 876 es.throwUninformativeAndGenericDOMException(InvalidAccessError); | 876 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr
or); |
| 877 return 0; | 877 return 0; |
| 878 } | 878 } |
| 879 | 879 |
| 880 return m_value.pair; | 880 return m_value.pair; |
| 881 } | 881 } |
| 882 | 882 |
| 883 static String formatNumber(double number, const char* suffix, unsigned suffixLen
gth) | 883 static String formatNumber(double number, const char* suffix, unsigned suffixLen
gth) |
| 884 { | 884 { |
| 885 DecimalNumber decimal(number); | 885 DecimalNumber decimal(number); |
| 886 | 886 |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 return m_value.parserOperator == other.m_value.parserOperator; | 1331 return m_value.parserOperator == other.m_value.parserOperator; |
| 1332 case CSS_CALC: | 1332 case CSS_CALC: |
| 1333 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 1333 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); |
| 1334 case CSS_SHAPE: | 1334 case CSS_SHAPE: |
| 1335 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); | 1335 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); |
| 1336 } | 1336 } |
| 1337 return false; | 1337 return false; |
| 1338 } | 1338 } |
| 1339 | 1339 |
| 1340 } // namespace WebCore | 1340 } // namespace WebCore |
| OLD | NEW |