| 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, declare_storage %} |
| 3 {% from 'fields/group.tmpl' import define_field_group_class %} |
| 2 {{license()}} | 4 {{license()}} |
| 3 | 5 |
| 4 #ifndef ComputedStyleBase_h | 6 #ifndef ComputedStyleBase_h |
| 5 #define ComputedStyleBase_h | 7 #define ComputedStyleBase_h |
| 6 | 8 |
| 7 #include "core/style/ComputedStyleConstants.h" | 9 #include "core/style/ComputedStyleConstants.h" |
| 8 #include "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
| 11 #include "core/style/DataRef.h" |
| 9 {% for path in include_paths %} | 12 {% for path in include_paths %} |
| 10 #include "{{path}}" | 13 #include "{{path}}" |
| 11 {% endfor %} | 14 {% endfor %} |
| 12 | 15 |
| 13 {# Each field template has macros that we can call to generate specific | 16 {# Each field template has macros that we can call to generate specific |
| 14 aspects of the field (e.g. getters, setters). | 17 aspects of the field (e.g. getters, setters). |
| 15 #} | 18 #} |
| 16 {% import 'fields/keyword.tmpl' as keyword %} | 19 {% import 'fields/keyword.tmpl' as keyword %} |
| 17 {% import 'fields/primitive.tmpl' as primitive %} | 20 {% import 'fields/primitive.tmpl' as primitive %} |
| 18 {% import 'fields/monotonic_flag.tmpl' as monotonic_flag %} | 21 {% import 'fields/monotonic_flag.tmpl' as monotonic_flag %} |
| 19 {% import 'fields/storage_only.tmpl' as storage_only %} | 22 {% import 'fields/storage_only.tmpl' as storage_only %} |
| 20 {% import 'fields/external.tmpl' as external %} | 23 {% import 'fields/external.tmpl' as external %} |
| 21 {% from 'fields/field.tmpl' import encode %} | 24 {% from 'fields/field.tmpl' import encode %} |
| 22 {% set field_templates = { | 25 {% set field_templates = { |
| 23 'keyword': keyword, | 26 'keyword': keyword, |
| 24 'primitive': primitive, | 27 'primitive': primitive, |
| 25 'monotonic_flag': monotonic_flag, | 28 'monotonic_flag': monotonic_flag, |
| 26 'storage_only': storage_only, | 29 'storage_only': storage_only, |
| 27 'external': external | 30 'external': external |
| 28 } %} | 31 } %} |
| 29 | 32 |
| 30 namespace blink { | 33 namespace blink { |
| 31 | 34 |
| 32 // The generated portion of ComputedStyle. For more info, see the header comment | 35 // The generated portion of ComputedStyle. For more info, see the header comment |
| 33 // in ComputedStyle.h. | 36 // in ComputedStyle.h. |
| 34 class CORE_EXPORT ComputedStyleBase { | 37 class CORE_EXPORT ComputedStyleBase { |
| 35 public: | 38 public: |
| 36 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { | 39 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { |
| 37 return ( | 40 return ( |
| 38 {% for field in fields if field.is_inherited and field.is_independent %} | 41 {% for field in computed_style.all_fields if field.is_inherited and field.is
_independent %} |
| 39 {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}} | 42 {{getter_expression(field)}} == o.{{getter_expression(field)}}{{print_if
(not loop.last, ' &&')}} |
| 40 {% endfor %} | 43 {% endfor %} |
| 41 ); | 44 ); |
| 42 } | 45 } |
| 43 | 46 |
| 44 inline bool NonIndependentInheritedEqual(const ComputedStyleBase& o) const { | 47 inline bool NonIndependentInheritedEqual(const ComputedStyleBase& o) const { |
| 45 return ( | 48 return ( |
| 46 {% for field in fields if field.is_inherited and not field.is_independent %} | 49 {% for field in computed_style.all_fields if field.is_inherited and not fiel
d.is_independent %} |
| 47 {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}} | 50 {{getter_expression(field)}} == o.{{getter_expression(field)}}{{print_if
(not loop.last, ' &&')}} |
| 48 {% endfor %} | 51 {% endfor %} |
| 49 ); | 52 ); |
| 50 } | 53 } |
| 51 | 54 |
| 52 inline bool InheritedEqual(const ComputedStyleBase& o) const { | 55 inline bool InheritedEqual(const ComputedStyleBase& o) const { |
| 53 return IndependentInheritedEqual(o) && NonIndependentInheritedEqual(o); | 56 return IndependentInheritedEqual(o) && NonIndependentInheritedEqual(o); |
| 54 } | 57 } |
| 55 | 58 |
| 56 inline bool NonInheritedEqual(const ComputedStyleBase& o) const { | 59 inline bool NonInheritedEqual(const ComputedStyleBase& o) const { |
| 57 return ( | 60 return ( |
| 58 {% for field in fields if field.is_property and not field.is_inherited %} | 61 {% for field in computed_style.all_fields if field.is_property and not field
.is_inherited %} |
| 59 {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}} | 62 {{getter_expression(field)}} == o.{{getter_expression(field)}}{{print_if
(not loop.last, ' &&')}} |
| 60 {% endfor %} | 63 {% endfor %} |
| 61 ); | 64 ); |
| 62 } | 65 } |
| 63 | 66 |
| 64 enum IsAtShadowBoundary { | 67 enum IsAtShadowBoundary { |
| 65 kAtShadowBoundary, | 68 kAtShadowBoundary, |
| 66 kNotAtShadowBoundary, | 69 kNotAtShadowBoundary, |
| 67 }; | 70 }; |
| 68 void InheritFrom(const ComputedStyleBase& inheritParent, | 71 void InheritFrom(const ComputedStyleBase& inheritParent, |
| 69 IsAtShadowBoundary isAtShadowBoundary = kNotAtShadowBoundary)
; | 72 IsAtShadowBoundary isAtShadowBoundary = kNotAtShadowBoundary)
; |
| 70 | 73 |
| 71 void CopyNonInheritedFromCached(const ComputedStyleBase& other); | 74 void CopyNonInheritedFromCached(const ComputedStyleBase& other); |
| 72 | 75 |
| 73 // Copies the values of any independent inherited properties from the parent | 76 // Copies the values of any independent inherited properties from the parent |
| 74 // style that are marked as inherited by this style. | 77 // style that are marked as inherited by this style. |
| 75 void PropagateIndependentInheritedProperties( | 78 void PropagateIndependentInheritedProperties( |
| 76 const ComputedStyleBase& parentStyle); | 79 const ComputedStyleBase& parentStyle); |
| 77 | 80 |
| 78 // Fields. | 81 // Fields. |
| 79 // TODO(sashab): Remove initialFoo() static methods and update callers to | 82 // TODO(sashab): Remove initialFoo() static methods and update callers to |
| 80 // use resetFoo(), which can be more efficient. | 83 // use resetFoo(), which can be more efficient. |
| 81 | 84 |
| 82 {% for field in fields %} | 85 {% for field in computed_style.all_fields %} |
| 83 // {{field.property_name}} | 86 // {{field.property_name}} |
| 84 {{field_templates[field.field_template].decl_public_methods(field)|indent(2)}} | 87 {{field_templates[field.field_template].decl_public_methods(field)|indent(2)}} |
| 85 | 88 |
| 86 {% endfor %} | 89 {% endfor %} |
| 90 private: |
| 91 {% for subgroup in computed_style.subgroups %} |
| 92 {{define_field_group_class(subgroup)|indent(2)}} |
| 93 |
| 94 {% endfor %} |
| 95 |
| 87 protected: | 96 protected: |
| 88 // Constructor and destructor are protected so that only the parent class Comp
utedStyle | 97 // Constructor and destructor are protected so that only the parent class Comp
utedStyle |
| 89 // can instantiate this class. | 98 // can instantiate this class. |
| 90 ALWAYS_INLINE ComputedStyleBase() : | 99 ALWAYS_INLINE ComputedStyleBase() : |
| 91 {% for field in fields %} | 100 {% for field in computed_style.fields %} |
| 92 {{field.name}}({{encode(field, field.default_value)}}){{print_if(not loop.
last, ',')}} | 101 {{field.name}}({{encode(field, field.default_value)}}){{print_if(not loop.
last, ',')}} |
| 93 {% endfor %} | 102 {% endfor %} |
| 94 {} | 103 { |
| 104 {% for subgroup in computed_style.subgroups %} |
| 105 {{subgroup.member_name}}.Init(); |
| 106 {% endfor %} |
| 107 } |
| 95 | 108 |
| 96 {% for field in fields %} | 109 {% for field in computed_style.fields %} |
| 97 {% if field.field_template in ('storage_only', 'monotonic_flag', 'external') %
} | 110 {% if field.field_template in ('storage_only', 'monotonic_flag', 'external') %
} |
| 98 // {{field.property_name}} | 111 // {{field.property_name}} |
| 99 {{field_templates[field.field_template].decl_protected_methods(field)|indent(2
)}} | 112 {{field_templates[field.field_template].decl_protected_methods(field)|indent(2
)}} |
| 100 | 113 |
| 101 {% endif %} | 114 {% endif %} |
| 102 {% endfor %} | 115 {% endfor %} |
| 103 | 116 |
| 104 ~ComputedStyleBase() = default; | 117 ~ComputedStyleBase() = default; |
| 105 | 118 |
| 119 // Storage. |
| 120 {% for subgroup in computed_style.subgroups %} |
| 121 DataRef<{{subgroup.type_name}}> {{subgroup.member_name}}; |
| 122 {% endfor %} |
| 123 |
| 106 private: | 124 private: |
| 107 // Storage. | 125 {% for field in computed_style.fields %} |
| 108 {% for field in fields %} | 126 {{declare_storage(field)}} |
| 109 {% if field.is_bit_field %} | |
| 110 unsigned {{field.name}} : {{field.size}}; // {{field.type_name}} | |
| 111 {% else %} | |
| 112 {{field.type_name}} {{field.name}}; | |
| 113 {% endif %} | |
| 114 {% endfor %} | 127 {% endfor %} |
| 115 }; | 128 }; |
| 116 | 129 |
| 117 } // namespace blink | 130 } // namespace blink |
| 118 | 131 |
| 119 #endif // ComputedStyleBase_h | 132 #endif // ComputedStyleBase_h |
| OLD | NEW |