OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CSSSimpleLength_h | |
6 #define CSSSimpleLength_h | |
7 | |
8 #include "core/css/cssom/CSSLengthValue.h" | |
9 | |
10 namespace blink { | |
11 | |
12 class CSSPrimitiveValue; | |
13 class ExceptionState; | |
14 | |
15 class CORE_EXPORT CSSSimpleLength final : public CSSLengthValue { | |
16 WTF_MAKE_NONCOPYABLE(CSSSimpleLength); | |
17 DEFINE_WRAPPERTYPEINFO(); | |
18 | |
19 public: | |
20 static CSSSimpleLength* Create(double, const String& type, ExceptionState&); | |
21 static CSSSimpleLength* Create(double value, | |
22 CSSPrimitiveValue::UnitType type) { | |
23 return new CSSSimpleLength(value, type); | |
24 } | |
25 static CSSSimpleLength* FromCSSValue(const CSSPrimitiveValue&); | |
26 | |
27 bool ContainsPercent() const override; | |
28 | |
29 double value() const { return value_; } | |
30 String unit() const; | |
31 CSSPrimitiveValue::UnitType LengthUnit() const { return unit_; } | |
32 | |
33 StyleValueType GetType() const override { | |
34 return StyleValueType::kSimpleLengthType; | |
35 } | |
36 | |
37 CSSValue* ToCSSValue() const override; | |
38 | |
39 protected: | |
40 virtual CSSLengthValue* AddInternal(const CSSLengthValue* other); | |
41 virtual CSSLengthValue* SubtractInternal(const CSSLengthValue* other); | |
42 virtual CSSLengthValue* MultiplyInternal(double); | |
43 virtual CSSLengthValue* DivideInternal(double); | |
44 | |
45 private: | |
46 CSSSimpleLength(double value, CSSPrimitiveValue::UnitType unit) | |
47 : CSSLengthValue(), unit_(unit), value_(value) {} | |
48 | |
49 CSSPrimitiveValue::UnitType unit_; | |
50 double value_; | |
51 }; | |
52 | |
53 #define DEFINE_SIMPLE_LENGTH_TYPE_CASTS(argumentType) \ | |
54 DEFINE_TYPE_CASTS( \ | |
55 CSSSimpleLength, argumentType, value, \ | |
56 value->GetType() == CSSLengthValue::StyleValueType::kSimpleLengthType, \ | |
57 value.GetType() == CSSLengthValue::StyleValueType::kSimpleLengthType) | |
58 | |
59 DEFINE_SIMPLE_LENGTH_TYPE_CASTS(CSSLengthValue); | |
60 DEFINE_SIMPLE_LENGTH_TYPE_CASTS(CSSStyleValue); | |
61 | |
62 } // namespace blink | |
63 | |
64 #endif | |
OLD | NEW |