| 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 "wtf/MathExtras.h" | 9 #include "wtf/MathExtras.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 CSSAngleValue* CSSAngleValue::create(double value, | 13 CSSAngleValue* CSSAngleValue::create(double value, const String& unit) { |
| 14 const String& unit, | |
| 15 ExceptionState& exceptionState) { | |
| 16 CSSPrimitiveValue::UnitType primitiveUnit = | 14 CSSPrimitiveValue::UnitType primitiveUnit = |
| 17 CSSPrimitiveValue::stringToUnitType(unit); | 15 CSSPrimitiveValue::stringToUnitType(unit); |
| 18 DCHECK(CSSPrimitiveValue::isAngle(primitiveUnit)); | 16 DCHECK(CSSPrimitiveValue::isAngle(primitiveUnit)); |
| 19 return new CSSAngleValue(value, primitiveUnit); | 17 return new CSSAngleValue(value, primitiveUnit); |
| 20 } | 18 } |
| 21 | 19 |
| 22 double CSSAngleValue::degrees() const { | 20 double CSSAngleValue::degrees() const { |
| 23 switch (m_unit) { | 21 switch (m_unit) { |
| 24 case CSSPrimitiveValue::UnitType::Degrees: | 22 case CSSPrimitiveValue::UnitType::Degrees: |
| 25 return m_value; | 23 return m_value; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 45 | 43 |
| 46 double CSSAngleValue::turns() const { | 44 double CSSAngleValue::turns() const { |
| 47 return deg2turn(degrees()); | 45 return deg2turn(degrees()); |
| 48 } | 46 } |
| 49 | 47 |
| 50 CSSValue* CSSAngleValue::toCSSValue() const { | 48 CSSValue* CSSAngleValue::toCSSValue() const { |
| 51 return CSSPrimitiveValue::create(m_value, m_unit); | 49 return CSSPrimitiveValue::create(m_value, m_unit); |
| 52 } | 50 } |
| 53 | 51 |
| 54 } // namespace blink | 52 } // namespace blink |
| OLD | NEW |