OLD | NEW |
---|---|
1 {% from 'macros.tmpl' import license %} | 1 {% from 'macros.tmpl' import license, print_if %} |
2 {{license()}} | 2 {{license()}} |
3 | 3 |
4 #ifndef ComputedStyleBase_h | 4 #ifndef ComputedStyleBase_h |
5 #define ComputedStyleBase_h | 5 #define ComputedStyleBase_h |
6 | 6 |
7 #include "core/ComputedStyleBaseConstants.h" | 7 #include "core/ComputedStyleBaseConstants.h" |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 {% for field in fields if field.storage_type_path != None %} | 9 {% for field in fields if field.storage_type_path != None %} |
10 #include "{{field.storage_type_path}}.h" | 10 #include "{{field.storage_type_path}}.h" |
11 {% endfor %} | 11 {% endfor %} |
12 | 12 |
13 {# Returns the default value for the field, converted to fit in the storage cont ainer. #} | 13 {# Returns the default value for the field, converted to fit in the storage cont ainer. #} |
14 {% macro default_value(field) %} | 14 {% macro default_value(field) -%} |
sashab
2017/02/19 23:17:03
What's the dashes for?
shend
2017/02/19 23:20:17
They strip out leading/trailing whitespace so you
| |
15 {# We only support enum fields for now. #} | 15 {# We only support enum fields for now. #} |
16 static_cast<unsigned>({{field.default_value}}){% endmacro %} | 16 static_cast<unsigned>({{field.default_value}}) |
17 {%- endmacro %} | |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
19 | 20 |
20 // The generated portion of ComputedStyle. For more info, see the header comment | 21 // The generated portion of ComputedStyle. For more info, see the header comment |
21 // in ComputedStyle.h. | 22 // in ComputedStyle.h. |
22 class CORE_EXPORT ComputedStyleBase { | 23 class CORE_EXPORT ComputedStyleBase { |
23 public: | 24 public: |
24 ALWAYS_INLINE ComputedStyleBase() : | 25 ALWAYS_INLINE ComputedStyleBase() : |
25 {% for field in fields %} | 26 {% for field in fields %} |
26 {% set trailing_comma = "," if field != fields[-1] else "" %} | 27 {{field.name}}({{default_value(field)}}){{print_if(not loop.last, ',')}} |
sashab
2017/02/19 23:17:03
Woah loop.last awesome!!
shend
2017/02/19 23:20:17
\o/
| |
27 {{field.name}}({{default_value(field)}}){{trailing_comma}} | |
28 {% endfor %} | 28 {% endfor %} |
29 {} | 29 {} |
30 ~ComputedStyleBase() {} | 30 ~ComputedStyleBase() {} |
31 | 31 |
32 ALWAYS_INLINE ComputedStyleBase(const ComputedStyleBase& o) : | 32 ALWAYS_INLINE ComputedStyleBase(const ComputedStyleBase& o) : |
33 {% for field in fields %} | 33 {% for field in fields %} |
34 {% set trailing_comma = "," if field != fields[-1] else "" %} | 34 {{field.name}}(o.{{field.name}}){{print_if(not loop.last, ',')}} |
35 {{field.name}}(o.{{field.name}}){{trailing_comma}} | |
36 {% endfor %} | 35 {% endfor %} |
37 {} | 36 {} |
38 | 37 |
39 bool operator==(const ComputedStyleBase& o) const { | 38 bool operator==(const ComputedStyleBase& o) const { |
40 return true && | 39 return true && |
41 {% for field in fields %} | 40 {% for field in fields %} |
42 {{field.name}} == o.{{field.name}} && | 41 {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}} |
43 {% endfor %} | 42 {% endfor %} |
44 true; | 43 ; |
45 } | 44 } |
46 | 45 |
47 bool operator!=(const ComputedStyleBase& o) const { return !(*this == o); } | 46 bool operator!=(const ComputedStyleBase& o) const { return !(*this == o); } |
48 | 47 |
49 inline bool inheritedEqual(const ComputedStyleBase& o) const { | 48 inline bool inheritedEqual(const ComputedStyleBase& o) const { |
50 return true && | 49 return true && |
51 {% for field in fields if field.is_property and field.is_inherited %} | 50 {% for field in fields if field.is_property and field.is_inherited %} |
52 {{field.name}} == o.{{field.name}} && | 51 {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}} |
53 {% endfor %} | 52 {% endfor %} |
54 true; | 53 ; |
55 } | 54 } |
56 | 55 |
57 inline bool independentInheritedEqual(const ComputedStyleBase& o) const { | 56 inline bool independentInheritedEqual(const ComputedStyleBase& o) const { |
58 return true && | 57 return true && |
59 {% for field in fields if field.is_property and field.is_inherited and field .is_independent %} | 58 {% for field in fields if field.is_property and field.is_inherited and field .is_independent %} |
60 {{field.name}} == o.{{field.name}} && | 59 {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}} |
61 {% endfor %} | 60 {% endfor %} |
62 true; | 61 ; |
63 } | 62 } |
64 | 63 |
65 inline bool nonIndependentInheritedEqual(const ComputedStyleBase& o) const { | 64 inline bool nonIndependentInheritedEqual(const ComputedStyleBase& o) const { |
66 return true && | 65 return true && |
67 {% for field in fields if field.is_property and field.is_inherited and not f ield.is_independent %} | 66 {% for field in fields if field.is_property and field.is_inherited and not f ield.is_independent %} |
68 {{field.name}} == o.{{field.name}} && | 67 {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}} |
69 {% endfor %} | 68 {% endfor %} |
70 true; | 69 ; |
71 } | 70 } |
72 | 71 |
73 inline bool nonInheritedEqual(const ComputedStyleBase& o) const { | 72 inline bool nonInheritedEqual(const ComputedStyleBase& o) const { |
74 return true && | 73 return true && |
75 {% for field in fields if field.is_property and not field.is_inherited %} | 74 {% for field in fields if field.is_property and not field.is_inherited %} |
76 {{field.name}} == o.{{field.name}} && | 75 {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}} |
77 {% endfor %} | 76 {% endfor %} |
78 true; | 77 ; |
79 } | 78 } |
80 | 79 |
81 void setBitDefaults() { | 80 void setBitDefaults() { |
82 {% for field in fields %} | 81 {% for field in fields %} |
83 {{field.resetter_method_name}}(); | 82 {{field.resetter_method_name}}(); |
84 {% endfor %} | 83 {% endfor %} |
85 } | 84 } |
86 | 85 |
87 enum IsAtShadowBoundary { | 86 enum IsAtShadowBoundary { |
88 AtShadowBoundary, | 87 AtShadowBoundary, |
(...skipping 23 matching lines...) Expand all Loading... | |
112 protected: | 111 protected: |
113 // Storage. | 112 // Storage. |
114 {% for field in fields %} | 113 {% for field in fields %} |
115 unsigned {{field.name}} : {{field.size}}; // {{field.storage_type}} | 114 unsigned {{field.name}} : {{field.size}}; // {{field.storage_type}} |
116 {% endfor %} | 115 {% endfor %} |
117 }; | 116 }; |
118 | 117 |
119 } // namespace blink | 118 } // namespace blink |
120 | 119 |
121 #endif // ComputedStyleBase_h | 120 #endif // ComputedStyleBase_h |
OLD | NEW |