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/CSSSkew.h" | 5 #include "core/css/cssom/CSSSkew.h" |
6 | 6 |
7 #include "core/css/CSSFunctionValue.h" | 7 #include "core/css/CSSFunctionValue.h" |
8 #include "core/css/CSSPrimitiveValue.h" | 8 #include "core/css/CSSPrimitiveValue.h" |
9 #include "core/css/cssom/CSSAngleValue.h" | |
9 | 10 |
10 namespace blink { | 11 namespace blink { |
11 | 12 |
13 CSSSkew* CSSSkew::fromCSSValue(const CSSFunctionValue& value) { | |
14 const CSSPrimitiveValue& xValue = toCSSPrimitiveValue(value.item(0)); | |
15 if (xValue.isCalculated()) { | |
Timothy Loh
2016/11/29 03:49:37
Maybe add a TODO to handle this and the below calc
meade_UTC10
2016/11/29 05:18:03
Done.
| |
16 return nullptr; | |
17 } | |
18 DCHECK(xValue.isAngle()); | |
19 switch (value.functionType()) { | |
20 case CSSValueSkew: | |
21 if (value.length() == 2U) { | |
22 const CSSPrimitiveValue& yValue = toCSSPrimitiveValue(value.item(1)); | |
23 if (yValue.isCalculated()) { | |
24 return nullptr; | |
25 } | |
26 DCHECK(yValue.isAngle()); | |
27 return CSSSkew::create( | |
28 CSSAngleValue::create(xValue.getDoubleValue(), | |
29 xValue.typeWithCalcResolved()), | |
30 CSSAngleValue::create(yValue.getDoubleValue(), | |
31 yValue.typeWithCalcResolved())); | |
32 } | |
33 // Else fall through; skew(ax) == skewX(ax). | |
34 case CSSValueSkewX: | |
35 DCHECK_EQ(value.length(), 1U); | |
36 return CSSSkew::create( | |
37 CSSAngleValue::create(xValue.getDoubleValue(), | |
38 xValue.typeWithCalcResolved()), | |
39 CSSAngleValue::create(0, CSSPrimitiveValue::UnitType::Degrees)); | |
40 case CSSValueSkewY: | |
41 DCHECK_EQ(value.length(), 1U); | |
42 return CSSSkew::create( | |
43 CSSAngleValue::create(0, CSSPrimitiveValue::UnitType::Degrees), | |
44 CSSAngleValue::create(xValue.getDoubleValue(), | |
45 xValue.typeWithCalcResolved())); | |
46 default: | |
47 NOTREACHED(); | |
48 return nullptr; | |
49 } | |
50 } | |
51 | |
12 CSSFunctionValue* CSSSkew::toCSSValue() const { | 52 CSSFunctionValue* CSSSkew::toCSSValue() const { |
13 CSSFunctionValue* result = CSSFunctionValue::create(CSSValueSkew); | 53 CSSFunctionValue* result = CSSFunctionValue::create(CSSValueSkew); |
14 result->append(*CSSPrimitiveValue::create( | 54 result->append(*CSSPrimitiveValue::create(m_ax->value(), m_ax->unit())); |
15 m_ax->degrees(), CSSPrimitiveValue::UnitType::Number)); | 55 result->append(*CSSPrimitiveValue::create(m_ay->value(), m_ay->unit())); |
16 result->append(*CSSPrimitiveValue::create( | |
17 m_ay->degrees(), CSSPrimitiveValue::UnitType::Number)); | |
18 return result; | 56 return result; |
19 } | 57 } |
20 | 58 |
21 } // namespace blink | 59 } // namespace blink |
OLD | NEW |