| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/CSSUnitValue.h" | 5 #include "core/css/cssom/CSSUnitValue.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 namespace { | 11 namespace { |
| 12 | 12 |
| 13 bool IsValidUnit(CSSPrimitiveValue::UnitType unit) { | 13 bool IsValidUnit(CSSPrimitiveValue::UnitType unit) { |
| 14 // UserUnits returns true for CSSPrimitiveValue::isLength below. | 14 // UserUnits returns true for CSSPrimitiveValue::IsLength below. |
| 15 if (unit == CSSPrimitiveValue::UnitType::kUserUnits) | 15 if (unit == CSSPrimitiveValue::UnitType::kUserUnits) |
| 16 return false; | 16 return false; |
| 17 if (unit == CSSPrimitiveValue::UnitType::kNumber || | 17 if (unit == CSSPrimitiveValue::UnitType::kNumber || |
| 18 unit == CSSPrimitiveValue::UnitType::kPercentage || | 18 unit == CSSPrimitiveValue::UnitType::kPercentage || |
| 19 CSSPrimitiveValue::IsLength(unit) || CSSPrimitiveValue::IsAngle(unit) || | 19 CSSPrimitiveValue::IsLength(unit) || CSSPrimitiveValue::IsAngle(unit) || |
| 20 CSSPrimitiveValue::IsTime(unit) || CSSPrimitiveValue::IsFrequency(unit) || | 20 CSSPrimitiveValue::IsTime(unit) || CSSPrimitiveValue::IsFrequency(unit) || |
| 21 CSSPrimitiveValue::IsResolution(unit) || CSSPrimitiveValue::IsFlex(unit)) | 21 CSSPrimitiveValue::IsResolution(unit) || CSSPrimitiveValue::IsFlex(unit)) |
| 22 return true; | 22 return true; |
| 23 return false; | 23 return false; |
| 24 } | 24 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 if (CSSPrimitiveValue::IsFlex(unit_)) | 87 if (CSSPrimitiveValue::IsFlex(unit_)) |
| 88 return "flex"; | 88 return "flex"; |
| 89 return ""; | 89 return ""; |
| 90 } | 90 } |
| 91 | 91 |
| 92 const CSSValue* CSSUnitValue::ToCSSValue() const { | 92 const CSSValue* CSSUnitValue::ToCSSValue() const { |
| 93 return CSSPrimitiveValue::Create(value_, unit_); | 93 return CSSPrimitiveValue::Create(value_, unit_); |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace blink | 96 } // namespace blink |
| OLD | NEW |