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, |
| 14 CSSPrimitiveValue::UnitType unit) { |
| 15 DCHECK(CSSPrimitiveValue::isAngle(unit)); |
| 16 return new CSSAngleValue(value, unit); |
| 17 } |
| 18 |
13 CSSAngleValue* CSSAngleValue::create(double value, const String& unit) { | 19 CSSAngleValue* CSSAngleValue::create(double value, const String& unit) { |
14 CSSPrimitiveValue::UnitType primitiveUnit = | 20 CSSPrimitiveValue::UnitType primitiveUnit = |
15 CSSPrimitiveValue::stringToUnitType(unit); | 21 CSSPrimitiveValue::stringToUnitType(unit); |
16 DCHECK(CSSPrimitiveValue::isAngle(primitiveUnit)); | 22 return create(value, primitiveUnit); |
17 return new CSSAngleValue(value, primitiveUnit); | |
18 } | 23 } |
19 | 24 |
20 CSSAngleValue* CSSAngleValue::fromCSSValue(const CSSPrimitiveValue& value) { | 25 CSSAngleValue* CSSAngleValue::fromCSSValue(const CSSPrimitiveValue& value) { |
21 DCHECK(value.isAngle()); | 26 DCHECK(value.isAngle()); |
22 if (value.isCalculated()) | 27 if (value.isCalculated()) |
23 return nullptr; | 28 return nullptr; |
24 return new CSSAngleValue(value.getDoubleValue(), | 29 return new CSSAngleValue(value.getDoubleValue(), |
25 value.typeWithCalcResolved()); | 30 value.typeWithCalcResolved()); |
26 } | 31 } |
27 | 32 |
(...skipping 23 matching lines...) Expand all Loading... |
51 | 56 |
52 double CSSAngleValue::turns() const { | 57 double CSSAngleValue::turns() const { |
53 return deg2turn(degrees()); | 58 return deg2turn(degrees()); |
54 } | 59 } |
55 | 60 |
56 CSSValue* CSSAngleValue::toCSSValue() const { | 61 CSSValue* CSSAngleValue::toCSSValue() const { |
57 return CSSPrimitiveValue::create(m_value, m_unit); | 62 return CSSPrimitiveValue::create(m_value, m_unit); |
58 } | 63 } |
59 | 64 |
60 } // namespace blink | 65 } // namespace blink |
OLD | NEW |