Chromium Code Reviews| 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 | |
|
alancutter (OOO until 2018)
2017/05/12 07:06:22
This should be clearer that this may only be templ
nainar
2017/05/12 07:31:33
Done.
| |
| 51 // on ComputedStyle. This allows us to diff functions on ComputedStyle that | |
|
alancutter (OOO until 2018)
2017/05/12 07:06:22
*This allows ComputedStyleBase to use hand written
nainar
2017/05/12 07:31:33
Done.
| |
| 52 // ComputedStyleBase would otherwise not know about. | |
| 53 template <class ComputedStyleFinal> | |
| 49 class CORE_EXPORT ComputedStyleBase { | 54 class CORE_EXPORT ComputedStyleBase { |
| 50 public: | 55 public: |
| 51 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { | 56 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { |
| 52 return ( | 57 return ( |
| 53 {{fieldwise_compare(computed_style, computed_style.all_fields | 58 {{fieldwise_compare(computed_style, computed_style.all_fields |
| 54 |selectattr("is_property") | 59 |selectattr("is_property") |
| 55 |selectattr("is_inherited") | 60 |selectattr("is_inherited") |
| 56 |selectattr("is_independent") | 61 |selectattr("is_independent") |
| 57 |list | 62 |list |
| 58 )|indent(8)}} | 63 )|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. | 120 // style that are marked as inherited by this style. |
| 116 void PropagateIndependentInheritedProperties( | 121 void PropagateIndependentInheritedProperties( |
| 117 const ComputedStyleBase& parentStyle) { | 122 const ComputedStyleBase& parentStyle) { |
| 118 {% for field in computed_style.all_fields if field.is_property and field.is_ independent %} | 123 {% for field in computed_style.all_fields if field.is_property and field.is_ independent %} |
| 119 if ({{field.is_inherited_method_name}}()) | 124 if ({{field.is_inherited_method_name}}()) |
| 120 {{setter_expression(field)}} = parentStyle.{{getter_expression(field)}}; | 125 {{setter_expression(field)}} = parentStyle.{{getter_expression(field)}}; |
| 121 {% endfor %} | 126 {% endfor %} |
| 122 } | 127 } |
| 123 | 128 |
| 124 {% for name, groups_to_diff in diff_functions_map.items() %} | 129 {% for name, groups_to_diff in diff_functions_map.items() %} |
| 125 bool {{name}}(const ComputedStyleBase& other) const { | 130 bool {{name}}(const ComputedStyleFinal& other) const { |
| 126 {{fieldwise_diff(groups_to_diff)|indent(2)}} | 131 {{fieldwise_diff(groups_to_diff)|indent(2)}} |
| 127 return false; | 132 return false; |
| 128 } | 133 } |
| 129 {% endfor %} | 134 {% endfor %} |
| 130 | 135 |
| 131 // Fields. | 136 // Fields. |
| 132 // TODO(sashab): Remove initialFoo() static methods and update callers to | 137 // TODO(sashab): Remove initialFoo() static methods and update callers to |
| 133 // use resetFoo(), which can be more efficient. | 138 // use resetFoo(), which can be more efficient. |
| 134 | 139 |
| 135 {% for field in computed_style.all_fields %} | 140 {% 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) * | 181 return static_cast<unsigned>(std::min<float>(width, kMaxForBorderWidth) * |
| 177 kBorderWidthDenominator); | 182 kBorderWidthDenominator); |
| 178 } | 183 } |
| 179 | 184 |
| 180 private: | 185 private: |
| 181 {% for field in computed_style.fields %} | 186 {% for field in computed_style.fields %} |
| 182 {{declare_storage(field)}} | 187 {{declare_storage(field)}} |
| 183 {% endfor %} | 188 {% endfor %} |
| 184 }; | 189 }; |
| 185 | 190 |
| 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 | 191 } // namespace blink |
| 192 | 192 |
| 193 #endif // ComputedStyleBase_h | 193 #endif // ComputedStyleBase_h |
| OLD | NEW |