| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/CSSSimpleLength.h" | 5 #include "core/css/cssom/CSSSimpleLength.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/CSSCalcLength.h" | 9 #include "core/css/cssom/CSSCalcLength.h" |
| 10 #include "wtf/text/StringBuilder.h" | 10 #include "platform/wtf/text/StringBuilder.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 CSSSimpleLength* CSSSimpleLength::Create(double value, | 14 CSSSimpleLength* CSSSimpleLength::Create(double value, |
| 15 const String& type, | 15 const String& type, |
| 16 ExceptionState& exception_state) { | 16 ExceptionState& exception_state) { |
| 17 CSSPrimitiveValue::UnitType unit = CSSLengthValue::UnitFromName(type); | 17 CSSPrimitiveValue::UnitType unit = CSSLengthValue::UnitFromName(type); |
| 18 if (!CSSLengthValue::IsSupportedLengthUnit(unit)) { | 18 if (!CSSLengthValue::IsSupportedLengthUnit(unit)) { |
| 19 exception_state.ThrowTypeError("Invalid unit for CSSSimpleLength: " + type); | 19 exception_state.ThrowTypeError("Invalid unit for CSSSimpleLength: " + type); |
| 20 return nullptr; | 20 return nullptr; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 CSSLengthValue* CSSSimpleLength::DivideInternal(double x) { | 60 CSSLengthValue* CSSSimpleLength::DivideInternal(double x) { |
| 61 DCHECK_NE(x, 0); | 61 DCHECK_NE(x, 0); |
| 62 return Create(value_ / x, unit_); | 62 return Create(value_ / x, unit_); |
| 63 } | 63 } |
| 64 | 64 |
| 65 CSSValue* CSSSimpleLength::ToCSSValue() const { | 65 CSSValue* CSSSimpleLength::ToCSSValue() const { |
| 66 return CSSPrimitiveValue::Create(value_, unit_); | 66 return CSSPrimitiveValue::Create(value_, unit_); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace blink | 69 } // namespace blink |
| OLD | NEW |