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 "bindings/core/v8/ExceptionState.h" |
8 #include "core/css/CSSFunctionValue.h" | 8 #include "core/css/CSSFunctionValue.h" |
9 #include "core/css/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 case CSSValueRotateZ: | 54 case CSSValueRotateZ: |
55 return CSSRotation::Create(0, 0, 1, angle); | 55 return CSSRotation::Create(0, 0, 1, angle); |
56 default: | 56 default: |
57 NOTREACHED(); | 57 NOTREACHED(); |
58 return nullptr; | 58 return nullptr; |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 } // namespace | 62 } // namespace |
63 | 63 |
| 64 CSSRotation* CSSRotation::Create(CSSNumericValue* angle, |
| 65 ExceptionState& exception_state) { |
| 66 if (angle->GetType() != CSSStyleValue::StyleValueType::kAngleType) { |
| 67 exception_state.ThrowTypeError("Must pass an angle to CSSRotation"); |
| 68 return nullptr; |
| 69 } |
| 70 return new CSSRotation(0, 0, 1, angle, true /* is2D */); |
| 71 } |
| 72 |
64 CSSRotation* CSSRotation::Create(double x, | 73 CSSRotation* CSSRotation::Create(double x, |
65 double y, | 74 double y, |
66 double z, | 75 double z, |
67 CSSNumericValue* angle, | 76 CSSNumericValue* angle, |
68 ExceptionState& exception_state) { | 77 ExceptionState& exception_state) { |
69 if (angle->GetType() != CSSStyleValue::StyleValueType::kAngleType) { | 78 if (angle->GetType() != CSSStyleValue::StyleValueType::kAngleType) { |
70 exception_state.ThrowTypeError("Must pass an angle to CSSRotation"); | 79 exception_state.ThrowTypeError("Must pass an angle to CSSRotation"); |
71 return nullptr; | 80 return nullptr; |
72 } | 81 } |
73 return new CSSRotation(x, y, z, angle); | 82 return new CSSRotation(x, y, z, angle, false /* is2D */); |
| 83 } |
| 84 |
| 85 CSSRotation* CSSRotation::Create(CSSNumericValue* angle) { |
| 86 DCHECK_EQ(angle->GetType(), CSSStyleValue::StyleValueType::kAngleType); |
| 87 return new CSSRotation(0, 0, 1, angle, true /* is2D */); |
74 } | 88 } |
75 | 89 |
76 CSSRotation* CSSRotation::Create(double x, | 90 CSSRotation* CSSRotation::Create(double x, |
77 double y, | 91 double y, |
78 double z, | 92 double z, |
79 CSSNumericValue* angle) { | 93 CSSNumericValue* angle) { |
80 DCHECK_EQ(angle->GetType(), CSSStyleValue::StyleValueType::kAngleType); | 94 DCHECK_EQ(angle->GetType(), CSSStyleValue::StyleValueType::kAngleType); |
81 return new CSSRotation(x, y, z, angle); | 95 return new CSSRotation(x, y, z, angle, false /* is2D */); |
82 } | 96 } |
83 | 97 |
84 CSSRotation* CSSRotation::FromCSSValue(const CSSFunctionValue& value) { | 98 CSSRotation* CSSRotation::FromCSSValue(const CSSFunctionValue& value) { |
85 switch (value.FunctionType()) { | 99 switch (value.FunctionType()) { |
86 case CSSValueRotate: | 100 case CSSValueRotate: |
87 return FromCSSRotate(value); | 101 return FromCSSRotate(value); |
88 case CSSValueRotate3d: | 102 case CSSValueRotate3d: |
89 return FromCSSRotate3d(value); | 103 return FromCSSRotate3d(value); |
90 case CSSValueRotateX: | 104 case CSSValueRotateX: |
91 case CSSValueRotateY: | 105 case CSSValueRotateY: |
(...skipping 16 matching lines...) Expand all Loading... |
108 return; | 122 return; |
109 } | 123 } |
110 angle_ = angle; | 124 angle_ = angle; |
111 } | 125 } |
112 | 126 |
113 CSSFunctionValue* CSSRotation::ToCSSValue() const { | 127 CSSFunctionValue* CSSRotation::ToCSSValue() const { |
114 return nullptr; | 128 return nullptr; |
115 // TODO(meade): Re-implement this when we finish rewriting number/length | 129 // TODO(meade): Re-implement this when we finish rewriting number/length |
116 // types. | 130 // types. |
117 // CSSFunctionValue* result = | 131 // CSSFunctionValue* result = |
118 // CSSFunctionValue::Create(is2d_ ? CSSValueRotate : CSSValueRotate3d); | 132 // CSSFunctionValue::Create(is2D() ? CSSValueRotate : CSSValueRotate3d); |
119 // if (!is2d_) { | 133 // if (!is2D()) { |
120 // result->Append( | 134 // result->Append( |
121 // *CSSPrimitiveValue::Create(x_, CSSPrimitiveValue::UnitType::kNumber)); | 135 // *CSSPrimitiveValue::Create(x_, CSSPrimitiveValue::UnitType::kNumber)); |
122 // result->Append( | 136 // result->Append( |
123 // *CSSPrimitiveValue::Create(y_, CSSPrimitiveValue::UnitType::kNumber)); | 137 // *CSSPrimitiveValue::Create(y_, CSSPrimitiveValue::UnitType::kNumber)); |
124 // result->Append( | 138 // result->Append( |
125 // *CSSPrimitiveValue::Create(z_, CSSPrimitiveValue::UnitType::kNumber)); | 139 // *CSSPrimitiveValue::Create(z_, CSSPrimitiveValue::UnitType::kNumber)); |
126 // } | 140 // } |
127 // result->Append(*CSSPrimitiveValue::Create(angle_->Value(), | 141 // result->Append(*CSSPrimitiveValue::Create(angle_->Value(), |
128 // angle_->Unit())); | 142 // angle_->Unit())); |
129 // return result; | 143 // return result; |
130 } | 144 } |
131 | 145 |
132 } // namespace blink | 146 } // namespace blink |
OLD | NEW |