Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/CSSCalcLength.h

Issue 2011833002: Typed CSSOM: Rename CalcLength and StyleCalcLength to CSSCalcLength (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 CSSCalcLength_h
6 #define StyleCalcLength_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 CalcDictionary; 13 class CalcDictionary;
14 class CSSSimpleLength; 14 class CSSSimpleLength;
15 15
16 class CORE_EXPORT StyleCalcLength final : public CSSLengthValue { 16 class CORE_EXPORT CSSCalcLength final : public CSSLengthValue {
17 DEFINE_WRAPPERTYPEINFO(); 17 DEFINE_WRAPPERTYPEINFO();
18 public: 18 public:
19 static StyleCalcLength* create(const CSSLengthValue*); 19 static CSSCalcLength* create(const CSSLengthValue*);
20 static StyleCalcLength* create(const CalcDictionary&, ExceptionState&); 20 static CSSCalcLength* create(const CalcDictionary&, ExceptionState&);
21 static StyleCalcLength* 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 #define GETTER_MACRO(name, type) \ 26 #define GETTER_MACRO(name, type) \
27 double name(bool& isNull) \ 27 double name(bool& isNull) \
28 { \ 28 { \
29 isNull = !hasAtIndex(indexForUnit(type)); \ 29 isNull = !hasAtIndex(indexForUnit(type)); \
30 return get(type); \ 30 return get(type); \
31 } 31 }
(...skipping 21 matching lines...) Expand all
53 CSSValue* toCSSValue() const override; 53 CSSValue* toCSSValue() const override;
54 54
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 CSSCalcLength();
64 StyleCalcLength(const StyleCalcLength& other); 64 CSSCalcLength(const CSSCalcLength& other);
65 StyleCalcLength(const CSSSimpleLength& other); 65 CSSCalcLength(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 14 matching lines...) Expand all
90 DCHECK(index < CSSLengthValue::kNumSupportedUnits); 90 DCHECK(index < CSSLengthValue::kNumSupportedUnits);
91 return m_values[index]; 91 return m_values[index];
92 } 92 }
93 double get(CSSPrimitiveValue::UnitType unit) const { return getAtIndex(index ForUnit(unit)); } 93 double get(CSSPrimitiveValue::UnitType unit) const { return getAtIndex(index ForUnit(unit)); }
94 94
95 Vector<double, CSSLengthValue::kNumSupportedUnits> m_values; 95 Vector<double, CSSLengthValue::kNumSupportedUnits> m_values;
96 BitVector m_hasValues; 96 BitVector m_hasValues;
97 }; 97 };
98 98
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(CSSCalcLength, 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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/core.gypi ('k') | third_party/WebKit/Source/core/css/cssom/CSSCalcLength.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698