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

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

Issue 1303153003: Change Counter to be a CSSValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase & removed dependent patchsets 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
« no previous file with comments | « Source/core/css/CSSPrimitiveValue.h ('k') | Source/core/css/CSSValue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/Counter.h"
30 #include "core/css/Pair.h" 29 #include "core/css/Pair.h"
31 #include "core/css/Rect.h" 30 #include "core/css/Rect.h"
32 #include "core/css/StyleSheetContents.h" 31 #include "core/css/StyleSheetContents.h"
33 #include "core/dom/Node.h" 32 #include "core/dom/Node.h"
34 #include "core/style/ComputedStyle.h" 33 #include "core/style/ComputedStyle.h"
35 #include "platform/LayoutUnit.h" 34 #include "platform/LayoutUnit.h"
36 #include "platform/fonts/FontMetrics.h" 35 #include "platform/fonts/FontMetrics.h"
37 #include "wtf/StdLibExtras.h" 36 #include "wtf/StdLibExtras.h"
38 #include "wtf/ThreadSpecific.h" 37 #include "wtf/ThreadSpecific.h"
39 #include "wtf/Threading.h" 38 #include "wtf/Threading.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 m_primitiveUnitType = static_cast<unsigned>(type); 334 m_primitiveUnitType = static_cast<unsigned>(type);
336 } 335 }
337 336
338 void CSSPrimitiveValue::init(const LengthSize& lengthSize, const ComputedStyle& style) 337 void CSSPrimitiveValue::init(const LengthSize& lengthSize, const ComputedStyle& style)
339 { 338 {
340 init(UnitType::Pair); 339 init(UnitType::Pair);
341 m_hasCachedCSSText = false; 340 m_hasCachedCSSText = false;
342 m_value.pair = Pair::create(create(lengthSize.width(), style.effectiveZoom() ), create(lengthSize.height(), style.effectiveZoom()), Pair::KeepIdenticalValues ).leakRef(); 341 m_value.pair = Pair::create(create(lengthSize.width(), style.effectiveZoom() ), create(lengthSize.height(), style.effectiveZoom()), Pair::KeepIdenticalValues ).leakRef();
343 } 342 }
344 343
345 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Counter> c)
346 {
347 init(UnitType::Counter);
348 m_hasCachedCSSText = false;
349 m_value.counter = c.leakRef();
350 }
351
352 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Rect> r) 344 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Rect> r)
353 { 345 {
354 init(UnitType::Rect); 346 init(UnitType::Rect);
355 m_hasCachedCSSText = false; 347 m_hasCachedCSSText = false;
356 m_value.rect = r.leakRef(); 348 m_value.rect = r.leakRef();
357 } 349 }
358 350
359 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Quad> quad) 351 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Quad> quad)
360 { 352 {
361 init(UnitType::Quad); 353 init(UnitType::Quad);
(...skipping 30 matching lines...) Expand all
392 void CSSPrimitiveValue::cleanup() 384 void CSSPrimitiveValue::cleanup()
393 { 385 {
394 switch (type()) { 386 switch (type()) {
395 case UnitType::CustomIdentifier: 387 case UnitType::CustomIdentifier:
396 case UnitType::String: 388 case UnitType::String:
397 case UnitType::URI: 389 case UnitType::URI:
398 case UnitType::Attribute: 390 case UnitType::Attribute:
399 if (m_value.string) 391 if (m_value.string)
400 m_value.string->deref(); 392 m_value.string->deref();
401 break; 393 break;
402 case UnitType::Counter:
403 // We must not call deref() when oilpan is enabled because m_value.count er is traced.
404 #if !ENABLE(OILPAN)
405 m_value.counter->deref();
406 #endif
407 break;
408 case UnitType::Rect: 394 case UnitType::Rect:
409 // We must not call deref() when oilpan is enabled because m_value.rect is traced. 395 // We must not call deref() when oilpan is enabled because m_value.rect is traced.
410 #if !ENABLE(OILPAN) 396 #if !ENABLE(OILPAN)
411 m_value.rect->deref(); 397 m_value.rect->deref();
412 #endif 398 #endif
413 break; 399 break;
414 case UnitType::Quad: 400 case UnitType::Quad:
415 // We must not call deref() when oilpan is enabled because m_value.quad is traced. 401 // We must not call deref() when oilpan is enabled because m_value.quad is traced.
416 #if !ENABLE(OILPAN) 402 #if !ENABLE(OILPAN)
417 m_value.quad->deref(); 403 m_value.quad->deref();
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 return "vmin"; 897 return "vmin";
912 case UnitType::ViewportMax: 898 case UnitType::ViewportMax:
913 return "vmax"; 899 return "vmax";
914 case UnitType::Unknown: 900 case UnitType::Unknown:
915 case UnitType::CustomIdentifier: 901 case UnitType::CustomIdentifier:
916 case UnitType::String: 902 case UnitType::String:
917 case UnitType::URI: 903 case UnitType::URI:
918 case UnitType::ValueID: 904 case UnitType::ValueID:
919 case UnitType::PropertyID: 905 case UnitType::PropertyID:
920 case UnitType::Attribute: 906 case UnitType::Attribute:
921 case UnitType::Counter:
922 case UnitType::Rect: 907 case UnitType::Rect:
923 case UnitType::Quad: 908 case UnitType::Quad:
924 case UnitType::RGBColor: 909 case UnitType::RGBColor:
925 case UnitType::Pair: 910 case UnitType::Pair:
926 case UnitType::Calc: 911 case UnitType::Calc:
927 case UnitType::Shape: 912 case UnitType::Shape:
928 case UnitType::CalcPercentageWithNumber: 913 case UnitType::CalcPercentageWithNumber:
929 case UnitType::CalcPercentageWithLength: 914 case UnitType::CalcPercentageWithLength:
930 case UnitType::QuirkyEms: 915 case UnitType::QuirkyEms:
931 break; 916 break;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 case UnitType::Attribute: { 983 case UnitType::Attribute: {
999 StringBuilder result; 984 StringBuilder result;
1000 result.reserveCapacity(6 + m_value.string->length()); 985 result.reserveCapacity(6 + m_value.string->length());
1001 result.appendLiteral("attr("); 986 result.appendLiteral("attr(");
1002 result.append(m_value.string); 987 result.append(m_value.string);
1003 result.append(')'); 988 result.append(')');
1004 989
1005 text = result.toString(); 990 text = result.toString();
1006 break; 991 break;
1007 } 992 }
1008 case UnitType::Counter: {
1009 StringBuilder result;
1010 String separator = m_value.counter->separator();
1011 if (separator.isEmpty())
1012 result.appendLiteral("counter(");
1013 else
1014 result.appendLiteral("counters(");
1015
1016 result.append(m_value.counter->identifier());
1017 if (!separator.isEmpty()) {
1018 result.appendLiteral(", ");
1019 result.append(serializeString(separator));
1020 }
1021 String listStyle = m_value.counter->listStyle();
1022 bool isDefaultListStyle = m_value.counter->listStyleIdent() == CSSValueD ecimal;
1023 if (!listStyle.isEmpty() && !isDefaultListStyle) {
1024 result.appendLiteral(", ");
1025 result.append(listStyle);
1026 }
1027 result.append(')');
1028
1029 text = result.toString();
1030 break;
1031 }
1032 case UnitType::Rect: 993 case UnitType::Rect:
1033 text = getRectValue()->cssText(); 994 text = getRectValue()->cssText();
1034 break; 995 break;
1035 case UnitType::Quad: 996 case UnitType::Quad:
1036 text = getQuadValue()->cssText(); 997 text = getQuadValue()->cssText();
1037 break; 998 break;
1038 case UnitType::RGBColor: { 999 case UnitType::RGBColor: {
1039 text = Color(m_value.rgbcolor).serializedAsCSSComponentValue(); 1000 text = Color(m_value.rgbcolor).serializedAsCSSComponentValue();
1040 break; 1001 break;
1041 } 1002 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 return m_value.num == other.m_value.num; 1060 return m_value.num == other.m_value.num;
1100 case UnitType::PropertyID: 1061 case UnitType::PropertyID:
1101 return m_value.propertyID == other.m_value.propertyID; 1062 return m_value.propertyID == other.m_value.propertyID;
1102 case UnitType::ValueID: 1063 case UnitType::ValueID:
1103 return m_value.valueID == other.m_value.valueID; 1064 return m_value.valueID == other.m_value.valueID;
1104 case UnitType::CustomIdentifier: 1065 case UnitType::CustomIdentifier:
1105 case UnitType::String: 1066 case UnitType::String:
1106 case UnitType::URI: 1067 case UnitType::URI:
1107 case UnitType::Attribute: 1068 case UnitType::Attribute:
1108 return equal(m_value.string, other.m_value.string); 1069 return equal(m_value.string, other.m_value.string);
1109 case UnitType::Counter:
1110 return m_value.counter && other.m_value.counter && m_value.counter->equa ls(*other.m_value.counter);
1111 case UnitType::Rect: 1070 case UnitType::Rect:
1112 return m_value.rect && other.m_value.rect && m_value.rect->equals(*other .m_value.rect); 1071 return m_value.rect && other.m_value.rect && m_value.rect->equals(*other .m_value.rect);
1113 case UnitType::Quad: 1072 case UnitType::Quad:
1114 return m_value.quad && other.m_value.quad && m_value.quad->equals(*other .m_value.quad); 1073 return m_value.quad && other.m_value.quad && m_value.quad->equals(*other .m_value.quad);
1115 case UnitType::RGBColor: 1074 case UnitType::RGBColor:
1116 return m_value.rgbcolor == other.m_value.rgbcolor; 1075 return m_value.rgbcolor == other.m_value.rgbcolor;
1117 case UnitType::Pair: 1076 case UnitType::Pair:
1118 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other .m_value.pair); 1077 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other .m_value.pair);
1119 case UnitType::Calc: 1078 case UnitType::Calc:
1120 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other .m_value.calc); 1079 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other .m_value.calc);
1121 case UnitType::Shape: 1080 case UnitType::Shape:
1122 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot her.m_value.shape); 1081 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot her.m_value.shape);
1123 case UnitType::Integer: 1082 case UnitType::Integer:
1124 case UnitType::Chs: 1083 case UnitType::Chs:
1125 case UnitType::CalcPercentageWithNumber: 1084 case UnitType::CalcPercentageWithNumber:
1126 case UnitType::CalcPercentageWithLength: 1085 case UnitType::CalcPercentageWithLength:
1127 case UnitType::QuirkyEms: 1086 case UnitType::QuirkyEms:
1128 return false; 1087 return false;
1129 } 1088 }
1130 return false; 1089 return false;
1131 } 1090 }
1132 1091
1133 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue) 1092 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue)
1134 { 1093 {
1135 #if ENABLE(OILPAN) 1094 #if ENABLE(OILPAN)
1136 switch (type()) { 1095 switch (type()) {
1137 case UnitType::Counter:
1138 visitor->trace(m_value.counter);
1139 break;
1140 case UnitType::Rect: 1096 case UnitType::Rect:
1141 visitor->trace(m_value.rect); 1097 visitor->trace(m_value.rect);
1142 break; 1098 break;
1143 case UnitType::Quad: 1099 case UnitType::Quad:
1144 visitor->trace(m_value.quad); 1100 visitor->trace(m_value.quad);
1145 break; 1101 break;
1146 case UnitType::Pair: 1102 case UnitType::Pair:
1147 visitor->trace(m_value.pair); 1103 visitor->trace(m_value.pair);
1148 break; 1104 break;
1149 case UnitType::Calc: 1105 case UnitType::Calc:
1150 visitor->trace(m_value.calc); 1106 visitor->trace(m_value.calc);
1151 break; 1107 break;
1152 case UnitType::Shape: 1108 case UnitType::Shape:
1153 visitor->trace(m_value.shape); 1109 visitor->trace(m_value.shape);
1154 break; 1110 break;
1155 default: 1111 default:
1156 break; 1112 break;
1157 } 1113 }
1158 #endif 1114 #endif
1159 CSSValue::traceAfterDispatch(visitor); 1115 CSSValue::traceAfterDispatch(visitor);
1160 } 1116 }
1161 1117
1162 } // namespace blink 1118 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/CSSPrimitiveValue.h ('k') | Source/core/css/CSSValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698