| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 Integer, | 101 Integer, |
| 102 Rems, | 102 Rems, |
| 103 Chs, | 103 Chs, |
| 104 Shape, | 104 Shape, |
| 105 Calc, | 105 Calc, |
| 106 CalcPercentageWithNumber, | 106 CalcPercentageWithNumber, |
| 107 CalcPercentageWithLength, | 107 CalcPercentageWithLength, |
| 108 String, | 108 String, |
| 109 PropertyID, | 109 PropertyID, |
| 110 ValueID, | 110 ValueID, |
| 111 |
| 112 // This value is used to handle quirky margins in reflow roots (body, td
, and th) like WinIE. |
| 113 // The basic idea is that a stylesheet can use the value __qem (for quir
ky em) instead of em. |
| 114 // When the quirky value is used, if you're in quirks mode, the margin w
ill collapse away |
| 115 // inside a table cell. This quirk is specified in the HTML spec but our
impl is different. |
| 116 // TODO: Remove this. crbug.com/443952 |
| 111 QuirkyEms, | 117 QuirkyEms, |
| 112 }; | 118 }; |
| 113 | 119 |
| 114 enum LengthUnitType { | 120 enum LengthUnitType { |
| 115 UnitTypePixels = 0, | 121 UnitTypePixels = 0, |
| 116 UnitTypePercentage, | 122 UnitTypePercentage, |
| 117 UnitTypeFontSize, | 123 UnitTypeFontSize, |
| 118 UnitTypeFontXSize, | 124 UnitTypeFontXSize, |
| 119 UnitTypeRootFontSize, | 125 UnitTypeRootFontSize, |
| 120 UnitTypeZeroCharacterWidth, | 126 UnitTypeZeroCharacterWidth, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 bool isAngle() const | 159 bool isAngle() const |
| 154 { | 160 { |
| 155 return type() == UnitType::Degrees | 161 return type() == UnitType::Degrees |
| 156 || type() == UnitType::Radians | 162 || type() == UnitType::Radians |
| 157 || type() == UnitType::Gradians | 163 || type() == UnitType::Gradians |
| 158 || type() == UnitType::Turns; | 164 || type() == UnitType::Turns; |
| 159 } | 165 } |
| 160 bool isCustomIdent() const { return type() == UnitType::CustomIdentifier; } | 166 bool isCustomIdent() const { return type() == UnitType::CustomIdentifier; } |
| 161 bool isFontRelativeLength() const | 167 bool isFontRelativeLength() const |
| 162 { | 168 { |
| 163 return type() == UnitType::Ems | 169 return type() == UnitType::QuirkyEms |
| 170 || type() == UnitType::Ems |
| 164 || type() == UnitType::Exs | 171 || type() == UnitType::Exs |
| 165 || type() == UnitType::Rems | 172 || type() == UnitType::Rems |
| 166 || type() == UnitType::Chs; | 173 || type() == UnitType::Chs; |
| 167 } | 174 } |
| 175 bool isQuirkyEms() const { return type() == UnitType::QuirkyEms; } |
| 168 bool isViewportPercentageLength() const { return isViewportPercentageLength(
type()); } | 176 bool isViewportPercentageLength() const { return isViewportPercentageLength(
type()); } |
| 169 static bool isViewportPercentageLength(UnitType type) { return type >= UnitT
ype::ViewportWidth && type <= UnitType::ViewportMax; } | 177 static bool isViewportPercentageLength(UnitType type) { return type >= UnitT
ype::ViewportWidth && type <= UnitType::ViewportMax; } |
| 170 static bool isLength(UnitType type) | 178 static bool isLength(UnitType type) |
| 171 { | 179 { |
| 172 return (type >= UnitType::Ems && type <= UnitType::Picas) || type == Uni
tType::Rems || type == UnitType::Chs || isViewportPercentageLength(type); | 180 return (type >= UnitType::Ems && type <= UnitType::Picas) || type == Uni
tType::QuirkyEms || type == UnitType::Rems || type == UnitType::Chs || isViewpor
tPercentageLength(type); |
| 173 } | 181 } |
| 174 bool isLength() const { return isLength(typeWithCalcResolved()); } | 182 bool isLength() const { return isLength(typeWithCalcResolved()); } |
| 175 bool isNumber() const { return typeWithCalcResolved() == UnitType::Number ||
typeWithCalcResolved() == UnitType::Integer; } | 183 bool isNumber() const { return typeWithCalcResolved() == UnitType::Number ||
typeWithCalcResolved() == UnitType::Integer; } |
| 176 bool isPercentage() const { return typeWithCalcResolved() == UnitType::Perce
ntage; } | 184 bool isPercentage() const { return typeWithCalcResolved() == UnitType::Perce
ntage; } |
| 177 bool isPropertyID() const { return type() == UnitType::PropertyID; } | 185 bool isPropertyID() const { return type() == UnitType::PropertyID; } |
| 178 bool isPx() const { return typeWithCalcResolved() == UnitType::Pixels; } | 186 bool isPx() const { return typeWithCalcResolved() == UnitType::Pixels; } |
| 179 bool isRGBColor() const { return type() == UnitType::RGBColor; } | 187 bool isRGBColor() const { return type() == UnitType::RGBColor; } |
| 180 bool isShape() const { return type() == UnitType::Shape; } | 188 bool isShape() const { return type() == UnitType::Shape; } |
| 181 bool isString() const { return type() == UnitType::String; } | 189 bool isString() const { return type() == UnitType::String; } |
| 182 bool isTime() const { return type() == UnitType::Seconds || type() == UnitTy
pe::Milliseconds; } | 190 bool isTime() const { return type() == UnitType::Seconds || type() == UnitTy
pe::Milliseconds; } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 222 } |
| 215 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value,
float zoom) | 223 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value,
float zoom) |
| 216 { | 224 { |
| 217 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, zoom)); | 225 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, zoom)); |
| 218 } | 226 } |
| 219 template<typename T> static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create
(T value) | 227 template<typename T> static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create
(T value) |
| 220 { | 228 { |
| 221 return adoptRefWillBeNoop(new CSSPrimitiveValue(value)); | 229 return adoptRefWillBeNoop(new CSSPrimitiveValue(value)); |
| 222 } | 230 } |
| 223 | 231 |
| 224 // This value is used to handle quirky margins in reflow roots (body, td, an
d th) like WinIE. | |
| 225 // The basic idea is that a stylesheet can use the value __qem (for quirky e
m) instead of em. | |
| 226 // When the quirky value is used, if you're in quirks mode, the margin will
collapse away | |
| 227 // inside a table cell. | |
| 228 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createAllowingMarginQuirk(d
ouble value, UnitType type) | |
| 229 { | |
| 230 CSSPrimitiveValue* quirkValue = new CSSPrimitiveValue(value, type); | |
| 231 quirkValue->m_isQuirkValue = true; | |
| 232 return adoptRefWillBeNoop(quirkValue); | |
| 233 } | |
| 234 | |
| 235 ~CSSPrimitiveValue(); | 232 ~CSSPrimitiveValue(); |
| 236 | 233 |
| 237 void cleanup(); | 234 void cleanup(); |
| 238 | 235 |
| 239 UnitType typeWithCalcResolved() const; | 236 UnitType typeWithCalcResolved() const; |
| 240 | 237 |
| 241 double computeDegrees() const; | 238 double computeDegrees() const; |
| 242 double computeSeconds() const; | 239 double computeSeconds() const; |
| 243 | 240 |
| 244 // Computes a length in pixels, resolving relative lengths | 241 // Computes a length in pixels, resolving relative lengths |
| (...skipping 14 matching lines...) Expand all Loading... |
| 259 CSSCalcValue* cssCalcValue() const { ASSERT(isCalculated()); return m_value.
calc; } | 256 CSSCalcValue* cssCalcValue() const { ASSERT(isCalculated()); return m_value.
calc; } |
| 260 CSSPropertyID getPropertyID() const { ASSERT(isPropertyID()); return m_value
.propertyID; } | 257 CSSPropertyID getPropertyID() const { ASSERT(isPropertyID()); return m_value
.propertyID; } |
| 261 | 258 |
| 262 CSSValueID getValueID() const { return type() == UnitType::ValueID ? m_value
.valueID : CSSValueInvalid; } | 259 CSSValueID getValueID() const { return type() == UnitType::ValueID ? m_value
.valueID : CSSValueInvalid; } |
| 263 | 260 |
| 264 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa
lueMappings.h | 261 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa
lueMappings.h |
| 265 | 262 |
| 266 static const char* unitTypeToString(UnitType); | 263 static const char* unitTypeToString(UnitType); |
| 267 String customCSSText() const; | 264 String customCSSText() const; |
| 268 | 265 |
| 269 bool isQuirkValue() const { return m_isQuirkValue; } | |
| 270 | |
| 271 bool equals(const CSSPrimitiveValue&) const; | 266 bool equals(const CSSPrimitiveValue&) const; |
| 272 | 267 |
| 273 DECLARE_TRACE_AFTER_DISPATCH(); | 268 DECLARE_TRACE_AFTER_DISPATCH(); |
| 274 | 269 |
| 275 static UnitType canonicalUnitTypeForCategory(UnitCategory); | 270 static UnitType canonicalUnitTypeForCategory(UnitCategory); |
| 276 static double conversionToCanonicalUnitsScaleFactor(UnitType); | 271 static double conversionToCanonicalUnitsScaleFactor(UnitType); |
| 277 | 272 |
| 278 // Returns true and populates lengthUnitType, if unitType is a length unit.
Otherwise, returns false. | 273 // Returns true and populates lengthUnitType, if unitType is a length unit.
Otherwise, returns false. |
| 279 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); | 274 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); |
| 280 static UnitType lengthUnitTypeToUnitType(LengthUnitType); | 275 static UnitType lengthUnitTypeToUnitType(LengthUnitType); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 }; | 321 }; |
| 327 | 322 |
| 328 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; | 323 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; |
| 329 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray; | 324 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray; |
| 330 | 325 |
| 331 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); | 326 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); |
| 332 | 327 |
| 333 } // namespace blink | 328 } // namespace blink |
| 334 | 329 |
| 335 #endif // CSSPrimitiveValue_h | 330 #endif // CSSPrimitiveValue_h |
| OLD | NEW |