| 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/CSSPerspective.h" | 5 #include "core/css/cssom/CSSPerspective.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 CSSPerspective* CSSPerspective::Create(const CSSNumericValue* length, | 11 CSSPerspective* CSSPerspective::Create(const CSSNumericValue* length, |
| 12 ExceptionState& exception_state) { | 12 ExceptionState& exception_state) { |
| 13 if (length->ContainsPercent()) { | 13 if (length->ContainsPercent()) { |
| 14 exception_state.ThrowTypeError( | 14 exception_state.ThrowTypeError( |
| 15 "CSSPerspective does not support CSSNumericValues with percent units"); | 15 "CSSPerspective does not support CSSNumericValues with percent units"); |
| 16 return nullptr; | 16 return nullptr; |
| 17 } | 17 } |
| 18 return new CSSPerspective(length); | 18 return new CSSPerspective(length); |
| 19 } | 19 } |
| 20 | 20 |
| 21 CSSPerspective* CSSPerspective::FromCSSValue(const CSSFunctionValue& value) { | 21 CSSPerspective* CSSPerspective::FromCSSValue(const CSSFunctionValue& value) { |
| 22 DCHECK_EQ(value.FunctionType(), CSSValuePerspective); | 22 DCHECK_EQ(value.FunctionType(), CSSValuePerspective); |
| 23 DCHECK_EQ(value.length(), 1U); | 23 DCHECK_EQ(value.length(), 1U); |
| 24 CSSNumericValue* length = | 24 CSSNumericValue* length = |
| 25 CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(0))); | 25 CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(0))); |
| 26 // TODO(meade): This shouldn't happen once CSSNumericValue is fully |
| 27 // implemented, so once that happens this check can be removed. |
| 28 if (!length) |
| 29 return nullptr; |
| 26 DCHECK(!length->ContainsPercent()); | 30 DCHECK(!length->ContainsPercent()); |
| 27 return new CSSPerspective(length); | 31 return new CSSPerspective(length); |
| 28 } | 32 } |
| 29 | 33 |
| 30 CSSFunctionValue* CSSPerspective::ToCSSValue() const { | 34 CSSFunctionValue* CSSPerspective::ToCSSValue() const { |
| 31 return nullptr; | 35 CSSFunctionValue* result = CSSFunctionValue::Create(CSSValuePerspective); |
| 32 // CSSFunctionValue* result = CSSFunctionValue::Create(CSSValuePerspective); | 36 result->Append(*length_->ToCSSValue()); |
| 33 // result->Append(*length_->ToCSSValue()); | 37 return result; |
| 34 // return result; | |
| 35 } | 38 } |
| 36 | 39 |
| 37 } // namespace blink | 40 } // namespace blink |
| OLD | NEW |