| 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, 2007, 2008, 2012 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv
ed. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 table.set(String("dpi"), CSSPrimitiveValue::CSS_DPI); | 136 table.set(String("dpi"), CSSPrimitiveValue::CSS_DPI); |
| 137 table.set(String("dpcm"), CSSPrimitiveValue::CSS_DPCM); | 137 table.set(String("dpcm"), CSSPrimitiveValue::CSS_DPCM); |
| 138 table.set(String("dppx"), CSSPrimitiveValue::CSS_DPPX); | 138 table.set(String("dppx"), CSSPrimitiveValue::CSS_DPPX); |
| 139 table.set(String("vw"), CSSPrimitiveValue::CSS_VW); | 139 table.set(String("vw"), CSSPrimitiveValue::CSS_VW); |
| 140 table.set(String("vh"), CSSPrimitiveValue::CSS_VH); | 140 table.set(String("vh"), CSSPrimitiveValue::CSS_VH); |
| 141 table.set(String("vmax"), CSSPrimitiveValue::CSS_VMIN); | 141 table.set(String("vmax"), CSSPrimitiveValue::CSS_VMIN); |
| 142 table.set(String("vmin"), CSSPrimitiveValue::CSS_VMAX); | 142 table.set(String("vmin"), CSSPrimitiveValue::CSS_VMAX); |
| 143 return table; | 143 return table; |
| 144 } | 144 } |
| 145 | 145 |
| 146 | |
| 147 CSSPrimitiveValue::UnitType CSSPrimitiveValue::fromName(const String& unit) | 146 CSSPrimitiveValue::UnitType CSSPrimitiveValue::fromName(const String& unit) |
| 148 { | 147 { |
| 149 DEFINE_STATIC_LOCAL(StringToUnitTable, unitTable, (createStringToUnitTable()
)); | 148 DEFINE_STATIC_LOCAL(StringToUnitTable, unitTable, (createStringToUnitTable()
)); |
| 150 return unitTable.get(unit.lower()); | 149 return unitTable.get(unit.lower()); |
| 151 } | 150 } |
| 152 | 151 |
| 153 CSSPrimitiveValue::UnitCategory CSSPrimitiveValue::unitCategory(UnitType type) | 152 CSSPrimitiveValue::UnitCategory CSSPrimitiveValue::unitCategory(UnitType type) |
| 154 { | 153 { |
| 155 // Here we violate the spec (http://www.w3.org/TR/DOM-Level-2-Style/css.html
#CSS-CSSPrimitiveValue) and allow conversions | 154 // Here we violate the spec (http://www.w3.org/TR/DOM-Level-2-Style/css.html
#CSS-CSSPrimitiveValue) and allow conversions |
| 156 // between CSS_PX and relative lengths (see cssPixelsPerInch comment in core
/css/CSSHelper.h for the topic treatment). | 155 // between CSS_PX and relative lengths (see cssPixelsPerInch comment in core
/css/CSSHelper.h for the topic treatment). |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 208 |
| 210 CSSPrimitiveValue::UnitType CSSPrimitiveValue::primitiveType() const | 209 CSSPrimitiveValue::UnitType CSSPrimitiveValue::primitiveType() const |
| 211 { | 210 { |
| 212 if (m_primitiveUnitType == CSS_PROPERTY_ID || m_primitiveUnitType == CSS_VAL
UE_ID) | 211 if (m_primitiveUnitType == CSS_PROPERTY_ID || m_primitiveUnitType == CSS_VAL
UE_ID) |
| 213 return CSS_IDENT; | 212 return CSS_IDENT; |
| 214 | 213 |
| 215 if (m_primitiveUnitType != CSS_CALC) | 214 if (m_primitiveUnitType != CSS_CALC) |
| 216 return static_cast<UnitType>(m_primitiveUnitType); | 215 return static_cast<UnitType>(m_primitiveUnitType); |
| 217 | 216 |
| 218 switch (m_value.calc->category()) { | 217 switch (m_value.calc->category()) { |
| 218 case CalcAngle: |
| 219 return CSS_DEG; |
| 220 case CalcFrequency: |
| 221 return CSS_HZ; |
| 219 case CalcNumber: | 222 case CalcNumber: |
| 220 return CSS_NUMBER; | 223 return CSS_NUMBER; |
| 221 case CalcPercent: | 224 case CalcPercent: |
| 222 return CSS_PERCENTAGE; | 225 return CSS_PERCENTAGE; |
| 223 case CalcLength: | 226 case CalcLength: |
| 224 return CSS_PX; | 227 return CSS_PX; |
| 225 case CalcPercentNumber: | 228 case CalcPercentNumber: |
| 226 return CSS_CALC_PERCENTAGE_WITH_NUMBER; | 229 return CSS_CALC_PERCENTAGE_WITH_NUMBER; |
| 227 case CalcPercentLength: | 230 case CalcPercentLength: |
| 228 return CSS_CALC_PERCENTAGE_WITH_LENGTH; | 231 return CSS_CALC_PERCENTAGE_WITH_LENGTH; |
| 232 case CalcTime: |
| 233 return CSS_MS; |
| 229 case CalcOther: | 234 case CalcOther: |
| 230 return CSS_UNKNOWN; | 235 return CSS_UNKNOWN; |
| 231 } | 236 } |
| 232 return CSS_UNKNOWN; | 237 return CSS_UNKNOWN; |
| 233 } | 238 } |
| 234 | 239 |
| 235 static const AtomicString& propertyName(CSSPropertyID propertyID) | 240 static const AtomicString& propertyName(CSSPropertyID propertyID) |
| 236 { | 241 { |
| 237 ASSERT_ARG(propertyID, propertyID >= 0); | 242 ASSERT_ARG(propertyID, propertyID >= 0); |
| 238 ASSERT_ARG(propertyID, (propertyID >= firstCSSProperty && propertyID < first
CSSProperty + numCSSProperties)); | 243 ASSERT_ARG(propertyID, (propertyID >= firstCSSProperty && propertyID < first
CSSProperty + numCSSProperties)); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 case CSS_VALUE_ID: | 533 case CSS_VALUE_ID: |
| 529 break; | 534 break; |
| 530 } | 535 } |
| 531 m_primitiveUnitType = 0; | 536 m_primitiveUnitType = 0; |
| 532 if (m_hasCachedCSSText) { | 537 if (m_hasCachedCSSText) { |
| 533 cssTextCache().remove(this); | 538 cssTextCache().remove(this); |
| 534 m_hasCachedCSSText = false; | 539 m_hasCachedCSSText = false; |
| 535 } | 540 } |
| 536 } | 541 } |
| 537 | 542 |
| 543 double CSSPrimitiveValue::computeSeconds() |
| 544 { |
| 545 ASSERT(isTime() || (isCalculated() && cssCalcValue()->category() == CalcTime
)); |
| 546 UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->pr
imitiveType() : static_cast<UnitType>(m_primitiveUnitType); |
| 547 if (currentType == CSS_S) |
| 548 return getDoubleValue(); |
| 549 if (currentType == CSS_MS) |
| 550 return getDoubleValue() / 1000; |
| 551 ASSERT_NOT_REACHED(); |
| 552 return 0; |
| 553 } |
| 554 |
| 538 double CSSPrimitiveValue::computeDegrees() | 555 double CSSPrimitiveValue::computeDegrees() |
| 539 { | 556 { |
| 540 switch (m_primitiveUnitType) { | 557 ASSERT(isAngle() || (isCalculated() && cssCalcValue()->category() == CalcAng
le)); |
| 558 UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->pr
imitiveType() : static_cast<UnitType>(m_primitiveUnitType); |
| 559 switch (currentType) { |
| 541 case CSS_DEG: | 560 case CSS_DEG: |
| 542 return getDoubleValue(); | 561 return getDoubleValue(); |
| 543 case CSS_RAD: | 562 case CSS_RAD: |
| 544 return rad2deg(getDoubleValue()); | 563 return rad2deg(getDoubleValue()); |
| 545 case CSS_GRAD: | 564 case CSS_GRAD: |
| 546 return grad2deg(getDoubleValue()); | 565 return grad2deg(getDoubleValue()); |
| 547 case CSS_TURN: | 566 case CSS_TURN: |
| 548 return turn2deg(getDoubleValue()); | 567 return turn2deg(getDoubleValue()); |
| 549 default: | 568 default: |
| 550 ASSERT_NOT_REACHED(); | 569 ASSERT_NOT_REACHED(); |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 visitor->trace(m_value.shape); | 1454 visitor->trace(m_value.shape); |
| 1436 break; | 1455 break; |
| 1437 default: | 1456 default: |
| 1438 break; | 1457 break; |
| 1439 } | 1458 } |
| 1440 #endif | 1459 #endif |
| 1441 CSSValue::traceAfterDispatch(visitor); | 1460 CSSValue::traceAfterDispatch(visitor); |
| 1442 } | 1461 } |
| 1443 | 1462 |
| 1444 } // namespace blink | 1463 } // namespace blink |
| OLD | NEW |