| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 Points, | 80 Points, |
| 81 Picas, | 81 Picas, |
| 82 Degrees, | 82 Degrees, |
| 83 Radians, | 83 Radians, |
| 84 Gradians, | 84 Gradians, |
| 85 Turns, | 85 Turns, |
| 86 Milliseconds, | 86 Milliseconds, |
| 87 Seconds, | 87 Seconds, |
| 88 Hertz, | 88 Hertz, |
| 89 Kilohertz, | 89 Kilohertz, |
| 90 CustomIdentifier, | |
| 91 URI, | |
| 92 RGBColor, | 90 RGBColor, |
| 93 ViewportWidth, | 91 ViewportWidth, |
| 94 ViewportHeight, | 92 ViewportHeight, |
| 95 ViewportMin, | 93 ViewportMin, |
| 96 ViewportMax, | 94 ViewportMax, |
| 97 DotsPerPixel, | 95 DotsPerPixel, |
| 98 DotsPerInch, | 96 DotsPerInch, |
| 99 DotsPerCentimeter, | 97 DotsPerCentimeter, |
| 100 Fraction, | 98 Fraction, |
| 101 Integer, | 99 Integer, |
| 102 Rems, | 100 Rems, |
| 103 Chs, | 101 Chs, |
| 104 Shape, | 102 Shape, |
| 105 Calc, | 103 Calc, |
| 106 CalcPercentageWithNumber, | 104 CalcPercentageWithNumber, |
| 107 CalcPercentageWithLength, | 105 CalcPercentageWithLength, |
| 108 String, | |
| 109 PropertyID, | 106 PropertyID, |
| 110 ValueID, | 107 ValueID, |
| 111 QuirkyEms, | 108 QuirkyEms, |
| 112 }; | 109 }; |
| 113 | 110 |
| 114 enum LengthUnitType { | 111 enum LengthUnitType { |
| 115 UnitTypePixels = 0, | 112 UnitTypePixels = 0, |
| 116 UnitTypePercentage, | 113 UnitTypePercentage, |
| 117 UnitTypeFontSize, | 114 UnitTypeFontSize, |
| 118 UnitTypeFontXSize, | 115 UnitTypeFontXSize, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 147 |
| 151 static UnitType fromName(const String& unit); | 148 static UnitType fromName(const String& unit); |
| 152 | 149 |
| 153 bool isAngle() const | 150 bool isAngle() const |
| 154 { | 151 { |
| 155 return type() == UnitType::Degrees | 152 return type() == UnitType::Degrees |
| 156 || type() == UnitType::Radians | 153 || type() == UnitType::Radians |
| 157 || type() == UnitType::Gradians | 154 || type() == UnitType::Gradians |
| 158 || type() == UnitType::Turns; | 155 || type() == UnitType::Turns; |
| 159 } | 156 } |
| 160 bool isCustomIdent() const { return type() == UnitType::CustomIdentifier; } | |
| 161 bool isFontRelativeLength() const | 157 bool isFontRelativeLength() const |
| 162 { | 158 { |
| 163 return type() == UnitType::Ems | 159 return type() == UnitType::Ems |
| 164 || type() == UnitType::Exs | 160 || type() == UnitType::Exs |
| 165 || type() == UnitType::Rems | 161 || type() == UnitType::Rems |
| 166 || type() == UnitType::Chs; | 162 || type() == UnitType::Chs; |
| 167 } | 163 } |
| 168 bool isViewportPercentageLength() const { return isViewportPercentageLength(
type()); } | 164 bool isViewportPercentageLength() const { return isViewportPercentageLength(
type()); } |
| 169 static bool isViewportPercentageLength(UnitType type) { return type >= UnitT
ype::ViewportWidth && type <= UnitType::ViewportMax; } | 165 static bool isViewportPercentageLength(UnitType type) { return type >= UnitT
ype::ViewportWidth && type <= UnitType::ViewportMax; } |
| 170 static bool isLength(UnitType type) | 166 static bool isLength(UnitType type) |
| 171 { | 167 { |
| 172 return (type >= UnitType::Ems && type <= UnitType::Picas) || type == Uni
tType::Rems || type == UnitType::Chs || isViewportPercentageLength(type); | 168 return (type >= UnitType::Ems && type <= UnitType::Picas) || type == Uni
tType::Rems || type == UnitType::Chs || isViewportPercentageLength(type); |
| 173 } | 169 } |
| 174 bool isLength() const { return isLength(typeWithCalcResolved()); } | 170 bool isLength() const { return isLength(typeWithCalcResolved()); } |
| 175 bool isNumber() const { return typeWithCalcResolved() == UnitType::Number ||
typeWithCalcResolved() == UnitType::Integer; } | 171 bool isNumber() const { return typeWithCalcResolved() == UnitType::Number ||
typeWithCalcResolved() == UnitType::Integer; } |
| 176 bool isPercentage() const { return typeWithCalcResolved() == UnitType::Perce
ntage; } | 172 bool isPercentage() const { return typeWithCalcResolved() == UnitType::Perce
ntage; } |
| 177 bool isPropertyID() const { return type() == UnitType::PropertyID; } | 173 bool isPropertyID() const { return type() == UnitType::PropertyID; } |
| 178 bool isPx() const { return typeWithCalcResolved() == UnitType::Pixels; } | 174 bool isPx() const { return typeWithCalcResolved() == UnitType::Pixels; } |
| 179 bool isRGBColor() const { return type() == UnitType::RGBColor; } | 175 bool isRGBColor() const { return type() == UnitType::RGBColor; } |
| 180 bool isShape() const { return type() == UnitType::Shape; } | 176 bool isShape() const { return type() == UnitType::Shape; } |
| 181 bool isString() const { return type() == UnitType::String; } | |
| 182 bool isTime() const { return type() == UnitType::Seconds || type() == UnitTy
pe::Milliseconds; } | 177 bool isTime() const { return type() == UnitType::Seconds || type() == UnitTy
pe::Milliseconds; } |
| 183 bool isURI() const { return type() == UnitType::URI; } | |
| 184 bool isCalculated() const { return type() == UnitType::Calc; } | 178 bool isCalculated() const { return type() == UnitType::Calc; } |
| 185 bool isCalculatedPercentageWithNumber() const { return typeWithCalcResolved(
) == UnitType::CalcPercentageWithNumber; } | 179 bool isCalculatedPercentageWithNumber() const { return typeWithCalcResolved(
) == UnitType::CalcPercentageWithNumber; } |
| 186 bool isCalculatedPercentageWithLength() const { return typeWithCalcResolved(
) == UnitType::CalcPercentageWithLength; } | 180 bool isCalculatedPercentageWithLength() const { return typeWithCalcResolved(
) == UnitType::CalcPercentageWithLength; } |
| 187 static bool isDotsPerInch(UnitType type) { return type == UnitType::DotsPerI
nch; } | 181 static bool isDotsPerInch(UnitType type) { return type == UnitType::DotsPerI
nch; } |
| 188 static bool isDotsPerPixel(UnitType type) { return type == UnitType::DotsPer
Pixel; } | 182 static bool isDotsPerPixel(UnitType type) { return type == UnitType::DotsPer
Pixel; } |
| 189 static bool isDotsPerCentimeter(UnitType type) { return type == UnitType::Do
tsPerCentimeter; } | 183 static bool isDotsPerCentimeter(UnitType type) { return type == UnitType::Do
tsPerCentimeter; } |
| 190 static bool isResolution(UnitType type) { return type >= UnitType::DotsPerPi
xel && type <= UnitType::DotsPerCentimeter; } | 184 static bool isResolution(UnitType type) { return type >= UnitType::DotsPerPi
xel && type <= UnitType::DotsPerCentimeter; } |
| 191 bool isFlex() const { return typeWithCalcResolved() == UnitType::Fraction; } | 185 bool isFlex() const { return typeWithCalcResolved() == UnitType::Fraction; } |
| 192 bool isValueID() const { return type() == UnitType::ValueID; } | 186 bool isValueID() const { return type() == UnitType::ValueID; } |
| 193 bool colorIsDerivedFromElement() const; | 187 bool colorIsDerivedFromElement() const; |
| 194 | 188 |
| 195 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createIdentifier(CSSValueID
valueID) | 189 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createIdentifier(CSSValueID
valueID) |
| 196 { | 190 { |
| 197 return adoptRefWillBeNoop(new CSSPrimitiveValue(valueID)); | 191 return adoptRefWillBeNoop(new CSSPrimitiveValue(valueID)); |
| 198 } | 192 } |
| 199 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createIdentifier(CSSPropert
yID propertyID) | 193 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createIdentifier(CSSPropert
yID propertyID) |
| 200 { | 194 { |
| 201 return adoptRefWillBeNoop(new CSSPrimitiveValue(propertyID)); | 195 return adoptRefWillBeNoop(new CSSPrimitiveValue(propertyID)); |
| 202 } | 196 } |
| 203 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createColor(RGBA32 rgbValue
) | 197 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createColor(RGBA32 rgbValue
) |
| 204 { | 198 { |
| 205 return adoptRefWillBeNoop(new CSSPrimitiveValue(rgbValue)); | 199 return adoptRefWillBeNoop(new CSSPrimitiveValue(rgbValue)); |
| 206 } | 200 } |
| 207 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(double value, UnitTy
pe type) | 201 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(double value, UnitTy
pe type) |
| 208 { | 202 { |
| 209 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, type)); | 203 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, type)); |
| 210 } | 204 } |
| 211 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const String& value,
UnitType type) | |
| 212 { | |
| 213 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, type)); | |
| 214 } | |
| 215 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value,
float zoom) | 205 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value,
float zoom) |
| 216 { | 206 { |
| 217 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, zoom)); | 207 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, zoom)); |
| 218 } | 208 } |
| 219 template<typename T> static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create
(T value) | 209 template<typename T> static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create
(T value) |
| 220 { | 210 { |
| 221 return adoptRefWillBeNoop(new CSSPrimitiveValue(value)); | 211 return adoptRefWillBeNoop(new CSSPrimitiveValue(value)); |
| 222 } | 212 } |
| 223 | 213 |
| 224 // This value is used to handle quirky margins in reflow roots (body, td, an
d th) like WinIE. | 214 // This value is used to handle quirky margins in reflow roots (body, td, an
d th) like WinIE. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 245 template<typename T> T computeLength(const CSSToLengthConversionData&); | 235 template<typename T> T computeLength(const CSSToLengthConversionData&); |
| 246 | 236 |
| 247 // Converts to a Length (Fixed, Percent or Calculated) | 237 // Converts to a Length (Fixed, Percent or Calculated) |
| 248 Length convertToLength(const CSSToLengthConversionData&); | 238 Length convertToLength(const CSSToLengthConversionData&); |
| 249 | 239 |
| 250 double getDoubleValue() const; | 240 double getDoubleValue() const; |
| 251 float getFloatValue() const { return getValue<float>(); } | 241 float getFloatValue() const { return getValue<float>(); } |
| 252 int getIntValue() const { return getValue<int>(); } | 242 int getIntValue() const { return getValue<int>(); } |
| 253 template<typename T> inline T getValue() const { return clampTo<T>(getDouble
Value()); } | 243 template<typename T> inline T getValue() const { return clampTo<T>(getDouble
Value()); } |
| 254 | 244 |
| 255 String getStringValue() const; | |
| 256 RGBA32 getRGBA32Value() const { ASSERT(isRGBColor()); return m_value.rgbcolo
r; } | 245 RGBA32 getRGBA32Value() const { ASSERT(isRGBColor()); return m_value.rgbcolo
r; } |
| 257 | 246 |
| 258 CSSBasicShape* getShapeValue() const { ASSERT(isShape()); return m_value.sha
pe; } | 247 CSSBasicShape* getShapeValue() const { ASSERT(isShape()); return m_value.sha
pe; } |
| 259 CSSCalcValue* cssCalcValue() const { ASSERT(isCalculated()); return m_value.
calc; } | 248 CSSCalcValue* cssCalcValue() const { ASSERT(isCalculated()); return m_value.
calc; } |
| 260 CSSPropertyID getPropertyID() const { ASSERT(isPropertyID()); return m_value
.propertyID; } | 249 CSSPropertyID getPropertyID() const { ASSERT(isPropertyID()); return m_value
.propertyID; } |
| 261 | 250 |
| 262 CSSValueID getValueID() const { return type() == UnitType::ValueID ? m_value
.valueID : CSSValueInvalid; } | 251 CSSValueID getValueID() const { return type() == UnitType::ValueID ? m_value
.valueID : CSSValueInvalid; } |
| 263 | 252 |
| 264 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa
lueMappings.h | 253 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa
lueMappings.h |
| 265 | 254 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 277 | 266 |
| 278 // Returns true and populates lengthUnitType, if unitType is a length unit.
Otherwise, returns false. | 267 // Returns true and populates lengthUnitType, if unitType is a length unit.
Otherwise, returns false. |
| 279 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); | 268 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); |
| 280 static UnitType lengthUnitTypeToUnitType(LengthUnitType); | 269 static UnitType lengthUnitTypeToUnitType(LengthUnitType); |
| 281 | 270 |
| 282 private: | 271 private: |
| 283 CSSPrimitiveValue(CSSValueID); | 272 CSSPrimitiveValue(CSSValueID); |
| 284 CSSPrimitiveValue(CSSPropertyID); | 273 CSSPrimitiveValue(CSSPropertyID); |
| 285 CSSPrimitiveValue(RGBA32 color); | 274 CSSPrimitiveValue(RGBA32 color); |
| 286 CSSPrimitiveValue(const Length&, float zoom); | 275 CSSPrimitiveValue(const Length&, float zoom); |
| 287 CSSPrimitiveValue(const String&, UnitType); | |
| 288 CSSPrimitiveValue(double, UnitType); | 276 CSSPrimitiveValue(double, UnitType); |
| 289 | 277 |
| 290 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa
ppings.h | 278 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa
ppings.h |
| 291 template<typename T> CSSPrimitiveValue(T* val) | 279 template<typename T> CSSPrimitiveValue(T* val) |
| 292 : CSSValue(PrimitiveClass) | 280 : CSSValue(PrimitiveClass) |
| 293 { | 281 { |
| 294 init(PassRefPtrWillBeRawPtr<T>(val)); | 282 init(PassRefPtrWillBeRawPtr<T>(val)); |
| 295 } | 283 } |
| 296 | 284 |
| 297 template<typename T> CSSPrimitiveValue(PassRefPtrWillBeRawPtr<T> val) | 285 template<typename T> CSSPrimitiveValue(PassRefPtrWillBeRawPtr<T> val) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 310 void init(PassRefPtrWillBeRawPtr<CSSCalcValue>); | 298 void init(PassRefPtrWillBeRawPtr<CSSCalcValue>); |
| 311 | 299 |
| 312 double computeLengthDouble(const CSSToLengthConversionData&); | 300 double computeLengthDouble(const CSSToLengthConversionData&); |
| 313 | 301 |
| 314 inline UnitType type() const { return static_cast<UnitType>(m_primitiveUnitT
ype); } | 302 inline UnitType type() const { return static_cast<UnitType>(m_primitiveUnitT
ype); } |
| 315 | 303 |
| 316 union { | 304 union { |
| 317 CSSPropertyID propertyID; | 305 CSSPropertyID propertyID; |
| 318 CSSValueID valueID; | 306 CSSValueID valueID; |
| 319 double num; | 307 double num; |
| 320 StringImpl* string; | |
| 321 RGBA32 rgbcolor; | 308 RGBA32 rgbcolor; |
| 322 // FIXME: oilpan: Should be members, but no support for members in union
s. Just trace the raw ptr for now. | 309 // FIXME: oilpan: Should be members, but no support for members in union
s. Just trace the raw ptr for now. |
| 323 CSSBasicShape* shape; | 310 CSSBasicShape* shape; |
| 324 CSSCalcValue* calc; | 311 CSSCalcValue* calc; |
| 325 } m_value; | 312 } m_value; |
| 326 }; | 313 }; |
| 327 | 314 |
| 328 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; | 315 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; |
| 329 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray; | 316 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray; |
| 330 | 317 |
| 331 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); | 318 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); |
| 332 | 319 |
| 333 } // namespace blink | 320 } // namespace blink |
| 334 | 321 |
| 335 #endif // CSSPrimitiveValue_h | 322 #endif // CSSPrimitiveValue_h |
| OLD | NEW |