| 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/CSSTranslation.h" | 5 #include "core/css/cssom/CSSTranslation.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 "core/css/cssom/CSSNumericValue.h" |
| 9 | 10 |
| 10 namespace blink { | 11 namespace blink { |
| 11 | 12 |
| 12 CSSTranslation* CSSTranslation::Create(CSSLengthValue* x, | 13 CSSTranslation* CSSTranslation::Create(CSSNumericValue* x, |
| 13 CSSLengthValue* y, | 14 CSSNumericValue* y, |
| 14 CSSLengthValue* z, | 15 CSSNumericValue* z, |
| 15 ExceptionState& exception_state) { | 16 ExceptionState& exception_state) { |
| 16 if (z->ContainsPercent()) { | 17 if (z->ContainsPercent()) { |
| 17 exception_state.ThrowTypeError( | 18 exception_state.ThrowTypeError( |
| 18 "CSSTranslation does not support z CSSLengthValue with percent units"); | 19 "CSSTranslation does not support z CSSNumericValue with percent units"); |
| 19 return nullptr; | 20 return nullptr; |
| 20 } | 21 } |
| 21 return new CSSTranslation(x, y, z); | 22 return new CSSTranslation(x, y, z); |
| 22 } | 23 } |
| 23 | 24 |
| 24 CSSFunctionValue* CSSTranslation::ToCSSValue() const { | 25 CSSFunctionValue* CSSTranslation::ToCSSValue() const { |
| 25 CSSFunctionValue* result = CSSFunctionValue::Create( | 26 CSSFunctionValue* result = CSSFunctionValue::Create( |
| 26 Is2D() ? CSSValueTranslate : CSSValueTranslate3d); | 27 Is2D() ? CSSValueTranslate : CSSValueTranslate3d); |
| 27 result->Append(*x_->ToCSSValue()); | 28 result->Append(*x_->ToCSSValue()); |
| 28 result->Append(*y_->ToCSSValue()); | 29 result->Append(*y_->ToCSSValue()); |
| 29 if (!Is2D()) | 30 if (!Is2D()) |
| 30 result->Append(*z_->ToCSSValue()); | 31 result->Append(*z_->ToCSSValue()); |
| 31 return result; | 32 return result; |
| 32 } | 33 } |
| 33 | 34 |
| 34 } // namespace blink | 35 } // namespace blink |
| OLD | NEW |