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

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: 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 implements the storage aspect of
suzyh_UTC10 (ex-contributor) 2017/05/17 09:01:27 I find this paragraph unclear, I think particularl
shend 2017/05/17 23:30:00 Done.
51 // on ComputedStyle. This allows ComputedStyleBase to use hand written 51 // ComputedStyle. Conceptually, it stores a set of data members or 'fields'
52 // functions it would otherwise not know about. 52 // that are used in ComputedStyle. These fields can represent CSS properties or
53 // It should only be templated with the ComputedStyle class and no other class 53 // internal style information.
54 // is allowed. 54 //
55 // However, storing every data member directly in this class is wasteful, since
suzyh_UTC10 (ex-contributor) 2017/05/17 09:01:27 On a first read through, it's not clear why this i
shend 2017/05/17 23:30:00 Rewrote the paragraph.
56 // not every data member is used frequently. Thus, we group fields into
57 // nested classes inside ComputedStyleBase and store pointers to
58 // these groups instead. For example, 'width' and 'height' are stored in a group
59 // called StyleBoxData. ComputedStyleBase stores a pointer to an instance of
60 // StyleBoxData, so different multiple ComputedStyleBases can save memory by
suzyh_UTC10 (ex-contributor) 2017/05/17 09:01:27 "different multiple" is redundant - pick just one
shend 2017/05/17 23:30:00 Done.
61 // sharing the same instance of StyleBoxData. Furthermore, these nested classes
suzyh_UTC10 (ex-contributor) 2017/05/17 09:01:27 I think put a paragraph break here and have the ne
shend 2017/05/17 23:30:00 Omitted discussion of nested classes, since it's a
62 // can themselves contain nested classes and so on, meaning we can view the
63 // storage of ComputedStyleBase as a tree structure of groups with
64 // ComputedStyleBase at the root:
65 //
66 // ComputedStyleBase
suzyh_UTC10 (ex-contributor) 2017/05/17 09:01:27 I wouldn't bother listing all of these groups, esp
shend 2017/05/17 23:30:00 Done.
67 // |- StyleSurroundData
68 // |- StyleBackgroundData
69 // |- StyleVisualData
70 // |- StyleBoxData
71 // |- StyleInheritedData
72 // |- StyleRareInheritedData
73 // |- StyleRareNonInheritedData
74 // |- StyleDeprecatedFlexibleBoxData
75 // |- StyleFlexibleBoxData
76 // |- StyleMultiColData
77 // |- StyleTransformData
78 // |- StyleWillChangeData
79 // |- StyleGridData
80 // |- StyleGridItemData
81 // |- StyleScrollSnapData
82 //
83 // where every field belongs to exactly one of these groups. ComputedStyle
84 // should never refer to these groups, since they may changed if we find a
suzyh_UTC10 (ex-contributor) 2017/05/17 09:01:27 I misinterpreted this sentence the first time thro
shend 2017/05/17 23:30:00 Removed this sentence as it is not worth the confu
85 // better layout structure.
suzyh_UTC10 (ex-contributor) 2017/05/17 09:01:27 There's no need to specify a reason why they may h
shend 2017/05/17 23:30:00 Done.
86 //
87 // Not every field has the same interface. The interface for a field is
88 // determined by its 'template'. Different field templates result in slightly
89 // different accessors and helpers. For example, a field with the 'keyword'
suzyh_UTC10 (ex-contributor) 2017/05/17 09:01:27 I don't think it's necessary to specify "Different
shend 2017/05/17 23:30:00 Done.
90 // template has only one setter, whereas an 'external' field has an extra setter
91 // that takes an rvalue reference. A list of the available templates can be
92 // found in CSSProperties.json5.
93 //
94 // ComputedStyleBase is a template class to allow it to use functions on
95 // ComputedStyle. This allows ComputedStyleBase to use hand written functions it
96 // would otherwise not know about. It should only be templated with the
97 // ComputedStyle class and no other class is allowed.
suzyh_UTC10 (ex-contributor) 2017/05/17 09:01:27 Consider adding a TODO (ideally with bug reference
shend 2017/05/17 23:30:00 Added TODO, but no bug as it is a very small chang
suzyh_UTC10 (ex-contributor) 2017/05/19 02:33:59 The main reason to add a bug is not because a TODO
55 template <class ComputedStyleFinal> 98 template <class ComputedStyleFinal>
56 class CORE_EXPORT ComputedStyleBase { 99 class CORE_EXPORT ComputedStyleBase {
57 public: 100 public:
58 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { 101 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const {
59 return ( 102 return (
60 {{fieldwise_compare(computed_style, computed_style.all_fields 103 {{fieldwise_compare(computed_style, computed_style.all_fields
61 |selectattr("is_property") 104 |selectattr("is_property")
62 |selectattr("is_inherited") 105 |selectattr("is_inherited")
63 |selectattr("is_independent") 106 |selectattr("is_independent")
64 |list 107 |list
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 229
187 private: 230 private:
188 {% for field in computed_style.fields %} 231 {% for field in computed_style.fields %}
189 {{declare_storage(field)}} 232 {{declare_storage(field)}}
190 {% endfor %} 233 {% endfor %}
191 }; 234 };
192 235
193 } // namespace blink 236 } // namespace blink
194 237
195 #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