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/CSSRotation.h" | 5 #include "core/css/cssom/CSSRotation.h" |
6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" |
7 #include "core/css/CSSFunctionValue.h" | 8 #include "core/css/CSSFunctionValue.h" |
8 #include "core/css/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
9 | 10 |
10 namespace blink { | 11 namespace blink { |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 bool IsNumberValue(const CSSValue& value) { | 15 bool IsNumberValue(const CSSValue& value) { |
15 return value.IsPrimitiveValue() && ToCSSPrimitiveValue(value).IsNumber(); | 16 return value.IsPrimitiveValue() && ToCSSPrimitiveValue(value).IsNumber(); |
16 } | 17 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 case CSSValueRotateZ: | 54 case CSSValueRotateZ: |
54 return CSSRotation::Create(0, 0, 1, angle); | 55 return CSSRotation::Create(0, 0, 1, angle); |
55 default: | 56 default: |
56 NOTREACHED(); | 57 NOTREACHED(); |
57 return nullptr; | 58 return nullptr; |
58 } | 59 } |
59 } | 60 } |
60 | 61 |
61 } // namespace | 62 } // namespace |
62 | 63 |
| 64 CSSRotation* CSSRotation::Create(double x, |
| 65 double y, |
| 66 double z, |
| 67 CSSNumericValue* angle, |
| 68 ExceptionState& exception_state) { |
| 69 if (angle->GetType() != CSSStyleValue::StyleValueType::kAngleType) { |
| 70 exception_state.ThrowTypeError("Must pass an angle to CSSRotation"); |
| 71 return nullptr; |
| 72 } |
| 73 return new CSSRotation(x, y, z, angle); |
| 74 } |
| 75 |
| 76 CSSRotation* CSSRotation::Create(double x, |
| 77 double y, |
| 78 double z, |
| 79 CSSNumericValue* angle) { |
| 80 DCHECK_EQ(angle->GetType(), CSSStyleValue::StyleValueType::kAngleType); |
| 81 return new CSSRotation(x, y, z, angle); |
| 82 } |
| 83 |
63 CSSRotation* CSSRotation::FromCSSValue(const CSSFunctionValue& value) { | 84 CSSRotation* CSSRotation::FromCSSValue(const CSSFunctionValue& value) { |
64 switch (value.FunctionType()) { | 85 switch (value.FunctionType()) { |
65 case CSSValueRotate: | 86 case CSSValueRotate: |
66 return FromCSSRotate(value); | 87 return FromCSSRotate(value); |
67 case CSSValueRotate3d: | 88 case CSSValueRotate3d: |
68 return FromCSSRotate3d(value); | 89 return FromCSSRotate3d(value); |
69 case CSSValueRotateX: | 90 case CSSValueRotateX: |
70 case CSSValueRotateY: | 91 case CSSValueRotateY: |
71 case CSSValueRotateZ: | 92 case CSSValueRotateZ: |
72 return FromCSSRotateXYZ(value); | 93 return FromCSSRotateXYZ(value); |
(...skipping 16 matching lines...) Expand all Loading... |
89 // *CSSPrimitiveValue::Create(y_, CSSPrimitiveValue::UnitType::kNumber)); | 110 // *CSSPrimitiveValue::Create(y_, CSSPrimitiveValue::UnitType::kNumber)); |
90 // result->Append( | 111 // result->Append( |
91 // *CSSPrimitiveValue::Create(z_, CSSPrimitiveValue::UnitType::kNumber)); | 112 // *CSSPrimitiveValue::Create(z_, CSSPrimitiveValue::UnitType::kNumber)); |
92 // } | 113 // } |
93 // result->Append(*CSSPrimitiveValue::Create(angle_->Value(), | 114 // result->Append(*CSSPrimitiveValue::Create(angle_->Value(), |
94 // angle_->Unit())); | 115 // angle_->Unit())); |
95 // return result; | 116 // return result; |
96 } | 117 } |
97 | 118 |
98 } // namespace blink | 119 } // namespace blink |
OLD | NEW |