| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 bool isPx() const { return typeWithCalcResolved() == UnitType::Pixels; } | 193 bool isPx() const { return typeWithCalcResolved() == UnitType::Pixels; } |
| 194 bool isTime() const { return type() == UnitType::Seconds || type() == UnitTy
pe::Milliseconds; } | 194 bool isTime() const { return type() == UnitType::Seconds || type() == UnitTy
pe::Milliseconds; } |
| 195 bool isCalculated() const { return type() == UnitType::Calc; } | 195 bool isCalculated() const { return type() == UnitType::Calc; } |
| 196 bool isCalculatedPercentageWithNumber() const { return typeWithCalcResolved(
) == UnitType::CalcPercentageWithNumber; } | 196 bool isCalculatedPercentageWithNumber() const { return typeWithCalcResolved(
) == UnitType::CalcPercentageWithNumber; } |
| 197 bool isCalculatedPercentageWithLength() const { return typeWithCalcResolved(
) == UnitType::CalcPercentageWithLength; } | 197 bool isCalculatedPercentageWithLength() const { return typeWithCalcResolved(
) == UnitType::CalcPercentageWithLength; } |
| 198 static bool isResolution(UnitType type) { return type >= UnitType::DotsPerPi
xel && type <= UnitType::DotsPerCentimeter; } | 198 static bool isResolution(UnitType type) { return type >= UnitType::DotsPerPi
xel && type <= UnitType::DotsPerCentimeter; } |
| 199 bool isFlex() const { return typeWithCalcResolved() == UnitType::Fraction; } | 199 bool isFlex() const { return typeWithCalcResolved() == UnitType::Fraction; } |
| 200 bool isValueID() const { return type() == UnitType::ValueID; } | 200 bool isValueID() const { return type() == UnitType::ValueID; } |
| 201 bool colorIsDerivedFromElement() const; | 201 bool colorIsDerivedFromElement() const; |
| 202 | 202 |
| 203 static RawPtr<CSSPrimitiveValue> createIdentifier(CSSValueID valueID) | 203 static CSSPrimitiveValue* createIdentifier(CSSValueID valueID) |
| 204 { | 204 { |
| 205 return new CSSPrimitiveValue(valueID); | 205 return new CSSPrimitiveValue(valueID); |
| 206 } | 206 } |
| 207 static RawPtr<CSSPrimitiveValue> create(double value, UnitType type) | 207 static CSSPrimitiveValue* create(double value, UnitType type) |
| 208 { | 208 { |
| 209 return new CSSPrimitiveValue(value, type); | 209 return new CSSPrimitiveValue(value, type); |
| 210 } | 210 } |
| 211 static RawPtr<CSSPrimitiveValue> create(const Length& value, float zoom) | 211 static CSSPrimitiveValue* create(const Length& value, float zoom) |
| 212 { | 212 { |
| 213 return new CSSPrimitiveValue(value, zoom); | 213 return new CSSPrimitiveValue(value, zoom); |
| 214 } | 214 } |
| 215 template<typename T> static RawPtr<CSSPrimitiveValue> create(T value) | 215 template<typename T> static CSSPrimitiveValue* create(T value) |
| 216 { | 216 { |
| 217 static_assert(!std::is_same<T, CSSValueID>::value, "Do not call create()
with a CSSValueID; call createIdentifier() instead"); | 217 static_assert(!std::is_same<T, CSSValueID>::value, "Do not call create()
with a CSSValueID; call createIdentifier() instead"); |
| 218 return new CSSPrimitiveValue(value); | 218 return new CSSPrimitiveValue(value); |
| 219 } | 219 } |
| 220 | 220 |
| 221 ~CSSPrimitiveValue(); | 221 ~CSSPrimitiveValue(); |
| 222 | 222 |
| 223 UnitType typeWithCalcResolved() const; | 223 UnitType typeWithCalcResolved() const; |
| 224 | 224 |
| 225 double computeDegrees() const; | 225 double computeDegrees() const; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 255 // Returns true and populates lengthUnitType, if unitType is a length unit.
Otherwise, returns false. | 255 // Returns true and populates lengthUnitType, if unitType is a length unit.
Otherwise, returns false. |
| 256 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); | 256 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); |
| 257 static UnitType lengthUnitTypeToUnitType(LengthUnitType); | 257 static UnitType lengthUnitTypeToUnitType(LengthUnitType); |
| 258 | 258 |
| 259 private: | 259 private: |
| 260 CSSPrimitiveValue(CSSValueID); | 260 CSSPrimitiveValue(CSSValueID); |
| 261 CSSPrimitiveValue(const Length&, float zoom); | 261 CSSPrimitiveValue(const Length&, float zoom); |
| 262 CSSPrimitiveValue(double, UnitType); | 262 CSSPrimitiveValue(double, UnitType); |
| 263 | 263 |
| 264 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa
ppings.h | 264 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa
ppings.h |
| 265 |
| 265 template<typename T> CSSPrimitiveValue(T* val) | 266 template<typename T> CSSPrimitiveValue(T* val) |
| 266 : CSSValue(PrimitiveClass) | 267 : CSSValue(PrimitiveClass) |
| 267 { | 268 { |
| 268 init(RawPtr<T>(val)); | |
| 269 } | |
| 270 | |
| 271 template<typename T> CSSPrimitiveValue(RawPtr<T> val) | |
| 272 : CSSValue(PrimitiveClass) | |
| 273 { | |
| 274 init(val); | 269 init(val); |
| 275 } | 270 } |
| 276 | 271 |
| 277 static void create(int); // compile-time guard | 272 static void create(int); // compile-time guard |
| 278 static void create(unsigned); // compile-time guard | 273 static void create(unsigned); // compile-time guard |
| 279 template<typename T> operator T*(); // compile-time guard | 274 template<typename T> operator T*(); // compile-time guard |
| 280 | 275 |
| 281 void init(UnitType); | 276 void init(UnitType); |
| 282 void init(const Length&); | 277 void init(const Length&); |
| 283 void init(RawPtr<CSSCalcValue>); | 278 void init(CSSCalcValue*); |
| 284 | 279 |
| 285 double computeLengthDouble(const CSSToLengthConversionData&) const; | 280 double computeLengthDouble(const CSSToLengthConversionData&) const; |
| 286 | 281 |
| 287 inline UnitType type() const { return static_cast<UnitType>(m_primitiveUnitT
ype); } | 282 inline UnitType type() const { return static_cast<UnitType>(m_primitiveUnitT
ype); } |
| 288 | 283 |
| 289 union { | 284 union { |
| 290 CSSValueID valueID; | 285 CSSValueID valueID; |
| 291 double num; | 286 double num; |
| 292 // FIXME: oilpan: Should be a member, but no support for members in unio
ns. Just trace the raw ptr for now. | 287 // FIXME: oilpan: Should be a member, but no support for members in unio
ns. Just trace the raw ptr for now. |
| 293 CSSCalcValue* calc; | 288 CSSCalcValue* calc; |
| 294 } m_value; | 289 } m_value; |
| 295 }; | 290 }; |
| 296 | 291 |
| 297 using CSSLengthArray = CSSPrimitiveValue::CSSLengthArray; | 292 using CSSLengthArray = CSSPrimitiveValue::CSSLengthArray; |
| 298 using CSSLengthTypeArray = CSSPrimitiveValue::CSSLengthTypeArray; | 293 using CSSLengthTypeArray = CSSPrimitiveValue::CSSLengthTypeArray; |
| 299 | 294 |
| 300 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); | 295 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); |
| 301 | 296 |
| 302 } // namespace blink | 297 } // namespace blink |
| 303 | 298 |
| 304 #endif // CSSPrimitiveValue_h | 299 #endif // CSSPrimitiveValue_h |
| OLD | NEW |