| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 CSS_TURN = 107, | 111 CSS_TURN = 107, |
| 111 CSS_REMS = 108, | 112 CSS_REMS = 108, |
| 112 CSS_CHS = 109, | 113 CSS_CHS = 109, |
| 113 CSS_SHAPE = 111, | 114 CSS_SHAPE = 111, |
| 114 CSS_QUAD = 112, | 115 CSS_QUAD = 112, |
| 115 CSS_CALC = 113, | 116 CSS_CALC = 113, |
| 116 CSS_CALC_PERCENTAGE_WITH_NUMBER = 114, | 117 CSS_CALC_PERCENTAGE_WITH_NUMBER = 114, |
| 117 CSS_CALC_PERCENTAGE_WITH_LENGTH = 115, | 118 CSS_CALC_PERCENTAGE_WITH_LENGTH = 115, |
| 118 CSS_STRING = 116, | 119 CSS_STRING = 116, |
| 119 CSS_PROPERTY_ID = 117, | 120 CSS_PROPERTY_ID = 117, |
| 120 CSS_VALUE_ID = 118 | 121 CSS_VALUE_ID = 118, |
| 122 |
| 123 CSS_VARIABLE_REFERENCE = 119 |
| 121 }; | 124 }; |
| 122 | 125 |
| 123 enum LengthUnitType { | 126 enum LengthUnitType { |
| 124 UnitTypePixels = 0, | 127 UnitTypePixels = 0, |
| 125 UnitTypePercentage, | 128 UnitTypePercentage, |
| 126 UnitTypeFontSize, | 129 UnitTypeFontSize, |
| 127 UnitTypeFontXSize, | 130 UnitTypeFontXSize, |
| 128 UnitTypeRootFontSize, | 131 UnitTypeRootFontSize, |
| 129 UnitTypeZeroCharacterWidth, | 132 UnitTypeZeroCharacterWidth, |
| 130 UnitTypeViewportWidth, | 133 UnitTypeViewportWidth, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 171 } |
| 169 bool isAttr() const { return m_primitiveUnitType == CSS_ATTR; } | 172 bool isAttr() const { return m_primitiveUnitType == CSS_ATTR; } |
| 170 bool isCounter() const { return m_primitiveUnitType == CSS_COUNTER; } | 173 bool isCounter() const { return m_primitiveUnitType == CSS_COUNTER; } |
| 171 bool isFontRelativeLength() const | 174 bool isFontRelativeLength() const |
| 172 { | 175 { |
| 173 return m_primitiveUnitType == CSS_EMS | 176 return m_primitiveUnitType == CSS_EMS |
| 174 || m_primitiveUnitType == CSS_EXS | 177 || m_primitiveUnitType == CSS_EXS |
| 175 || m_primitiveUnitType == CSS_REMS | 178 || m_primitiveUnitType == CSS_REMS |
| 176 || m_primitiveUnitType == CSS_CHS; | 179 || m_primitiveUnitType == CSS_CHS; |
| 177 } | 180 } |
| 181 bool isVariableReference() const { return primitiveType() == CSS_VARIABLE_RE
FERENCE; } |
| 178 bool isViewportPercentageLength() const { return isViewportPercentageLength(
static_cast<UnitType>(m_primitiveUnitType)); } | 182 bool isViewportPercentageLength() const { return isViewportPercentageLength(
static_cast<UnitType>(m_primitiveUnitType)); } |
| 179 static bool isViewportPercentageLength(UnitType type) { return type >= CSS_V
W && type <= CSS_VMAX; } | 183 static bool isViewportPercentageLength(UnitType type) { return type >= CSS_V
W && type <= CSS_VMAX; } |
| 180 static bool isLength(UnitType type) | 184 static bool isLength(UnitType type) |
| 181 { | 185 { |
| 182 return (type >= CSS_EMS && type <= CSS_PC) || type == CSS_REMS || type =
= CSS_CHS || isViewportPercentageLength(type); | 186 return (type >= CSS_EMS && type <= CSS_PC) || type == CSS_REMS || type =
= CSS_CHS || isViewportPercentageLength(type); |
| 183 } | 187 } |
| 184 bool isLength() const { return isLength(primitiveType()); } | 188 bool isLength() const { return isLength(primitiveType()); } |
| 185 bool isNumber() const { return primitiveType() == CSS_NUMBER; } | 189 bool isNumber() const { return primitiveType() == CSS_NUMBER; } |
| 186 bool isPercentage() const { return primitiveType() == CSS_PERCENTAGE; } | 190 bool isPercentage() const { return primitiveType() == CSS_PERCENTAGE; } |
| 187 bool isPx() const { return primitiveType() == CSS_PX; } | 191 bool isPx() const { return primitiveType() == CSS_PX; } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, type)); | 227 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, type)); |
| 224 } | 228 } |
| 225 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value,
float zoom) | 229 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value,
float zoom) |
| 226 { | 230 { |
| 227 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, zoom)); | 231 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, zoom)); |
| 228 } | 232 } |
| 229 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const LengthSize& va
lue, const ComputedStyle& style) | 233 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const LengthSize& va
lue, const ComputedStyle& style) |
| 230 { | 234 { |
| 231 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, style)); | 235 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, style)); |
| 232 } | 236 } |
| 237 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(CSSVariableData* val
ue) |
| 238 { |
| 239 return adoptRefWillBeNoop(new CSSPrimitiveValue(value)); |
| 240 } |
| 233 template<typename T> static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create
(T value) | 241 template<typename T> static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create
(T value) |
| 234 { | 242 { |
| 235 return adoptRefWillBeNoop(new CSSPrimitiveValue(value)); | 243 return adoptRefWillBeNoop(new CSSPrimitiveValue(value)); |
| 236 } | 244 } |
| 237 | 245 |
| 238 // This value is used to handle quirky margins in reflow roots (body, td, an
d th) like WinIE. | 246 // This value is used to handle quirky margins in reflow roots (body, td, an
d th) like WinIE. |
| 239 // The basic idea is that a stylesheet can use the value __qem (for quirky e
m) instead of em. | 247 // The basic idea is that a stylesheet can use the value __qem (for quirky e
m) instead of em. |
| 240 // When the quirky value is used, if you're in quirks mode, the margin will
collapse away | 248 // When the quirky value is used, if you're in quirks mode, the margin will
collapse away |
| 241 // inside a table cell. | 249 // inside a table cell. |
| 242 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createAllowingMarginQuirk(d
ouble value, UnitType type) | 250 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createAllowingMarginQuirk(d
ouble value, UnitType type) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 Quad* getQuadValue() const { return m_primitiveUnitType != CSS_QUAD ? 0 : m_
value.quad; } | 283 Quad* getQuadValue() const { return m_primitiveUnitType != CSS_QUAD ? 0 : m_
value.quad; } |
| 276 | 284 |
| 277 RGBA32 getRGBA32Value() const { return m_primitiveUnitType != CSS_RGBCOLOR ?
0 : m_value.rgbcolor; } | 285 RGBA32 getRGBA32Value() const { return m_primitiveUnitType != CSS_RGBCOLOR ?
0 : m_value.rgbcolor; } |
| 278 | 286 |
| 279 Pair* getPairValue() const { return m_primitiveUnitType != CSS_PAIR ? 0 : m_
value.pair; } | 287 Pair* getPairValue() const { return m_primitiveUnitType != CSS_PAIR ? 0 : m_
value.pair; } |
| 280 | 288 |
| 281 CSSBasicShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHA
PE ? 0 : m_value.shape; } | 289 CSSBasicShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHA
PE ? 0 : m_value.shape; } |
| 282 | 290 |
| 283 CSSCalcValue* cssCalcValue() const { return m_primitiveUnitType != CSS_CALC
? 0 : m_value.calc; } | 291 CSSCalcValue* cssCalcValue() const { return m_primitiveUnitType != CSS_CALC
? 0 : m_value.calc; } |
| 284 | 292 |
| 293 CSSVariableData* getVariableDataValue() const { return m_primitiveUnitType !
= CSS_VARIABLE_REFERENCE ? 0 : m_value.variableData; } |
| 294 |
| 285 CSSPropertyID getPropertyID() const { return m_primitiveUnitType == CSS_PROP
ERTY_ID ? m_value.propertyID : CSSPropertyInvalid; } | 295 CSSPropertyID getPropertyID() const { return m_primitiveUnitType == CSS_PROP
ERTY_ID ? m_value.propertyID : CSSPropertyInvalid; } |
| 286 CSSValueID getValueID() const { return m_primitiveUnitType == CSS_VALUE_ID ?
m_value.valueID : CSSValueInvalid; } | 296 CSSValueID getValueID() const { return m_primitiveUnitType == CSS_VALUE_ID ?
m_value.valueID : CSSValueInvalid; } |
| 287 | 297 |
| 288 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa
lueMappings.h | 298 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa
lueMappings.h |
| 289 | 299 |
| 290 static const char* unitTypeToString(UnitType); | 300 static const char* unitTypeToString(UnitType); |
| 291 String customCSSText() const; | 301 String customCSSText() const; |
| 292 | 302 |
| 293 bool isQuirkValue() { return m_isQuirkValue; } | 303 bool isQuirkValue() { return m_isQuirkValue; } |
| 294 | 304 |
| 295 bool equals(const CSSPrimitiveValue&) const; | 305 bool equals(const CSSPrimitiveValue&) const; |
| 296 | 306 |
| 297 DECLARE_TRACE_AFTER_DISPATCH(); | 307 DECLARE_TRACE_AFTER_DISPATCH(); |
| 298 | 308 |
| 299 static UnitType canonicalUnitTypeForCategory(UnitCategory); | 309 static UnitType canonicalUnitTypeForCategory(UnitCategory); |
| 300 static double conversionToCanonicalUnitsScaleFactor(UnitType); | 310 static double conversionToCanonicalUnitsScaleFactor(UnitType); |
| 301 | 311 |
| 302 // Returns true and populates lengthUnitType, if unitType is a length unit.
Otherwise, returns false. | 312 // Returns true and populates lengthUnitType, if unitType is a length unit.
Otherwise, returns false. |
| 303 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); | 313 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); |
| 304 static UnitType lengthUnitTypeToUnitType(LengthUnitType); | 314 static UnitType lengthUnitTypeToUnitType(LengthUnitType); |
| 305 | 315 |
| 306 private: | 316 private: |
| 307 CSSPrimitiveValue(CSSValueID); | 317 CSSPrimitiveValue(CSSValueID); |
| 308 CSSPrimitiveValue(CSSPropertyID); | 318 CSSPrimitiveValue(CSSPropertyID); |
| 309 CSSPrimitiveValue(RGBA32 color); | 319 CSSPrimitiveValue(RGBA32 color); |
| 310 CSSPrimitiveValue(const Length&, float zoom); | 320 CSSPrimitiveValue(const Length&, float zoom); |
| 311 CSSPrimitiveValue(const LengthSize&, const ComputedStyle&); | 321 CSSPrimitiveValue(const LengthSize&, const ComputedStyle&); |
| 312 CSSPrimitiveValue(const String&, UnitType); | 322 CSSPrimitiveValue(const String&, UnitType); |
| 313 CSSPrimitiveValue(double, UnitType); | 323 CSSPrimitiveValue(double, UnitType); |
| 324 CSSPrimitiveValue(CSSVariableData*); |
| 314 | 325 |
| 315 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa
ppings.h | 326 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa
ppings.h |
| 316 template<typename T> CSSPrimitiveValue(T* val) | 327 template<typename T> CSSPrimitiveValue(T* val) |
| 317 : CSSValue(PrimitiveClass) | 328 : CSSValue(PrimitiveClass) |
| 318 { | 329 { |
| 319 init(PassRefPtrWillBeRawPtr<T>(val)); | 330 init(PassRefPtrWillBeRawPtr<T>(val)); |
| 320 } | 331 } |
| 321 | 332 |
| 322 template<typename T> CSSPrimitiveValue(PassRefPtrWillBeRawPtr<T> val) | 333 template<typename T> CSSPrimitiveValue(PassRefPtrWillBeRawPtr<T> val) |
| 323 : CSSValue(PrimitiveClass) | 334 : CSSValue(PrimitiveClass) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 346 double num; | 357 double num; |
| 347 StringImpl* string; | 358 StringImpl* string; |
| 348 RGBA32 rgbcolor; | 359 RGBA32 rgbcolor; |
| 349 // FIXME: oilpan: Should be members, but no support for members in union
s. Just trace the raw ptr for now. | 360 // FIXME: oilpan: Should be members, but no support for members in union
s. Just trace the raw ptr for now. |
| 350 CSSBasicShape* shape; | 361 CSSBasicShape* shape; |
| 351 CSSCalcValue* calc; | 362 CSSCalcValue* calc; |
| 352 Counter* counter; | 363 Counter* counter; |
| 353 Pair* pair; | 364 Pair* pair; |
| 354 Rect* rect; | 365 Rect* rect; |
| 355 Quad* quad; | 366 Quad* quad; |
| 367 CSSVariableData* variableData; |
| 356 } m_value; | 368 } m_value; |
| 357 }; | 369 }; |
| 358 | 370 |
| 359 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; | 371 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; |
| 360 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray; | 372 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray; |
| 361 | 373 |
| 362 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); | 374 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); |
| 363 | 375 |
| 364 } // namespace blink | 376 } // namespace blink |
| 365 | 377 |
| 366 #endif // CSSPrimitiveValue_h | 378 #endif // CSSPrimitiveValue_h |
| OLD | NEW |