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

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

Issue 2875233002: Move code from from ComputedStyleBase.cpp.tmpl to .h.tmpl (Closed)
Patch Set: Indent 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
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, declare_storage, f ieldwise_compare %} 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"
11 #include "core/style/DataRef.h" 11 #include "core/style/DataRef.h"
12 #include "core/style/StyleDifference.h" 12 #include "core/style/StyleDifference.h"
13 #include "platform/wtf/SizeAssertions.h"
13 {% for path in include_paths %} 14 {% for path in include_paths %}
14 #include "{{path}}" 15 #include "{{path}}"
15 {% endfor %} 16 {% endfor %}
16 17
17 {# Each field template has macros that we can call to generate specific 18 {# Each field template has macros that we can call to generate specific
18 aspects of the field (e.g. getters, setters). 19 aspects of the field (e.g. getters, setters).
19 #} 20 #}
20 {% import 'fields/keyword.tmpl' as keyword %} 21 {% import 'fields/keyword.tmpl' as keyword %}
21 {% import 'fields/primitive.tmpl' as primitive %} 22 {% import 'fields/primitive.tmpl' as primitive %}
22 {% import 'fields/monotonic_flag.tmpl' as monotonic_flag %} 23 {% import 'fields/monotonic_flag.tmpl' as monotonic_flag %}
23 {% import 'fields/storage_only.tmpl' as storage_only %} 24 {% import 'fields/storage_only.tmpl' as storage_only %}
24 {% import 'fields/external.tmpl' as external %} 25 {% import 'fields/external.tmpl' as external %}
25 {% from 'fields/field.tmpl' import encode %} 26 {% from 'fields/field.tmpl' import encode %}
26 {% set field_templates = { 27 {% set field_templates = {
27 'keyword': keyword, 28 'keyword': keyword,
28 'primitive': primitive, 29 'primitive': primitive,
29 'monotonic_flag': monotonic_flag, 30 'monotonic_flag': monotonic_flag,
30 'storage_only': storage_only, 31 'storage_only': storage_only,
31 'external': external 32 'external': external
32 } %} 33 } %}
33 34
34 namespace blink { 35 namespace blink {
35 36
37 struct SameSizeAsComputedStyleBase {
38 {% if computed_style.subgroups is defined %}
39 void* dataRefs[{{computed_style.subgroups|length}}];
40 {% endif %}
41 {% for field in computed_style.fields|rejectattr("is_bit_field") %}
42 {{field.type_name}} {{field.name}};
43 {% endfor %}
44 unsigned m_bit_fields[{{computed_style.num_32_bit_words_for_bit_fields}}];
45 };
46
36 // 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
37 // in ComputedStyle.h. 48 // in ComputedStyle.h.
38 class CORE_EXPORT ComputedStyleBase { 49 class CORE_EXPORT ComputedStyleBase {
39 public: 50 public:
40 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { 51 inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const {
41 return ( 52 return (
42 {{fieldwise_compare(computed_style, computed_style.all_fields 53 {{fieldwise_compare(computed_style, computed_style.all_fields
43 |selectattr("is_property") 54 |selectattr("is_property")
44 |selectattr("is_inherited") 55 |selectattr("is_inherited")
45 |selectattr("is_independent") 56 |selectattr("is_independent")
(...skipping 28 matching lines...) Expand all
74 |list 85 |list
75 )|indent(8)}} 86 )|indent(8)}}
76 true 87 true
77 ); 88 );
78 } 89 }
79 90
80 enum IsAtShadowBoundary { 91 enum IsAtShadowBoundary {
81 kAtShadowBoundary, 92 kAtShadowBoundary,
82 kNotAtShadowBoundary, 93 kNotAtShadowBoundary,
83 }; 94 };
84 void InheritFrom(const ComputedStyleBase& inheritParent,
85 IsAtShadowBoundary isAtShadowBoundary = kNotAtShadowBoundary) ;
86 95
87 void CopyNonInheritedFromCached(const ComputedStyleBase& other); 96 void InheritFrom(const ComputedStyleBase& other,
88 bool DiffNeedsFullLayoutAndPaintInvalidation( 97 IsAtShadowBoundary isAtShadowBoundary) {
89 const ComputedStyleBase& other) const; 98 {{fieldwise_copy(computed_style, computed_style.all_fields
90 bool ScrollAnchorDisablingPropertyChanged(const ComputedStyleBase& other, 99 |selectattr("is_property")
91 const StyleDifference&) const; 100 |selectattr("is_inherited")
101 |list
102 )|indent(4)}}
103 }
104
105 void CopyNonInheritedFromCached(
106 const ComputedStyleBase& other) {
107 {{fieldwise_copy(computed_style, computed_style.all_fields
108 |rejectattr("has_custom_compare_and_copy")
109 |rejectattr("is_inherited")
110 |list
111 )|indent(4)}}
112 }
92 113
93 // Copies the values of any independent inherited properties from the parent 114 // Copies the values of any independent inherited properties from the parent
94 // style that are marked as inherited by this style. 115 // style that are marked as inherited by this style.
95 void PropagateIndependentInheritedProperties( 116 void PropagateIndependentInheritedProperties(
96 const ComputedStyleBase& parentStyle); 117 const ComputedStyleBase& parentStyle) {
118 {% for field in computed_style.all_fields if field.is_property and field.is_ independent %}
119 if ({{field.is_inherited_method_name}}())
120 {{setter_expression(field)}} = parentStyle.{{getter_expression(field)}};
121 {% endfor %}
122 }
123
124 bool ScrollAnchorDisablingPropertyChanged(
125 const ComputedStyleBase& other,
126 const StyleDifference& diff) const {
127 {{fieldwise_diff(computed_style, computed_style.all_fields
128 |selectattr("property_name", "in", ["margin-top", "margin-left", "margin -right", "margin-bottom", "left", "right", "top", "bottom", "padding-top", "padd ing-left", "padding-right", "padding-bottom"])
129 |list
130 )|indent(4)}}
131 return false;
132 }
133
134 bool DiffNeedsFullLayoutAndPaintInvalidation(
135 const ComputedStyleBase& other) const {
136 {{fieldwise_diff(computed_style, computed_style.all_fields
137 |selectattr("property_name", "in", ["padding-top", "padding-left", "padd ing-right", "padding-bottom"])
138 |list
139 )|indent(4)}}
140 return false;
141 }
97 142
98 // Fields. 143 // Fields.
99 // TODO(sashab): Remove initialFoo() static methods and update callers to 144 // TODO(sashab): Remove initialFoo() static methods and update callers to
100 // use resetFoo(), which can be more efficient. 145 // use resetFoo(), which can be more efficient.
101 146
102 {% for field in computed_style.all_fields %} 147 {% for field in computed_style.all_fields %}
103 // {{field.property_name}} 148 // {{field.property_name}}
104 {{field_templates[field.field_template].decl_public_methods(field)|indent(2)}} 149 {{field_templates[field.field_template].decl_public_methods(field)|indent(2)}}
105 150
106 {% endfor %} 151 {% endfor %}
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return static_cast<unsigned>(std::min<float>(width, kMaxForBorderWidth) * 188 return static_cast<unsigned>(std::min<float>(width, kMaxForBorderWidth) *
144 kBorderWidthDenominator); 189 kBorderWidthDenominator);
145 } 190 }
146 191
147 private: 192 private:
148 {% for field in computed_style.fields %} 193 {% for field in computed_style.fields %}
149 {{declare_storage(field)}} 194 {{declare_storage(field)}}
150 {% endfor %} 195 {% endfor %}
151 }; 196 };
152 197
198 // If this fails, the packing algorithm in make_computed_style_base.py has
199 // failed to produce the optimal packed size. To fix, update the algorithm to
200 // ensure that the buckets are placed so that each takes up at most 1 word.
201 ASSERT_SIZE(ComputedStyleBase, SameSizeAsComputedStyleBase);
202
153 } // namespace blink 203 } // namespace blink
154 204
155 #endif // ComputedStyleBase_h 205 #endif // ComputedStyleBase_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.cpp.tmpl ('k') | third_party/WebKit/Source/core/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698