OLD | NEW |
1 {% from 'macros.tmpl' import license, print_if %} | 1 {% from 'macros.tmpl' import license, print_if %} |
2 {{license()}} | 2 {{license()}} |
3 | 3 |
4 #ifndef ComputedStyleBase_h | 4 #ifndef ComputedStyleBase_h |
5 #define ComputedStyleBase_h | 5 #define ComputedStyleBase_h |
6 | 6 |
7 #include "core/ComputedStyleBaseConstants.h" | 7 #include "core/ComputedStyleBaseConstants.h" |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 {% for path in include_paths %} | 9 {% for path in include_paths %} |
10 #include "{{path}}" | 10 #include "{{path}}" |
11 {% endfor %} | 11 {% endfor %} |
12 | 12 |
13 {# Returns the default value for the field, converted to fit in the storage cont
ainer. #} | 13 {# Each field template has macros that we can call to generate specific |
14 {% macro default_value(field) -%} | 14 aspects of the field (e.g. getters, setters). |
15 {# We only support enum fields for now. #} | 15 #} |
16 static_cast<unsigned>({{field.default_value}}) | 16 {% import 'fields/keyword.tmpl' as keyword %} |
17 {%- endmacro %} | 17 {% import 'fields/flag.tmpl' as flag %} |
| 18 {% import 'fields/monotonic_flag.tmpl' as monotonic_flag %} |
| 19 {% set field_templates = { 'keyword': keyword, 'flag': flag, 'monotonic_flag': m
onotonic_flag } %} |
18 | 20 |
19 namespace blink { | 21 namespace blink { |
20 | 22 |
21 // The generated portion of ComputedStyle. For more info, see the header comment | 23 // The generated portion of ComputedStyle. For more info, see the header comment |
22 // in ComputedStyle.h. | 24 // in ComputedStyle.h. |
23 class CORE_EXPORT ComputedStyleBase { | 25 class CORE_EXPORT ComputedStyleBase { |
24 public: | 26 public: |
25 ALWAYS_INLINE ComputedStyleBase() : | 27 ALWAYS_INLINE ComputedStyleBase() : |
26 {% for field in fields %} | 28 {% for field in fields %} |
27 {{field.name}}({{default_value(field)}}){{print_if(not loop.last, ',')}} | 29 {{field.name}}(static_cast<unsigned>({{field.default_value}})){{print_if(n
ot loop.last, ',')}} |
28 {% endfor %} | 30 {% endfor %} |
29 {} | 31 {} |
30 ~ComputedStyleBase() {} | 32 ~ComputedStyleBase() {} |
31 | 33 |
32 ALWAYS_INLINE ComputedStyleBase(const ComputedStyleBase& o) : | 34 ALWAYS_INLINE ComputedStyleBase(const ComputedStyleBase& o) : |
33 {% for field in fields %} | 35 {% for field in fields %} |
34 {{field.name}}(o.{{field.name}}){{print_if(not loop.last, ',')}} | 36 {{field.name}}(o.{{field.name}}){{print_if(not loop.last, ',')}} |
35 {% endfor %} | 37 {% endfor %} |
36 {} | 38 {} |
37 | 39 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // style that are marked as inherited by this style. | 92 // style that are marked as inherited by this style. |
91 void propagateIndependentInheritedProperties( | 93 void propagateIndependentInheritedProperties( |
92 const ComputedStyleBase& parentStyle); | 94 const ComputedStyleBase& parentStyle); |
93 | 95 |
94 // Fields. | 96 // Fields. |
95 // TODO(sashab): Remove initialFoo() static methods and update callers to | 97 // TODO(sashab): Remove initialFoo() static methods and update callers to |
96 // use resetFoo(), which can be more efficient. | 98 // use resetFoo(), which can be more efficient. |
97 | 99 |
98 {% for field in fields %} | 100 {% for field in fields %} |
99 // {{field.property_name}} | 101 // {{field.property_name}} |
100 inline static {{field.type_name}} {{field.initial_method_name}}() { | 102 {{field_templates[field.field_template].decl_methods(field)|indent(2)}} |
101 return {{field.default_value}}; | |
102 } | |
103 {{field.type_name}} {{field.getter_method_name}}() const { | |
104 return static_cast<{{field.type_name}}>({{field.name}}); | |
105 } | |
106 {% if field.is_nonproperty %} | |
107 void {{field.setter_method_name}}() { | |
108 {{field.name}} = static_cast<unsigned>(true); | |
109 } | |
110 {% else %} | |
111 void {{field.setter_method_name}}({{field.type_name}} v) { | |
112 {{field.name}} = static_cast<unsigned>(v); | |
113 } | |
114 {% endif %} | |
115 inline void {{field.resetter_method_name}}() { | |
116 {{field.name}} = {{default_value(field)}}; | |
117 } | |
118 | 103 |
119 {% endfor %} | 104 {% endfor %} |
120 protected: | 105 protected: |
121 // Storage. | 106 // Storage. |
122 {% for field in fields %} | 107 {% for field in fields %} |
123 unsigned {{field.name}} : {{field.size}}; // {{field.type_name}} | 108 unsigned {{field.name}} : {{field.size}}; // {{field.type_name}} |
124 {% endfor %} | 109 {% endfor %} |
125 }; | 110 }; |
126 | 111 |
127 } // namespace blink | 112 } // namespace blink |
128 | 113 |
129 #endif // ComputedStyleBase_h | 114 #endif // ComputedStyleBase_h |
OLD | NEW |