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