| 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 "config.h" | 21 #include "config.h" |
| 22 #include "core/css/CSSPrimitiveValue.h" | 22 #include "core/css/CSSPrimitiveValue.h" |
| 23 | 23 |
| 24 #include "core/css/CSSBasicShapes.h" | 24 #include "core/css/CSSBasicShapes.h" |
| 25 #include "core/css/CSSCalculationValue.h" | 25 #include "core/css/CSSCalculationValue.h" |
| 26 #include "core/css/CSSHelper.h" | 26 #include "core/css/CSSHelper.h" |
| 27 #include "core/css/CSSMarkup.h" | 27 #include "core/css/CSSMarkup.h" |
| 28 #include "core/css/CSSToLengthConversionData.h" | 28 #include "core/css/CSSToLengthConversionData.h" |
| 29 #include "core/css/Pair.h" | |
| 30 #include "core/css/StyleSheetContents.h" | 29 #include "core/css/StyleSheetContents.h" |
| 31 #include "core/dom/Node.h" | 30 #include "core/dom/Node.h" |
| 32 #include "core/style/ComputedStyle.h" | 31 #include "core/style/ComputedStyle.h" |
| 33 #include "platform/LayoutUnit.h" | 32 #include "platform/LayoutUnit.h" |
| 34 #include "platform/fonts/FontMetrics.h" | 33 #include "platform/fonts/FontMetrics.h" |
| 35 #include "wtf/StdLibExtras.h" | 34 #include "wtf/StdLibExtras.h" |
| 36 #include "wtf/ThreadSpecific.h" | 35 #include "wtf/ThreadSpecific.h" |
| 37 #include "wtf/Threading.h" | 36 #include "wtf/Threading.h" |
| 38 #include "wtf/text/StringBuffer.h" | 37 #include "wtf/text/StringBuffer.h" |
| 39 #include "wtf/text/StringBuilder.h" | 38 #include "wtf/text/StringBuilder.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 235 |
| 237 CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitType type) | 236 CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitType type) |
| 238 : CSSValue(PrimitiveClass) | 237 : CSSValue(PrimitiveClass) |
| 239 { | 238 { |
| 240 init(type); | 239 init(type); |
| 241 m_value.string = str.impl(); | 240 m_value.string = str.impl(); |
| 242 if (m_value.string) | 241 if (m_value.string) |
| 243 m_value.string->ref(); | 242 m_value.string->ref(); |
| 244 } | 243 } |
| 245 | 244 |
| 246 CSSPrimitiveValue::CSSPrimitiveValue(const LengthSize& lengthSize, const Compute
dStyle& style) | |
| 247 : CSSValue(PrimitiveClass) | |
| 248 { | |
| 249 init(lengthSize, style); | |
| 250 } | |
| 251 | |
| 252 CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color) | 245 CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color) |
| 253 : CSSValue(PrimitiveClass) | 246 : CSSValue(PrimitiveClass) |
| 254 { | 247 { |
| 255 init(UnitType::RGBColor); | 248 init(UnitType::RGBColor); |
| 256 m_value.rgbcolor = color; | 249 m_value.rgbcolor = color; |
| 257 } | 250 } |
| 258 | 251 |
| 259 CSSPrimitiveValue::CSSPrimitiveValue(const Length& length, float zoom) | 252 CSSPrimitiveValue::CSSPrimitiveValue(const Length& length, float zoom) |
| 260 : CSSValue(PrimitiveClass) | 253 : CSSValue(PrimitiveClass) |
| 261 { | 254 { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 ASSERT_NOT_REACHED(); | 319 ASSERT_NOT_REACHED(); |
| 327 break; | 320 break; |
| 328 } | 321 } |
| 329 } | 322 } |
| 330 | 323 |
| 331 void CSSPrimitiveValue::init(UnitType type) | 324 void CSSPrimitiveValue::init(UnitType type) |
| 332 { | 325 { |
| 333 m_primitiveUnitType = static_cast<unsigned>(type); | 326 m_primitiveUnitType = static_cast<unsigned>(type); |
| 334 } | 327 } |
| 335 | 328 |
| 336 void CSSPrimitiveValue::init(const LengthSize& lengthSize, const ComputedStyle&
style) | |
| 337 { | |
| 338 init(UnitType::Pair); | |
| 339 m_hasCachedCSSText = false; | |
| 340 m_value.pair = Pair::create(create(lengthSize.width(), style.effectiveZoom()
), create(lengthSize.height(), style.effectiveZoom()), Pair::KeepIdenticalValues
).leakRef(); | |
| 341 } | |
| 342 | |
| 343 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Pair> p) | |
| 344 { | |
| 345 init(UnitType::Pair); | |
| 346 m_hasCachedCSSText = false; | |
| 347 m_value.pair = p.leakRef(); | |
| 348 } | |
| 349 | |
| 350 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSCalcValue> c) | 329 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSCalcValue> c) |
| 351 { | 330 { |
| 352 init(UnitType::Calc); | 331 init(UnitType::Calc); |
| 353 m_hasCachedCSSText = false; | 332 m_hasCachedCSSText = false; |
| 354 m_value.calc = c.leakRef(); | 333 m_value.calc = c.leakRef(); |
| 355 } | 334 } |
| 356 | 335 |
| 357 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSBasicShape> shape) | 336 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSBasicShape> shape) |
| 358 { | 337 { |
| 359 init(UnitType::Shape); | 338 init(UnitType::Shape); |
| 360 m_hasCachedCSSText = false; | 339 m_hasCachedCSSText = false; |
| 361 m_value.shape = shape.leakRef(); | 340 m_value.shape = shape.leakRef(); |
| 362 } | 341 } |
| 363 | 342 |
| 364 CSSPrimitiveValue::~CSSPrimitiveValue() | 343 CSSPrimitiveValue::~CSSPrimitiveValue() |
| 365 { | 344 { |
| 366 cleanup(); | 345 cleanup(); |
| 367 } | 346 } |
| 368 | 347 |
| 369 void CSSPrimitiveValue::cleanup() | 348 void CSSPrimitiveValue::cleanup() |
| 370 { | 349 { |
| 371 switch (type()) { | 350 switch (type()) { |
| 372 case UnitType::CustomIdentifier: | 351 case UnitType::CustomIdentifier: |
| 373 case UnitType::String: | 352 case UnitType::String: |
| 374 case UnitType::URI: | 353 case UnitType::URI: |
| 375 case UnitType::Attribute: | 354 case UnitType::Attribute: |
| 376 if (m_value.string) | 355 if (m_value.string) |
| 377 m_value.string->deref(); | 356 m_value.string->deref(); |
| 378 break; | 357 break; |
| 379 case UnitType::Pair: | |
| 380 // We must not call deref() when oilpan is enabled because m_value.pair
is traced. | |
| 381 #if !ENABLE(OILPAN) | |
| 382 m_value.pair->deref(); | |
| 383 #endif | |
| 384 break; | |
| 385 case UnitType::Calc: | 358 case UnitType::Calc: |
| 386 // We must not call deref() when oilpan is enabled because m_value.calc
is traced. | 359 // We must not call deref() when oilpan is enabled because m_value.calc
is traced. |
| 387 #if !ENABLE(OILPAN) | 360 #if !ENABLE(OILPAN) |
| 388 m_value.calc->deref(); | 361 m_value.calc->deref(); |
| 389 #endif | 362 #endif |
| 390 break; | 363 break; |
| 391 case UnitType::CalcPercentageWithNumber: | 364 case UnitType::CalcPercentageWithNumber: |
| 392 case UnitType::CalcPercentageWithLength: | 365 case UnitType::CalcPercentageWithLength: |
| 393 ASSERT_NOT_REACHED(); | 366 ASSERT_NOT_REACHED(); |
| 394 break; | 367 break; |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 case UnitType::ViewportMax: | 844 case UnitType::ViewportMax: |
| 872 return "vmax"; | 845 return "vmax"; |
| 873 case UnitType::Unknown: | 846 case UnitType::Unknown: |
| 874 case UnitType::CustomIdentifier: | 847 case UnitType::CustomIdentifier: |
| 875 case UnitType::String: | 848 case UnitType::String: |
| 876 case UnitType::URI: | 849 case UnitType::URI: |
| 877 case UnitType::ValueID: | 850 case UnitType::ValueID: |
| 878 case UnitType::PropertyID: | 851 case UnitType::PropertyID: |
| 879 case UnitType::Attribute: | 852 case UnitType::Attribute: |
| 880 case UnitType::RGBColor: | 853 case UnitType::RGBColor: |
| 881 case UnitType::Pair: | |
| 882 case UnitType::Calc: | 854 case UnitType::Calc: |
| 883 case UnitType::Shape: | 855 case UnitType::Shape: |
| 884 case UnitType::CalcPercentageWithNumber: | 856 case UnitType::CalcPercentageWithNumber: |
| 885 case UnitType::CalcPercentageWithLength: | 857 case UnitType::CalcPercentageWithLength: |
| 886 case UnitType::QuirkyEms: | 858 case UnitType::QuirkyEms: |
| 887 break; | 859 break; |
| 888 }; | 860 }; |
| 889 ASSERT_NOT_REACHED(); | 861 ASSERT_NOT_REACHED(); |
| 890 return ""; | 862 return ""; |
| 891 } | 863 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 result.append(m_value.string); | 930 result.append(m_value.string); |
| 959 result.append(')'); | 931 result.append(')'); |
| 960 | 932 |
| 961 text = result.toString(); | 933 text = result.toString(); |
| 962 break; | 934 break; |
| 963 } | 935 } |
| 964 case UnitType::RGBColor: { | 936 case UnitType::RGBColor: { |
| 965 text = Color(m_value.rgbcolor).serializedAsCSSComponentValue(); | 937 text = Color(m_value.rgbcolor).serializedAsCSSComponentValue(); |
| 966 break; | 938 break; |
| 967 } | 939 } |
| 968 case UnitType::Pair: | |
| 969 text = getPairValue()->cssText(); | |
| 970 break; | |
| 971 case UnitType::Calc: | 940 case UnitType::Calc: |
| 972 text = m_value.calc->customCSSText(); | 941 text = m_value.calc->customCSSText(); |
| 973 break; | 942 break; |
| 974 case UnitType::Shape: | 943 case UnitType::Shape: |
| 975 text = m_value.shape->cssText(); | 944 text = m_value.shape->cssText(); |
| 976 break; | 945 break; |
| 977 case UnitType::CalcPercentageWithNumber: | 946 case UnitType::CalcPercentageWithNumber: |
| 978 case UnitType::CalcPercentageWithLength: | 947 case UnitType::CalcPercentageWithLength: |
| 979 case UnitType::QuirkyEms: | 948 case UnitType::QuirkyEms: |
| 980 ASSERT_NOT_REACHED(); | 949 ASSERT_NOT_REACHED(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 return m_value.propertyID == other.m_value.propertyID; | 996 return m_value.propertyID == other.m_value.propertyID; |
| 1028 case UnitType::ValueID: | 997 case UnitType::ValueID: |
| 1029 return m_value.valueID == other.m_value.valueID; | 998 return m_value.valueID == other.m_value.valueID; |
| 1030 case UnitType::CustomIdentifier: | 999 case UnitType::CustomIdentifier: |
| 1031 case UnitType::String: | 1000 case UnitType::String: |
| 1032 case UnitType::URI: | 1001 case UnitType::URI: |
| 1033 case UnitType::Attribute: | 1002 case UnitType::Attribute: |
| 1034 return equal(m_value.string, other.m_value.string); | 1003 return equal(m_value.string, other.m_value.string); |
| 1035 case UnitType::RGBColor: | 1004 case UnitType::RGBColor: |
| 1036 return m_value.rgbcolor == other.m_value.rgbcolor; | 1005 return m_value.rgbcolor == other.m_value.rgbcolor; |
| 1037 case UnitType::Pair: | |
| 1038 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other
.m_value.pair); | |
| 1039 case UnitType::Calc: | 1006 case UnitType::Calc: |
| 1040 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 1007 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); |
| 1041 case UnitType::Shape: | 1008 case UnitType::Shape: |
| 1042 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); | 1009 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); |
| 1043 case UnitType::Integer: | 1010 case UnitType::Integer: |
| 1044 case UnitType::Chs: | 1011 case UnitType::Chs: |
| 1045 case UnitType::CalcPercentageWithNumber: | 1012 case UnitType::CalcPercentageWithNumber: |
| 1046 case UnitType::CalcPercentageWithLength: | 1013 case UnitType::CalcPercentageWithLength: |
| 1047 case UnitType::QuirkyEms: | 1014 case UnitType::QuirkyEms: |
| 1048 return false; | 1015 return false; |
| 1049 } | 1016 } |
| 1050 return false; | 1017 return false; |
| 1051 } | 1018 } |
| 1052 | 1019 |
| 1053 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue) | 1020 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue) |
| 1054 { | 1021 { |
| 1055 #if ENABLE(OILPAN) | 1022 #if ENABLE(OILPAN) |
| 1056 switch (type()) { | 1023 switch (type()) { |
| 1057 case UnitType::Pair: | |
| 1058 visitor->trace(m_value.pair); | |
| 1059 break; | |
| 1060 case UnitType::Calc: | 1024 case UnitType::Calc: |
| 1061 visitor->trace(m_value.calc); | 1025 visitor->trace(m_value.calc); |
| 1062 break; | 1026 break; |
| 1063 case UnitType::Shape: | 1027 case UnitType::Shape: |
| 1064 visitor->trace(m_value.shape); | 1028 visitor->trace(m_value.shape); |
| 1065 break; | 1029 break; |
| 1066 default: | 1030 default: |
| 1067 break; | 1031 break; |
| 1068 } | 1032 } |
| 1069 #endif | 1033 #endif |
| 1070 CSSValue::traceAfterDispatch(visitor); | 1034 CSSValue::traceAfterDispatch(visitor); |
| 1071 } | 1035 } |
| 1072 | 1036 |
| 1073 } // namespace blink | 1037 } // namespace blink |
| OLD | NEW |