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 * |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "wtf/Forward.h" | 31 #include "wtf/Forward.h" |
32 #include "wtf/MathExtras.h" | 32 #include "wtf/MathExtras.h" |
33 #include "wtf/PassRefPtr.h" | 33 #include "wtf/PassRefPtr.h" |
34 #include "wtf/text/StringHash.h" | 34 #include "wtf/text/StringHash.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 class CSSBasicShape; | 38 class CSSBasicShape; |
39 class CSSCalcValue; | 39 class CSSCalcValue; |
40 class CSSToLengthConversionData; | 40 class CSSToLengthConversionData; |
41 class CSSVariableData; | |
41 class Counter; | 42 class Counter; |
42 class Length; | 43 class Length; |
43 class LengthSize; | 44 class LengthSize; |
44 class Pair; | 45 class Pair; |
45 class Quad; | 46 class Quad; |
46 class RGBColor; | 47 class RGBColor; |
47 class Rect; | 48 class Rect; |
48 class ComputedStyle; | 49 class ComputedStyle; |
49 | 50 |
50 // Dimension calculations are imprecise, often resulting in values of e.g. | 51 // Dimension calculations are imprecise, often resulting in values of e.g. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 CSS_REMS = 108, | 113 CSS_REMS = 108, |
113 CSS_CHS = 109, | 114 CSS_CHS = 109, |
114 CSS_SHAPE = 111, | 115 CSS_SHAPE = 111, |
115 CSS_QUAD = 112, | 116 CSS_QUAD = 112, |
116 CSS_CALC = 113, | 117 CSS_CALC = 113, |
117 CSS_CALC_PERCENTAGE_WITH_NUMBER = 114, | 118 CSS_CALC_PERCENTAGE_WITH_NUMBER = 114, |
118 CSS_CALC_PERCENTAGE_WITH_LENGTH = 115, | 119 CSS_CALC_PERCENTAGE_WITH_LENGTH = 115, |
119 CSS_STRING = 116, | 120 CSS_STRING = 116, |
120 CSS_PROPERTY_ID = 117, | 121 CSS_PROPERTY_ID = 117, |
121 CSS_VALUE_ID = 118, | 122 CSS_VALUE_ID = 118, |
122 CSS_QEM = 119 | 123 CSS_QEM = 119, |
124 CSS_VARIABLE_REFERENCE = 120 | |
123 }; | 125 }; |
124 | 126 |
125 enum LengthUnitType { | 127 enum LengthUnitType { |
126 UnitTypePixels = 0, | 128 UnitTypePixels = 0, |
127 UnitTypePercentage, | 129 UnitTypePercentage, |
128 UnitTypeFontSize, | 130 UnitTypeFontSize, |
129 UnitTypeFontXSize, | 131 UnitTypeFontXSize, |
130 UnitTypeRootFontSize, | 132 UnitTypeRootFontSize, |
131 UnitTypeZeroCharacterWidth, | 133 UnitTypeZeroCharacterWidth, |
132 UnitTypeViewportWidth, | 134 UnitTypeViewportWidth, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, type)); | 228 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, type)); |
227 } | 229 } |
228 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value, float zoom) | 230 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value, float zoom) |
229 { | 231 { |
230 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, zoom)); | 232 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, zoom)); |
231 } | 233 } |
232 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const LengthSize& va lue, const ComputedStyle& style) | 234 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const LengthSize& va lue, const ComputedStyle& style) |
233 { | 235 { |
234 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, style)); | 236 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, style)); |
235 } | 237 } |
238 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(CSSVariableData* val ue) | |
239 { | |
240 return adoptRefWillBeNoop(new CSSPrimitiveValue(value)); | |
241 } | |
236 template<typename T> static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create (T value) | 242 template<typename T> static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create (T value) |
237 { | 243 { |
238 return adoptRefWillBeNoop(new CSSPrimitiveValue(value)); | 244 return adoptRefWillBeNoop(new CSSPrimitiveValue(value)); |
239 } | 245 } |
240 | 246 |
241 // This value is used to handle quirky margins in reflow roots (body, td, an d th) like WinIE. | 247 // This value is used to handle quirky margins in reflow roots (body, td, an d th) like WinIE. |
242 // The basic idea is that a stylesheet can use the value __qem (for quirky e m) instead of em. | 248 // The basic idea is that a stylesheet can use the value __qem (for quirky e m) instead of em. |
243 // When the quirky value is used, if you're in quirks mode, the margin will collapse away | 249 // When the quirky value is used, if you're in quirks mode, the margin will collapse away |
244 // inside a table cell. | 250 // inside a table cell. |
245 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createAllowingMarginQuirk(d ouble value, UnitType type) | 251 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createAllowingMarginQuirk(d ouble value, UnitType type) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 Quad* getQuadValue() const { return m_primitiveUnitType != CSS_QUAD ? 0 : m_ value.quad; } | 284 Quad* getQuadValue() const { return m_primitiveUnitType != CSS_QUAD ? 0 : m_ value.quad; } |
279 | 285 |
280 RGBA32 getRGBA32Value() const { return m_primitiveUnitType != CSS_RGBCOLOR ? 0 : m_value.rgbcolor; } | 286 RGBA32 getRGBA32Value() const { return m_primitiveUnitType != CSS_RGBCOLOR ? 0 : m_value.rgbcolor; } |
281 | 287 |
282 Pair* getPairValue() const { return m_primitiveUnitType != CSS_PAIR ? 0 : m_ value.pair; } | 288 Pair* getPairValue() const { return m_primitiveUnitType != CSS_PAIR ? 0 : m_ value.pair; } |
283 | 289 |
284 CSSBasicShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHA PE ? 0 : m_value.shape; } | 290 CSSBasicShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHA PE ? 0 : m_value.shape; } |
285 | 291 |
286 CSSCalcValue* cssCalcValue() const { return m_primitiveUnitType != CSS_CALC ? 0 : m_value.calc; } | 292 CSSCalcValue* cssCalcValue() const { return m_primitiveUnitType != CSS_CALC ? 0 : m_value.calc; } |
287 | 293 |
294 CSSVariableData* getVariableDataValue() const { return m_primitiveUnitType ! = CSS_VARIABLE_REFERENCE ? 0 : m_value.variableData; } | |
Timothy Loh
2015/07/23 08:11:46
Better to ASSERT type is variable and always retur
leviw_travelin_and_unemployed
2015/08/04 00:42:20
Every other method in the file follows the other c
| |
295 | |
288 CSSPropertyID getPropertyID() const { return m_primitiveUnitType == CSS_PROP ERTY_ID ? m_value.propertyID : CSSPropertyInvalid; } | 296 CSSPropertyID getPropertyID() const { return m_primitiveUnitType == CSS_PROP ERTY_ID ? m_value.propertyID : CSSPropertyInvalid; } |
289 CSSValueID getValueID() const { return m_primitiveUnitType == CSS_VALUE_ID ? m_value.valueID : CSSValueInvalid; } | 297 CSSValueID getValueID() const { return m_primitiveUnitType == CSS_VALUE_ID ? m_value.valueID : CSSValueInvalid; } |
290 | 298 |
291 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa lueMappings.h | 299 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa lueMappings.h |
292 | 300 |
293 static const char* unitTypeToString(UnitType); | 301 static const char* unitTypeToString(UnitType); |
294 String customCSSText() const; | 302 String customCSSText() const; |
295 | 303 |
296 bool isQuirkValue() { return m_isQuirkValue; } | 304 bool isQuirkValue() { return m_isQuirkValue; } |
297 | 305 |
298 bool equals(const CSSPrimitiveValue&) const; | 306 bool equals(const CSSPrimitiveValue&) const; |
299 | 307 |
300 DECLARE_TRACE_AFTER_DISPATCH(); | 308 DECLARE_TRACE_AFTER_DISPATCH(); |
301 | 309 |
302 static UnitType canonicalUnitTypeForCategory(UnitCategory); | 310 static UnitType canonicalUnitTypeForCategory(UnitCategory); |
303 static double conversionToCanonicalUnitsScaleFactor(UnitType); | 311 static double conversionToCanonicalUnitsScaleFactor(UnitType); |
304 | 312 |
305 // Returns true and populates lengthUnitType, if unitType is a length unit. Otherwise, returns false. | 313 // Returns true and populates lengthUnitType, if unitType is a length unit. Otherwise, returns false. |
306 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); | 314 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); |
307 static UnitType lengthUnitTypeToUnitType(LengthUnitType); | 315 static UnitType lengthUnitTypeToUnitType(LengthUnitType); |
308 | 316 |
309 private: | 317 private: |
310 CSSPrimitiveValue(CSSValueID); | 318 CSSPrimitiveValue(CSSValueID); |
311 CSSPrimitiveValue(CSSPropertyID); | 319 CSSPrimitiveValue(CSSPropertyID); |
312 CSSPrimitiveValue(RGBA32 color); | 320 CSSPrimitiveValue(RGBA32 color); |
313 CSSPrimitiveValue(const Length&, float zoom); | 321 CSSPrimitiveValue(const Length&, float zoom); |
314 CSSPrimitiveValue(const LengthSize&, const ComputedStyle&); | 322 CSSPrimitiveValue(const LengthSize&, const ComputedStyle&); |
315 CSSPrimitiveValue(const String&, UnitType); | 323 CSSPrimitiveValue(const String&, UnitType); |
316 CSSPrimitiveValue(double, UnitType); | 324 CSSPrimitiveValue(double, UnitType); |
325 CSSPrimitiveValue(CSSVariableData*); | |
317 | 326 |
318 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa ppings.h | 327 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa ppings.h |
319 template<typename T> CSSPrimitiveValue(T* val) | 328 template<typename T> CSSPrimitiveValue(T* val) |
320 : CSSValue(PrimitiveClass) | 329 : CSSValue(PrimitiveClass) |
321 { | 330 { |
322 init(PassRefPtrWillBeRawPtr<T>(val)); | 331 init(PassRefPtrWillBeRawPtr<T>(val)); |
323 } | 332 } |
324 | 333 |
325 template<typename T> CSSPrimitiveValue(PassRefPtrWillBeRawPtr<T> val) | 334 template<typename T> CSSPrimitiveValue(PassRefPtrWillBeRawPtr<T> val) |
326 : CSSValue(PrimitiveClass) | 335 : CSSValue(PrimitiveClass) |
(...skipping 22 matching lines...) Expand all Loading... | |
349 double num; | 358 double num; |
350 StringImpl* string; | 359 StringImpl* string; |
351 RGBA32 rgbcolor; | 360 RGBA32 rgbcolor; |
352 // FIXME: oilpan: Should be members, but no support for members in union s. Just trace the raw ptr for now. | 361 // FIXME: oilpan: Should be members, but no support for members in union s. Just trace the raw ptr for now. |
353 CSSBasicShape* shape; | 362 CSSBasicShape* shape; |
354 CSSCalcValue* calc; | 363 CSSCalcValue* calc; |
355 Counter* counter; | 364 Counter* counter; |
356 Pair* pair; | 365 Pair* pair; |
357 Rect* rect; | 366 Rect* rect; |
358 Quad* quad; | 367 Quad* quad; |
368 CSSVariableData* variableData; | |
359 } m_value; | 369 } m_value; |
360 }; | 370 }; |
361 | 371 |
362 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; | 372 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; |
363 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray; | 373 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray; |
364 | 374 |
365 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); | 375 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); |
366 | 376 |
367 } // namespace blink | 377 } // namespace blink |
368 | 378 |
369 #endif // CSSPrimitiveValue_h | 379 #endif // CSSPrimitiveValue_h |
OLD | NEW |