Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp

Issue 2514043002: [CSS Typed OM] Add CSSValue->CSSSkew conversions (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSSkew.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSSkew.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698