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

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, 7 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 %} 2 {% from 'fields/field.tmpl' import encode, getter_expression, setter_expression, declare_storage, fieldwise_compare, fieldwise_copy, fieldwise_diff %}
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
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 children nodes (called
suzyh_UTC10 (ex-contributor) 2017/05/19 02:33:59 Nit: I think the usual phrasing would be "child no
shend 2017/05/22 01:42:23 Done.
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 groups to share the same
suzyh_UTC10 (ex-contributor) 2017/05/19 02:33:59 Is the sharing by multiple groups within one Compu
shend 2017/05/22 01:42:23 Done.
70 // 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.
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 220
187 private: 221 private:
188 {% for field in computed_style.fields %} 222 {% for field in computed_style.fields %}
189 {{declare_storage(field)}} 223 {{declare_storage(field)}}
190 {% endfor %} 224 {% endfor %}
191 }; 225 };
192 226
193 } // namespace blink 227 } // namespace blink
194 228
195 #endif // ComputedStyleBase_h 229 #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