| 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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 return result; | 622 return result; |
| 623 | 623 |
| 624 return result * multiplier; | 624 return result * multiplier; |
| 625 } | 625 } |
| 626 | 626 |
| 627 void CSSPrimitiveValue::setFloatValue(unsigned short, double, ExceptionState& es
) | 627 void CSSPrimitiveValue::setFloatValue(unsigned short, double, ExceptionState& es
) |
| 628 { | 628 { |
| 629 // Keeping values immutable makes optimizations easier and allows sharing of
the primitive value objects. | 629 // Keeping values immutable makes optimizations easier and allows sharing of
the primitive value objects. |
| 630 // No other engine supports mutating style through this API. Computed style
is always read-only anyway. | 630 // No other engine supports mutating style through this API. Computed style
is always read-only anyway. |
| 631 // Supporting setter would require making primitive value copy-on-write and
taking care of style invalidation. | 631 // Supporting setter would require making primitive value copy-on-write and
taking care of style invalidation. |
| 632 es.throwDOMException(NoModificationAllowedError); | 632 es.throwUninformativeAndGenericDOMException(NoModificationAllowedError); |
| 633 } | 633 } |
| 634 | 634 |
| 635 double CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(unsigned short u
nitType) | 635 double CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(unsigned short u
nitType) |
| 636 { | 636 { |
| 637 double factor = 1.0; | 637 double factor = 1.0; |
| 638 // FIXME: the switch can be replaced by an array of scale factors. | 638 // FIXME: the switch can be replaced by an array of scale factors. |
| 639 switch (unitType) { | 639 switch (unitType) { |
| 640 // These are "canonical" units in their respective categories. | 640 // These are "canonical" units in their respective categories. |
| 641 case CSS_PX: | 641 case CSS_PX: |
| 642 case CSS_DEG: | 642 case CSS_DEG: |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 } | 682 } |
| 683 | 683 |
| 684 return factor; | 684 return factor; |
| 685 } | 685 } |
| 686 | 686 |
| 687 double CSSPrimitiveValue::getDoubleValue(unsigned short unitType, ExceptionState
& es) const | 687 double CSSPrimitiveValue::getDoubleValue(unsigned short unitType, ExceptionState
& es) const |
| 688 { | 688 { |
| 689 double result = 0; | 689 double result = 0; |
| 690 bool success = getDoubleValueInternal(static_cast<UnitTypes>(unitType), &res
ult); | 690 bool success = getDoubleValueInternal(static_cast<UnitTypes>(unitType), &res
ult); |
| 691 if (!success) { | 691 if (!success) { |
| 692 es.throwDOMException(InvalidAccessError); | 692 es.throwUninformativeAndGenericDOMException(InvalidAccessError); |
| 693 return 0.0; | 693 return 0.0; |
| 694 } | 694 } |
| 695 | 695 |
| 696 return result; | 696 return result; |
| 697 } | 697 } |
| 698 | 698 |
| 699 double CSSPrimitiveValue::getDoubleValue(unsigned short unitType) const | 699 double CSSPrimitiveValue::getDoubleValue(unsigned short unitType) const |
| 700 { | 700 { |
| 701 double result = 0; | 701 double result = 0; |
| 702 getDoubleValueInternal(static_cast<UnitTypes>(unitType), &result); | 702 getDoubleValueInternal(static_cast<UnitTypes>(unitType), &result); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 | 782 |
| 783 *result = convertedValue; | 783 *result = convertedValue; |
| 784 return true; | 784 return true; |
| 785 } | 785 } |
| 786 | 786 |
| 787 void CSSPrimitiveValue::setStringValue(unsigned short, const String&, ExceptionS
tate& es) | 787 void CSSPrimitiveValue::setStringValue(unsigned short, const String&, ExceptionS
tate& es) |
| 788 { | 788 { |
| 789 // Keeping values immutable makes optimizations easier and allows sharing of
the primitive value objects. | 789 // Keeping values immutable makes optimizations easier and allows sharing of
the primitive value objects. |
| 790 // No other engine supports mutating style through this API. Computed style
is always read-only anyway. | 790 // No other engine supports mutating style through this API. Computed style
is always read-only anyway. |
| 791 // Supporting setter would require making primitive value copy-on-write and
taking care of style invalidation. | 791 // Supporting setter would require making primitive value copy-on-write and
taking care of style invalidation. |
| 792 es.throwDOMException(NoModificationAllowedError); | 792 es.throwUninformativeAndGenericDOMException(NoModificationAllowedError); |
| 793 } | 793 } |
| 794 | 794 |
| 795 String CSSPrimitiveValue::getStringValue(ExceptionState& es) const | 795 String CSSPrimitiveValue::getStringValue(ExceptionState& es) const |
| 796 { | 796 { |
| 797 switch (m_primitiveUnitType) { | 797 switch (m_primitiveUnitType) { |
| 798 case CSS_STRING: | 798 case CSS_STRING: |
| 799 case CSS_ATTR: | 799 case CSS_ATTR: |
| 800 case CSS_URI: | 800 case CSS_URI: |
| 801 case CSS_VARIABLE_NAME: | 801 case CSS_VARIABLE_NAME: |
| 802 return m_value.string; | 802 return m_value.string; |
| 803 case CSS_VALUE_ID: | 803 case CSS_VALUE_ID: |
| 804 return valueName(m_value.valueID); | 804 return valueName(m_value.valueID); |
| 805 case CSS_PROPERTY_ID: | 805 case CSS_PROPERTY_ID: |
| 806 return propertyName(m_value.propertyID); | 806 return propertyName(m_value.propertyID); |
| 807 default: | 807 default: |
| 808 es.throwDOMException(InvalidAccessError); | 808 es.throwUninformativeAndGenericDOMException(InvalidAccessError); |
| 809 break; | 809 break; |
| 810 } | 810 } |
| 811 | 811 |
| 812 return String(); | 812 return String(); |
| 813 } | 813 } |
| 814 | 814 |
| 815 String CSSPrimitiveValue::getStringValue() const | 815 String CSSPrimitiveValue::getStringValue() const |
| 816 { | 816 { |
| 817 switch (m_primitiveUnitType) { | 817 switch (m_primitiveUnitType) { |
| 818 case CSS_STRING: | 818 case CSS_STRING: |
| 819 case CSS_ATTR: | 819 case CSS_ATTR: |
| 820 case CSS_URI: | 820 case CSS_URI: |
| 821 case CSS_VARIABLE_NAME: | 821 case CSS_VARIABLE_NAME: |
| 822 return m_value.string; | 822 return m_value.string; |
| 823 case CSS_VALUE_ID: | 823 case CSS_VALUE_ID: |
| 824 return valueName(m_value.valueID); | 824 return valueName(m_value.valueID); |
| 825 case CSS_PROPERTY_ID: | 825 case CSS_PROPERTY_ID: |
| 826 return propertyName(m_value.propertyID); | 826 return propertyName(m_value.propertyID); |
| 827 default: | 827 default: |
| 828 break; | 828 break; |
| 829 } | 829 } |
| 830 | 830 |
| 831 return String(); | 831 return String(); |
| 832 } | 832 } |
| 833 | 833 |
| 834 Counter* CSSPrimitiveValue::getCounterValue(ExceptionState& es) const | 834 Counter* CSSPrimitiveValue::getCounterValue(ExceptionState& es) const |
| 835 { | 835 { |
| 836 if (m_primitiveUnitType != CSS_COUNTER) { | 836 if (m_primitiveUnitType != CSS_COUNTER) { |
| 837 es.throwDOMException(InvalidAccessError); | 837 es.throwUninformativeAndGenericDOMException(InvalidAccessError); |
| 838 return 0; | 838 return 0; |
| 839 } | 839 } |
| 840 | 840 |
| 841 return m_value.counter; | 841 return m_value.counter; |
| 842 } | 842 } |
| 843 | 843 |
| 844 Rect* CSSPrimitiveValue::getRectValue(ExceptionState& es) const | 844 Rect* CSSPrimitiveValue::getRectValue(ExceptionState& es) const |
| 845 { | 845 { |
| 846 if (m_primitiveUnitType != CSS_RECT) { | 846 if (m_primitiveUnitType != CSS_RECT) { |
| 847 es.throwDOMException(InvalidAccessError); | 847 es.throwUninformativeAndGenericDOMException(InvalidAccessError); |
| 848 return 0; | 848 return 0; |
| 849 } | 849 } |
| 850 | 850 |
| 851 return m_value.rect; | 851 return m_value.rect; |
| 852 } | 852 } |
| 853 | 853 |
| 854 Quad* CSSPrimitiveValue::getQuadValue(ExceptionState& es) const | 854 Quad* CSSPrimitiveValue::getQuadValue(ExceptionState& es) const |
| 855 { | 855 { |
| 856 if (m_primitiveUnitType != CSS_QUAD) { | 856 if (m_primitiveUnitType != CSS_QUAD) { |
| 857 es.throwDOMException(InvalidAccessError); | 857 es.throwUninformativeAndGenericDOMException(InvalidAccessError); |
| 858 return 0; | 858 return 0; |
| 859 } | 859 } |
| 860 | 860 |
| 861 return m_value.quad; | 861 return m_value.quad; |
| 862 } | 862 } |
| 863 | 863 |
| 864 PassRefPtr<RGBColor> CSSPrimitiveValue::getRGBColorValue(ExceptionState& es) con
st | 864 PassRefPtr<RGBColor> CSSPrimitiveValue::getRGBColorValue(ExceptionState& es) con
st |
| 865 { | 865 { |
| 866 if (m_primitiveUnitType != CSS_RGBCOLOR) { | 866 if (m_primitiveUnitType != CSS_RGBCOLOR) { |
| 867 es.throwDOMException(InvalidAccessError); | 867 es.throwUninformativeAndGenericDOMException(InvalidAccessError); |
| 868 return 0; | 868 return 0; |
| 869 } | 869 } |
| 870 | 870 |
| 871 // FIMXE: This should not return a new object for each invocation. | 871 // FIMXE: This should not return a new object for each invocation. |
| 872 return RGBColor::create(m_value.rgbcolor); | 872 return RGBColor::create(m_value.rgbcolor); |
| 873 } | 873 } |
| 874 | 874 |
| 875 Pair* CSSPrimitiveValue::getPairValue(ExceptionState& es) const | 875 Pair* CSSPrimitiveValue::getPairValue(ExceptionState& es) const |
| 876 { | 876 { |
| 877 if (m_primitiveUnitType != CSS_PAIR) { | 877 if (m_primitiveUnitType != CSS_PAIR) { |
| 878 es.throwDOMException(InvalidAccessError); | 878 es.throwUninformativeAndGenericDOMException(InvalidAccessError); |
| 879 return 0; | 879 return 0; |
| 880 } | 880 } |
| 881 | 881 |
| 882 return m_value.pair; | 882 return m_value.pair; |
| 883 } | 883 } |
| 884 | 884 |
| 885 static String formatNumber(double number, const char* suffix, unsigned suffixLen
gth) | 885 static String formatNumber(double number, const char* suffix, unsigned suffixLen
gth) |
| 886 { | 886 { |
| 887 DecimalNumber decimal(number); | 887 DecimalNumber decimal(number); |
| 888 | 888 |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 return m_value.parserOperator == other.m_value.parserOperator; | 1333 return m_value.parserOperator == other.m_value.parserOperator; |
| 1334 case CSS_CALC: | 1334 case CSS_CALC: |
| 1335 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 1335 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); |
| 1336 case CSS_SHAPE: | 1336 case CSS_SHAPE: |
| 1337 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); | 1337 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); |
| 1338 } | 1338 } |
| 1339 return false; | 1339 return false; |
| 1340 } | 1340 } |
| 1341 | 1341 |
| 1342 } // namespace WebCore | 1342 } // namespace WebCore |
| OLD | NEW |