OLD | NEW |
---|---|
1 {% from 'macros.tmpl' import license, print_if %} | 1 {% from 'macros.tmpl' import license, print_if %} |
2 {% from 'fields/field.tmpl' import encode, getter_expression, setter_expression, declare_storage, fieldwise_compare, fieldwise_copy, fieldwise_diff %} | 2 {% from 'fields/field.tmpl' import encode, getter_expression, setter_expression, declare_storage, fieldwise_compare, fieldwise_copy, fieldwise_diff %} |
3 {% from 'fields/group.tmpl' import define_field_group_class %} | 3 {% from 'fields/group.tmpl' import define_field_group_class %} |
4 {{license()}} | 4 {{license()}} |
5 | 5 |
6 #ifndef ComputedStyleBase_h | 6 #ifndef ComputedStyleBase_h |
7 #define ComputedStyleBase_h | 7 #define ComputedStyleBase_h |
8 | 8 |
9 #include "core/style/ComputedStyleConstants.h" | 9 #include "core/style/ComputedStyleConstants.h" |
10 #include "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
27 {% set field_templates = { | 27 {% set field_templates = { |
28 'keyword': keyword, | 28 'keyword': keyword, |
29 'primitive': primitive, | 29 'primitive': primitive, |
30 'monotonic_flag': monotonic_flag, | 30 'monotonic_flag': monotonic_flag, |
31 'storage_only': storage_only, | 31 'storage_only': storage_only, |
32 'external': external | 32 'external': external |
33 } %} | 33 } %} |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
37 struct SameSizeAsComputedStyleBase { | |
38 {% if computed_style.subgroups is defined %} | |
39 void* dataRefs[{{computed_style.subgroups|length}}]; | |
40 {% endif %} | |
41 {% for field in computed_style.fields|rejectattr("is_bit_field") %} | |
42 {{field.type_name}} {{field.name}}; | |
43 {% endfor %} | |
44 unsigned m_bit_fields[{{computed_style.num_32_bit_words_for_bit_fields}}]; | |
45 }; | |
46 | |
47 // The generated portion of ComputedStyle. For more info, see the header comment | 37 // The generated portion of ComputedStyle. For more info, see the header comment |
48 // in ComputedStyle.h. | 38 // in ComputedStyle.h. |
39 template <class T> | |
alancutter (OOO until 2018)
2017/05/12 06:45:43
Rename T to ComputedStyleFinal or something simila
nainar
2017/05/12 06:59:18
Done.
| |
49 class CORE_EXPORT ComputedStyleBase { | 40 class CORE_EXPORT ComputedStyleBase { |
50 public: | 41 public: |
51 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { | 42 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { |
52 return ( | 43 return ( |
53 {{fieldwise_compare(computed_style, computed_style.all_fields | 44 {{fieldwise_compare(computed_style, computed_style.all_fields |
54 |selectattr("is_property") | 45 |selectattr("is_property") |
55 |selectattr("is_inherited") | 46 |selectattr("is_inherited") |
56 |selectattr("is_independent") | 47 |selectattr("is_independent") |
57 |list | 48 |list |
58 )|indent(8)}} | 49 )|indent(8)}} |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 // style that are marked as inherited by this style. | 106 // style that are marked as inherited by this style. |
116 void PropagateIndependentInheritedProperties( | 107 void PropagateIndependentInheritedProperties( |
117 const ComputedStyleBase& parentStyle) { | 108 const ComputedStyleBase& parentStyle) { |
118 {% for field in computed_style.all_fields if field.is_property and field.is_ independent %} | 109 {% for field in computed_style.all_fields if field.is_property and field.is_ independent %} |
119 if ({{field.is_inherited_method_name}}()) | 110 if ({{field.is_inherited_method_name}}()) |
120 {{setter_expression(field)}} = parentStyle.{{getter_expression(field)}}; | 111 {{setter_expression(field)}} = parentStyle.{{getter_expression(field)}}; |
121 {% endfor %} | 112 {% endfor %} |
122 } | 113 } |
123 | 114 |
124 {% for name, groups_to_diff in diff_functions_map.items() %} | 115 {% for name, groups_to_diff in diff_functions_map.items() %} |
125 bool {{name}}(const ComputedStyleBase& other) const { | 116 bool {{name}}(const T& other) const { |
126 {{fieldwise_diff(groups_to_diff)|indent(2)}} | 117 {{fieldwise_diff(groups_to_diff)|indent(2)}} |
127 return false; | 118 return false; |
128 } | 119 } |
129 {% endfor %} | 120 {% endfor %} |
130 | 121 |
131 // Fields. | 122 // Fields. |
132 // TODO(sashab): Remove initialFoo() static methods and update callers to | 123 // TODO(sashab): Remove initialFoo() static methods and update callers to |
133 // use resetFoo(), which can be more efficient. | 124 // use resetFoo(), which can be more efficient. |
134 | 125 |
135 {% for field in computed_style.all_fields %} | 126 {% for field in computed_style.all_fields %} |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 return static_cast<unsigned>(std::min<float>(width, kMaxForBorderWidth) * | 167 return static_cast<unsigned>(std::min<float>(width, kMaxForBorderWidth) * |
177 kBorderWidthDenominator); | 168 kBorderWidthDenominator); |
178 } | 169 } |
179 | 170 |
180 private: | 171 private: |
181 {% for field in computed_style.fields %} | 172 {% for field in computed_style.fields %} |
182 {{declare_storage(field)}} | 173 {{declare_storage(field)}} |
183 {% endfor %} | 174 {% endfor %} |
184 }; | 175 }; |
185 | 176 |
186 // If this fails, the packing algorithm in make_computed_style_base.py has | |
187 // failed to produce the optimal packed size. To fix, update the algorithm to | |
188 // ensure that the buckets are placed so that each takes up at most 1 word. | |
189 ASSERT_SIZE(ComputedStyleBase, SameSizeAsComputedStyleBase); | |
190 | |
alancutter (OOO until 2018)
2017/05/12 06:45:42
Put this in ComputedStyle.h
nainar
2017/05/12 06:59:18
Done. Removed the CL description too
| |
191 } // namespace blink | 177 } // namespace blink |
192 | 178 |
193 #endif // ComputedStyleBase_h | 179 #endif // ComputedStyleBase_h |
OLD | NEW |