| {% from 'macros.tmpl' import license, print_if %} |
| {% from 'fields/field.tmpl' import encode, getter_expression, declare_storage, fieldwise_compare %} |
| {% from 'fields/group.tmpl' import define_field_group_class %} |
| {{license()}} |
| |
| #ifndef ComputedStyleBase_h |
| #define ComputedStyleBase_h |
| |
| #include "core/style/ComputedStyleConstants.h" |
| #include "core/CoreExport.h" |
| #include "core/style/DataRef.h" |
| {% for path in include_paths %} |
| #include "{{path}}" |
| {% endfor %} |
| |
| {# Each field template has macros that we can call to generate specific |
| aspects of the field (e.g. getters, setters). |
| #} |
| {% import 'fields/keyword.tmpl' as keyword %} |
| {% import 'fields/primitive.tmpl' as primitive %} |
| {% import 'fields/monotonic_flag.tmpl' as monotonic_flag %} |
| {% import 'fields/storage_only.tmpl' as storage_only %} |
| {% import 'fields/external.tmpl' as external %} |
| {% from 'fields/field.tmpl' import encode %} |
| {% set field_templates = { |
| 'keyword': keyword, |
| 'primitive': primitive, |
| 'monotonic_flag': monotonic_flag, |
| 'storage_only': storage_only, |
| 'external': external |
| } %} |
| |
| namespace blink { |
| |
| // The generated portion of ComputedStyle. For more info, see the header comment |
| // in ComputedStyle.h. |
| class CORE_EXPORT ComputedStyleBase { |
| public: |
| inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { |
| return ( |
| {{fieldwise_compare(computed_style, computed_style.all_fields |
| |selectattr("is_inherited") |
| |selectattr("is_independent") |
| |list |
| )|indent(8)}} |
| true |
| ); |
| } |
| |
| inline bool NonIndependentInheritedEqual(const ComputedStyleBase& o) const { |
| return ( |
| {{fieldwise_compare(computed_style, computed_style.all_fields |
| |selectattr("is_inherited") |
| |rejectattr("is_independent") |
| |list |
| )|indent(8)}} |
| true |
| ); |
| } |
| |
| inline bool InheritedEqual(const ComputedStyleBase& o) const { |
| return IndependentInheritedEqual(o) && NonIndependentInheritedEqual(o); |
| } |
| |
| inline bool NonInheritedEqual(const ComputedStyleBase& o) const { |
| return ( |
| {{fieldwise_compare(computed_style, computed_style.all_fields |
| |selectattr("is_property") |
| |rejectattr("is_inherited") |
| |list |
| )|indent(8)}} |
| true |
| ); |
| } |
| |
| enum IsAtShadowBoundary { |
| kAtShadowBoundary, |
| kNotAtShadowBoundary, |
| }; |
| void InheritFrom(const ComputedStyleBase& inheritParent, |
| IsAtShadowBoundary isAtShadowBoundary = kNotAtShadowBoundary); |
| |
| void CopyNonInheritedFromCached(const ComputedStyleBase& other); |
| |
| // Copies the values of any independent inherited properties from the parent |
| // style that are marked as inherited by this style. |
| void PropagateIndependentInheritedProperties( |
| const ComputedStyleBase& parentStyle); |
| |
| // Fields. |
| // TODO(sashab): Remove initialFoo() static methods and update callers to |
| // use resetFoo(), which can be more efficient. |
| |
| {% for field in computed_style.all_fields %} |
| // {{field.property_name}} |
| {{field_templates[field.field_template].decl_public_methods(field)|indent(2)}} |
| |
| {% endfor %} |
| private: |
| {% for subgroup in computed_style.subgroups %} |
| {{define_field_group_class(subgroup)|indent(2)}} |
| |
| {% endfor %} |
| |
| protected: |
| // Constructor and destructor are protected so that only the parent class ComputedStyle |
| // can instantiate this class. |
| ALWAYS_INLINE ComputedStyleBase() : |
| {% for field in computed_style.fields %} |
| {{field.name}}({{encode(field, field.default_value)}}){{print_if(not loop.last, ',')}} |
| {% endfor %} |
| { |
| {% for subgroup in computed_style.subgroups %} |
| {{subgroup.member_name}}.Init(); |
| {% endfor %} |
| } |
| |
| {% for field in computed_style.fields %} |
| {% if field.field_template in ('storage_only', 'monotonic_flag', 'external') %} |
| // {{field.property_name}} |
| {{field_templates[field.field_template].decl_protected_methods(field)|indent(2)}} |
| |
| {% endif %} |
| {% endfor %} |
| |
| ~ComputedStyleBase() = default; |
| |
| // Storage. |
| {% for subgroup in computed_style.subgroups %} |
| DataRef<{{subgroup.type_name}}> {{subgroup.member_name}}; |
| {% endfor %} |
| |
| private: |
| {% for field in computed_style.fields %} |
| {{declare_storage(field)}} |
| {% endfor %} |
| }; |
| |
| } // namespace blink |
| |
| #endif // ComputedStyleBase_h |