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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 213 } |
214 | 214 |
215 CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitType type) | 215 CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitType type) |
216 : CSSValue(PrimitiveClass) | 216 : CSSValue(PrimitiveClass) |
217 { | 217 { |
218 init(type); | 218 init(type); |
219 ASSERT(std::isfinite(num)); | 219 ASSERT(std::isfinite(num)); |
220 m_value.num = num; | 220 m_value.num = num; |
221 } | 221 } |
222 | 222 |
223 CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color) | |
224 : CSSValue(PrimitiveClass) | |
225 { | |
226 init(UnitType::RGBColor); | |
227 m_value.rgbcolor = color; | |
228 } | |
229 | |
230 CSSPrimitiveValue::CSSPrimitiveValue(const Length& length, float zoom) | 223 CSSPrimitiveValue::CSSPrimitiveValue(const Length& length, float zoom) |
231 : CSSValue(PrimitiveClass) | 224 : CSSValue(PrimitiveClass) |
232 { | 225 { |
233 switch (length.type()) { | 226 switch (length.type()) { |
234 case Auto: | 227 case Auto: |
235 init(UnitType::ValueID); | 228 init(UnitType::ValueID); |
236 m_value.valueID = CSSValueAuto; | 229 m_value.valueID = CSSValueAuto; |
237 break; | 230 break; |
238 case Intrinsic: | 231 case Intrinsic: |
239 init(UnitType::ValueID); | 232 init(UnitType::ValueID); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 case UnitType::Kilohertz: | 345 case UnitType::Kilohertz: |
353 case UnitType::Turns: | 346 case UnitType::Turns: |
354 case UnitType::ViewportWidth: | 347 case UnitType::ViewportWidth: |
355 case UnitType::ViewportHeight: | 348 case UnitType::ViewportHeight: |
356 case UnitType::ViewportMin: | 349 case UnitType::ViewportMin: |
357 case UnitType::ViewportMax: | 350 case UnitType::ViewportMax: |
358 case UnitType::DotsPerPixel: | 351 case UnitType::DotsPerPixel: |
359 case UnitType::DotsPerInch: | 352 case UnitType::DotsPerInch: |
360 case UnitType::DotsPerCentimeter: | 353 case UnitType::DotsPerCentimeter: |
361 case UnitType::Fraction: | 354 case UnitType::Fraction: |
362 case UnitType::RGBColor: | |
363 case UnitType::Unknown: | 355 case UnitType::Unknown: |
364 case UnitType::ValueID: | 356 case UnitType::ValueID: |
365 break; | 357 break; |
366 } | 358 } |
367 if (m_hasCachedCSSText) { | 359 if (m_hasCachedCSSText) { |
368 cssTextCache().remove(this); | 360 cssTextCache().remove(this); |
369 m_hasCachedCSSText = false; | 361 m_hasCachedCSSText = false; |
370 } | 362 } |
371 } | 363 } |
372 | 364 |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 case UnitType::ViewportWidth: | 771 case UnitType::ViewportWidth: |
780 return "vw"; | 772 return "vw"; |
781 case UnitType::ViewportHeight: | 773 case UnitType::ViewportHeight: |
782 return "vh"; | 774 return "vh"; |
783 case UnitType::ViewportMin: | 775 case UnitType::ViewportMin: |
784 return "vmin"; | 776 return "vmin"; |
785 case UnitType::ViewportMax: | 777 case UnitType::ViewportMax: |
786 return "vmax"; | 778 return "vmax"; |
787 case UnitType::Unknown: | 779 case UnitType::Unknown: |
788 case UnitType::ValueID: | 780 case UnitType::ValueID: |
789 case UnitType::RGBColor: | |
790 case UnitType::Calc: | 781 case UnitType::Calc: |
791 case UnitType::CalcPercentageWithNumber: | 782 case UnitType::CalcPercentageWithNumber: |
792 case UnitType::CalcPercentageWithLength: | 783 case UnitType::CalcPercentageWithLength: |
793 break; | 784 break; |
794 }; | 785 }; |
795 ASSERT_NOT_REACHED(); | 786 ASSERT_NOT_REACHED(); |
796 return ""; | 787 return ""; |
797 } | 788 } |
798 | 789 |
799 String CSSPrimitiveValue::customCSSText() const | 790 String CSSPrimitiveValue::customCSSText() const |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 case UnitType::Fraction: | 829 case UnitType::Fraction: |
839 case UnitType::ViewportWidth: | 830 case UnitType::ViewportWidth: |
840 case UnitType::ViewportHeight: | 831 case UnitType::ViewportHeight: |
841 case UnitType::ViewportMin: | 832 case UnitType::ViewportMin: |
842 case UnitType::ViewportMax: | 833 case UnitType::ViewportMax: |
843 text = formatNumber(m_value.num, unitTypeToString(type())); | 834 text = formatNumber(m_value.num, unitTypeToString(type())); |
844 break; | 835 break; |
845 case UnitType::ValueID: | 836 case UnitType::ValueID: |
846 text = valueName(m_value.valueID); | 837 text = valueName(m_value.valueID); |
847 break; | 838 break; |
848 case UnitType::RGBColor: { | |
849 text = Color(m_value.rgbcolor).serializedAsCSSComponentValue(); | |
850 break; | |
851 } | |
852 case UnitType::Calc: | 839 case UnitType::Calc: |
853 text = m_value.calc->customCSSText(); | 840 text = m_value.calc->customCSSText(); |
854 break; | 841 break; |
855 case UnitType::CalcPercentageWithNumber: | 842 case UnitType::CalcPercentageWithNumber: |
856 case UnitType::CalcPercentageWithLength: | 843 case UnitType::CalcPercentageWithLength: |
857 ASSERT_NOT_REACHED(); | 844 ASSERT_NOT_REACHED(); |
858 break; | 845 break; |
859 } | 846 } |
860 | 847 |
861 ASSERT(!cssTextCache().contains(this)); | 848 ASSERT(!cssTextCache().contains(this)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 case UnitType::Kilohertz: | 882 case UnitType::Kilohertz: |
896 case UnitType::Turns: | 883 case UnitType::Turns: |
897 case UnitType::ViewportWidth: | 884 case UnitType::ViewportWidth: |
898 case UnitType::ViewportHeight: | 885 case UnitType::ViewportHeight: |
899 case UnitType::ViewportMin: | 886 case UnitType::ViewportMin: |
900 case UnitType::ViewportMax: | 887 case UnitType::ViewportMax: |
901 case UnitType::Fraction: | 888 case UnitType::Fraction: |
902 return m_value.num == other.m_value.num; | 889 return m_value.num == other.m_value.num; |
903 case UnitType::ValueID: | 890 case UnitType::ValueID: |
904 return m_value.valueID == other.m_value.valueID; | 891 return m_value.valueID == other.m_value.valueID; |
905 case UnitType::RGBColor: | |
906 return m_value.rgbcolor == other.m_value.rgbcolor; | |
907 case UnitType::Calc: | 892 case UnitType::Calc: |
908 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 893 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); |
909 case UnitType::Integer: | 894 case UnitType::Integer: |
910 case UnitType::Chs: | 895 case UnitType::Chs: |
911 case UnitType::CalcPercentageWithNumber: | 896 case UnitType::CalcPercentageWithNumber: |
912 case UnitType::CalcPercentageWithLength: | 897 case UnitType::CalcPercentageWithLength: |
913 case UnitType::QuirkyEms: | 898 case UnitType::QuirkyEms: |
914 return false; | 899 return false; |
915 } | 900 } |
916 return false; | 901 return false; |
917 } | 902 } |
918 | 903 |
919 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue) | 904 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue) |
920 { | 905 { |
921 #if ENABLE(OILPAN) | 906 #if ENABLE(OILPAN) |
922 switch (type()) { | 907 switch (type()) { |
923 case UnitType::Calc: | 908 case UnitType::Calc: |
924 visitor->trace(m_value.calc); | 909 visitor->trace(m_value.calc); |
925 break; | 910 break; |
926 default: | 911 default: |
927 break; | 912 break; |
928 } | 913 } |
929 #endif | 914 #endif |
930 CSSValue::traceAfterDispatch(visitor); | 915 CSSValue::traceAfterDispatch(visitor); |
931 } | 916 } |
932 | 917 |
933 } // namespace blink | 918 } // namespace blink |
OLD | NEW |