| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 226 } |
| 227 | 227 |
| 228 CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitType type) | 228 CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitType type) |
| 229 : CSSValue(PrimitiveClass) | 229 : CSSValue(PrimitiveClass) |
| 230 { | 230 { |
| 231 init(type); | 231 init(type); |
| 232 ASSERT(std::isfinite(num)); | 232 ASSERT(std::isfinite(num)); |
| 233 m_value.num = num; | 233 m_value.num = num; |
| 234 } | 234 } |
| 235 | 235 |
| 236 CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitType type) | |
| 237 : CSSValue(PrimitiveClass) | |
| 238 { | |
| 239 init(type); | |
| 240 m_value.string = str.impl(); | |
| 241 if (m_value.string) | |
| 242 m_value.string->ref(); | |
| 243 } | |
| 244 | |
| 245 CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color) | 236 CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color) |
| 246 : CSSValue(PrimitiveClass) | 237 : CSSValue(PrimitiveClass) |
| 247 { | 238 { |
| 248 init(UnitType::RGBColor); | 239 init(UnitType::RGBColor); |
| 249 m_value.rgbcolor = color; | 240 m_value.rgbcolor = color; |
| 250 } | 241 } |
| 251 | 242 |
| 252 CSSPrimitiveValue::CSSPrimitiveValue(const Length& length, float zoom) | 243 CSSPrimitiveValue::CSSPrimitiveValue(const Length& length, float zoom) |
| 253 : CSSValue(PrimitiveClass) | 244 : CSSValue(PrimitiveClass) |
| 254 { | 245 { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 332 } |
| 342 | 333 |
| 343 CSSPrimitiveValue::~CSSPrimitiveValue() | 334 CSSPrimitiveValue::~CSSPrimitiveValue() |
| 344 { | 335 { |
| 345 cleanup(); | 336 cleanup(); |
| 346 } | 337 } |
| 347 | 338 |
| 348 void CSSPrimitiveValue::cleanup() | 339 void CSSPrimitiveValue::cleanup() |
| 349 { | 340 { |
| 350 switch (type()) { | 341 switch (type()) { |
| 351 case UnitType::CustomIdentifier: | |
| 352 case UnitType::String: | |
| 353 case UnitType::URI: | |
| 354 if (m_value.string) | |
| 355 m_value.string->deref(); | |
| 356 break; | |
| 357 case UnitType::Calc: | 342 case UnitType::Calc: |
| 358 // We must not call deref() when oilpan is enabled because m_value.calc
is traced. | 343 // We must not call deref() when oilpan is enabled because m_value.calc
is traced. |
| 359 #if !ENABLE(OILPAN) | 344 #if !ENABLE(OILPAN) |
| 360 m_value.calc->deref(); | 345 m_value.calc->deref(); |
| 361 #endif | 346 #endif |
| 362 break; | 347 break; |
| 363 case UnitType::CalcPercentageWithNumber: | 348 case UnitType::CalcPercentageWithNumber: |
| 364 case UnitType::CalcPercentageWithLength: | 349 case UnitType::CalcPercentageWithLength: |
| 365 ASSERT_NOT_REACHED(); | 350 ASSERT_NOT_REACHED(); |
| 366 break; | 351 break; |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 return CSSPrimitiveValue::UnitType::ViewportMin; | 717 return CSSPrimitiveValue::UnitType::ViewportMin; |
| 733 case UnitTypeViewportMax: | 718 case UnitTypeViewportMax: |
| 734 return CSSPrimitiveValue::UnitType::ViewportMax; | 719 return CSSPrimitiveValue::UnitType::ViewportMax; |
| 735 case LengthUnitTypeCount: | 720 case LengthUnitTypeCount: |
| 736 break; | 721 break; |
| 737 } | 722 } |
| 738 ASSERT_NOT_REACHED(); | 723 ASSERT_NOT_REACHED(); |
| 739 return CSSPrimitiveValue::UnitType::Unknown; | 724 return CSSPrimitiveValue::UnitType::Unknown; |
| 740 } | 725 } |
| 741 | 726 |
| 742 String CSSPrimitiveValue::getStringValue() const | |
| 743 { | |
| 744 switch (type()) { | |
| 745 case UnitType::CustomIdentifier: | |
| 746 case UnitType::String: | |
| 747 case UnitType::URI: | |
| 748 return m_value.string; | |
| 749 default: | |
| 750 break; | |
| 751 } | |
| 752 | |
| 753 ASSERT_NOT_REACHED(); | |
| 754 return String(); | |
| 755 } | |
| 756 | |
| 757 static String formatNumber(double number, const char* suffix, unsigned suffixLen
gth) | 727 static String formatNumber(double number, const char* suffix, unsigned suffixLen
gth) |
| 758 { | 728 { |
| 759 #if OS(WIN) && _MSC_VER < 1900 | 729 #if OS(WIN) && _MSC_VER < 1900 |
| 760 unsigned oldFormat = _set_output_format(_TWO_DIGIT_EXPONENT); | 730 unsigned oldFormat = _set_output_format(_TWO_DIGIT_EXPONENT); |
| 761 #endif | 731 #endif |
| 762 String result = String::format("%.6g", number); | 732 String result = String::format("%.6g", number); |
| 763 #if OS(WIN) && _MSC_VER < 1900 | 733 #if OS(WIN) && _MSC_VER < 1900 |
| 764 _set_output_format(oldFormat); | 734 _set_output_format(oldFormat); |
| 765 #endif | 735 #endif |
| 766 result.append(suffix, suffixLength); | 736 result.append(suffix, suffixLength); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 return "fr"; | 802 return "fr"; |
| 833 case UnitType::ViewportWidth: | 803 case UnitType::ViewportWidth: |
| 834 return "vw"; | 804 return "vw"; |
| 835 case UnitType::ViewportHeight: | 805 case UnitType::ViewportHeight: |
| 836 return "vh"; | 806 return "vh"; |
| 837 case UnitType::ViewportMin: | 807 case UnitType::ViewportMin: |
| 838 return "vmin"; | 808 return "vmin"; |
| 839 case UnitType::ViewportMax: | 809 case UnitType::ViewportMax: |
| 840 return "vmax"; | 810 return "vmax"; |
| 841 case UnitType::Unknown: | 811 case UnitType::Unknown: |
| 842 case UnitType::CustomIdentifier: | |
| 843 case UnitType::String: | |
| 844 case UnitType::URI: | |
| 845 case UnitType::ValueID: | 812 case UnitType::ValueID: |
| 846 case UnitType::PropertyID: | 813 case UnitType::PropertyID: |
| 847 case UnitType::RGBColor: | 814 case UnitType::RGBColor: |
| 848 case UnitType::Calc: | 815 case UnitType::Calc: |
| 849 case UnitType::Shape: | 816 case UnitType::Shape: |
| 850 case UnitType::CalcPercentageWithNumber: | 817 case UnitType::CalcPercentageWithNumber: |
| 851 case UnitType::CalcPercentageWithLength: | 818 case UnitType::CalcPercentageWithLength: |
| 852 case UnitType::QuirkyEms: | 819 case UnitType::QuirkyEms: |
| 853 break; | 820 break; |
| 854 }; | 821 }; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 case UnitType::Hertz: | 861 case UnitType::Hertz: |
| 895 case UnitType::Kilohertz: | 862 case UnitType::Kilohertz: |
| 896 case UnitType::Turns: | 863 case UnitType::Turns: |
| 897 case UnitType::Fraction: | 864 case UnitType::Fraction: |
| 898 case UnitType::ViewportWidth: | 865 case UnitType::ViewportWidth: |
| 899 case UnitType::ViewportHeight: | 866 case UnitType::ViewportHeight: |
| 900 case UnitType::ViewportMin: | 867 case UnitType::ViewportMin: |
| 901 case UnitType::ViewportMax: | 868 case UnitType::ViewportMax: |
| 902 text = formatNumber(m_value.num, unitTypeToString(type())); | 869 text = formatNumber(m_value.num, unitTypeToString(type())); |
| 903 break; | 870 break; |
| 904 case UnitType::CustomIdentifier: | |
| 905 text = quoteCSSStringIfNeeded(m_value.string); | |
| 906 break; | |
| 907 case UnitType::String: { | |
| 908 text = serializeString(m_value.string); | |
| 909 break; | |
| 910 } | |
| 911 case UnitType::URI: | |
| 912 text = "url(" + quoteCSSURLIfNeeded(m_value.string) + ")"; | |
| 913 break; | |
| 914 case UnitType::ValueID: | 871 case UnitType::ValueID: |
| 915 text = valueName(m_value.valueID); | 872 text = valueName(m_value.valueID); |
| 916 break; | 873 break; |
| 917 case UnitType::PropertyID: | 874 case UnitType::PropertyID: |
| 918 text = propertyName(m_value.propertyID); | 875 text = propertyName(m_value.propertyID); |
| 919 break; | 876 break; |
| 920 case UnitType::RGBColor: { | 877 case UnitType::RGBColor: { |
| 921 text = Color(m_value.rgbcolor).serializedAsCSSComponentValue(); | 878 text = Color(m_value.rgbcolor).serializedAsCSSComponentValue(); |
| 922 break; | 879 break; |
| 923 } | 880 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 case UnitType::ViewportWidth: | 930 case UnitType::ViewportWidth: |
| 974 case UnitType::ViewportHeight: | 931 case UnitType::ViewportHeight: |
| 975 case UnitType::ViewportMin: | 932 case UnitType::ViewportMin: |
| 976 case UnitType::ViewportMax: | 933 case UnitType::ViewportMax: |
| 977 case UnitType::Fraction: | 934 case UnitType::Fraction: |
| 978 return m_value.num == other.m_value.num; | 935 return m_value.num == other.m_value.num; |
| 979 case UnitType::PropertyID: | 936 case UnitType::PropertyID: |
| 980 return m_value.propertyID == other.m_value.propertyID; | 937 return m_value.propertyID == other.m_value.propertyID; |
| 981 case UnitType::ValueID: | 938 case UnitType::ValueID: |
| 982 return m_value.valueID == other.m_value.valueID; | 939 return m_value.valueID == other.m_value.valueID; |
| 983 case UnitType::CustomIdentifier: | |
| 984 case UnitType::String: | |
| 985 case UnitType::URI: | |
| 986 return equal(m_value.string, other.m_value.string); | |
| 987 case UnitType::RGBColor: | 940 case UnitType::RGBColor: |
| 988 return m_value.rgbcolor == other.m_value.rgbcolor; | 941 return m_value.rgbcolor == other.m_value.rgbcolor; |
| 989 case UnitType::Calc: | 942 case UnitType::Calc: |
| 990 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 943 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); |
| 991 case UnitType::Shape: | 944 case UnitType::Shape: |
| 992 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); | 945 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); |
| 993 case UnitType::Integer: | 946 case UnitType::Integer: |
| 994 case UnitType::Chs: | 947 case UnitType::Chs: |
| 995 case UnitType::CalcPercentageWithNumber: | 948 case UnitType::CalcPercentageWithNumber: |
| 996 case UnitType::CalcPercentageWithLength: | 949 case UnitType::CalcPercentageWithLength: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1011 visitor->trace(m_value.shape); | 964 visitor->trace(m_value.shape); |
| 1012 break; | 965 break; |
| 1013 default: | 966 default: |
| 1014 break; | 967 break; |
| 1015 } | 968 } |
| 1016 #endif | 969 #endif |
| 1017 CSSValue::traceAfterDispatch(visitor); | 970 CSSValue::traceAfterDispatch(visitor); |
| 1018 } | 971 } |
| 1019 | 972 |
| 1020 } // namespace blink | 973 } // namespace blink |
| OLD | NEW |