OLD | NEW |
1 {% from 'macros.tmpl' import license %} | 1 {% from 'macros.tmpl' import license %} |
2 {# | 2 {# |
3 This file is for property handlers which use the templating engine to | 3 This file is for property handlers which use the templating engine to |
4 reduce (handwritten) code duplication. | 4 reduce (handwritten) code duplication. |
5 | 5 |
6 The `properties' dict can be used to access a property's parameters in | 6 The `properties' dict can be used to access a property's parameters in |
7 jinja2 templates (i.e. setter, getter, initial, type_name) | 7 jinja2 templates (i.e. setter, getter, initial, type_name) |
8 #} | 8 #} |
9 #include "config.h" | 9 #include "config.h" |
10 #include "StyleBuilderFunctions.h" | 10 #include "StyleBuilderFunctions.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 {%- endmacro %} | 26 {%- endmacro %} |
27 {% macro set_value(property) %} | 27 {% macro set_value(property) %} |
28 {% if property.svg %} | 28 {% if property.svg %} |
29 state.style()->accessSVGStyle().{{property.setter}} | 29 state.style()->accessSVGStyle().{{property.setter}} |
30 {%- elif property.font %} | 30 {%- elif property.font %} |
31 state.fontBuilder().{{property.setter}} | 31 state.fontBuilder().{{property.setter}} |
32 {%- else %} | 32 {%- else %} |
33 state.style()->{{property.setter}} | 33 state.style()->{{property.setter}} |
34 {%- endif %} | 34 {%- endif %} |
35 {% endmacro %} | 35 {% endmacro %} |
| 36 {% macro convert_and_set_value(property) %} |
| 37 {% if property.converter %} |
| 38 {{set_value(property)}}(StyleBuilderConverter::{{property.converter}}(state, val
ue)); |
| 39 {%- else %} |
| 40 {{set_value(property)}}(static_cast<{{property.type_name}}>(*toCSSPrimitiveValue
(value))); |
| 41 {%- endif %} |
| 42 {% endmacro %} |
36 | 43 |
37 namespace blink { | 44 namespace blink { |
38 | 45 |
39 {% for property_id, property in properties.items() if property.should_declare_fu
nctions %} | 46 {% for property_id, property in properties.items() if property.should_declare_fu
nctions %} |
40 {% set apply_type = property.apply_type %} | 47 {% set apply_type = property.apply_type %} |
41 {% if not property.custom_initial %} | 48 {% if not property.custom_initial %} |
42 {{declare_initial_function(property_id)}} | 49 {{declare_initial_function(property_id)}} |
43 { | 50 { |
44 {% if property.svg %} | 51 {% if property.svg %} |
45 {{set_value(property)}}(SVGRenderStyle::{{property.initial}}()); | 52 {{set_value(property)}}(SVGRenderStyle::{{property.initial}}()); |
(...skipping 14 matching lines...) Expand all Loading... |
60 {{set_value(property)}}(state.parentFontDescription().{{property.getter}}())
; | 67 {{set_value(property)}}(state.parentFontDescription().{{property.getter}}())
; |
61 {% else %} | 68 {% else %} |
62 {{set_value(property)}}(state.parentStyle()->{{property.getter}}()); | 69 {{set_value(property)}}(state.parentStyle()->{{property.getter}}()); |
63 {% endif %} | 70 {% endif %} |
64 } | 71 } |
65 | 72 |
66 {% endif %} | 73 {% endif %} |
67 {% if not property.custom_value %} | 74 {% if not property.custom_value %} |
68 {{declare_value_function(property_id)}} | 75 {{declare_value_function(property_id)}} |
69 { | 76 { |
70 {% if property.converter %} | 77 {{convert_and_set_value(property)}} |
71 {{set_value(property)}}(StyleBuilderConverter::{{property.converter}}(state,
value)); | |
72 {% else %} | |
73 {{set_value(property)}}(static_cast<{{property.type_name}}>(*toCSSPrimitiveV
alue(value))); | |
74 {% endif %} | |
75 } | 78 } |
76 | 79 |
77 {% endif %} | 80 {% endif %} |
78 {% endfor %} | 81 {% endfor %} |
79 | 82 |
80 {% macro apply_animation(property_id, attribute, animation) %} | 83 {% macro apply_animation(property_id, attribute, animation) %} |
81 {% set vector = attribute|lower_first + "List()" %} | 84 {% set vector = attribute|lower_first + "List()" %} |
82 {{declare_initial_function(property_id)}} | 85 {{declare_initial_function(property_id)}} |
83 { | 86 { |
84 CSS{{animation}}Data& data = state.style()->access{{animation}}s(); | 87 CSS{{animation}}Data& data = state.style()->access{{animation}}s(); |
(...skipping 24 matching lines...) Expand all Loading... |
109 {{apply_animation('CSSPropertyWebkitAnimationFillMode', 'FillMode', 'Animation')
}} | 112 {{apply_animation('CSSPropertyWebkitAnimationFillMode', 'FillMode', 'Animation')
}} |
110 {{apply_animation('CSSPropertyWebkitAnimationIterationCount', 'IterationCount',
'Animation')}} | 113 {{apply_animation('CSSPropertyWebkitAnimationIterationCount', 'IterationCount',
'Animation')}} |
111 {{apply_animation('CSSPropertyWebkitAnimationName', 'Name', 'Animation')}} | 114 {{apply_animation('CSSPropertyWebkitAnimationName', 'Name', 'Animation')}} |
112 {{apply_animation('CSSPropertyWebkitAnimationPlayState', 'PlayState', 'Animation
')}} | 115 {{apply_animation('CSSPropertyWebkitAnimationPlayState', 'PlayState', 'Animation
')}} |
113 {{apply_animation('CSSPropertyWebkitAnimationTimingFunction', 'TimingFunction',
'Animation')}} | 116 {{apply_animation('CSSPropertyWebkitAnimationTimingFunction', 'TimingFunction',
'Animation')}} |
114 {{apply_animation('CSSPropertyWebkitTransitionDelay', 'Delay', 'Transition')}} | 117 {{apply_animation('CSSPropertyWebkitTransitionDelay', 'Delay', 'Transition')}} |
115 {{apply_animation('CSSPropertyWebkitTransitionDuration', 'Duration', 'Transition
')}} | 118 {{apply_animation('CSSPropertyWebkitTransitionDuration', 'Duration', 'Transition
')}} |
116 {{apply_animation('CSSPropertyWebkitTransitionProperty', 'Property', 'Transition
')}} | 119 {{apply_animation('CSSPropertyWebkitTransitionProperty', 'Property', 'Transition
')}} |
117 {{apply_animation('CSSPropertyWebkitTransitionTimingFunction', 'TimingFunction',
'Transition')}} | 120 {{apply_animation('CSSPropertyWebkitTransitionTimingFunction', 'TimingFunction',
'Transition')}} |
118 | 121 |
119 {% macro apply_auto(property_id, auto_getter=none, auto_setter=none, auto_identi
ty='CSSValueAuto', compute_length=false) %} | 122 {% macro apply_auto(property_id, auto_getter=none, auto_setter=none, auto_identi
ty='CSSValueAuto') %} |
120 {% set property = properties[property_id] %} | 123 {% set property = properties[property_id] %} |
121 {% set auto_getter = auto_getter or 'hasAuto' + property.name_for_methods %} | 124 {% set auto_getter = auto_getter or 'hasAuto' + property.name_for_methods %} |
122 {% set auto_setter = auto_setter or 'setHasAuto' + property.name_for_methods %} | 125 {% set auto_setter = auto_setter or 'setHasAuto' + property.name_for_methods %} |
123 {{declare_initial_function(property_id)}} | 126 {{declare_initial_function(property_id)}} |
124 { | 127 { |
125 state.style()->{{auto_setter}}(); | 128 state.style()->{{auto_setter}}(); |
126 } | 129 } |
127 | 130 |
128 {{declare_inherit_function(property_id)}} | 131 {{declare_inherit_function(property_id)}} |
129 { | 132 { |
130 if (state.parentStyle()->{{auto_getter}}()) | 133 if (state.parentStyle()->{{auto_getter}}()) |
131 state.style()->{{auto_setter}}(); | 134 state.style()->{{auto_setter}}(); |
132 else | 135 else |
133 {{set_value(property)}}(state.parentStyle()->{{property.getter}}()); | 136 {{set_value(property)}}(state.parentStyle()->{{property.getter}}()); |
134 } | 137 } |
135 | 138 |
136 {{declare_value_function(property_id)}} | 139 {{declare_value_function(property_id)}} |
137 { | 140 { |
138 if (!value->isPrimitiveValue()) | 141 if (!value->isPrimitiveValue()) |
139 return; | 142 return; |
140 | 143 |
141 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 144 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
142 if (primitiveValue->getValueID() == {{auto_identity}}) | 145 if (primitiveValue->getValueID() == {{auto_identity}}) |
143 state.style()->{{auto_setter}}(); | 146 state.style()->{{auto_setter}}(); |
144 else | 147 else |
145 {% if compute_length %} | 148 {{convert_and_set_value(property)}} |
146 {{set_value(property)}}(primitiveValue->computeLength<{{property.type_na
me}}>(state.cssToLengthConversionData())); | |
147 {% else %} | |
148 {{set_value(property)}}(*primitiveValue); | |
149 {% endif %} | |
150 } | 149 } |
151 {% endmacro %} | 150 {% endmacro %} |
152 {{apply_auto('CSSPropertyOrphans')}} | 151 {{apply_auto('CSSPropertyOrphans')}} |
153 {{apply_auto('CSSPropertyWebkitColumnCount')}} | 152 {{apply_auto('CSSPropertyWebkitColumnCount')}} |
154 {{apply_auto('CSSPropertyWebkitColumnGap', auto_getter='hasNormalColumnGap', aut
o_setter='setHasNormalColumnGap', auto_identity='CSSValueNormal', compute_length
=true)}} | 153 {{apply_auto('CSSPropertyWebkitColumnGap', auto_getter='hasNormalColumnGap', aut
o_setter='setHasNormalColumnGap', auto_identity='CSSValueNormal')}} |
155 {{apply_auto('CSSPropertyWebkitColumnWidth', compute_length=true)}} | 154 {{apply_auto('CSSPropertyWebkitColumnWidth')}} |
156 {{apply_auto('CSSPropertyWidows')}} | 155 {{apply_auto('CSSPropertyWidows')}} |
157 {{apply_auto('CSSPropertyZIndex')}} | 156 {{apply_auto('CSSPropertyZIndex')}} |
158 | 157 |
159 static bool lengthTypeAndValueMatch(const Length& length, LengthType type, float
value) | 158 static bool lengthTypeAndValueMatch(const Length& length, LengthType type, float
value) |
160 { | 159 { |
161 return length.type() == type && length.value() == value; | 160 return length.type() == type && length.value() == value; |
162 } | 161 } |
163 | 162 |
164 static bool lengthTypeAndValueMatch(const LengthBox& lengthBox, LengthType type,
float value) | 163 static bool lengthTypeAndValueMatch(const LengthBox& lengthBox, LengthType type,
float value) |
165 { | 164 { |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 } | 633 } |
635 {{set_value(property)}}(ptype, c, url, | 634 {{set_value(property)}}(ptype, c, url, |
636 state.applyPropertyToRegularStyle(), | 635 state.applyPropertyToRegularStyle(), |
637 state.applyPropertyToVisitedLinkStyle()); | 636 state.applyPropertyToVisitedLinkStyle()); |
638 } | 637 } |
639 } | 638 } |
640 {% endmacro %} | 639 {% endmacro %} |
641 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} | 640 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} |
642 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} | 641 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} |
643 } // namespace blink | 642 } // namespace blink |
OLD | NEW |