| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 return static_cast<float>(ceiledValue); | 58 return static_cast<float>(ceiledValue); |
| 59 if (proximityToNextInt >= 0.99 && value < 0) | 59 if (proximityToNextInt >= 0.99 && value < 0) |
| 60 return static_cast<float>(floor(value)); | 60 return static_cast<float>(floor(value)); |
| 61 return static_cast<float>(value); | 61 return static_cast<float>(value); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // CSSPrimitiveValue stores numeric data types (e.g. 1, 10px, 4%) and calc() | 64 // CSSPrimitiveValue stores numeric data types (e.g. 1, 10px, 4%) and calc() |
| 65 // values (e.g. calc(3px + 2em)). | 65 // values (e.g. calc(3px + 2em)). |
| 66 class CORE_EXPORT CSSPrimitiveValue : public CSSValue { | 66 class CORE_EXPORT CSSPrimitiveValue : public CSSValue { |
| 67 public: | 67 public: |
| 68 // These units are iterated through, so be careful when adding or changing the
order. | 68 // These units are iterated through, so be careful when adding or changing the |
| 69 // order. |
| 69 enum class UnitType { | 70 enum class UnitType { |
| 70 Unknown, | 71 Unknown, |
| 71 Number, | 72 Number, |
| 72 Percentage, | 73 Percentage, |
| 73 // Length units | 74 // Length units |
| 74 Ems, | 75 Ems, |
| 75 Exs, | 76 Exs, |
| 76 Pixels, | 77 Pixels, |
| 77 Centimeters, | 78 Centimeters, |
| 78 Millimeters, | 79 Millimeters, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 102 DotsPerCentimeter, | 103 DotsPerCentimeter, |
| 103 // Other units | 104 // Other units |
| 104 Fraction, | 105 Fraction, |
| 105 Integer, | 106 Integer, |
| 106 Calc, | 107 Calc, |
| 107 CalcPercentageWithNumber, | 108 CalcPercentageWithNumber, |
| 108 CalcPercentageWithLength, | 109 CalcPercentageWithLength, |
| 109 CalcLengthWithNumber, | 110 CalcLengthWithNumber, |
| 110 CalcPercentageWithLengthAndNumber, | 111 CalcPercentageWithLengthAndNumber, |
| 111 | 112 |
| 112 // This value is used to handle quirky margins in reflow roots (body, td, an
d th) like WinIE. | 113 // This value is used to handle quirky margins in reflow roots (body, td, |
| 113 // The basic idea is that a stylesheet can use the value __qem (for quirky e
m) instead of em. | 114 // and th) like WinIE. The basic idea is that a stylesheet can use the value |
| 114 // When the quirky value is used, if you're in quirks mode, the margin will
collapse away | 115 // __qem (for quirky em) instead of em. When the quirky value is used, if |
| 115 // inside a table cell. This quirk is specified in the HTML spec but our imp
l is different. | 116 // you're in quirks mode, the margin will collapse away inside a table cell. |
| 117 // This quirk is specified in the HTML spec but our impl is different. |
| 116 // TODO: Remove this. crbug.com/443952 | 118 // TODO: Remove this. crbug.com/443952 |
| 117 QuirkyEms, | 119 QuirkyEms, |
| 118 }; | 120 }; |
| 119 | 121 |
| 120 enum LengthUnitType { | 122 enum LengthUnitType { |
| 121 UnitTypePixels = 0, | 123 UnitTypePixels = 0, |
| 122 UnitTypePercentage, | 124 UnitTypePercentage, |
| 123 UnitTypeFontSize, | 125 UnitTypeFontSize, |
| 124 UnitTypeFontXSize, | 126 UnitTypeFontXSize, |
| 125 UnitTypeRootFontSize, | 127 UnitTypeRootFontSize, |
| 126 UnitTypeZeroCharacterWidth, | 128 UnitTypeZeroCharacterWidth, |
| 127 UnitTypeViewportWidth, | 129 UnitTypeViewportWidth, |
| 128 UnitTypeViewportHeight, | 130 UnitTypeViewportHeight, |
| 129 UnitTypeViewportMin, | 131 UnitTypeViewportMin, |
| 130 UnitTypeViewportMax, | 132 UnitTypeViewportMax, |
| 131 | 133 |
| 132 // This value must come after the last length unit type to enable iteration
over the length unit types. | 134 // This value must come after the last length unit type to enable iteration |
| 135 // over the length unit types. |
| 133 LengthUnitTypeCount, | 136 LengthUnitTypeCount, |
| 134 }; | 137 }; |
| 135 | 138 |
| 136 struct CSSLengthArray { | 139 struct CSSLengthArray { |
| 137 CSSLengthArray() : values(LengthUnitTypeCount) { | 140 CSSLengthArray() : values(LengthUnitTypeCount) { |
| 138 typeFlags.resize(LengthUnitTypeCount); | 141 typeFlags.resize(LengthUnitTypeCount); |
| 139 } | 142 } |
| 140 | 143 |
| 141 Vector<double, CSSPrimitiveValue::LengthUnitTypeCount> values; | 144 Vector<double, CSSPrimitiveValue::LengthUnitTypeCount> values; |
| 142 BitVector typeFlags; | 145 BitVector typeFlags; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 261 |
| 259 String customCSSText() const; | 262 String customCSSText() const; |
| 260 | 263 |
| 261 bool equals(const CSSPrimitiveValue&) const; | 264 bool equals(const CSSPrimitiveValue&) const; |
| 262 | 265 |
| 263 DECLARE_TRACE_AFTER_DISPATCH(); | 266 DECLARE_TRACE_AFTER_DISPATCH(); |
| 264 | 267 |
| 265 static UnitType canonicalUnitTypeForCategory(UnitCategory); | 268 static UnitType canonicalUnitTypeForCategory(UnitCategory); |
| 266 static double conversionToCanonicalUnitsScaleFactor(UnitType); | 269 static double conversionToCanonicalUnitsScaleFactor(UnitType); |
| 267 | 270 |
| 268 // Returns true and populates lengthUnitType, if unitType is a length unit. Ot
herwise, returns false. | 271 // Returns true and populates lengthUnitType, if unitType is a length unit. |
| 272 // Otherwise, returns false. |
| 269 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); | 273 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); |
| 270 static UnitType lengthUnitTypeToUnitType(LengthUnitType); | 274 static UnitType lengthUnitTypeToUnitType(LengthUnitType); |
| 271 | 275 |
| 272 private: | 276 private: |
| 273 CSSPrimitiveValue(const Length&, float zoom); | 277 CSSPrimitiveValue(const Length&, float zoom); |
| 274 CSSPrimitiveValue(double, UnitType); | 278 CSSPrimitiveValue(double, UnitType); |
| 275 | 279 |
| 276 template <typename T> | 280 template <typename T> |
| 277 CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMappings.h | 281 CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMappings.h |
| 278 | 282 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 295 void init(CSSCalcValue*); | 299 void init(CSSCalcValue*); |
| 296 | 300 |
| 297 double computeLengthDouble(const CSSToLengthConversionData&) const; | 301 double computeLengthDouble(const CSSToLengthConversionData&) const; |
| 298 | 302 |
| 299 inline UnitType type() const { | 303 inline UnitType type() const { |
| 300 return static_cast<UnitType>(m_primitiveUnitType); | 304 return static_cast<UnitType>(m_primitiveUnitType); |
| 301 } | 305 } |
| 302 | 306 |
| 303 union { | 307 union { |
| 304 double num; | 308 double num; |
| 305 // FIXME: oilpan: Should be a member, but no support for members in unions.
Just trace the raw ptr for now. | 309 // FIXME: oilpan: Should be a member, but no support for members in unions. |
| 310 // Just trace the raw ptr for now. |
| 306 CSSCalcValue* calc; | 311 CSSCalcValue* calc; |
| 307 } m_value; | 312 } m_value; |
| 308 }; | 313 }; |
| 309 | 314 |
| 310 using CSSLengthArray = CSSPrimitiveValue::CSSLengthArray; | 315 using CSSLengthArray = CSSPrimitiveValue::CSSLengthArray; |
| 311 | 316 |
| 312 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); | 317 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); |
| 313 | 318 |
| 314 } // namespace blink | 319 } // namespace blink |
| 315 | 320 |
| 316 #endif // CSSPrimitiveValue_h | 321 #endif // CSSPrimitiveValue_h |
| OLD | NEW |