| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 case CalcPercentLength: | 183 case CalcPercentLength: |
| 184 return UnitType::CalcPercentageWithLength; | 184 return UnitType::CalcPercentageWithLength; |
| 185 case CalcTime: | 185 case CalcTime: |
| 186 return UnitType::Milliseconds; | 186 return UnitType::Milliseconds; |
| 187 case CalcOther: | 187 case CalcOther: |
| 188 return UnitType::Unknown; | 188 return UnitType::Unknown; |
| 189 } | 189 } |
| 190 return UnitType::Unknown; | 190 return UnitType::Unknown; |
| 191 } | 191 } |
| 192 | 192 |
| 193 static const AtomicString& propertyName(CSSPropertyID propertyID) | |
| 194 { | |
| 195 return getPropertyNameAtomicString(propertyID); | |
| 196 } | |
| 197 | |
| 198 static const AtomicString& valueName(CSSValueID valueID) | 193 static const AtomicString& valueName(CSSValueID valueID) |
| 199 { | 194 { |
| 200 ASSERT_ARG(valueID, valueID >= 0); | 195 ASSERT_ARG(valueID, valueID >= 0); |
| 201 ASSERT_ARG(valueID, valueID < numCSSValueKeywords); | 196 ASSERT_ARG(valueID, valueID < numCSSValueKeywords); |
| 202 | 197 |
| 203 if (valueID < 0) | 198 if (valueID < 0) |
| 204 return nullAtom; | 199 return nullAtom; |
| 205 | 200 |
| 206 static AtomicString* keywordStrings = new AtomicString[numCSSValueKeywords];
// Leaked intentionally. | 201 static AtomicString* keywordStrings = new AtomicString[numCSSValueKeywords];
// Leaked intentionally. |
| 207 AtomicString& keywordString = keywordStrings[valueID]; | 202 AtomicString& keywordString = keywordStrings[valueID]; |
| 208 if (keywordString.isNull()) | 203 if (keywordString.isNull()) |
| 209 keywordString = getValueName(valueID); | 204 keywordString = getValueName(valueID); |
| 210 return keywordString; | 205 return keywordString; |
| 211 } | 206 } |
| 212 | 207 |
| 213 CSSPrimitiveValue::CSSPrimitiveValue(CSSValueID valueID) | 208 CSSPrimitiveValue::CSSPrimitiveValue(CSSValueID valueID) |
| 214 : CSSValue(PrimitiveClass) | 209 : CSSValue(PrimitiveClass) |
| 215 { | 210 { |
| 216 init(UnitType::ValueID); | 211 init(UnitType::ValueID); |
| 217 m_value.valueID = valueID; | 212 m_value.valueID = valueID; |
| 218 } | 213 } |
| 219 | 214 |
| 220 CSSPrimitiveValue::CSSPrimitiveValue(CSSPropertyID propertyID) | |
| 221 : CSSValue(PrimitiveClass) | |
| 222 { | |
| 223 init(UnitType::PropertyID); | |
| 224 m_value.propertyID = propertyID; | |
| 225 } | |
| 226 | |
| 227 CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitType type) | 215 CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitType type) |
| 228 : CSSValue(PrimitiveClass) | 216 : CSSValue(PrimitiveClass) |
| 229 { | 217 { |
| 230 init(type); | 218 init(type); |
| 231 ASSERT(std::isfinite(num)); | 219 ASSERT(std::isfinite(num)); |
| 232 m_value.num = num; | 220 m_value.num = num; |
| 233 } | 221 } |
| 234 | 222 |
| 235 CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color) | 223 CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color) |
| 236 : CSSValue(PrimitiveClass) | 224 : CSSValue(PrimitiveClass) |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 case UnitType::ViewportWidth: | 354 case UnitType::ViewportWidth: |
| 367 case UnitType::ViewportHeight: | 355 case UnitType::ViewportHeight: |
| 368 case UnitType::ViewportMin: | 356 case UnitType::ViewportMin: |
| 369 case UnitType::ViewportMax: | 357 case UnitType::ViewportMax: |
| 370 case UnitType::DotsPerPixel: | 358 case UnitType::DotsPerPixel: |
| 371 case UnitType::DotsPerInch: | 359 case UnitType::DotsPerInch: |
| 372 case UnitType::DotsPerCentimeter: | 360 case UnitType::DotsPerCentimeter: |
| 373 case UnitType::Fraction: | 361 case UnitType::Fraction: |
| 374 case UnitType::RGBColor: | 362 case UnitType::RGBColor: |
| 375 case UnitType::Unknown: | 363 case UnitType::Unknown: |
| 376 case UnitType::PropertyID: | |
| 377 case UnitType::ValueID: | 364 case UnitType::ValueID: |
| 378 break; | 365 break; |
| 379 } | 366 } |
| 380 if (m_hasCachedCSSText) { | 367 if (m_hasCachedCSSText) { |
| 381 cssTextCache().remove(this); | 368 cssTextCache().remove(this); |
| 382 m_hasCachedCSSText = false; | 369 m_hasCachedCSSText = false; |
| 383 } | 370 } |
| 384 } | 371 } |
| 385 | 372 |
| 386 double CSSPrimitiveValue::computeSeconds() const | 373 double CSSPrimitiveValue::computeSeconds() const |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 case UnitType::ViewportWidth: | 779 case UnitType::ViewportWidth: |
| 793 return "vw"; | 780 return "vw"; |
| 794 case UnitType::ViewportHeight: | 781 case UnitType::ViewportHeight: |
| 795 return "vh"; | 782 return "vh"; |
| 796 case UnitType::ViewportMin: | 783 case UnitType::ViewportMin: |
| 797 return "vmin"; | 784 return "vmin"; |
| 798 case UnitType::ViewportMax: | 785 case UnitType::ViewportMax: |
| 799 return "vmax"; | 786 return "vmax"; |
| 800 case UnitType::Unknown: | 787 case UnitType::Unknown: |
| 801 case UnitType::ValueID: | 788 case UnitType::ValueID: |
| 802 case UnitType::PropertyID: | |
| 803 case UnitType::RGBColor: | 789 case UnitType::RGBColor: |
| 804 case UnitType::Calc: | 790 case UnitType::Calc: |
| 805 case UnitType::CalcPercentageWithNumber: | 791 case UnitType::CalcPercentageWithNumber: |
| 806 case UnitType::CalcPercentageWithLength: | 792 case UnitType::CalcPercentageWithLength: |
| 807 break; | 793 break; |
| 808 }; | 794 }; |
| 809 ASSERT_NOT_REACHED(); | 795 ASSERT_NOT_REACHED(); |
| 810 return ""; | 796 return ""; |
| 811 } | 797 } |
| 812 | 798 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 case UnitType::Fraction: | 838 case UnitType::Fraction: |
| 853 case UnitType::ViewportWidth: | 839 case UnitType::ViewportWidth: |
| 854 case UnitType::ViewportHeight: | 840 case UnitType::ViewportHeight: |
| 855 case UnitType::ViewportMin: | 841 case UnitType::ViewportMin: |
| 856 case UnitType::ViewportMax: | 842 case UnitType::ViewportMax: |
| 857 text = formatNumber(m_value.num, unitTypeToString(type())); | 843 text = formatNumber(m_value.num, unitTypeToString(type())); |
| 858 break; | 844 break; |
| 859 case UnitType::ValueID: | 845 case UnitType::ValueID: |
| 860 text = valueName(m_value.valueID); | 846 text = valueName(m_value.valueID); |
| 861 break; | 847 break; |
| 862 case UnitType::PropertyID: | |
| 863 text = propertyName(m_value.propertyID); | |
| 864 break; | |
| 865 case UnitType::RGBColor: { | 848 case UnitType::RGBColor: { |
| 866 text = Color(m_value.rgbcolor).serializedAsCSSComponentValue(); | 849 text = Color(m_value.rgbcolor).serializedAsCSSComponentValue(); |
| 867 break; | 850 break; |
| 868 } | 851 } |
| 869 case UnitType::Calc: | 852 case UnitType::Calc: |
| 870 text = m_value.calc->customCSSText(); | 853 text = m_value.calc->customCSSText(); |
| 871 break; | 854 break; |
| 872 case UnitType::CalcPercentageWithNumber: | 855 case UnitType::CalcPercentageWithNumber: |
| 873 case UnitType::CalcPercentageWithLength: | 856 case UnitType::CalcPercentageWithLength: |
| 874 ASSERT_NOT_REACHED(); | 857 ASSERT_NOT_REACHED(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 case UnitType::Seconds: | 893 case UnitType::Seconds: |
| 911 case UnitType::Hertz: | 894 case UnitType::Hertz: |
| 912 case UnitType::Kilohertz: | 895 case UnitType::Kilohertz: |
| 913 case UnitType::Turns: | 896 case UnitType::Turns: |
| 914 case UnitType::ViewportWidth: | 897 case UnitType::ViewportWidth: |
| 915 case UnitType::ViewportHeight: | 898 case UnitType::ViewportHeight: |
| 916 case UnitType::ViewportMin: | 899 case UnitType::ViewportMin: |
| 917 case UnitType::ViewportMax: | 900 case UnitType::ViewportMax: |
| 918 case UnitType::Fraction: | 901 case UnitType::Fraction: |
| 919 return m_value.num == other.m_value.num; | 902 return m_value.num == other.m_value.num; |
| 920 case UnitType::PropertyID: | |
| 921 return m_value.propertyID == other.m_value.propertyID; | |
| 922 case UnitType::ValueID: | 903 case UnitType::ValueID: |
| 923 return m_value.valueID == other.m_value.valueID; | 904 return m_value.valueID == other.m_value.valueID; |
| 924 case UnitType::RGBColor: | 905 case UnitType::RGBColor: |
| 925 return m_value.rgbcolor == other.m_value.rgbcolor; | 906 return m_value.rgbcolor == other.m_value.rgbcolor; |
| 926 case UnitType::Calc: | 907 case UnitType::Calc: |
| 927 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 908 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); |
| 928 case UnitType::Integer: | 909 case UnitType::Integer: |
| 929 case UnitType::Chs: | 910 case UnitType::Chs: |
| 930 case UnitType::CalcPercentageWithNumber: | 911 case UnitType::CalcPercentageWithNumber: |
| 931 case UnitType::CalcPercentageWithLength: | 912 case UnitType::CalcPercentageWithLength: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 943 visitor->trace(m_value.calc); | 924 visitor->trace(m_value.calc); |
| 944 break; | 925 break; |
| 945 default: | 926 default: |
| 946 break; | 927 break; |
| 947 } | 928 } |
| 948 #endif | 929 #endif |
| 949 CSSValue::traceAfterDispatch(visitor); | 930 CSSValue::traceAfterDispatch(visitor); |
| 950 } | 931 } |
| 951 | 932 |
| 952 } // namespace blink | 933 } // namespace blink |
| OLD | NEW |