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 28 matching lines...) Expand all Loading... |
39 void* dataRefs[{{computed_style.subgroups|length}}]; | 39 void* dataRefs[{{computed_style.subgroups|length}}]; |
40 {% endif %} | 40 {% endif %} |
41 {% for field in computed_style.fields|rejectattr("is_bit_field") %} | 41 {% for field in computed_style.fields|rejectattr("is_bit_field") %} |
42 {{field.type_name}} {{field.name}}; | 42 {{field.type_name}} {{field.name}}; |
43 {% endfor %} | 43 {% endfor %} |
44 unsigned m_bit_fields[{{computed_style.num_32_bit_words_for_bit_fields}}]; | 44 unsigned m_bit_fields[{{computed_style.num_32_bit_words_for_bit_fields}}]; |
45 }; | 45 }; |
46 | 46 |
47 // The generated portion of ComputedStyle. For more info, see the header comment | 47 // The generated portion of ComputedStyle. For more info, see the header comment |
48 // in ComputedStyle.h. | 48 // in ComputedStyle.h. |
| 49 |
| 50 // ComputedStyleBase is a templated class to allow it to use functions |
| 51 // on ComputedStyle. This allows ComputedStyleBase to use hand written |
| 52 // functions it would otherwise not know about. |
| 53 // It should only be templated with the ComputedStyle class and no other class |
| 54 // is allowed. |
| 55 template <class ComputedStyleFinal> |
49 class CORE_EXPORT ComputedStyleBase { | 56 class CORE_EXPORT ComputedStyleBase { |
50 public: | 57 public: |
51 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { | 58 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { |
52 return ( | 59 return ( |
53 {{fieldwise_compare(computed_style, computed_style.all_fields | 60 {{fieldwise_compare(computed_style, computed_style.all_fields |
54 |selectattr("is_property") | 61 |selectattr("is_property") |
55 |selectattr("is_inherited") | 62 |selectattr("is_inherited") |
56 |selectattr("is_independent") | 63 |selectattr("is_independent") |
57 |list | 64 |list |
58 )|indent(8)}} | 65 )|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. | 122 // style that are marked as inherited by this style. |
116 void PropagateIndependentInheritedProperties( | 123 void PropagateIndependentInheritedProperties( |
117 const ComputedStyleBase& parentStyle) { | 124 const ComputedStyleBase& parentStyle) { |
118 {% for field in computed_style.all_fields if field.is_property and field.is_
independent %} | 125 {% for field in computed_style.all_fields if field.is_property and field.is_
independent %} |
119 if ({{field.is_inherited_method_name}}()) | 126 if ({{field.is_inherited_method_name}}()) |
120 {{setter_expression(field)}} = parentStyle.{{getter_expression(field)}}; | 127 {{setter_expression(field)}} = parentStyle.{{getter_expression(field)}}; |
121 {% endfor %} | 128 {% endfor %} |
122 } | 129 } |
123 | 130 |
124 {% for name, groups_to_diff in diff_functions_map.items() %} | 131 {% for name, groups_to_diff in diff_functions_map.items() %} |
125 bool {{name}}(const ComputedStyleBase& other) const { | 132 bool {{name}}(const ComputedStyleFinal& other) const { |
126 {{fieldwise_diff(groups_to_diff)|indent(4)}} | 133 {{fieldwise_diff(groups_to_diff)|indent(4)}} |
127 return false; | 134 return false; |
128 } | 135 } |
129 {% endfor %} | 136 {% endfor %} |
130 | 137 |
131 // Fields. | 138 // Fields. |
132 // TODO(sashab): Remove initialFoo() static methods and update callers to | 139 // TODO(sashab): Remove initialFoo() static methods and update callers to |
133 // use resetFoo(), which can be more efficient. | 140 // use resetFoo(), which can be more efficient. |
134 | 141 |
135 {% for field in computed_style.all_fields %} | 142 {% 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) * | 183 return static_cast<unsigned>(std::min<float>(width, kMaxForBorderWidth) * |
177 kBorderWidthDenominator); | 184 kBorderWidthDenominator); |
178 } | 185 } |
179 | 186 |
180 private: | 187 private: |
181 {% for field in computed_style.fields %} | 188 {% for field in computed_style.fields %} |
182 {{declare_storage(field)}} | 189 {{declare_storage(field)}} |
183 {% endfor %} | 190 {% endfor %} |
184 }; | 191 }; |
185 | 192 |
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 | |
191 } // namespace blink | 193 } // namespace blink |
192 | 194 |
193 #endif // ComputedStyleBase_h | 195 #endif // ComputedStyleBase_h |
OLD | NEW |