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 #ifndef CSSUnitValue_h | 5 #ifndef CSSUnitValue_h |
6 #define CSSUnitValue_h | 6 #define CSSUnitValue_h |
7 | 7 |
8 #include "core/css/CSSPrimitiveValue.h" | 8 #include "core/css/CSSPrimitiveValue.h" |
9 #include "core/css/cssom/CSSNumericValue.h" | 9 #include "core/css/cssom/CSSNumericValue.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 class CORE_EXPORT CSSUnitValue final : public CSSNumericValue { | 13 class CORE_EXPORT CSSUnitValue final : public CSSNumericValue { |
14 WTF_MAKE_NONCOPYABLE(CSSUnitValue); | 14 WTF_MAKE_NONCOPYABLE(CSSUnitValue); |
15 DEFINE_WRAPPERTYPEINFO(); | 15 DEFINE_WRAPPERTYPEINFO(); |
16 | 16 |
17 public: | 17 public: |
18 static CSSPrimitiveValue::UnitType UnitFromName(const String& name); | 18 static CSSPrimitiveValue::UnitType UnitFromName(const String& name); |
19 static CSSUnitValue* Create(double value, | 19 static CSSUnitValue* Create(double value, |
20 const String& unit, | 20 const String& unit, |
21 ExceptionState&); | 21 ExceptionState&); |
22 static CSSUnitValue* Create(double value, CSSPrimitiveValue::UnitType); | 22 static CSSUnitValue* Create(double value, CSSPrimitiveValue::UnitType); |
23 static CSSUnitValue* FromCSSValue(const CSSPrimitiveValue&); | 23 static CSSUnitValue* FromCSSValue(const CSSPrimitiveValue&); |
24 | 24 |
25 void setValue(double new_value) { value_ = new_value; } | 25 void setValue(double new_value) { value_ = new_value; } |
26 double value() const { return value_; } | 26 double value() const { return value_; } |
27 void setUnit(const String& new_unit, ExceptionState&); | 27 void setUnit(const String& new_unit, ExceptionState&); |
28 String unit() const; | 28 String unit() const; |
29 | 29 |
30 String cssType() const; | 30 String type() const; |
31 | 31 |
32 StyleValueType GetType() const override { return StyleValueType::kUnitType; } | 32 StyleValueType GetType() const override { return StyleValueType::kUnitType; } |
33 | 33 |
34 const CSSValue* ToCSSValue() const override; | 34 const CSSValue* ToCSSValue() const override; |
35 | 35 |
36 private: | 36 private: |
37 CSSUnitValue(double value, CSSPrimitiveValue::UnitType unit) | 37 CSSUnitValue(double value, CSSPrimitiveValue::UnitType unit) |
38 : CSSNumericValue(), value_(value), unit_(unit) {} | 38 : CSSNumericValue(), value_(value), unit_(unit) {} |
39 | 39 |
40 double value_; | 40 double value_; |
41 CSSPrimitiveValue::UnitType unit_; | 41 CSSPrimitiveValue::UnitType unit_; |
42 }; | 42 }; |
43 | 43 |
44 } // namespace blink | 44 } // namespace blink |
45 | 45 |
46 #endif // CSSUnitValue_h | 46 #endif // CSSUnitValue_h |
OLD | NEW |