Chromium Code Reviews| 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/CSSVariableData.h" | |
| 29 #include "core/css/Counter.h" | 30 #include "core/css/Counter.h" |
| 30 #include "core/css/Pair.h" | 31 #include "core/css/Pair.h" |
| 31 #include "core/css/Rect.h" | 32 #include "core/css/Rect.h" |
| 32 #include "core/css/StyleSheetContents.h" | 33 #include "core/css/StyleSheetContents.h" |
| 33 #include "core/dom/Node.h" | 34 #include "core/dom/Node.h" |
| 34 #include "core/style/ComputedStyle.h" | 35 #include "core/style/ComputedStyle.h" |
| 35 #include "platform/LayoutUnit.h" | 36 #include "platform/LayoutUnit.h" |
| 36 #include "platform/fonts/FontMetrics.h" | 37 #include "platform/fonts/FontMetrics.h" |
| 37 #include "wtf/StdLibExtras.h" | 38 #include "wtf/StdLibExtras.h" |
| 38 #include "wtf/ThreadSpecific.h" | 39 #include "wtf/ThreadSpecific.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 | 239 |
| 239 CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitType type) | 240 CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitType type) |
| 240 : CSSValue(PrimitiveClass) | 241 : CSSValue(PrimitiveClass) |
| 241 { | 242 { |
| 242 init(type); | 243 init(type); |
| 243 m_value.string = str.impl(); | 244 m_value.string = str.impl(); |
| 244 if (m_value.string) | 245 if (m_value.string) |
| 245 m_value.string->ref(); | 246 m_value.string->ref(); |
| 246 } | 247 } |
| 247 | 248 |
| 249 CSSPrimitiveValue::CSSPrimitiveValue(CSSVariableData* variableData) | |
| 250 : CSSValue(PrimitiveClass) | |
| 251 { | |
| 252 init(UnitType::VariableReference); | |
| 253 m_value.variableData = variableData; | |
| 254 ASSERT(m_value.variableData); | |
| 255 m_value.variableData->ref(); | |
| 256 } | |
|
alancutter (OOO until 2018)
2015/08/25 01:59:08
This should be done in an init(PassRefPtrWillBeRaw
| |
| 257 | |
| 248 CSSPrimitiveValue::CSSPrimitiveValue(const LengthSize& lengthSize, const Compute dStyle& style) | 258 CSSPrimitiveValue::CSSPrimitiveValue(const LengthSize& lengthSize, const Compute dStyle& style) |
| 249 : CSSValue(PrimitiveClass) | 259 : CSSValue(PrimitiveClass) |
| 250 { | 260 { |
| 251 init(lengthSize, style); | 261 init(lengthSize, style); |
| 252 } | 262 } |
| 253 | 263 |
| 254 CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color) | 264 CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color) |
| 255 : CSSValue(PrimitiveClass) | 265 : CSSValue(PrimitiveClass) |
| 256 { | 266 { |
| 257 init(UnitType::RGBColor); | 267 init(UnitType::RGBColor); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 case UnitType::CalcPercentageWithNumber: | 442 case UnitType::CalcPercentageWithNumber: |
| 433 case UnitType::CalcPercentageWithLength: | 443 case UnitType::CalcPercentageWithLength: |
| 434 ASSERT_NOT_REACHED(); | 444 ASSERT_NOT_REACHED(); |
| 435 break; | 445 break; |
| 436 case UnitType::Shape: | 446 case UnitType::Shape: |
| 437 // We must not call deref() when oilpan is enabled because m_value.shape is traced. | 447 // We must not call deref() when oilpan is enabled because m_value.shape is traced. |
| 438 #if !ENABLE(OILPAN) | 448 #if !ENABLE(OILPAN) |
| 439 m_value.shape->deref(); | 449 m_value.shape->deref(); |
| 440 #endif | 450 #endif |
| 441 break; | 451 break; |
| 452 case UnitType::VariableReference: | |
| 453 #if !ENABLE(OILPAN) | |
| 454 m_value.variableData->deref(); | |
| 455 #endif | |
| 456 break; | |
| 442 case UnitType::Number: | 457 case UnitType::Number: |
| 443 case UnitType::Integer: | 458 case UnitType::Integer: |
| 444 case UnitType::Percentage: | 459 case UnitType::Percentage: |
| 445 case UnitType::Ems: | 460 case UnitType::Ems: |
| 446 case UnitType::QuirkyEms: | 461 case UnitType::QuirkyEms: |
| 447 case UnitType::Exs: | 462 case UnitType::Exs: |
| 448 case UnitType::Rems: | 463 case UnitType::Rems: |
| 449 case UnitType::Chs: | 464 case UnitType::Chs: |
| 450 case UnitType::Pixels: | 465 case UnitType::Pixels: |
| 451 case UnitType::Centimeters: | 466 case UnitType::Centimeters: |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 921 case UnitType::Counter: | 936 case UnitType::Counter: |
| 922 case UnitType::Rect: | 937 case UnitType::Rect: |
| 923 case UnitType::Quad: | 938 case UnitType::Quad: |
| 924 case UnitType::RGBColor: | 939 case UnitType::RGBColor: |
| 925 case UnitType::Pair: | 940 case UnitType::Pair: |
| 926 case UnitType::Calc: | 941 case UnitType::Calc: |
| 927 case UnitType::Shape: | 942 case UnitType::Shape: |
| 928 case UnitType::CalcPercentageWithNumber: | 943 case UnitType::CalcPercentageWithNumber: |
| 929 case UnitType::CalcPercentageWithLength: | 944 case UnitType::CalcPercentageWithLength: |
| 930 case UnitType::QuirkyEms: | 945 case UnitType::QuirkyEms: |
| 946 case UnitType::VariableReference: | |
| 931 break; | 947 break; |
| 932 }; | 948 }; |
| 933 ASSERT_NOT_REACHED(); | 949 ASSERT_NOT_REACHED(); |
| 934 return ""; | 950 return ""; |
| 935 } | 951 } |
| 936 | 952 |
| 937 String CSSPrimitiveValue::customCSSText() const | 953 String CSSPrimitiveValue::customCSSText() const |
| 938 { | 954 { |
| 939 if (m_hasCachedCSSText) { | 955 if (m_hasCachedCSSText) { |
| 940 ASSERT(cssTextCache().contains(this)); | 956 ASSERT(cssTextCache().contains(this)); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1041 } | 1057 } |
| 1042 case UnitType::Pair: | 1058 case UnitType::Pair: |
| 1043 text = getPairValue()->cssText(); | 1059 text = getPairValue()->cssText(); |
| 1044 break; | 1060 break; |
| 1045 case UnitType::Calc: | 1061 case UnitType::Calc: |
| 1046 text = m_value.calc->customCSSText(); | 1062 text = m_value.calc->customCSSText(); |
| 1047 break; | 1063 break; |
| 1048 case UnitType::Shape: | 1064 case UnitType::Shape: |
| 1049 text = m_value.shape->cssText(); | 1065 text = m_value.shape->cssText(); |
| 1050 break; | 1066 break; |
| 1067 case UnitType::VariableReference: { | |
| 1068 StringBuilder result; | |
| 1069 result.appendLiteral("var("); | |
|
Timothy Loh
2015/08/25 09:21:09
Shouldn't this just return (..).serialize(), inste
| |
| 1070 CSSParserTokenRange range = m_value.variableData->tokenRange(); | |
| 1071 result.append(range.serialize()); | |
| 1072 result.appendLiteral(")"); | |
| 1073 text = result.toString(); | |
| 1074 break; | |
| 1075 } | |
| 1051 case UnitType::CalcPercentageWithNumber: | 1076 case UnitType::CalcPercentageWithNumber: |
| 1052 case UnitType::CalcPercentageWithLength: | 1077 case UnitType::CalcPercentageWithLength: |
| 1053 case UnitType::QuirkyEms: | 1078 case UnitType::QuirkyEms: |
| 1054 ASSERT_NOT_REACHED(); | 1079 ASSERT_NOT_REACHED(); |
| 1055 break; | 1080 break; |
| 1056 } | 1081 } |
| 1057 | 1082 |
| 1058 ASSERT(!cssTextCache().contains(this)); | 1083 ASSERT(!cssTextCache().contains(this)); |
| 1059 cssTextCache().set(this, text); | 1084 cssTextCache().set(this, text); |
| 1060 m_hasCachedCSSText = true; | 1085 m_hasCachedCSSText = true; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1113 case UnitType::Quad: | 1138 case UnitType::Quad: |
| 1114 return m_value.quad && other.m_value.quad && m_value.quad->equals(*other .m_value.quad); | 1139 return m_value.quad && other.m_value.quad && m_value.quad->equals(*other .m_value.quad); |
| 1115 case UnitType::RGBColor: | 1140 case UnitType::RGBColor: |
| 1116 return m_value.rgbcolor == other.m_value.rgbcolor; | 1141 return m_value.rgbcolor == other.m_value.rgbcolor; |
| 1117 case UnitType::Pair: | 1142 case UnitType::Pair: |
| 1118 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other .m_value.pair); | 1143 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other .m_value.pair); |
| 1119 case UnitType::Calc: | 1144 case UnitType::Calc: |
| 1120 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other .m_value.calc); | 1145 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other .m_value.calc); |
| 1121 case UnitType::Shape: | 1146 case UnitType::Shape: |
| 1122 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot her.m_value.shape); | 1147 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot her.m_value.shape); |
| 1148 case UnitType::VariableReference: | |
| 1149 return m_value.variableData == other.m_value.variableData; | |
| 1123 case UnitType::Integer: | 1150 case UnitType::Integer: |
| 1124 case UnitType::Chs: | 1151 case UnitType::Chs: |
| 1125 case UnitType::CalcPercentageWithNumber: | 1152 case UnitType::CalcPercentageWithNumber: |
| 1126 case UnitType::CalcPercentageWithLength: | 1153 case UnitType::CalcPercentageWithLength: |
| 1127 case UnitType::QuirkyEms: | 1154 case UnitType::QuirkyEms: |
| 1128 return false; | 1155 return false; |
| 1129 } | 1156 } |
| 1130 return false; | 1157 return false; |
| 1131 } | 1158 } |
| 1132 | 1159 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1153 visitor->trace(m_value.shape); | 1180 visitor->trace(m_value.shape); |
| 1154 break; | 1181 break; |
| 1155 default: | 1182 default: |
| 1156 break; | 1183 break; |
| 1157 } | 1184 } |
| 1158 #endif | 1185 #endif |
| 1159 CSSValue::traceAfterDispatch(visitor); | 1186 CSSValue::traceAfterDispatch(visitor); |
| 1160 } | 1187 } |
| 1161 | 1188 |
| 1162 } // namespace blink | 1189 } // namespace blink |
| OLD | NEW |