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 #ifndef SimpleLength_h | 5 #ifndef SimpleLength_h |
6 #define SimpleLength_h | 6 #define SimpleLength_h |
7 | 7 |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "core/css/cssom/LengthValue.h" | 9 #include "core/css/cssom/LengthValue.h" |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 | 33 |
34 double value() const { return m_value; } | 34 double value() const { return m_value; } |
35 String unit() const { return LengthValue::lengthTypeToString(m_unit); } | 35 String unit() const { return LengthValue::lengthTypeToString(m_unit); } |
36 LengthUnit lengthUnit() const { return m_unit; } | 36 LengthUnit lengthUnit() const { return m_unit; } |
37 | 37 |
38 void setValue(double value) { m_value = value; } | 38 void setValue(double value) { m_value = value; } |
39 | 39 |
40 StyleValueType type() const override { return StyleValueType::SimpleLengthTy
pe; } | 40 StyleValueType type() const override { return StyleValueType::SimpleLengthTy
pe; } |
41 | 41 |
| 42 String cssString() const override; |
42 PassRefPtrWillBeRawPtr<CSSValue> toCSSValue() const override; | 43 PassRefPtrWillBeRawPtr<CSSValue> toCSSValue() const override; |
43 | 44 |
44 protected: | 45 protected: |
45 virtual LengthValue* addInternal(const LengthValue* other, ExceptionState&); | 46 virtual LengthValue* addInternal(const LengthValue* other, ExceptionState&); |
46 virtual LengthValue* subtractInternal(const LengthValue* other, ExceptionSta
te&); | 47 virtual LengthValue* subtractInternal(const LengthValue* other, ExceptionSta
te&); |
47 virtual LengthValue* multiplyInternal(double, ExceptionState&); | 48 virtual LengthValue* multiplyInternal(double, ExceptionState&); |
48 virtual LengthValue* divideInternal(double, ExceptionState&); | 49 virtual LengthValue* divideInternal(double, ExceptionState&); |
49 | 50 |
50 private: | 51 private: |
51 SimpleLength(double value, LengthUnit unit) : LengthValue(), m_unit(unit), m
_value(value) {} | 52 SimpleLength(double value, LengthUnit unit) : LengthValue(), m_unit(unit), m
_value(value) {} |
52 | 53 |
53 LengthUnit m_unit; | 54 LengthUnit m_unit; |
54 double m_value; | 55 double m_value; |
55 }; | 56 }; |
56 | 57 |
57 #define DEFINE_SIMPLE_LENGTH_TYPE_CASTS(argumentType) \ | 58 #define DEFINE_SIMPLE_LENGTH_TYPE_CASTS(argumentType) \ |
58 DEFINE_TYPE_CASTS(SimpleLength, argumentType, value, \ | 59 DEFINE_TYPE_CASTS(SimpleLength, argumentType, value, \ |
59 value->type() == LengthValue::StyleValueType::SimpleLengthType, \ | 60 value->type() == LengthValue::StyleValueType::SimpleLengthType, \ |
60 value.type() == LengthValue::StyleValueType::SimpleLengthType) | 61 value.type() == LengthValue::StyleValueType::SimpleLengthType) |
61 | 62 |
62 DEFINE_SIMPLE_LENGTH_TYPE_CASTS(LengthValue); | 63 DEFINE_SIMPLE_LENGTH_TYPE_CASTS(LengthValue); |
63 DEFINE_SIMPLE_LENGTH_TYPE_CASTS(StyleValue); | 64 DEFINE_SIMPLE_LENGTH_TYPE_CASTS(StyleValue); |
64 | 65 |
65 } // namespace blink | 66 } // namespace blink |
66 | 67 |
67 #endif | 68 #endif |
OLD | NEW |