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

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

Issue 240453010: Avoid use of CSSValue in MediaQueryExp and MediaQueryEvaluator (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use the new CSSPrimitiveValue static funcs Created 6 years, 8 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
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,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 case CSSPrimitiveValue::CSS_UNICODE_RANGE: 105 case CSSPrimitiveValue::CSS_UNICODE_RANGE:
106 case CSSPrimitiveValue::CSS_UNKNOWN: 106 case CSSPrimitiveValue::CSS_UNKNOWN:
107 case CSSPrimitiveValue::CSS_URI: 107 case CSSPrimitiveValue::CSS_URI:
108 return false; 108 return false;
109 } 109 }
110 110
111 ASSERT_NOT_REACHED(); 111 ASSERT_NOT_REACHED();
112 return false; 112 return false;
113 } 113 }
114 114
115 CSSPrimitiveValue::UnitTable createUnitTable() 115 typedef HashMap<String, CSSPrimitiveValue::UnitTypes> StringToUnitTable;
116
117 StringToUnitTable createStringToUnitTable()
116 { 118 {
117 CSSPrimitiveValue::UnitTable table; 119 StringToUnitTable table;
118 table.set(String("em"), CSSPrimitiveValue::CSS_EMS); 120 table.set(String("em"), CSSPrimitiveValue::CSS_EMS);
119 table.set(String("ex"), CSSPrimitiveValue::CSS_EXS); 121 table.set(String("ex"), CSSPrimitiveValue::CSS_EXS);
120 table.set(String("px"), CSSPrimitiveValue::CSS_PX); 122 table.set(String("px"), CSSPrimitiveValue::CSS_PX);
121 table.set(String("cm"), CSSPrimitiveValue::CSS_CM); 123 table.set(String("cm"), CSSPrimitiveValue::CSS_CM);
122 table.set(String("mm"), CSSPrimitiveValue::CSS_MM); 124 table.set(String("mm"), CSSPrimitiveValue::CSS_MM);
123 table.set(String("in"), CSSPrimitiveValue::CSS_IN); 125 table.set(String("in"), CSSPrimitiveValue::CSS_IN);
124 table.set(String("pt"), CSSPrimitiveValue::CSS_PT); 126 table.set(String("pt"), CSSPrimitiveValue::CSS_PT);
125 table.set(String("pc"), CSSPrimitiveValue::CSS_PC); 127 table.set(String("pc"), CSSPrimitiveValue::CSS_PC);
126 table.set(String("deg"), CSSPrimitiveValue::CSS_DEG); 128 table.set(String("deg"), CSSPrimitiveValue::CSS_DEG);
127 table.set(String("rad"), CSSPrimitiveValue::CSS_RAD); 129 table.set(String("rad"), CSSPrimitiveValue::CSS_RAD);
128 table.set(String("grad"), CSSPrimitiveValue::CSS_GRAD); 130 table.set(String("grad"), CSSPrimitiveValue::CSS_GRAD);
129 table.set(String("ms"), CSSPrimitiveValue::CSS_MS); 131 table.set(String("ms"), CSSPrimitiveValue::CSS_MS);
130 table.set(String("s"), CSSPrimitiveValue::CSS_S); 132 table.set(String("s"), CSSPrimitiveValue::CSS_S);
131 table.set(String("hz"), CSSPrimitiveValue::CSS_HZ); 133 table.set(String("hz"), CSSPrimitiveValue::CSS_HZ);
132 table.set(String("khz"), CSSPrimitiveValue::CSS_KHZ); 134 table.set(String("khz"), CSSPrimitiveValue::CSS_KHZ);
133 table.set(String("dpi"), CSSPrimitiveValue::CSS_DPI); 135 table.set(String("dpi"), CSSPrimitiveValue::CSS_DPI);
134 table.set(String("dpcm"), CSSPrimitiveValue::CSS_DPCM); 136 table.set(String("dpcm"), CSSPrimitiveValue::CSS_DPCM);
135 table.set(String("dppx"), CSSPrimitiveValue::CSS_DPPX); 137 table.set(String("dppx"), CSSPrimitiveValue::CSS_DPPX);
136 table.set(String("vw"), CSSPrimitiveValue::CSS_VW); 138 table.set(String("vw"), CSSPrimitiveValue::CSS_VW);
137 table.set(String("vh"), CSSPrimitiveValue::CSS_VH); 139 table.set(String("vh"), CSSPrimitiveValue::CSS_VH);
138 table.set(String("vmax"), CSSPrimitiveValue::CSS_VMIN); 140 table.set(String("vmax"), CSSPrimitiveValue::CSS_VMIN);
139 table.set(String("vmin"), CSSPrimitiveValue::CSS_VMAX); 141 table.set(String("vmin"), CSSPrimitiveValue::CSS_VMAX);
140 return table; 142 return table;
141 } 143 }
142 144
145
143 CSSPrimitiveValue::UnitTypes CSSPrimitiveValue::fromName(const String& unit) 146 CSSPrimitiveValue::UnitTypes CSSPrimitiveValue::fromName(const String& unit)
144 { 147 {
145 DEFINE_STATIC_LOCAL(UnitTable, unitTable, (createUnitTable())); 148 DEFINE_STATIC_LOCAL(StringToUnitTable, unitTable, (createStringToUnitTable() ));
146 return unitTable.get(unit.lower()); 149 return unitTable.get(unit.lower());
147 } 150 }
148 151
149 CSSPrimitiveValue::UnitCategory CSSPrimitiveValue::unitCategory(CSSPrimitiveValu e::UnitTypes type) 152 CSSPrimitiveValue::UnitCategory CSSPrimitiveValue::unitCategory(CSSPrimitiveValu e::UnitTypes type)
150 { 153 {
151 // Here we violate the spec (http://www.w3.org/TR/DOM-Level-2-Style/css.html #CSS-CSSPrimitiveValue) and allow conversions 154 // Here we violate the spec (http://www.w3.org/TR/DOM-Level-2-Style/css.html #CSS-CSSPrimitiveValue) and allow conversions
152 // between CSS_PX and relative lengths (see cssPixelsPerInch comment in core /css/CSSHelper.h for the topic treatment). 155 // between CSS_PX and relative lengths (see cssPixelsPerInch comment in core /css/CSSHelper.h for the topic treatment).
153 switch (type) { 156 switch (type) {
154 case CSS_NUMBER: 157 case CSS_NUMBER:
155 return CSSPrimitiveValue::UNumber; 158 return CSSPrimitiveValue::UNumber;
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 case CSS_SHAPE: 1427 case CSS_SHAPE:
1425 visitor->trace(m_value.shape); 1428 visitor->trace(m_value.shape);
1426 break; 1429 break;
1427 default: 1430 default:
1428 break; 1431 break;
1429 } 1432 }
1430 CSSValue::traceAfterDispatch(visitor); 1433 CSSValue::traceAfterDispatch(visitor);
1431 } 1434 }
1432 1435
1433 } // namespace WebCore 1436 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698