| 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" | |
| 10 #include "wtf/MathExtras.h" | 9 #include "wtf/MathExtras.h" |
| 11 | 10 |
| 12 namespace blink { | 11 namespace blink { |
| 13 | 12 |
| 14 CSSAngleValue* CSSAngleValue::create(double value, const String& unit, Exception
State& exceptionState) | 13 CSSAngleValue* CSSAngleValue::create(double value, const String& unit, Exception
State& exceptionState) |
| 15 { | 14 { |
| 16 CSSPrimitiveValue::UnitType primitiveUnit; | 15 CSSPrimitiveValue::UnitType primitiveUnit = CSSPrimitiveValue::stringToUnitT
ype(unit); |
| 17 if (unit.is8Bit()) | |
| 18 primitiveUnit = lookupCSSPrimitiveValueUnit(unit.characters8(), unit.len
gth()); | |
| 19 else | |
| 20 primitiveUnit = lookupCSSPrimitiveValueUnit(unit.characters16(), unit.le
ngth()); | |
| 21 DCHECK(CSSPrimitiveValue::isAngle(primitiveUnit)); | 16 DCHECK(CSSPrimitiveValue::isAngle(primitiveUnit)); |
| 22 return new CSSAngleValue(value, primitiveUnit); | 17 return new CSSAngleValue(value, primitiveUnit); |
| 23 } | 18 } |
| 24 | 19 |
| 25 double CSSAngleValue::degrees() const | 20 double CSSAngleValue::degrees() const |
| 26 { | 21 { |
| 27 switch (m_unit) { | 22 switch (m_unit) { |
| 28 case CSSPrimitiveValue::UnitType::Degrees: | 23 case CSSPrimitiveValue::UnitType::Degrees: |
| 29 return m_value; | 24 return m_value; |
| 30 case CSSPrimitiveValue::UnitType::Radians: | 25 case CSSPrimitiveValue::UnitType::Radians: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 53 { | 48 { |
| 54 return deg2turn(degrees()); | 49 return deg2turn(degrees()); |
| 55 } | 50 } |
| 56 | 51 |
| 57 CSSValue* CSSAngleValue::toCSSValue() const | 52 CSSValue* CSSAngleValue::toCSSValue() const |
| 58 { | 53 { |
| 59 return CSSPrimitiveValue::create(m_value, m_unit); | 54 return CSSPrimitiveValue::create(m_value, m_unit); |
| 60 } | 55 } |
| 61 | 56 |
| 62 } // namespace blink | 57 } // namespace blink |
| OLD | NEW |