| 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, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include "core/css/CSSPrimitiveValue.h" | 21 #include "core/css/CSSPrimitiveValue.h" |
| 22 | 22 |
| 23 #include "core/css/CSSCalculationValue.h" | 23 #include "core/css/CSSCalculationValue.h" |
| 24 #include "core/css/CSSHelper.h" | 24 #include "core/css/CSSHelper.h" |
| 25 #include "core/css/CSSMarkup.h" | 25 #include "core/css/CSSMarkup.h" |
| 26 #include "core/css/CSSToLengthConversionData.h" | 26 #include "core/css/CSSToLengthConversionData.h" |
| 27 #include "core/css/StyleSheetContents.h" | 27 #include "core/css/StyleSheetContents.h" |
| 28 #include "core/css/serializer/CSSDeserializeStream.h" |
| 29 #include "core/css/serializer/CSSSerializeStream.h" |
| 28 #include "core/dom/Node.h" | 30 #include "core/dom/Node.h" |
| 29 #include "core/style/ComputedStyle.h" | 31 #include "core/style/ComputedStyle.h" |
| 30 #include "platform/LayoutUnit.h" | 32 #include "platform/LayoutUnit.h" |
| 31 #include "platform/fonts/FontMetrics.h" | 33 #include "platform/fonts/FontMetrics.h" |
| 32 #include "wtf/StdLibExtras.h" | 34 #include "wtf/StdLibExtras.h" |
| 33 #include "wtf/ThreadSpecific.h" | 35 #include "wtf/ThreadSpecific.h" |
| 34 #include "wtf/Threading.h" | 36 #include "wtf/Threading.h" |
| 35 #include "wtf/text/StringBuffer.h" | 37 #include "wtf/text/StringBuffer.h" |
| 36 #include "wtf/text/StringBuilder.h" | 38 #include "wtf/text/StringBuilder.h" |
| 37 | 39 |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 848 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); |
| 847 case UnitType::Chs: | 849 case UnitType::Chs: |
| 848 case UnitType::CalcPercentageWithNumber: | 850 case UnitType::CalcPercentageWithNumber: |
| 849 case UnitType::CalcPercentageWithLength: | 851 case UnitType::CalcPercentageWithLength: |
| 850 case UnitType::QuirkyEms: | 852 case UnitType::QuirkyEms: |
| 851 return false; | 853 return false; |
| 852 } | 854 } |
| 853 return false; | 855 return false; |
| 854 } | 856 } |
| 855 | 857 |
| 858 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPrimitiveValue::deserialize(CSSDese
rializeStream* stream) |
| 859 { |
| 860 RefPtrWillBeRawPtr<CSSValue> value = stream->readNullableRef<CSSValue>(); |
| 861 if (!value) |
| 862 return nullptr; |
| 863 return toCSSPrimitiveValue(value.get()); |
| 864 } |
| 865 |
| 866 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPrimitiveValue::deserializeAfterDis
patch(CSSDeserializeStream* stream) |
| 867 { |
| 868 UnitType type = static_cast<UnitType>(stream->readUnsigned()); |
| 869 switch (type) { |
| 870 case UnitType::Calc: { |
| 871 RefPtrWillBeRawPtr<CSSCalcValue> calcValue = CSSCalcValue::deserialize(s
tream); |
| 872 return create(calcValue.release()); |
| 873 } |
| 874 case UnitType::CalcPercentageWithNumber: |
| 875 case UnitType::CalcPercentageWithLength: |
| 876 case UnitType::Unknown: |
| 877 default: |
| 878 ASSERT_NOT_REACHED(); |
| 879 return nullptr; |
| 880 case UnitType::Number: |
| 881 case UnitType::Integer: |
| 882 case UnitType::Percentage: |
| 883 case UnitType::Ems: |
| 884 case UnitType::QuirkyEms: |
| 885 case UnitType::Exs: |
| 886 case UnitType::Rems: |
| 887 case UnitType::Chs: |
| 888 case UnitType::Centimeters: |
| 889 case UnitType::Millimeters: |
| 890 case UnitType::Inches: |
| 891 case UnitType::Points: |
| 892 case UnitType::Picas: |
| 893 case UnitType::UserUnits: |
| 894 case UnitType::Degrees: |
| 895 case UnitType::Radians: |
| 896 case UnitType::Gradians: |
| 897 case UnitType::Milliseconds: |
| 898 case UnitType::Seconds: |
| 899 case UnitType::Hertz: |
| 900 case UnitType::Kilohertz: |
| 901 case UnitType::Turns: |
| 902 case UnitType::ViewportWidth: |
| 903 case UnitType::ViewportHeight: |
| 904 case UnitType::ViewportMin: |
| 905 case UnitType::ViewportMax: |
| 906 case UnitType::DotsPerPixel: |
| 907 case UnitType::DotsPerInch: |
| 908 case UnitType::DotsPerCentimeter: |
| 909 case UnitType::Fraction: |
| 910 case UnitType::Pixels: { |
| 911 double num = stream->readDouble(); |
| 912 return create(num, type); |
| 913 } |
| 914 case UnitType::ValueID: { |
| 915 unsigned valueID = stream->readUnsigned(); |
| 916 return createIdentifier(static_cast<CSSValueID>(valueID)); |
| 917 } |
| 918 } |
| 919 } |
| 920 |
| 921 void CSSPrimitiveValue::serializeAfterDispatch(CSSSerializeStream* stream) const |
| 922 { |
| 923 stream->writeEnumAsInt<UnitType>(type()); |
| 924 switch (type()) { |
| 925 case UnitType::Calc: |
| 926 cssCalcValue()->serialize(stream); |
| 927 break; |
| 928 case UnitType::CalcPercentageWithNumber: |
| 929 case UnitType::CalcPercentageWithLength: |
| 930 case UnitType::Unknown: |
| 931 default: |
| 932 ASSERT_NOT_REACHED(); |
| 933 break; |
| 934 case UnitType::Number: |
| 935 case UnitType::Integer: |
| 936 case UnitType::Percentage: |
| 937 case UnitType::Ems: |
| 938 case UnitType::QuirkyEms: |
| 939 case UnitType::Exs: |
| 940 case UnitType::Rems: |
| 941 case UnitType::Chs: |
| 942 case UnitType::Centimeters: |
| 943 case UnitType::Millimeters: |
| 944 case UnitType::Inches: |
| 945 case UnitType::Points: |
| 946 case UnitType::Picas: |
| 947 case UnitType::UserUnits: |
| 948 case UnitType::Degrees: |
| 949 case UnitType::Radians: |
| 950 case UnitType::Gradians: |
| 951 case UnitType::Milliseconds: |
| 952 case UnitType::Seconds: |
| 953 case UnitType::Hertz: |
| 954 case UnitType::Kilohertz: |
| 955 case UnitType::Turns: |
| 956 case UnitType::ViewportWidth: |
| 957 case UnitType::ViewportHeight: |
| 958 case UnitType::ViewportMin: |
| 959 case UnitType::ViewportMax: |
| 960 case UnitType::DotsPerPixel: |
| 961 case UnitType::DotsPerInch: |
| 962 case UnitType::DotsPerCentimeter: |
| 963 case UnitType::Fraction: |
| 964 case UnitType::Pixels: |
| 965 stream->writeDouble(m_value.num); |
| 966 break; |
| 967 case UnitType::ValueID: |
| 968 stream->writeUnsigned(static_cast<unsigned>(m_value.valueID)); |
| 969 break; |
| 970 } |
| 971 } |
| 972 |
| 856 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue) | 973 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue) |
| 857 { | 974 { |
| 858 #if ENABLE(OILPAN) | 975 #if ENABLE(OILPAN) |
| 859 switch (type()) { | 976 switch (type()) { |
| 860 case UnitType::Calc: | 977 case UnitType::Calc: |
| 861 visitor->trace(m_value.calc); | 978 visitor->trace(m_value.calc); |
| 862 break; | 979 break; |
| 863 default: | 980 default: |
| 864 break; | 981 break; |
| 865 } | 982 } |
| 866 #endif | 983 #endif |
| 867 CSSValue::traceAfterDispatch(visitor); | 984 CSSValue::traceAfterDispatch(visitor); |
| 868 } | 985 } |
| 869 | 986 |
| 870 } // namespace blink | 987 } // namespace blink |
| OLD | NEW |