| 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, get_expr, set_expr %} |
| 3 {% from 'fields/group.tmpl' import def_group %} |
| 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/flag.tmpl' as flag %} | 20 {% import 'fields/flag.tmpl' as flag %} |
| 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 'flag': flag, | 27 'flag': flag, |
| 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 {{get_expr(field)}} == o.{{get_expr(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 {{get_expr(field)}} == o.{{get_expr(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 {{get_expr(field)}} == o.{{get_expr(field)}}{{print_if(not loop.last, '
&&')}} |
| 60 {% endfor %} | 63 {% endfor %} |
| 61 ); | 64 ); |
| 62 } | 65 } |
| 63 | 66 |
| 64 enum IsAtShadowBoundary { | 67 enum IsAtShadowBoundary { |
| 65 AtShadowBoundary, | 68 AtShadowBoundary, |
| 66 NotAtShadowBoundary, | 69 NotAtShadowBoundary, |
| 67 }; | 70 }; |
| 68 void inheritFrom(const ComputedStyleBase& inheritParent, | 71 void inheritFrom(const ComputedStyleBase& inheritParent, |
| 69 IsAtShadowBoundary isAtShadowBoundary = NotAtShadowBoundary); | 72 IsAtShadowBoundary isAtShadowBoundary = NotAtShadowBoundary); |
| 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_methods(field)|indent(2)}} | 87 {{field_templates[field.field_template].decl_methods(field)|indent(2)}} |
| 85 | 88 |
| 86 {% endfor %} | 89 {% endfor %} |
| 90 private: |
| 91 {% for subgroup in computed_style.subgroups %} |
| 92 {{def_group(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 ~ComputedStyleBase() = default; | 109 ~ComputedStyleBase() = default; |
| 97 | 110 |
| 98 // Storage. | 111 // Storage. |
| 99 {% for field in fields %} | 112 {% for subgroup in computed_style.subgroups %} |
| 113 DataRef<{{subgroup.type_name}}> {{subgroup.member_name}}; |
| 114 {% endfor %} |
| 115 |
| 116 {% for field in computed_style.fields %} |
| 100 {% if field.is_bit_field %} | 117 {% if field.is_bit_field %} |
| 101 unsigned {{field.name}} : {{field.size}}; // {{field.type_name}} | 118 unsigned {{field.name}} : {{field.size}}; // {{field.type_name}} |
| 102 {% else %} | 119 {% else %} |
| 103 {{field.type_name}} {{field.name}}; | 120 {{field.type_name}} {{field.name}}; |
| 104 {% endif %} | 121 {% endif %} |
| 105 {% endfor %} | 122 {% endfor %} |
| 106 }; | 123 }; |
| 107 | 124 |
| 108 } // namespace blink | 125 } // namespace blink |
| 109 | 126 |
| 110 #endif // ComputedStyleBase_h | 127 #endif // ComputedStyleBase_h |
| OLD | NEW |