Chromium Code Reviews| 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 CSSCalcLength_h | 5 #ifndef CSSCalcLength_h |
| 6 #define CSSCalcLength_h | 6 #define CSSCalcLength_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 CSSCalcDictionary; | 13 class CSSCalcDictionary; |
| 14 class CSSSimpleLength; | 14 class CSSSimpleLength; |
| 15 | 15 |
| 16 class CORE_EXPORT CSSCalcLength final : public CSSLengthValue { | 16 class CORE_EXPORT CSSCalcLength final : public CSSLengthValue { |
| 17 DEFINE_WRAPPERTYPEINFO(); | 17 DEFINE_WRAPPERTYPEINFO(); |
| 18 public: | 18 public: |
| 19 static CSSCalcLength* create(const CSSLengthValue*); | 19 static CSSCalcLength* create(const CSSLengthValue*); |
| 20 static CSSCalcLength* create(const CSSCalcDictionary&, ExceptionState&); | 20 static CSSCalcLength* create(const CSSCalcDictionary&, ExceptionState&); |
| 21 static CSSCalcLength* create(const CSSLengthValue* length, ExceptionState&) | 21 static CSSCalcLength* create(const CSSLengthValue* length, ExceptionState&) |
| 22 { | 22 { |
| 23 return create(length); | 23 return create(length); |
| 24 } | 24 } |
| 25 | 25 |
| 26 static CSSCalcLength* fromLength(const Length&); | |
| 27 | |
| 26 #define GETTER_MACRO(name, type) \ | 28 #define GETTER_MACRO(name, type) \ |
| 27 double name(bool& isNull) \ | 29 double name(bool& isNull) \ |
| 28 { \ | 30 { \ |
| 29 isNull = !hasAtIndex(indexForUnit(type)); \ | 31 isNull = !hasAtIndex(indexForUnit(type)); \ |
| 30 return get(type); \ | 32 return get(type); \ |
| 31 } | 33 } |
| 32 | 34 |
| 33 GETTER_MACRO(px, CSSPrimitiveValue::UnitType::Pixels) | 35 GETTER_MACRO(px, CSSPrimitiveValue::UnitType::Pixels) |
| 34 GETTER_MACRO(percent, CSSPrimitiveValue::UnitType::Percentage) | 36 GETTER_MACRO(percent, CSSPrimitiveValue::UnitType::Percentage) |
| 35 GETTER_MACRO(em, CSSPrimitiveValue::UnitType::Ems) | 37 GETTER_MACRO(em, CSSPrimitiveValue::UnitType::Ems) |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 46 GETTER_MACRO(pc, CSSPrimitiveValue::UnitType::Picas) | 48 GETTER_MACRO(pc, CSSPrimitiveValue::UnitType::Picas) |
| 47 GETTER_MACRO(pt, CSSPrimitiveValue::UnitType::Points) | 49 GETTER_MACRO(pt, CSSPrimitiveValue::UnitType::Points) |
| 48 | 50 |
| 49 #undef GETTER_MACRO | 51 #undef GETTER_MACRO |
| 50 | 52 |
| 51 bool containsPercent() const override; | 53 bool containsPercent() const override; |
| 52 | 54 |
| 53 CSSValue* toCSSValue() const override; | 55 CSSValue* toCSSValue() const override; |
| 54 | 56 |
| 55 StyleValueType type() const override { return CalcLengthType; } | 57 StyleValueType type() const override { return CalcLengthType; } |
| 58 | |
| 56 protected: | 59 protected: |
| 57 CSSLengthValue* addInternal(const CSSLengthValue* other) override; | 60 CSSLengthValue* addInternal(const CSSLengthValue* other) override; |
|
meade_UTC10
2016/09/27 04:41:39
Nit: no need for extra indent?
rjwright
2016/09/28 01:38:24
Done.
| |
| 58 CSSLengthValue* subtractInternal(const CSSLengthValue* other) override; | 61 CSSLengthValue* subtractInternal(const CSSLengthValue* other) override; |
| 59 CSSLengthValue* multiplyInternal(double) override; | 62 CSSLengthValue* multiplyInternal(double) override; |
| 60 CSSLengthValue* divideInternal(double) override; | 63 CSSLengthValue* divideInternal(double) override; |
| 61 | 64 |
| 62 private: | 65 private: |
| 63 CSSCalcLength(); | 66 CSSCalcLength(); |
| 64 CSSCalcLength(const CSSCalcLength& other); | 67 CSSCalcLength(const CSSCalcLength& other); |
| 65 CSSCalcLength(const CSSSimpleLength& other); | 68 CSSCalcLength(const CSSSimpleLength& other); |
| 66 | 69 |
| 67 static int indexForUnit(CSSPrimitiveValue::UnitType); | 70 static int indexForUnit(CSSPrimitiveValue::UnitType); |
| 68 static CSSPrimitiveValue::UnitType unitFromIndex(int index) | 71 static CSSPrimitiveValue::UnitType unitFromIndex(int index) |
| 69 { | 72 { |
| 70 DCHECK(index < CSSLengthValue::kNumSupportedUnits); | 73 DCHECK(index < CSSLengthValue::kNumSupportedUnits); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 99 #define DEFINE_CALC_LENGTH_TYPE_CASTS(argumentType) \ | 102 #define DEFINE_CALC_LENGTH_TYPE_CASTS(argumentType) \ |
| 100 DEFINE_TYPE_CASTS(CSSCalcLength, argumentType, value, \ | 103 DEFINE_TYPE_CASTS(CSSCalcLength, argumentType, value, \ |
| 101 value->type() == CSSLengthValue::StyleValueType::CalcLengthType, \ | 104 value->type() == CSSLengthValue::StyleValueType::CalcLengthType, \ |
| 102 value.type() == CSSLengthValue::StyleValueType::CalcLengthType) | 105 value.type() == CSSLengthValue::StyleValueType::CalcLengthType) |
| 103 | 106 |
| 104 DEFINE_CALC_LENGTH_TYPE_CASTS(CSSStyleValue); | 107 DEFINE_CALC_LENGTH_TYPE_CASTS(CSSStyleValue); |
| 105 | 108 |
| 106 } // namespace blink | 109 } // namespace blink |
| 107 | 110 |
| 108 #endif | 111 #endif |
| OLD | NEW |