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, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 */ | 20 */ |
21 | 21 |
22 #ifndef CSSPrimitiveValue_h | 22 #ifndef CSSPrimitiveValue_h |
23 #define CSSPrimitiveValue_h | 23 #define CSSPrimitiveValue_h |
24 | 24 |
| 25 #include "CSSPropertyNames.h" |
25 #include "CSSValueKeywords.h" | 26 #include "CSSValueKeywords.h" |
26 #include "core/css/CSSValue.h" | 27 #include "core/css/CSSValue.h" |
27 #include "core/platform/graphics/Color.h" | 28 #include "core/platform/graphics/Color.h" |
28 #include "wtf/Forward.h" | 29 #include "wtf/Forward.h" |
29 #include "wtf/MathExtras.h" | 30 #include "wtf/MathExtras.h" |
30 #include "wtf/PassRefPtr.h" | 31 #include "wtf/PassRefPtr.h" |
31 | 32 |
32 namespace WebCore { | 33 namespace WebCore { |
33 | 34 |
34 class CSSCalcValue; | 35 class CSSCalcValue; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // This is used by the CSS Exclusions draft | 123 // This is used by the CSS Exclusions draft |
123 CSS_SHAPE = 111, | 124 CSS_SHAPE = 111, |
124 | 125 |
125 // Used by border images. | 126 // Used by border images. |
126 CSS_QUAD = 112, | 127 CSS_QUAD = 112, |
127 | 128 |
128 CSS_CALC = 113, | 129 CSS_CALC = 113, |
129 CSS_CALC_PERCENTAGE_WITH_NUMBER = 114, | 130 CSS_CALC_PERCENTAGE_WITH_NUMBER = 114, |
130 CSS_CALC_PERCENTAGE_WITH_LENGTH = 115, | 131 CSS_CALC_PERCENTAGE_WITH_LENGTH = 115, |
131 CSS_VARIABLE_NAME = 116, | 132 CSS_VARIABLE_NAME = 116, |
| 133 |
| 134 CSS_PROPERTY_ID = 117, |
| 135 CSS_VALUE_ID = 118 |
132 }; | 136 }; |
133 | 137 |
134 // This enum follows the CSSParser::Units enum augmented with UNIT_FREQUENCY
for frequencies. | 138 // This enum follows the CSSParser::Units enum augmented with UNIT_FREQUENCY
for frequencies. |
135 enum UnitCategory { | 139 enum UnitCategory { |
136 UNumber, | 140 UNumber, |
137 UPercent, | 141 UPercent, |
138 ULength, | 142 ULength, |
139 UAngle, | 143 UAngle, |
140 UTime, | 144 UTime, |
141 UFrequency, | 145 UFrequency, |
(...skipping 12 matching lines...) Expand all Loading... |
154 bool isAttr() const { return m_primitiveUnitType == CSS_ATTR; } | 158 bool isAttr() const { return m_primitiveUnitType == CSS_ATTR; } |
155 bool isCounter() const { return m_primitiveUnitType == CSS_COUNTER; } | 159 bool isCounter() const { return m_primitiveUnitType == CSS_COUNTER; } |
156 bool isFontIndependentLength() const { return m_primitiveUnitType >= CSS_PX
&& m_primitiveUnitType <= CSS_PC; } | 160 bool isFontIndependentLength() const { return m_primitiveUnitType >= CSS_PX
&& m_primitiveUnitType <= CSS_PC; } |
157 bool isFontRelativeLength() const | 161 bool isFontRelativeLength() const |
158 { | 162 { |
159 return m_primitiveUnitType == CSS_EMS | 163 return m_primitiveUnitType == CSS_EMS |
160 || m_primitiveUnitType == CSS_EXS | 164 || m_primitiveUnitType == CSS_EXS |
161 || m_primitiveUnitType == CSS_REMS | 165 || m_primitiveUnitType == CSS_REMS |
162 || m_primitiveUnitType == CSS_CHS; | 166 || m_primitiveUnitType == CSS_CHS; |
163 } | 167 } |
164 bool isIdent() const { return m_primitiveUnitType == CSS_IDENT; } | |
165 bool isLength() const | 168 bool isLength() const |
166 { | 169 { |
167 unsigned short type = primitiveType(); | 170 unsigned short type = primitiveType(); |
168 return (type >= CSS_EMS && type <= CSS_PC) || type == CSS_REMS || type =
= CSS_CHS; | 171 return (type >= CSS_EMS && type <= CSS_PC) || type == CSS_REMS || type =
= CSS_CHS; |
169 } | 172 } |
170 bool isNumber() const { return primitiveType() == CSS_NUMBER; } | 173 bool isNumber() const { return primitiveType() == CSS_NUMBER; } |
171 bool isPercentage() const { return primitiveType() == CSS_PERCENTAGE; } | 174 bool isPercentage() const { return primitiveType() == CSS_PERCENTAGE; } |
172 bool isPx() const { return primitiveType() == CSS_PX; } | 175 bool isPx() const { return primitiveType() == CSS_PX; } |
173 bool isRect() const { return m_primitiveUnitType == CSS_RECT; } | 176 bool isRect() const { return m_primitiveUnitType == CSS_RECT; } |
174 bool isRGBColor() const { return m_primitiveUnitType == CSS_RGBCOLOR; } | 177 bool isRGBColor() const { return m_primitiveUnitType == CSS_RGBCOLOR; } |
175 bool isShape() const { return m_primitiveUnitType == CSS_SHAPE; } | 178 bool isShape() const { return m_primitiveUnitType == CSS_SHAPE; } |
176 bool isString() const { return m_primitiveUnitType == CSS_STRING; } | 179 bool isString() const { return m_primitiveUnitType == CSS_STRING; } |
177 bool isTime() const { return m_primitiveUnitType == CSS_S || m_primitiveUnit
Type == CSS_MS; } | 180 bool isTime() const { return m_primitiveUnitType == CSS_S || m_primitiveUnit
Type == CSS_MS; } |
178 bool isURI() const { return m_primitiveUnitType == CSS_URI; } | 181 bool isURI() const { return m_primitiveUnitType == CSS_URI; } |
179 bool isCalculated() const { return m_primitiveUnitType == CSS_CALC; } | 182 bool isCalculated() const { return m_primitiveUnitType == CSS_CALC; } |
180 bool isCalculatedPercentageWithNumber() const { return primitiveType() == CS
S_CALC_PERCENTAGE_WITH_NUMBER; } | 183 bool isCalculatedPercentageWithNumber() const { return primitiveType() == CS
S_CALC_PERCENTAGE_WITH_NUMBER; } |
181 bool isCalculatedPercentageWithLength() const { return primitiveType() == CS
S_CALC_PERCENTAGE_WITH_LENGTH; } | 184 bool isCalculatedPercentageWithLength() const { return primitiveType() == CS
S_CALC_PERCENTAGE_WITH_LENGTH; } |
182 bool isDotsPerInch() const { return primitiveType() == CSS_DPI; } | 185 bool isDotsPerInch() const { return primitiveType() == CSS_DPI; } |
183 bool isDotsPerPixel() const { return primitiveType() == CSS_DPPX; } | 186 bool isDotsPerPixel() const { return primitiveType() == CSS_DPPX; } |
184 bool isDotsPerCentimeter() const { return primitiveType() == CSS_DPCM; } | 187 bool isDotsPerCentimeter() const { return primitiveType() == CSS_DPCM; } |
185 bool isResolution() const | 188 bool isResolution() const |
186 { | 189 { |
187 unsigned short type = primitiveType(); | 190 unsigned short type = primitiveType(); |
188 return type >= CSS_DPPX && type <= CSS_DPCM; | 191 return type >= CSS_DPPX && type <= CSS_DPCM; |
189 } | 192 } |
190 bool isVariableName() const { return primitiveType() == CSS_VARIABLE_NAME; } | 193 bool isVariableName() const { return primitiveType() == CSS_VARIABLE_NAME; } |
191 bool isViewportPercentageLength() const { return m_primitiveUnitType >= CSS_
VW && m_primitiveUnitType <= CSS_VMAX; } | 194 bool isViewportPercentageLength() const { return m_primitiveUnitType >= CSS_
VW && m_primitiveUnitType <= CSS_VMAX; } |
192 bool isFlex() const { return primitiveType() == CSS_FR; } | 195 bool isFlex() const { return primitiveType() == CSS_FR; } |
| 196 bool isValueID() const { return m_primitiveUnitType == CSS_VALUE_ID; } |
193 | 197 |
194 static PassRefPtr<CSSPrimitiveValue> createIdentifier(int identifier) { retu
rn adoptRef(new CSSPrimitiveValue(identifier)); } | 198 static PassRefPtr<CSSPrimitiveValue> createIdentifier(CSSValueID valueID) {
return adoptRef(new CSSPrimitiveValue(valueID)); } |
| 199 static PassRefPtr<CSSPrimitiveValue> createIdentifier(CSSPropertyID property
ID) { return adoptRef(new CSSPrimitiveValue(propertyID)); } |
| 200 static PassRefPtr<CSSPrimitiveValue> createParserOperator(int parserOperator
) { return adoptRef(new CSSPrimitiveValue(parserOperator)); } |
195 static PassRefPtr<CSSPrimitiveValue> createColor(unsigned rgbValue) { return
adoptRef(new CSSPrimitiveValue(rgbValue)); } | 201 static PassRefPtr<CSSPrimitiveValue> createColor(unsigned rgbValue) { return
adoptRef(new CSSPrimitiveValue(rgbValue)); } |
196 static PassRefPtr<CSSPrimitiveValue> create(double value, UnitTypes type) {
return adoptRef(new CSSPrimitiveValue(value, type)); } | 202 static PassRefPtr<CSSPrimitiveValue> create(double value, UnitTypes type) {
return adoptRef(new CSSPrimitiveValue(value, type)); } |
197 static PassRefPtr<CSSPrimitiveValue> create(const String& value, UnitTypes t
ype) { return adoptRef(new CSSPrimitiveValue(value, type)); } | 203 static PassRefPtr<CSSPrimitiveValue> create(const String& value, UnitTypes t
ype) { return adoptRef(new CSSPrimitiveValue(value, type)); } |
198 | 204 |
199 template<typename T> static PassRefPtr<CSSPrimitiveValue> create(T value) | 205 template<typename T> static PassRefPtr<CSSPrimitiveValue> create(T value) |
200 { | 206 { |
201 return adoptRef(new CSSPrimitiveValue(value)); | 207 return adoptRef(new CSSPrimitiveValue(value)); |
202 } | 208 } |
203 | 209 |
204 // This value is used to handle quirky margins in reflow roots (body, td, an
d th) like WinIE. | 210 // This value is used to handle quirky margins in reflow roots (body, td, an
d th) like WinIE. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 PassRefPtr<RGBColor> getRGBColorValue(ExceptionCode&) const; | 292 PassRefPtr<RGBColor> getRGBColorValue(ExceptionCode&) const; |
287 RGBA32 getRGBA32Value() const { return m_primitiveUnitType != CSS_RGBCOLOR ?
0 : m_value.rgbcolor; } | 293 RGBA32 getRGBA32Value() const { return m_primitiveUnitType != CSS_RGBCOLOR ?
0 : m_value.rgbcolor; } |
288 | 294 |
289 Pair* getPairValue(ExceptionCode&) const; | 295 Pair* getPairValue(ExceptionCode&) const; |
290 Pair* getPairValue() const { return m_primitiveUnitType != CSS_PAIR ? 0 : m_
value.pair; } | 296 Pair* getPairValue() const { return m_primitiveUnitType != CSS_PAIR ? 0 : m_
value.pair; } |
291 | 297 |
292 CSSBasicShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHA
PE ? 0 : m_value.shape; } | 298 CSSBasicShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHA
PE ? 0 : m_value.shape; } |
293 | 299 |
294 CSSCalcValue* cssCalcValue() const { return m_primitiveUnitType != CSS_CALC
? 0 : m_value.calc; } | 300 CSSCalcValue* cssCalcValue() const { return m_primitiveUnitType != CSS_CALC
? 0 : m_value.calc; } |
295 | 301 |
296 int getIdent() const { return m_primitiveUnitType == CSS_IDENT ? m_value.ide
nt : 0; } | 302 CSSPropertyID getPropertyID() const { return m_primitiveUnitType == CSS_PROP
ERTY_ID ? m_value.propertyID : CSSPropertyInvalid; } |
| 303 CSSValueID getValueID() const { return m_primitiveUnitType == CSS_VALUE_ID ?
m_value.valueID : CSSValueInvalid; } |
297 | 304 |
298 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa
lueMappings.h | 305 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa
lueMappings.h |
299 | 306 |
300 String customCssText() const; | 307 String customCssText() const; |
301 String customSerializeResolvingVariables(const HashMap<AtomicString, String>
&) const; | 308 String customSerializeResolvingVariables(const HashMap<AtomicString, String>
&) const; |
302 bool hasVariableReference() const; | 309 bool hasVariableReference() const; |
303 | 310 |
304 bool isQuirkValue() { return m_isQuirkValue; } | 311 bool isQuirkValue() { return m_isQuirkValue; } |
305 | 312 |
306 void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*)
const; | 313 void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*)
const; |
307 | 314 |
308 Length viewportPercentageLength(); | 315 Length viewportPercentageLength(); |
309 | 316 |
310 PassRefPtr<CSSPrimitiveValue> cloneForCSSOM() const; | 317 PassRefPtr<CSSPrimitiveValue> cloneForCSSOM() const; |
311 void setCSSOMSafe() { m_isCSSOMSafe = true; } | 318 void setCSSOMSafe() { m_isCSSOMSafe = true; } |
312 | 319 |
313 bool equals(const CSSPrimitiveValue&) const; | 320 bool equals(const CSSPrimitiveValue&) const; |
314 | 321 |
315 void reportDescendantMemoryUsage(MemoryObjectInfo*) const; | 322 void reportDescendantMemoryUsage(MemoryObjectInfo*) const; |
316 | 323 |
317 private: | 324 private: |
318 // FIXME: int vs. unsigned overloading is too subtle to distinguish the colo
r and identifier cases. | 325 CSSPrimitiveValue(CSSValueID); |
319 CSSPrimitiveValue(int ident); | 326 CSSPrimitiveValue(CSSPropertyID); |
| 327 // FIXME: int vs. unsigned overloading is too subtle to distinguish the colo
r and operator cases. |
| 328 CSSPrimitiveValue(int parserOperator); |
320 CSSPrimitiveValue(unsigned color); // RGB value | 329 CSSPrimitiveValue(unsigned color); // RGB value |
321 CSSPrimitiveValue(const Length&); | 330 CSSPrimitiveValue(const Length&); |
322 CSSPrimitiveValue(const String&, UnitTypes); | 331 CSSPrimitiveValue(const String&, UnitTypes); |
323 CSSPrimitiveValue(double, UnitTypes); | 332 CSSPrimitiveValue(double, UnitTypes); |
324 | 333 |
325 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa
ppings.h | 334 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa
ppings.h |
326 template<typename T> CSSPrimitiveValue(T* val) | 335 template<typename T> CSSPrimitiveValue(T* val) |
327 : CSSValue(PrimitiveClass) | 336 : CSSValue(PrimitiveClass) |
328 { | 337 { |
329 init(PassRefPtr<T>(val)); | 338 init(PassRefPtr<T>(val)); |
(...skipping 15 matching lines...) Expand all Loading... |
345 void init(PassRefPtr<Rect>); | 354 void init(PassRefPtr<Rect>); |
346 void init(PassRefPtr<Pair>); | 355 void init(PassRefPtr<Pair>); |
347 void init(PassRefPtr<Quad>); | 356 void init(PassRefPtr<Quad>); |
348 void init(PassRefPtr<CSSBasicShape>); | 357 void init(PassRefPtr<CSSBasicShape>); |
349 void init(PassRefPtr<CSSCalcValue>); | 358 void init(PassRefPtr<CSSCalcValue>); |
350 bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const; | 359 bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const; |
351 | 360 |
352 double computeLengthDouble(RenderStyle* currentStyle, RenderStyle* rootStyle
, float multiplier, bool computingFontSize); | 361 double computeLengthDouble(RenderStyle* currentStyle, RenderStyle* rootStyle
, float multiplier, bool computingFontSize); |
353 | 362 |
354 union { | 363 union { |
355 int ident; | 364 CSSPropertyID propertyID; |
| 365 CSSValueID valueID; |
| 366 int parserOperator; |
356 double num; | 367 double num; |
357 StringImpl* string; | 368 StringImpl* string; |
358 Counter* counter; | 369 Counter* counter; |
359 Rect* rect; | 370 Rect* rect; |
360 Quad* quad; | 371 Quad* quad; |
361 unsigned rgbcolor; | 372 unsigned rgbcolor; |
362 Pair* pair; | 373 Pair* pair; |
363 CSSBasicShape* shape; | 374 CSSBasicShape* shape; |
364 CSSCalcValue* calc; | 375 CSSCalcValue* calc; |
365 } m_value; | 376 } m_value; |
(...skipping 10 matching lines...) Expand all Loading... |
376 ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isPrimitiveValue()); | 387 ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isPrimitiveValue()); |
377 return static_cast<const CSSPrimitiveValue*>(value); | 388 return static_cast<const CSSPrimitiveValue*>(value); |
378 } | 389 } |
379 | 390 |
380 // Catch unneeded cast. | 391 // Catch unneeded cast. |
381 void toCSSPrimitiveValue(const CSSPrimitiveValue*); | 392 void toCSSPrimitiveValue(const CSSPrimitiveValue*); |
382 | 393 |
383 } // namespace WebCore | 394 } // namespace WebCore |
384 | 395 |
385 #endif // CSSPrimitiveValue_h | 396 #endif // CSSPrimitiveValue_h |
OLD | NEW |