1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
{% from 'templates/fields/field.tmpl' import encode, declare_storage, compare, group_source_expression, field_source_expression %}
{% from 'templates/macros.tmpl' import print_if %}
{% macro declare_field_group_class(group): -%}
{% for subgroup in group.subgroups %}
{{declare_field_group_class(subgroup)}}
{% endfor %}
class {{group.type_name}} : public GarbageCollected<{{group.type_name}}> {
public:
explicit {{group.type_name}}();
CORE_EXPORT {{group.type_name}}(const {{group.type_name}}&);
static {{group.type_name}}* Create() {
return MakeGarbageCollected<{{group.type_name}}>();
}
{{group.type_name}}* Copy() const {
return MakeGarbageCollected<{{group.type_name}}>(*this);
}
{% if group.all_fields|selectattr("is_inherited")|list|length > 0 and
group.all_fields|rejectattr("is_inherited")|list|length > 0 %}
{{ ("You have a subgroup that contain both inherited and non-inherited"
"members. While the code still supports this for now, it is problematic"
"for performance, and you should not do it unless you are certain"
"it will not affect benchmarks and memory usage negatively."
"This line crashes Jinja on purpose, so that you can consider.")/0 }}
// Used when constructing ComputedStyleBase, since this group contains
// both inherited and non-inherited members.
CORE_EXPORT {{group.type_name}}(const {{group.type_name}}& source_for_noninherited,
const {{group.type_name}}& parent_style) :
{% set comma = joiner(", ") %}
{% for subgroup in group.subgroups %}
{{comma()}}{{subgroup.member_name}}({{group_source_expression(subgroup, 'source_for_noninherited', 'parent_style')}})
{% endfor %}
{% for field in group.fields %}
{{comma()}}{{field.name}}({{field_source_expression(field, 'source_for_noninherited', 'parent_style')}})
{% endfor %}
{}
{% endif %}
CORE_EXPORT void Trace(Visitor* visitor) const {
{% for subgroup in group.subgroups %}
visitor->Trace({{subgroup.member_name}});
{% endfor %}
{% for field in group.fields %}
{% if field.wrapper_pointer_name == 'Member' %}
visitor->Trace({{field.name}});
{% elif not field.size and not field.wrapper_pointer_name %}
TraceIfNeeded<{{field.type_name}}>::Trace(visitor, {{field.name}});
{% endif %}
{% endfor %}
}
bool operator==(const {{group.type_name}}& other) const {
return (true
{% for subgroup in group.subgroups %}
&& base::ValuesEquivalent({{subgroup.member_name}}, other.{{subgroup.member_name}})
{% endfor %}
{% for field in group.fields if not field.custom_compare %}
&& {{compare(field.wrapper_pointer_name, field.name, "other")}}
{% endfor %}
);
}
bool operator!=(const {{group.type_name}}& other) const { return !(*this == other); }
{% for subgroup in group.subgroups %}
Member<{{subgroup.type_name}}> {{subgroup.member_name}};
{% endfor %}
{% for field in group.fields %}
{{declare_storage(field)}}
{% endfor %}
};
{%- endmacro %}
{% macro define_field_group_class(group): -%}
{% for subgroup in group.subgroups %}
{{define_field_group_class(subgroup)}}
{% endfor %}
ComputedStyleBase::{{group.type_name}}::{{group.type_name}}() {{print_if(group.fields|length > 0 or group.subgroups|length > 0, ':')}}
{% set comma = joiner(", ") %}
{% for subgroup in group.subgroups %}
{{comma()}}{{subgroup.member_name}}({{subgroup.type_name}}::Create())
{% endfor %}
{% for field in group.fields %}
{{comma()}}{{field.name}}({{encode(field, field.default_value)}})
{% endfor %}
{}
ComputedStyleBase::{{group.type_name}}::{{group.type_name}}(const {{group.type_name}}& other) :
{% set comma = joiner(", ") %}
{% for subgroup in group.subgroups %}
{{comma()}}{{subgroup.member_name}}(other.{{subgroup.member_name}})
{% endfor %}
{% for field in group.fields %}
{% if field.wrapper_pointer_name %}
{{comma()}}{{field.name}}(MemberCopy(other.{{field.name}}))
{% else %}
{{comma()}}{{field.name}}(other.{{field.name}})
{% endif %}
{% endfor %}
{}
{%- endmacro %}
|