Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl

Issue 2886093002: Add class level comments to ComputedStyleBase. (Closed)
Patch Set: Rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 29 matching lines...) Expand all
40 void* dataRefs[{{computed_style.subgroups|length}}]; 40 void* dataRefs[{{computed_style.subgroups|length}}];
41 {% endif %} 41 {% endif %}
42 {% for field in computed_style.fields|rejectattr("is_bit_field") %} 42 {% for field in computed_style.fields|rejectattr("is_bit_field") %}
43 {{field.type_name}} {{field.name}}; 43 {{field.type_name}} {{field.name}};
44 {% endfor %} 44 {% endfor %}
45 unsigned m_bit_fields[{{computed_style.num_32_bit_words_for_bit_fields}}]; 45 unsigned m_bit_fields[{{computed_style.num_32_bit_words_for_bit_fields}}];
46 }; 46 };
47 47
48 // The generated portion of ComputedStyle. For more info, see the header comment 48 // The generated portion of ComputedStyle. For more info, see the header comment
49 // in ComputedStyle.h. 49 // in ComputedStyle.h.
50 50 //
51 // ComputedStyleBase is a templated class to allow it to use functions 51 // ComputedStyleBase is a generated class that stores data members or 'fields'
52 // on ComputedStyle. This allows ComputedStyleBase to use hand written 52 // used in ComputedStyle. These fields can represent CSS properties or internal
53 // functions it would otherwise not know about. 53 // style information.
54 // It should only be templated with the ComputedStyle class and no other class 54 //
55 // is allowed. 55 // STORAGE:
56 //
57 // Fields are organised in a tree structure, where a node (called a 'group')
58 // stores a set of fields and a set of pointers to child nodes (called
59 // 'subgroups'). We can visualise the tree structure with ComputedStyleBase as
60 // the root node:
61 //
62 // ComputedStyleBase (fields: display, vertical-align, ...)
63 // |- StyleSurroundData (fields: padding, border, ...)
64 // |- StyleBoxData (fields: width, height, ...)
65 // |- ...
66 // |- StyleRareNonInheritedData (fields: box-shadow, text-overflow, ...)
67 // |- StyleFlexibleBoxData (fields: flex-direction, flex-wrap, ...)
68 // |- ...
69 //
70 // This design saves memory by allowing multiple ComputedStyleBases to share the
71 // same instance of a subgroup. For example, if a page never uses flex box
72 // properties, then every ComputedStyleBase can share the same instance of
73 // StyleFlexibleBoxData. Without this sharing, we would need to allocate a copy
74 // of all the flex box fields for every ComputedStyleBase. Similarly, when an
75 // element inherits from its parent, its ComputedStyleBase can simply share all
76 // of its subgroups with the parent's.
77 //
78 // INTERFACE:
79 //
80 // The functions generated for a field is determined by its 'template'. For
81 // example, a field with the 'keyword' template has only one setter, whereas an
82 // 'external' field has an extra setter that takes an rvalue reference. A list
83 // of the available templates can be found in CSSProperties.json5.
84 //
85 // ComputedStyleBase is a template class to allow it to use functions on
86 // ComputedStyle. This allows ComputedStyleBase to use hand written functions it
87 // would otherwise not know about. It should only be templated with the
88 // ComputedStyle class and no other class is allowed.
56 template <class ComputedStyleFinal> 89 template <class ComputedStyleFinal>
57 class CORE_EXPORT ComputedStyleBase { 90 class CORE_EXPORT ComputedStyleBase {
58 public: 91 public:
59 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { 92 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const {
60 return ( 93 return (
61 {{fieldwise_compare(computed_style, computed_style.all_fields 94 {{fieldwise_compare(computed_style, computed_style.all_fields
62 |selectattr("is_property") 95 |selectattr("is_property")
63 |selectattr("is_inherited") 96 |selectattr("is_inherited")
64 |selectattr("is_independent") 97 |selectattr("is_independent")
65 |list 98 |list
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 229
197 private: 230 private:
198 {% for field in computed_style.fields %} 231 {% for field in computed_style.fields %}
199 {{declare_storage(field)}} 232 {{declare_storage(field)}}
200 {% endfor %} 233 {% endfor %}
201 }; 234 };
202 235
203 } // namespace blink 236 } // namespace blink
204 237
205 #endif // ComputedStyleBase_h 238 #endif // ComputedStyleBase_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698