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, setter_expression, declare_storage, fieldwise_compare, fieldwise_copy, fieldwise_diff, fieldwise_p ointer_compare_inherited %} | 2 {% from 'fields/field.tmpl' import encode, getter_expression, setter_expression, declare_storage, fieldwise_compare, fieldwise_copy, fieldwise_diff, fieldwise_p ointer_compare_inherited %} |
3 {% from 'fields/group.tmpl' import define_field_group_class %} | 3 {% from 'fields/group.tmpl' import define_field_group_class %} |
4 {{license()}} | 4 {{license()}} |
5 | 5 |
6 #ifndef ComputedStyleBase_h | 6 #ifndef ComputedStyleBase_h |
7 #define ComputedStyleBase_h | 7 #define ComputedStyleBase_h |
8 | 8 |
9 #include "core/style/ComputedStyleConstants.h" | 9 #include "core/style/ComputedStyleConstants.h" |
10 #include "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 void* dataRefs[{{computed_style.subgroups|length}}]; | 39 void* dataRefs[{{computed_style.subgroups|length}}]; |
40 {% endif %} | 40 {% endif %} |
41 {% for field in computed_style.fields|rejectattr("is_bit_field") %} | 41 {% for field in computed_style.fields|rejectattr("is_bit_field") %} |
42 {{field.type_name}} {{field.name}}; | 42 {{field.type_name}} {{field.name}}; |
43 {% endfor %} | 43 {% endfor %} |
44 unsigned m_bit_fields[{{computed_style.num_32_bit_words_for_bit_fields}}]; | 44 unsigned m_bit_fields[{{computed_style.num_32_bit_words_for_bit_fields}}]; |
45 }; | 45 }; |
46 | 46 |
47 // The generated portion of ComputedStyle. For more info, see the header comment | 47 // The generated portion of ComputedStyle. For more info, see the header comment |
48 // in ComputedStyle.h. | 48 // in ComputedStyle.h. |
49 | 49 // |
50 // ComputedStyleBase is a templated class to allow it to use functions | 50 // ComputedStyleBase is a generated class that stores data members or 'fields' |
51 // on ComputedStyle. This allows ComputedStyleBase to use hand written | 51 // used in ComputedStyle. These fields can represent CSS properties or internal |
52 // functions it would otherwise not know about. | 52 // style information. |
53 // It should only be templated with the ComputedStyle class and no other class | 53 // |
54 // is allowed. | 54 // STORAGE: |
55 // | |
56 // Fields are organised in a tree structure, where a node (called a 'group') | |
57 // stores a set of fields and a set of pointers to child nodes (called | |
58 // 'subgroups'). We can visualise the tree structure with ComputedStyleBase as | |
59 // the root node: | |
60 // | |
61 // ComputedStyleBase (fields: display, vertical-align, ...) | |
62 // |- StyleSurroundData (fields: padding, border, ...) | |
63 // |- StyleBoxData (fields: width, height, ...) | |
64 // |- ... | |
65 // |- StyleRareNonInheritedData (fields: box-shadow, text-overflow, ...) | |
66 // |- StyleFlexibleBoxData (fields: flex-direction, flex-wrap, ...) | |
67 // |- ... | |
68 // | |
69 // This design saves memory by allowing multiple ComputedStyleBases to share the | |
70 // same instance of a subgroup. For example, if a page never uses flex box | |
71 // properties, then every ComputedStyleBase can share the same instance of | |
72 // StyleFlexibleBoxData. Without this sharing, we would need to allocate a copy | |
73 // of all the flex box fields for every ComputedStyleBase. Similarly, when an | |
74 // element inherits from its parent, its ComputedStyleBase can simply share all | |
75 // of its subgroups with the parent's. | |
76 // | |
77 // INTERFACE: | |
78 // | |
79 // The functions generated for a field is determined by its 'template'. For | |
80 // example, a field with the 'keyword' template has only one setter, whereas an | |
81 // 'external' field has an extra setter that takes an rvalue reference. A list | |
82 // of the available templates can be found in CSSProperties.json5. | |
83 // | |
84 // ComputedStyleBase is a template class to allow it to use functions on | |
85 // ComputedStyle. This allows ComputedStyleBase to use hand written functions it | |
86 // would otherwise not know about. It should only be templated with the | |
87 // ComputedStyle class and no other class is allowed. | |
88 // TODO(nainar): Enforce this in code. | |
nainar
2017/05/24 08:08:53
This is done now.
| |
55 template <class ComputedStyleFinal> | 89 template <class ComputedStyleFinal> |
56 class CORE_EXPORT ComputedStyleBase { | 90 class CORE_EXPORT ComputedStyleBase { |
57 public: | 91 public: |
58 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { | 92 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { |
59 return ( | 93 return ( |
60 {{fieldwise_compare(computed_style, computed_style.all_fields | 94 {{fieldwise_compare(computed_style, computed_style.all_fields |
61 |selectattr("is_property") | 95 |selectattr("is_property") |
62 |selectattr("is_inherited") | 96 |selectattr("is_inherited") |
63 |selectattr("is_independent") | 97 |selectattr("is_independent") |
64 |list | 98 |list |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 | 228 |
195 private: | 229 private: |
196 {% for field in computed_style.fields %} | 230 {% for field in computed_style.fields %} |
197 {{declare_storage(field)}} | 231 {{declare_storage(field)}} |
198 {% endfor %} | 232 {% endfor %} |
199 }; | 233 }; |
200 | 234 |
201 } // namespace blink | 235 } // namespace blink |
202 | 236 |
203 #endif // ComputedStyleBase_h | 237 #endif // ComputedStyleBase_h |
OLD | NEW |