OLD | NEW |
1 {% from 'macros.tmpl' import license %} | 1 {% from 'macros.tmpl' import license %} |
2 {% from 'fields/field.tmpl' import getter_expression, setter_expression %} | 2 {% from 'fields/field.tmpl' import getter_expression, setter_expression, fieldwi
se_copy %} |
3 {{license()}} | 3 {{license()}} |
4 | 4 |
5 #include "core/ComputedStyleBase.h" | 5 #include "core/ComputedStyleBase.h" |
6 #include "platform/wtf/SizeAssertions.h" | 6 #include "platform/wtf/SizeAssertions.h" |
7 | 7 |
8 namespace blink { | 8 namespace blink { |
9 | 9 |
10 struct SameSizeAsComputedStyleBase { | 10 struct SameSizeAsComputedStyleBase { |
11 {% if computed_style.subgroups is defined %} | 11 {% if computed_style.subgroups is defined %} |
12 void* dataRefs[{{computed_style.subgroups|length}}]; | 12 void* dataRefs[{{computed_style.subgroups|length}}]; |
13 {% endif %} | 13 {% endif %} |
14 {% for field in computed_style.fields|rejectattr("is_bit_field") %} | 14 {% for field in computed_style.fields|rejectattr("is_bit_field") %} |
15 {{field.type_name}} {{field.name}}}; | 15 {{field.type_name}} {{field.name}}}; |
16 {% endfor %} | 16 {% endfor %} |
17 unsigned m_bit_fields[{{computed_style.num_32_bit_words_for_bit_fields}}]; | 17 unsigned m_bit_fields[{{computed_style.num_32_bit_words_for_bit_fields}}]; |
18 }; | 18 }; |
19 | 19 |
20 // If this fails, the packing algorithm in make_computed_style_base.py has | 20 // If this fails, the packing algorithm in make_computed_style_base.py has |
21 // failed to produce the optimal packed size. To fix, update the algorithm to | 21 // failed to produce the optimal packed size. To fix, update the algorithm to |
22 // ensure that the buckets are placed so that each takes up at most 1 word. | 22 // ensure that the buckets are placed so that each takes up at most 1 word. |
23 ASSERT_SIZE(ComputedStyleBase, SameSizeAsComputedStyleBase); | 23 ASSERT_SIZE(ComputedStyleBase, SameSizeAsComputedStyleBase); |
24 | 24 |
25 void ComputedStyleBase::InheritFrom(const ComputedStyleBase& inheritParent, | 25 void ComputedStyleBase::InheritFrom(const ComputedStyleBase& other, |
26 IsAtShadowBoundary isAtShadowBoundary) { | 26 IsAtShadowBoundary isAtShadowBoundary) { |
27 {% for field in computed_style.all_fields if field.is_inherited %} | 27 {{fieldwise_copy(computed_style, computed_style.all_fields |
28 {{setter_expression(field)}} = inheritParent.{{getter_expression(field)}}; | 28 |selectattr("is_inherited") |
29 {% endfor %} | 29 |list |
| 30 )|indent(2)}} |
30 } | 31 } |
31 | 32 |
32 void ComputedStyleBase::CopyNonInheritedFromCached( | 33 void ComputedStyleBase::CopyNonInheritedFromCached( |
33 const ComputedStyleBase& other) { | 34 const ComputedStyleBase& other) { |
34 {% for field in computed_style.all_fields if (field.is_property and not field.
is_inherited) or field.is_inherited_flag %} | 35 {{fieldwise_copy(computed_style, computed_style.all_fields |
35 {{setter_expression(field)}} = other.{{getter_expression(field)}}; | 36 |rejectattr("is_nonproperty") |
36 {% endfor %} | 37 |rejectattr("is_inherited") |
| 38 |list |
| 39 )|indent(2)}} |
37 } | 40 } |
38 | 41 |
39 void ComputedStyleBase::PropagateIndependentInheritedProperties( | 42 void ComputedStyleBase::PropagateIndependentInheritedProperties( |
40 const ComputedStyleBase& parentStyle) { | 43 const ComputedStyleBase& parentStyle) { |
41 {% for field in computed_style.all_fields if field.is_property and field.is_in
dependent %} | 44 {% for field in computed_style.all_fields if field.is_property and field.is_in
dependent %} |
42 if ({{field.is_inherited_method_name}}()) | 45 if ({{field.is_inherited_method_name}}()) |
43 {{setter_expression(field)}} = parentStyle.{{getter_expression(field)}}; | 46 {{setter_expression(field)}} = parentStyle.{{getter_expression(field)}}; |
44 {% endfor %} | 47 {% endfor %} |
45 } | 48 } |
46 | 49 |
47 } // namespace blink | 50 } // namespace blink |
OLD | NEW |