| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/cssom/CSSAngleValue.h" | 5 #include "core/css/cssom/CSSAngleValue.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "core/css/CSSPrimitiveValue.h" | 8 #include "core/css/CSSPrimitiveValue.h" |
| 9 #include "core/css/CSSPrimitiveValueUnitTrie.h" |
| 9 #include "wtf/MathExtras.h" | 10 #include "wtf/MathExtras.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 13 CSSAngleValue* CSSAngleValue::create(double value, const String& unit, Exception
State& exceptionState) | 14 CSSAngleValue* CSSAngleValue::create(double value, const String& unit, Exception
State& exceptionState) |
| 14 { | 15 { |
| 15 CSSPrimitiveValue::UnitType primitiveUnit = CSSPrimitiveValue::fromName(unit
); | 16 CSSPrimitiveValue::UnitType primitiveUnit; |
| 17 if (unit.is8Bit()) |
| 18 primitiveUnit = lookupCSSPrimitiveValueUnit(unit.characters8(), unit.len
gth()); |
| 19 else |
| 20 primitiveUnit = lookupCSSPrimitiveValueUnit(unit.characters16(), unit.le
ngth()); |
| 16 DCHECK(CSSPrimitiveValue::isAngle(primitiveUnit)); | 21 DCHECK(CSSPrimitiveValue::isAngle(primitiveUnit)); |
| 17 return new CSSAngleValue(value, primitiveUnit); | 22 return new CSSAngleValue(value, primitiveUnit); |
| 18 } | 23 } |
| 19 | 24 |
| 20 double CSSAngleValue::degrees() const | 25 double CSSAngleValue::degrees() const |
| 21 { | 26 { |
| 22 switch (m_unit) { | 27 switch (m_unit) { |
| 23 case CSSPrimitiveValue::UnitType::Degrees: | 28 case CSSPrimitiveValue::UnitType::Degrees: |
| 24 return m_value; | 29 return m_value; |
| 25 case CSSPrimitiveValue::UnitType::Radians: | 30 case CSSPrimitiveValue::UnitType::Radians: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 48 { | 53 { |
| 49 return deg2turn(degrees()); | 54 return deg2turn(degrees()); |
| 50 } | 55 } |
| 51 | 56 |
| 52 CSSValue* CSSAngleValue::toCSSValue() const | 57 CSSValue* CSSAngleValue::toCSSValue() const |
| 53 { | 58 { |
| 54 return cssValuePool().createValue(m_value, m_unit); | 59 return cssValuePool().createValue(m_value, m_unit); |
| 55 } | 60 } |
| 56 | 61 |
| 57 } // namespace blink | 62 } // namespace blink |
| OLD | NEW |