| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 StyleCalcLength_h | 5 #ifndef StyleCalcLength_h |
| 6 #define StyleCalcLength_h | 6 #define StyleCalcLength_h |
| 7 | 7 |
| 8 #include "core/css/cssom/CSSLengthValue.h" | 8 #include "core/css/cssom/CSSLengthValue.h" |
| 9 #include "wtf/BitVector.h" | 9 #include "wtf/BitVector.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class CalcDictionary; | 13 class CalcDictionary; |
| 14 class SimpleLength; | 14 class CSSSimpleLength; |
| 15 | 15 |
| 16 class CORE_EXPORT StyleCalcLength final : public CSSLengthValue { | 16 class CORE_EXPORT StyleCalcLength final : public CSSLengthValue { |
| 17 DEFINE_WRAPPERTYPEINFO(); | 17 DEFINE_WRAPPERTYPEINFO(); |
| 18 public: | 18 public: |
| 19 static StyleCalcLength* create(const CSSLengthValue*); | 19 static StyleCalcLength* create(const CSSLengthValue*); |
| 20 static StyleCalcLength* create(const CalcDictionary&, ExceptionState&); | 20 static StyleCalcLength* create(const CalcDictionary&, ExceptionState&); |
| 21 static StyleCalcLength* create(const CSSLengthValue* length, ExceptionState&
) | 21 static StyleCalcLength* create(const CSSLengthValue* length, ExceptionState&
) |
| 22 { | 22 { |
| 23 return create(length); | 23 return create(length); |
| 24 } | 24 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 55 StyleValueType type() const override { return CalcLengthType; } | 55 StyleValueType type() const override { return CalcLengthType; } |
| 56 protected: | 56 protected: |
| 57 CSSLengthValue* addInternal(const CSSLengthValue* other, ExceptionState&) ov
erride; | 57 CSSLengthValue* addInternal(const CSSLengthValue* other, ExceptionState&) ov
erride; |
| 58 CSSLengthValue* subtractInternal(const CSSLengthValue* other, ExceptionState
&) override; | 58 CSSLengthValue* subtractInternal(const CSSLengthValue* other, ExceptionState
&) override; |
| 59 CSSLengthValue* multiplyInternal(double, ExceptionState&) override; | 59 CSSLengthValue* multiplyInternal(double, ExceptionState&) override; |
| 60 CSSLengthValue* divideInternal(double, ExceptionState&) override; | 60 CSSLengthValue* divideInternal(double, ExceptionState&) override; |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 StyleCalcLength(); | 63 StyleCalcLength(); |
| 64 StyleCalcLength(const StyleCalcLength& other); | 64 StyleCalcLength(const StyleCalcLength& other); |
| 65 StyleCalcLength(const SimpleLength& other); | 65 StyleCalcLength(const CSSSimpleLength& other); |
| 66 | 66 |
| 67 static int indexForUnit(CSSPrimitiveValue::UnitType); | 67 static int indexForUnit(CSSPrimitiveValue::UnitType); |
| 68 static CSSPrimitiveValue::UnitType unitFromIndex(int index) | 68 static CSSPrimitiveValue::UnitType unitFromIndex(int index) |
| 69 { | 69 { |
| 70 DCHECK(index < CSSLengthValue::kNumSupportedUnits); | 70 DCHECK(index < CSSLengthValue::kNumSupportedUnits); |
| 71 int lowestValue = static_cast<int>(CSSPrimitiveValue::UnitType::Percenta
ge); | 71 int lowestValue = static_cast<int>(CSSPrimitiveValue::UnitType::Percenta
ge); |
| 72 return static_cast<CSSPrimitiveValue::UnitType>(index + lowestValue); | 72 return static_cast<CSSPrimitiveValue::UnitType>(index + lowestValue); |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool hasAtIndex(int index) const | 75 bool hasAtIndex(int index) const |
| (...skipping 23 matching lines...) Expand all Loading... |
| 99 #define DEFINE_CALC_LENGTH_TYPE_CASTS(argumentType) \ | 99 #define DEFINE_CALC_LENGTH_TYPE_CASTS(argumentType) \ |
| 100 DEFINE_TYPE_CASTS(StyleCalcLength, argumentType, value, \ | 100 DEFINE_TYPE_CASTS(StyleCalcLength, argumentType, value, \ |
| 101 value->type() == CSSLengthValue::StyleValueType::CalcLengthType, \ | 101 value->type() == CSSLengthValue::StyleValueType::CalcLengthType, \ |
| 102 value.type() == CSSLengthValue::StyleValueType::CalcLengthType) | 102 value.type() == CSSLengthValue::StyleValueType::CalcLengthType) |
| 103 | 103 |
| 104 DEFINE_CALC_LENGTH_TYPE_CASTS(StyleValue); | 104 DEFINE_CALC_LENGTH_TYPE_CASTS(StyleValue); |
| 105 | 105 |
| 106 } // namespace blink | 106 } // namespace blink |
| 107 | 107 |
| 108 #endif | 108 #endif |
| OLD | NEW |