| 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" | 29 #include "core/css/Pair.h" |
| 30 #include "core/css/Rect.h" | |
| 31 #include "core/css/StyleSheetContents.h" | 30 #include "core/css/StyleSheetContents.h" |
| 32 #include "core/dom/Node.h" | 31 #include "core/dom/Node.h" |
| 33 #include "core/style/ComputedStyle.h" | 32 #include "core/style/ComputedStyle.h" |
| 34 #include "platform/LayoutUnit.h" | 33 #include "platform/LayoutUnit.h" |
| 35 #include "platform/fonts/FontMetrics.h" | 34 #include "platform/fonts/FontMetrics.h" |
| 36 #include "wtf/StdLibExtras.h" | 35 #include "wtf/StdLibExtras.h" |
| 37 #include "wtf/ThreadSpecific.h" | 36 #include "wtf/ThreadSpecific.h" |
| 38 #include "wtf/Threading.h" | 37 #include "wtf/Threading.h" |
| 39 #include "wtf/text/StringBuffer.h" | 38 #include "wtf/text/StringBuffer.h" |
| 40 #include "wtf/text/StringBuilder.h" | 39 #include "wtf/text/StringBuilder.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 m_primitiveUnitType = static_cast<unsigned>(type); | 333 m_primitiveUnitType = static_cast<unsigned>(type); |
| 335 } | 334 } |
| 336 | 335 |
| 337 void CSSPrimitiveValue::init(const LengthSize& lengthSize, const ComputedStyle&
style) | 336 void CSSPrimitiveValue::init(const LengthSize& lengthSize, const ComputedStyle&
style) |
| 338 { | 337 { |
| 339 init(UnitType::Pair); | 338 init(UnitType::Pair); |
| 340 m_hasCachedCSSText = false; | 339 m_hasCachedCSSText = false; |
| 341 m_value.pair = Pair::create(create(lengthSize.width(), style.effectiveZoom()
), create(lengthSize.height(), style.effectiveZoom()), Pair::KeepIdenticalValues
).leakRef(); | 340 m_value.pair = Pair::create(create(lengthSize.width(), style.effectiveZoom()
), create(lengthSize.height(), style.effectiveZoom()), Pair::KeepIdenticalValues
).leakRef(); |
| 342 } | 341 } |
| 343 | 342 |
| 344 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Rect> r) | |
| 345 { | |
| 346 init(UnitType::Rect); | |
| 347 m_hasCachedCSSText = false; | |
| 348 m_value.rect = r.leakRef(); | |
| 349 } | |
| 350 | |
| 351 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Quad> quad) | |
| 352 { | |
| 353 init(UnitType::Quad); | |
| 354 m_hasCachedCSSText = false; | |
| 355 m_value.quad = quad.leakRef(); | |
| 356 } | |
| 357 | |
| 358 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Pair> p) | 343 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Pair> p) |
| 359 { | 344 { |
| 360 init(UnitType::Pair); | 345 init(UnitType::Pair); |
| 361 m_hasCachedCSSText = false; | 346 m_hasCachedCSSText = false; |
| 362 m_value.pair = p.leakRef(); | 347 m_value.pair = p.leakRef(); |
| 363 } | 348 } |
| 364 | 349 |
| 365 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSCalcValue> c) | 350 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSCalcValue> c) |
| 366 { | 351 { |
| 367 init(UnitType::Calc); | 352 init(UnitType::Calc); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 384 void CSSPrimitiveValue::cleanup() | 369 void CSSPrimitiveValue::cleanup() |
| 385 { | 370 { |
| 386 switch (type()) { | 371 switch (type()) { |
| 387 case UnitType::CustomIdentifier: | 372 case UnitType::CustomIdentifier: |
| 388 case UnitType::String: | 373 case UnitType::String: |
| 389 case UnitType::URI: | 374 case UnitType::URI: |
| 390 case UnitType::Attribute: | 375 case UnitType::Attribute: |
| 391 if (m_value.string) | 376 if (m_value.string) |
| 392 m_value.string->deref(); | 377 m_value.string->deref(); |
| 393 break; | 378 break; |
| 394 case UnitType::Rect: | |
| 395 // We must not call deref() when oilpan is enabled because m_value.rect
is traced. | |
| 396 #if !ENABLE(OILPAN) | |
| 397 m_value.rect->deref(); | |
| 398 #endif | |
| 399 break; | |
| 400 case UnitType::Quad: | |
| 401 // We must not call deref() when oilpan is enabled because m_value.quad
is traced. | |
| 402 #if !ENABLE(OILPAN) | |
| 403 m_value.quad->deref(); | |
| 404 #endif | |
| 405 break; | |
| 406 case UnitType::Pair: | 379 case UnitType::Pair: |
| 407 // We must not call deref() when oilpan is enabled because m_value.pair
is traced. | 380 // We must not call deref() when oilpan is enabled because m_value.pair
is traced. |
| 408 #if !ENABLE(OILPAN) | 381 #if !ENABLE(OILPAN) |
| 409 m_value.pair->deref(); | 382 m_value.pair->deref(); |
| 410 #endif | 383 #endif |
| 411 break; | 384 break; |
| 412 case UnitType::Calc: | 385 case UnitType::Calc: |
| 413 // We must not call deref() when oilpan is enabled because m_value.calc
is traced. | 386 // We must not call deref() when oilpan is enabled because m_value.calc
is traced. |
| 414 #if !ENABLE(OILPAN) | 387 #if !ENABLE(OILPAN) |
| 415 m_value.calc->deref(); | 388 m_value.calc->deref(); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 return "vmin"; | 870 return "vmin"; |
| 898 case UnitType::ViewportMax: | 871 case UnitType::ViewportMax: |
| 899 return "vmax"; | 872 return "vmax"; |
| 900 case UnitType::Unknown: | 873 case UnitType::Unknown: |
| 901 case UnitType::CustomIdentifier: | 874 case UnitType::CustomIdentifier: |
| 902 case UnitType::String: | 875 case UnitType::String: |
| 903 case UnitType::URI: | 876 case UnitType::URI: |
| 904 case UnitType::ValueID: | 877 case UnitType::ValueID: |
| 905 case UnitType::PropertyID: | 878 case UnitType::PropertyID: |
| 906 case UnitType::Attribute: | 879 case UnitType::Attribute: |
| 907 case UnitType::Rect: | |
| 908 case UnitType::Quad: | |
| 909 case UnitType::RGBColor: | 880 case UnitType::RGBColor: |
| 910 case UnitType::Pair: | 881 case UnitType::Pair: |
| 911 case UnitType::Calc: | 882 case UnitType::Calc: |
| 912 case UnitType::Shape: | 883 case UnitType::Shape: |
| 913 case UnitType::CalcPercentageWithNumber: | 884 case UnitType::CalcPercentageWithNumber: |
| 914 case UnitType::CalcPercentageWithLength: | 885 case UnitType::CalcPercentageWithLength: |
| 915 case UnitType::QuirkyEms: | 886 case UnitType::QuirkyEms: |
| 916 break; | 887 break; |
| 917 }; | 888 }; |
| 918 ASSERT_NOT_REACHED(); | 889 ASSERT_NOT_REACHED(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 case UnitType::Attribute: { | 954 case UnitType::Attribute: { |
| 984 StringBuilder result; | 955 StringBuilder result; |
| 985 result.reserveCapacity(6 + m_value.string->length()); | 956 result.reserveCapacity(6 + m_value.string->length()); |
| 986 result.appendLiteral("attr("); | 957 result.appendLiteral("attr("); |
| 987 result.append(m_value.string); | 958 result.append(m_value.string); |
| 988 result.append(')'); | 959 result.append(')'); |
| 989 | 960 |
| 990 text = result.toString(); | 961 text = result.toString(); |
| 991 break; | 962 break; |
| 992 } | 963 } |
| 993 case UnitType::Rect: | |
| 994 text = getRectValue()->cssText(); | |
| 995 break; | |
| 996 case UnitType::Quad: | |
| 997 text = getQuadValue()->cssText(); | |
| 998 break; | |
| 999 case UnitType::RGBColor: { | 964 case UnitType::RGBColor: { |
| 1000 text = Color(m_value.rgbcolor).serializedAsCSSComponentValue(); | 965 text = Color(m_value.rgbcolor).serializedAsCSSComponentValue(); |
| 1001 break; | 966 break; |
| 1002 } | 967 } |
| 1003 case UnitType::Pair: | 968 case UnitType::Pair: |
| 1004 text = getPairValue()->cssText(); | 969 text = getPairValue()->cssText(); |
| 1005 break; | 970 break; |
| 1006 case UnitType::Calc: | 971 case UnitType::Calc: |
| 1007 text = m_value.calc->customCSSText(); | 972 text = m_value.calc->customCSSText(); |
| 1008 break; | 973 break; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 return m_value.num == other.m_value.num; | 1025 return m_value.num == other.m_value.num; |
| 1061 case UnitType::PropertyID: | 1026 case UnitType::PropertyID: |
| 1062 return m_value.propertyID == other.m_value.propertyID; | 1027 return m_value.propertyID == other.m_value.propertyID; |
| 1063 case UnitType::ValueID: | 1028 case UnitType::ValueID: |
| 1064 return m_value.valueID == other.m_value.valueID; | 1029 return m_value.valueID == other.m_value.valueID; |
| 1065 case UnitType::CustomIdentifier: | 1030 case UnitType::CustomIdentifier: |
| 1066 case UnitType::String: | 1031 case UnitType::String: |
| 1067 case UnitType::URI: | 1032 case UnitType::URI: |
| 1068 case UnitType::Attribute: | 1033 case UnitType::Attribute: |
| 1069 return equal(m_value.string, other.m_value.string); | 1034 return equal(m_value.string, other.m_value.string); |
| 1070 case UnitType::Rect: | |
| 1071 return m_value.rect && other.m_value.rect && m_value.rect->equals(*other
.m_value.rect); | |
| 1072 case UnitType::Quad: | |
| 1073 return m_value.quad && other.m_value.quad && m_value.quad->equals(*other
.m_value.quad); | |
| 1074 case UnitType::RGBColor: | 1035 case UnitType::RGBColor: |
| 1075 return m_value.rgbcolor == other.m_value.rgbcolor; | 1036 return m_value.rgbcolor == other.m_value.rgbcolor; |
| 1076 case UnitType::Pair: | 1037 case UnitType::Pair: |
| 1077 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other
.m_value.pair); | 1038 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other
.m_value.pair); |
| 1078 case UnitType::Calc: | 1039 case UnitType::Calc: |
| 1079 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 1040 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); |
| 1080 case UnitType::Shape: | 1041 case UnitType::Shape: |
| 1081 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); | 1042 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); |
| 1082 case UnitType::Integer: | 1043 case UnitType::Integer: |
| 1083 case UnitType::Chs: | 1044 case UnitType::Chs: |
| 1084 case UnitType::CalcPercentageWithNumber: | 1045 case UnitType::CalcPercentageWithNumber: |
| 1085 case UnitType::CalcPercentageWithLength: | 1046 case UnitType::CalcPercentageWithLength: |
| 1086 case UnitType::QuirkyEms: | 1047 case UnitType::QuirkyEms: |
| 1087 return false; | 1048 return false; |
| 1088 } | 1049 } |
| 1089 return false; | 1050 return false; |
| 1090 } | 1051 } |
| 1091 | 1052 |
| 1092 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue) | 1053 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue) |
| 1093 { | 1054 { |
| 1094 #if ENABLE(OILPAN) | 1055 #if ENABLE(OILPAN) |
| 1095 switch (type()) { | 1056 switch (type()) { |
| 1096 case UnitType::Rect: | |
| 1097 visitor->trace(m_value.rect); | |
| 1098 break; | |
| 1099 case UnitType::Quad: | |
| 1100 visitor->trace(m_value.quad); | |
| 1101 break; | |
| 1102 case UnitType::Pair: | 1057 case UnitType::Pair: |
| 1103 visitor->trace(m_value.pair); | 1058 visitor->trace(m_value.pair); |
| 1104 break; | 1059 break; |
| 1105 case UnitType::Calc: | 1060 case UnitType::Calc: |
| 1106 visitor->trace(m_value.calc); | 1061 visitor->trace(m_value.calc); |
| 1107 break; | 1062 break; |
| 1108 case UnitType::Shape: | 1063 case UnitType::Shape: |
| 1109 visitor->trace(m_value.shape); | 1064 visitor->trace(m_value.shape); |
| 1110 break; | 1065 break; |
| 1111 default: | 1066 default: |
| 1112 break; | 1067 break; |
| 1113 } | 1068 } |
| 1114 #endif | 1069 #endif |
| 1115 CSSValue::traceAfterDispatch(visitor); | 1070 CSSValue::traceAfterDispatch(visitor); |
| 1116 } | 1071 } |
| 1117 | 1072 |
| 1118 } // namespace blink | 1073 } // namespace blink |
| OLD | NEW |