1{% from 'templates/macros.tmpl' import license, print_if, source_files_for_generated_file %} 2{% from 'templates/fields/field.tmpl' import encode, getter_expression, setter_expression, fieldwise_copy, fieldwise_diff %} 3{% from 'templates/fields/group.tmpl' import define_field_group_class %} 4{{license()}} 5 6{{source_files_for_generated_file(template_file, input_files)}} 7 8#include "third_party/blink/renderer/core/style/computed_style.h" 9#include "third_party/blink/renderer/core/style/computed_style_base.h" 10#include "third_party/blink/renderer/platform/wtf/size_assertions.h" 11 12namespace blink { 13 14struct SameSizeVerifierForComputedStyleBase { 15 {% if computed_style.subgroups is defined %} 16 void* data_refs[{{computed_style.subgroups|length}}]; 17 {% endif %} 18 {% for field in computed_style.fields|rejectattr("is_bit_field") %} 19 {{field.type_name}} {{field.name}}; 20 {% endfor %} 21 unsigned bit_fields[{{computed_style.num_32_bit_words_for_bit_fields}}]; 22}; 23 24// If this fails, the packing algorithm in make_computed_style_base.py has 25// failed to produce the optimal packed size. To fix, update the algorithm to 26// ensure that the buckets are placed so that each takes up at most 1 word. 27ASSERT_SIZE(ComputedStyleBase, SameSizeVerifierForComputedStyleBase); 28 29// Constructor and destructor are protected so that only the parent class ComputedStyle 30// can instantiate this class. 31ComputedStyleBase::ComputedStyleBase() : 32{% set comma = joiner(", ") %} 33{% for field in computed_style.fields %} 34 {{comma()}}{{field.name}}({{encode(field, field.default_value)}}) 35{% endfor %} 36{ 37 {% for subgroup in computed_style.subgroups %} 38 {{subgroup.member_name}}.Init(); 39 {% endfor %} 40} 41 42void ComputedStyleBase::InheritFrom(const ComputedStyleBase& other, 43 IsAtShadowBoundary isAtShadowBoundary) { 44 {{fieldwise_copy(computed_style, computed_style.all_fields 45 |selectattr("is_property") 46 |selectattr("is_inherited") 47 |list 48 )|indent(2)}} 49} 50 51void ComputedStyleBase::CopyNonInheritedFromCached( 52 const ComputedStyleBase& other) { 53 {{fieldwise_copy(computed_style, computed_style.all_fields 54 |rejectattr("has_custom_compare_and_copy") 55 |rejectattr("is_inherited") 56 |list 57 )|indent(2)}} 58} 59 60void ComputedStyleBase::PropagateIndependentInheritedProperties( 61 const ComputedStyleBase& parentStyle) { 62 {% for field in computed_style.all_fields if field.is_property and field.is_independent %} 63 if ({{field.is_inherited_method_name}}()) 64 {{setter_expression(field)}} = parentStyle.{{getter_expression(field)}}; 65 {% endfor %} 66} 67 68{% for name, groups_to_diff in diff_functions_map.items() %} 69bool ComputedStyleBase::{{name}}(const ComputedStyle& a, const ComputedStyle& b) { 70 {{fieldwise_diff(groups_to_diff)|indent(4)}} 71 return false; 72} 73 74{% endfor %} 75 76{% for group in computed_style.subgroups %} 77{{define_field_group_class(group)}} 78 79{% endfor %} 80 81} // namespace blink 82