Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: Source/core/css/CSSPrimitiveValue.cpp

Issue 1192983003: CSS Custom Properties (Variables) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Missing file :( Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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)
alancutter (OOO until 2018) 2015/08/05 08:01:43 This should be CSSPrimitiveValue::init(PassRefPtr<
250 : CSSValue(PrimitiveClass)
251 {
252 init(UnitType::VariableReference);
253 m_value.variableData = variableData;
254 ASSERT(m_value.variableData);
255 m_value.variableData->ref();
256 }
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
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
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
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 text = "var(" + m_value.variableData->string() + ")";
alancutter (OOO until 2018) 2015/08/05 08:01:43 This should serialize the tokens, I don't think re
1069 break;
1051 case UnitType::CalcPercentageWithNumber: 1070 case UnitType::CalcPercentageWithNumber:
1052 case UnitType::CalcPercentageWithLength: 1071 case UnitType::CalcPercentageWithLength:
1053 case UnitType::QuirkyEms: 1072 case UnitType::QuirkyEms:
1054 ASSERT_NOT_REACHED(); 1073 ASSERT_NOT_REACHED();
1055 break; 1074 break;
1056 } 1075 }
1057 1076
1058 ASSERT(!cssTextCache().contains(this)); 1077 ASSERT(!cssTextCache().contains(this));
1059 cssTextCache().set(this, text); 1078 cssTextCache().set(this, text);
1060 m_hasCachedCSSText = true; 1079 m_hasCachedCSSText = true;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 case UnitType::Quad: 1132 case UnitType::Quad:
1114 return m_value.quad && other.m_value.quad && m_value.quad->equals(*other .m_value.quad); 1133 return m_value.quad && other.m_value.quad && m_value.quad->equals(*other .m_value.quad);
1115 case UnitType::RGBColor: 1134 case UnitType::RGBColor:
1116 return m_value.rgbcolor == other.m_value.rgbcolor; 1135 return m_value.rgbcolor == other.m_value.rgbcolor;
1117 case UnitType::Pair: 1136 case UnitType::Pair:
1118 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other .m_value.pair); 1137 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other .m_value.pair);
1119 case UnitType::Calc: 1138 case UnitType::Calc:
1120 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other .m_value.calc); 1139 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other .m_value.calc);
1121 case UnitType::Shape: 1140 case UnitType::Shape:
1122 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot her.m_value.shape); 1141 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot her.m_value.shape);
1142 case UnitType::VariableReference:
1143 return m_value.variableData == other.m_value.variableData;
1123 case UnitType::Integer: 1144 case UnitType::Integer:
1124 case UnitType::Chs: 1145 case UnitType::Chs:
1125 case UnitType::CalcPercentageWithNumber: 1146 case UnitType::CalcPercentageWithNumber:
1126 case UnitType::CalcPercentageWithLength: 1147 case UnitType::CalcPercentageWithLength:
1127 case UnitType::QuirkyEms: 1148 case UnitType::QuirkyEms:
1128 return false; 1149 return false;
1129 } 1150 }
1130 return false; 1151 return false;
1131 } 1152 }
1132 1153
(...skipping 20 matching lines...) Expand all
1153 visitor->trace(m_value.shape); 1174 visitor->trace(m_value.shape);
1154 break; 1175 break;
1155 default: 1176 default:
1156 break; 1177 break;
1157 } 1178 }
1158 #endif 1179 #endif
1159 CSSValue::traceAfterDispatch(visitor); 1180 CSSValue::traceAfterDispatch(visitor);
1160 } 1181 }
1161 1182
1162 } // namespace blink 1183 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698