| 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 Counter; | |
| 42 class Length; | 41 class Length; |
| 43 class LengthSize; | 42 class LengthSize; |
| 44 class Pair; | 43 class Pair; |
| 45 class Quad; | 44 class Quad; |
| 46 class RGBColor; | 45 class RGBColor; |
| 47 class Rect; | 46 class Rect; |
| 48 class ComputedStyle; | 47 class ComputedStyle; |
| 49 | 48 |
| 50 // Dimension calculations are imprecise, often resulting in values of e.g. | 49 // Dimension calculations are imprecise, often resulting in values of e.g. |
| 51 // 44.99998. We need to go ahead and round if we're really close to the next | 50 // 44.99998. We need to go ahead and round if we're really close to the next |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 Radians, | 87 Radians, |
| 89 Gradians, | 88 Gradians, |
| 90 Turns, | 89 Turns, |
| 91 Milliseconds, | 90 Milliseconds, |
| 92 Seconds, | 91 Seconds, |
| 93 Hertz, | 92 Hertz, |
| 94 Kilohertz, | 93 Kilohertz, |
| 95 CustomIdentifier, | 94 CustomIdentifier, |
| 96 URI, | 95 URI, |
| 97 Attribute, | 96 Attribute, |
| 98 Counter, | |
| 99 Rect, | 97 Rect, |
| 100 RGBColor, | 98 RGBColor, |
| 101 ViewportWidth, | 99 ViewportWidth, |
| 102 ViewportHeight, | 100 ViewportHeight, |
| 103 ViewportMin, | 101 ViewportMin, |
| 104 ViewportMax, | 102 ViewportMax, |
| 105 DotsPerPixel, | 103 DotsPerPixel, |
| 106 DotsPerInch, | 104 DotsPerInch, |
| 107 DotsPerCentimeter, | 105 DotsPerCentimeter, |
| 108 Fraction, | 106 Fraction, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 static UnitType fromName(const String& unit); | 159 static UnitType fromName(const String& unit); |
| 162 | 160 |
| 163 bool isAngle() const | 161 bool isAngle() const |
| 164 { | 162 { |
| 165 return type() == UnitType::Degrees | 163 return type() == UnitType::Degrees |
| 166 || type() == UnitType::Radians | 164 || type() == UnitType::Radians |
| 167 || type() == UnitType::Gradians | 165 || type() == UnitType::Gradians |
| 168 || type() == UnitType::Turns; | 166 || type() == UnitType::Turns; |
| 169 } | 167 } |
| 170 bool isAttr() const { return type() == UnitType::Attribute; } | 168 bool isAttr() const { return type() == UnitType::Attribute; } |
| 171 bool isCounter() const { return type() == UnitType::Counter; } | |
| 172 bool isCustomIdent() const { return type() == UnitType::CustomIdentifier; } | 169 bool isCustomIdent() const { return type() == UnitType::CustomIdentifier; } |
| 173 bool isFontRelativeLength() const | 170 bool isFontRelativeLength() const |
| 174 { | 171 { |
| 175 return type() == UnitType::Ems | 172 return type() == UnitType::Ems |
| 176 || type() == UnitType::Exs | 173 || type() == UnitType::Exs |
| 177 || type() == UnitType::Rems | 174 || type() == UnitType::Rems |
| 178 || type() == UnitType::Chs; | 175 || type() == UnitType::Chs; |
| 179 } | 176 } |
| 180 bool isViewportPercentageLength() const { return isViewportPercentageLength(
type()); } | 177 bool isViewportPercentageLength() const { return isViewportPercentageLength(
type()); } |
| 181 static bool isViewportPercentageLength(UnitType type) { return type >= UnitT
ype::ViewportWidth && type <= UnitType::ViewportMax; } | 178 static bool isViewportPercentageLength(UnitType type) { return type >= UnitT
ype::ViewportWidth && type <= UnitType::ViewportMax; } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // Converts to a Length (Fixed, Percent or Calculated) | 262 // Converts to a Length (Fixed, Percent or Calculated) |
| 266 Length convertToLength(const CSSToLengthConversionData&); | 263 Length convertToLength(const CSSToLengthConversionData&); |
| 267 | 264 |
| 268 double getDoubleValue() const; | 265 double getDoubleValue() const; |
| 269 float getFloatValue() const { return getValue<float>(); } | 266 float getFloatValue() const { return getValue<float>(); } |
| 270 int getIntValue() const { return getValue<int>(); } | 267 int getIntValue() const { return getValue<int>(); } |
| 271 template<typename T> inline T getValue() const { return clampTo<T>(getDouble
Value()); } | 268 template<typename T> inline T getValue() const { return clampTo<T>(getDouble
Value()); } |
| 272 | 269 |
| 273 String getStringValue() const; | 270 String getStringValue() const; |
| 274 | 271 |
| 275 Counter* getCounterValue() const { ASSERT(isCounter()); return m_value.count
er; } | |
| 276 Rect* getRectValue() const { ASSERT(isRect()); return m_value.rect; } | 272 Rect* getRectValue() const { ASSERT(isRect()); return m_value.rect; } |
| 277 Quad* getQuadValue() const { ASSERT(isQuad()); return m_value.quad; } | 273 Quad* getQuadValue() const { ASSERT(isQuad()); return m_value.quad; } |
| 278 RGBA32 getRGBA32Value() const { ASSERT(isRGBColor()); return m_value.rgbcolo
r; } | 274 RGBA32 getRGBA32Value() const { ASSERT(isRGBColor()); return m_value.rgbcolo
r; } |
| 279 | 275 |
| 280 // TODO(timloh): Add isPair() and update callers so we can ASSERT(isPair()) | 276 // TODO(timloh): Add isPair() and update callers so we can ASSERT(isPair()) |
| 281 Pair* getPairValue() const { return type() != UnitType::Pair ? 0 : m_value.p
air; } | 277 Pair* getPairValue() const { return type() != UnitType::Pair ? 0 : m_value.p
air; } |
| 282 | 278 |
| 283 CSSBasicShape* getShapeValue() const { ASSERT(isShape()); return m_value.sha
pe; } | 279 CSSBasicShape* getShapeValue() const { ASSERT(isShape()); return m_value.sha
pe; } |
| 284 CSSCalcValue* cssCalcValue() const { ASSERT(isCalculated()); return m_value.
calc; } | 280 CSSCalcValue* cssCalcValue() const { ASSERT(isCalculated()); return m_value.
calc; } |
| 285 CSSPropertyID getPropertyID() const { ASSERT(isPropertyID()); return m_value
.propertyID; } | 281 CSSPropertyID getPropertyID() const { ASSERT(isPropertyID()); return m_value
.propertyID; } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 init(val); | 322 init(val); |
| 327 } | 323 } |
| 328 | 324 |
| 329 static void create(int); // compile-time guard | 325 static void create(int); // compile-time guard |
| 330 static void create(unsigned); // compile-time guard | 326 static void create(unsigned); // compile-time guard |
| 331 template<typename T> operator T*(); // compile-time guard | 327 template<typename T> operator T*(); // compile-time guard |
| 332 | 328 |
| 333 void init(UnitType); | 329 void init(UnitType); |
| 334 void init(const Length&); | 330 void init(const Length&); |
| 335 void init(const LengthSize&, const ComputedStyle&); | 331 void init(const LengthSize&, const ComputedStyle&); |
| 336 void init(PassRefPtrWillBeRawPtr<Counter>); | |
| 337 void init(PassRefPtrWillBeRawPtr<Rect>); | 332 void init(PassRefPtrWillBeRawPtr<Rect>); |
| 338 void init(PassRefPtrWillBeRawPtr<Pair>); | 333 void init(PassRefPtrWillBeRawPtr<Pair>); |
| 339 void init(PassRefPtrWillBeRawPtr<Quad>); | 334 void init(PassRefPtrWillBeRawPtr<Quad>); |
| 340 void init(PassRefPtrWillBeRawPtr<CSSBasicShape>); | 335 void init(PassRefPtrWillBeRawPtr<CSSBasicShape>); |
| 341 void init(PassRefPtrWillBeRawPtr<CSSCalcValue>); | 336 void init(PassRefPtrWillBeRawPtr<CSSCalcValue>); |
| 342 | 337 |
| 343 double computeLengthDouble(const CSSToLengthConversionData&); | 338 double computeLengthDouble(const CSSToLengthConversionData&); |
| 344 | 339 |
| 345 inline UnitType type() const { return static_cast<UnitType>(m_primitiveUnitT
ype); } | 340 inline UnitType type() const { return static_cast<UnitType>(m_primitiveUnitT
ype); } |
| 346 | 341 |
| 347 union { | 342 union { |
| 348 CSSPropertyID propertyID; | 343 CSSPropertyID propertyID; |
| 349 CSSValueID valueID; | 344 CSSValueID valueID; |
| 350 double num; | 345 double num; |
| 351 StringImpl* string; | 346 StringImpl* string; |
| 352 RGBA32 rgbcolor; | 347 RGBA32 rgbcolor; |
| 353 // FIXME: oilpan: Should be members, but no support for members in union
s. Just trace the raw ptr for now. | 348 // FIXME: oilpan: Should be members, but no support for members in union
s. Just trace the raw ptr for now. |
| 354 CSSBasicShape* shape; | 349 CSSBasicShape* shape; |
| 355 CSSCalcValue* calc; | 350 CSSCalcValue* calc; |
| 356 Counter* counter; | |
| 357 Pair* pair; | 351 Pair* pair; |
| 358 Rect* rect; | 352 Rect* rect; |
| 359 Quad* quad; | 353 Quad* quad; |
| 360 } m_value; | 354 } m_value; |
| 361 }; | 355 }; |
| 362 | 356 |
| 363 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; | 357 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; |
| 364 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray; | 358 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray; |
| 365 | 359 |
| 366 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); | 360 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); |
| 367 | 361 |
| 368 } // namespace blink | 362 } // namespace blink |
| 369 | 363 |
| 370 #endif // CSSPrimitiveValue_h | 364 #endif // CSSPrimitiveValue_h |
| OLD | NEW |