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

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

Issue 1949343002: [Obsolete] Typed CSSOM: Prefix LengthValue, CalcLength and SimpleLength with "CSS" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename layout test files Created 4 years, 7 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 CSSStyleCalcLength_h
6 #define StyleCalcLength_h 6 #define CSSStyleCalcLength_h
7 7
8 #include "core/css/cssom/LengthValue.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 LengthValue { 16 class CORE_EXPORT CSSStyleCalcLength final : public CSSLengthValue {
17 DEFINE_WRAPPERTYPEINFO(); 17 DEFINE_WRAPPERTYPEINFO();
18 public: 18 public:
19 static StyleCalcLength* create(const LengthValue*); 19 static CSSStyleCalcLength* create(const CSSLengthValue*);
20 static StyleCalcLength* create(const CalcDictionary&, ExceptionState&); 20 static CSSStyleCalcLength* create(const CalcDictionary&, ExceptionState&);
21 static StyleCalcLength* create(const LengthValue* length, ExceptionState&) 21 static CSSStyleCalcLength* create(const CSSLengthValue* length, ExceptionSta te&)
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 15 matching lines...) Expand all
47 GETTER_MACRO(pt, CSSPrimitiveValue::UnitType::Points) 47 GETTER_MACRO(pt, CSSPrimitiveValue::UnitType::Points)
48 48
49 #undef GETTER_MACRO 49 #undef GETTER_MACRO
50 50
51 bool containsPercent() const override; 51 bool containsPercent() const override;
52 52
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 LengthValue* addInternal(const LengthValue* other, ExceptionState&) override ; 57 CSSLengthValue* addInternal(const CSSLengthValue* other, ExceptionState&) ov erride;
58 LengthValue* subtractInternal(const LengthValue* other, ExceptionState&) ove rride; 58 CSSLengthValue* subtractInternal(const CSSLengthValue* other, ExceptionState &) override;
59 LengthValue* multiplyInternal(double, ExceptionState&) override; 59 CSSLengthValue* multiplyInternal(double, ExceptionState&) override;
60 LengthValue* divideInternal(double, ExceptionState&) override; 60 CSSLengthValue* divideInternal(double, ExceptionState&) override;
61 61
62 private: 62 private:
63 StyleCalcLength(); 63 CSSStyleCalcLength();
64 StyleCalcLength(const StyleCalcLength& other); 64 CSSStyleCalcLength(const CSSStyleCalcLength& other);
65 StyleCalcLength(const SimpleLength& other); 65 CSSStyleCalcLength(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 ASSERT(index < LengthValue::kNumSupportedUnits); 70 ASSERT(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
76 { 76 {
77 ASSERT(index < LengthValue::kNumSupportedUnits); 77 ASSERT(index < CSSLengthValue::kNumSupportedUnits);
78 return m_hasValues.quickGet(index); 78 return m_hasValues.quickGet(index);
79 } 79 }
80 bool has(CSSPrimitiveValue::UnitType unit) const { return hasAtIndex(indexFo rUnit(unit)); } 80 bool has(CSSPrimitiveValue::UnitType unit) const { return hasAtIndex(indexFo rUnit(unit)); }
81 void setAtIndex(double value, int index) 81 void setAtIndex(double value, int index)
82 { 82 {
83 ASSERT(index < LengthValue::kNumSupportedUnits); 83 ASSERT(index < CSSLengthValue::kNumSupportedUnits);
84 m_hasValues.quickSet(index); 84 m_hasValues.quickSet(index);
85 m_values[index] = value; 85 m_values[index] = value;
86 } 86 }
87 void set(double value, CSSPrimitiveValue::UnitType unit) { setAtIndex(value, indexForUnit(unit)); } 87 void set(double value, CSSPrimitiveValue::UnitType unit) { setAtIndex(value, indexForUnit(unit)); }
88 double getAtIndex(int index) const 88 double getAtIndex(int index) const
89 { 89 {
90 ASSERT(index < LengthValue::kNumSupportedUnits); 90 ASSERT(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, LengthValue::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(CSSStyleCalcLength, argumentType, value, \
101 value->type() == LengthValue::StyleValueType::CalcLengthType, \ 101 value->type() == CSSLengthValue::StyleValueType::CalcLengthType, \
102 value.type() == LengthValue::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

Powered by Google App Engine
This is Rietveld 408576698