OLD | NEW |
(Empty) | |
| 1 {% from 'macros.tmpl' import license %} |
| 2 {{license()}} |
| 3 |
| 4 #ifndef ComputedStyleBase_h |
| 5 #define ComputedStyleBase_h |
| 6 |
| 7 #include "core/ComputedStyleBaseConstants.h" |
| 8 #include "core/CoreExport.h" |
| 9 |
| 10 {# Returns the default value for the field, converted to fit in the storage cont
ainer. #} |
| 11 {% macro default_value(field) %} |
| 12 {# We only support enum fields for now. #} |
| 13 static_cast<unsigned>({{field.default_value}}){% endmacro %} |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 // The generated portion of ComputedStyle. For more info, see the header comment |
| 18 // in ComputedStyle.h. |
| 19 class CORE_EXPORT ComputedStyleBase { |
| 20 public: |
| 21 ALWAYS_INLINE ComputedStyleBase() : |
| 22 {% for field in fields %} |
| 23 {% set trailing_comma = "," if field != fields[-1] else "" %} |
| 24 {{field.name}}({{default_value(field)}}){{trailing_comma}} |
| 25 {% endfor %} |
| 26 {} |
| 27 ~ComputedStyleBase() {} |
| 28 |
| 29 ALWAYS_INLINE ComputedStyleBase(const ComputedStyleBase& o) : |
| 30 {% for field in fields %} |
| 31 {% set trailing_comma = "," if field != fields[-1] else "" %} |
| 32 {{field.name}}(o.{{field.name}}){{trailing_comma}} |
| 33 {% endfor %} |
| 34 {} |
| 35 |
| 36 bool operator==(const ComputedStyleBase& o) const |
| 37 { |
| 38 return true |
| 39 {% for field in fields %} |
| 40 && {{field.name}} == o.{{field.name}} |
| 41 {% endfor %} |
| 42 && true; |
| 43 } |
| 44 |
| 45 bool operator!=(const ComputedStyleBase& o) const { return !(*this == o); } |
| 46 |
| 47 inline bool inheritedEqual(const ComputedStyleBase& o) const |
| 48 { |
| 49 return true |
| 50 {% for field in fields if field.property['inherited'] %} |
| 51 && {{field.name}} == o.{{field.name}} |
| 52 {% endfor %} |
| 53 && true; |
| 54 } |
| 55 |
| 56 inline bool independentInheritedEqual(const ComputedStyleBase& o) const |
| 57 { |
| 58 return true |
| 59 {% for field in fields if field.property['inherited'] and field.property
['independent'] %} |
| 60 && {{field.name}} == o.{{field.name}} |
| 61 {% endfor %} |
| 62 && true; |
| 63 } |
| 64 |
| 65 inline bool nonIndependentInheritedEqual(const ComputedStyleBase& o) const |
| 66 { |
| 67 return true |
| 68 {% for field in fields if field.property['inherited'] and not field.prop
erty['independent'] %} |
| 69 && {{field.name}} == o.{{field.name}} |
| 70 {% endfor %} |
| 71 && true; |
| 72 } |
| 73 |
| 74 inline bool nonInheritedEqual(const ComputedStyleBase& o) const |
| 75 { |
| 76 return true |
| 77 {% for field in fields if not field.property['inherited'] %} |
| 78 && {{field.name}} == o.{{field.name}} |
| 79 {% endfor %} |
| 80 && true; |
| 81 } |
| 82 |
| 83 void setBitDefaults() |
| 84 { |
| 85 {% for field in fields %} |
| 86 reset{{field.property['upper_camel_name']}}(); |
| 87 {% endfor %} |
| 88 } |
| 89 |
| 90 enum IsAtShadowBoundary { |
| 91 AtShadowBoundary, |
| 92 NotAtShadowBoundary, |
| 93 }; |
| 94 void inheritFrom(const ComputedStyleBase& inheritParent, IsAtShadowBoundary
isAtShadowBoundary = NotAtShadowBoundary); |
| 95 |
| 96 // Fields. |
| 97 // TODO(sashab): Remove initialFoo() static methods and update callers to |
| 98 // use resetFoo(), which can be more efficient. |
| 99 {% for field in fields %} |
| 100 // {{field.property['name']}} |
| 101 inline static {{field.type}} initial{{field.property['upper_camel_name']}}()
{ return {{field.default_value}}; } |
| 102 {{field.type}} {{field.property['lower_camel_name']}}() const { return stati
c_cast<{{field.type}}>({{field.name}}); } |
| 103 void set{{field.property['upper_camel_name']}}({{field.type}} v) { {{field.n
ame}} = static_cast<unsigned>(v); } |
| 104 inline void reset{{field.property['upper_camel_name']}}() { {{field.name}} =
{{default_value(field)}}; } |
| 105 |
| 106 {% endfor %} |
| 107 protected: |
| 108 // Storage. |
| 109 {% for field in fields %} |
| 110 unsigned {{field.name}} : {{field.size}}; // {{field.type}} |
| 111 {% endfor %} |
| 112 }; |
| 113 |
| 114 } // namespace blink |
| 115 |
| 116 #endif // ComputedStyleBase_h |
OLD | NEW |