OLD | NEW |
| (Empty) |
1 {% from "macros.tmpl" import lower_first -%} | |
2 | |
3 {# | |
4 This file is for property handlers which use the templating engine to | |
5 reduce (handwritten) code duplication. | |
6 | |
7 The `properties' dict can be used to access a property's parameters in | |
8 jinja2 templates (i.e. setter, getter, initial, type_name) | |
9 -#} | |
10 | |
11 #include "config.h" | |
12 #include "StyleBuilderFunctions.h" | |
13 | |
14 #include "CSSValueKeywords.h" | |
15 #include "core/css/BasicShapeFunctions.h" | |
16 #include "core/css/CSSPrimitiveValueMappings.h" | |
17 #include "core/css/Pair.h" | |
18 #include "core/css/resolver/StyleResolverState.h" | |
19 #include "core/platform/animation/CSSAnimationDataList.h" | |
20 | |
21 | |
22 {%- macro declare_initial_function(property_id) -%} | |
23 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat
e) | |
24 {%- endmacro %} | |
25 | |
26 {%- macro declare_inherit_function(property_id) -%} | |
27 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat
e) | |
28 {%- endmacro %} | |
29 | |
30 {%- macro declare_value_function(property_id) -%} | |
31 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state,
CSSValue* value) | |
32 {%- endmacro %} | |
33 | |
34 // FIXME: This is duplicated in StyleBuilder.cpp.tmpl, but we'll move the | |
35 // function definitions there over to here later. | |
36 {%- macro set_value(property) %} | |
37 {%- if property.svg -%} | |
38 state.style()->accessSVGStyle()->{{property.setter}} | |
39 {%- else -%} | |
40 state.style()->{{property.setter}} | |
41 {%- endif -%} | |
42 {%- endmacro %} | |
43 | |
44 namespace WebCore { | |
45 | |
46 {%- macro apply_animation(property_id, attribute, animation) %} | |
47 {{ declare_initial_function(property_id) }} | |
48 { | |
49 CSSAnimationDataList* list = state.style()->access{{animation}}(); | |
50 if (list->isEmpty()) | |
51 list->append(CSSAnimationData::create()); | |
52 list->animation(0)->set{{attribute}}(CSSAnimationData::initialAnimation{{att
ribute}}()); | |
53 {%- if property_id == "CSSPropertyWebkitTransitionProperty" %} | |
54 list->animation(0)->setAnimationMode(CSSAnimationData::AnimateAll); | |
55 {%- endif %} | |
56 for (size_t i = 1; i < list->size(); ++i) | |
57 list->animation(i)->clear{{attribute}}(); | |
58 } | |
59 | |
60 {{ declare_inherit_function(property_id) }} | |
61 { | |
62 CSSAnimationDataList* list = state.style()->access{{animation}}(); | |
63 const CSSAnimationDataList* parentList = state.parentStyle()->{{animation|lo
wer}}(); | |
64 size_t i = 0, parentSize = parentList ? parentList->size() : 0; | |
65 for ( ; i < parentSize && parentList->animation(i)->is{{attribute}}Set(); ++
i) { | |
66 if (list->size() <= i) | |
67 list->append(CSSAnimationData::create()); | |
68 list->animation(i)->set{{attribute}}(parentList->animation(i)->{{lower_f
irst(attribute)}}()); | |
69 list->animation(i)->setAnimationMode(parentList->animation(i)->animation
Mode()); | |
70 } | |
71 | |
72 // Reset any remaining animations to not have the property set. | |
73 for ( ; i < list->size(); ++i) | |
74 list->animation(i)->clear{{attribute}}(); | |
75 } | |
76 | |
77 {{ declare_value_function(property_id) }} | |
78 { | |
79 CSSAnimationDataList* list = state.style()->access{{animation}}(); | |
80 size_t childIndex = 0; | |
81 if (value->isValueList()) { | |
82 // Walk each value and put it into an animation, creating new animations
as needed. | |
83 for (CSSValueListIterator i = value; i.hasMore(); i.advance()) { | |
84 if (childIndex <= list->size()) | |
85 list->append(CSSAnimationData::create()); | |
86 state.styleMap().mapAnimation{{attribute}}(list->animation(childInde
x), i.value()); | |
87 ++childIndex; | |
88 } | |
89 } else { | |
90 if (list->isEmpty()) | |
91 list->append(CSSAnimationData::create()); | |
92 state.styleMap().mapAnimation{{attribute}}(list->animation(childIndex),
value); | |
93 childIndex = 1; | |
94 } | |
95 for ( ; childIndex < list->size(); ++childIndex) { | |
96 // Reset all remaining animations to not have the property set. | |
97 list->animation(childIndex)->clear{{attribute}}(); | |
98 } | |
99 } | |
100 {%- endmacro %} | |
101 | |
102 {{ apply_animation("CSSPropertyWebkitAnimationDelay", "Delay", "Animations") }} | |
103 {{ apply_animation("CSSPropertyWebkitAnimationDirection", "Direction", "Animatio
ns") }} | |
104 {{ apply_animation("CSSPropertyWebkitAnimationDuration", "Duration", "Animations
") }} | |
105 {{ apply_animation("CSSPropertyWebkitAnimationFillMode", "FillMode", "Animations
") }} | |
106 {{ apply_animation("CSSPropertyWebkitAnimationIterationCount", "IterationCount",
"Animations") }} | |
107 {{ apply_animation("CSSPropertyWebkitAnimationName", "Name", "Animations") }} | |
108 {{ apply_animation("CSSPropertyWebkitAnimationPlayState", "PlayState", "Animatio
ns") }} | |
109 {{ apply_animation("CSSPropertyWebkitAnimationTimingFunction", "TimingFunction",
"Animations") }} | |
110 {{ apply_animation("CSSPropertyWebkitTransitionDelay", "Delay", "Transitions") }
} | |
111 {{ apply_animation("CSSPropertyWebkitTransitionDuration", "Duration", "Transitio
ns") }} | |
112 {{ apply_animation("CSSPropertyWebkitTransitionProperty", "Property", "Transitio
ns") }} | |
113 {{ apply_animation("CSSPropertyWebkitTransitionTimingFunction", "TimingFunction"
, "Transitions") }} | |
114 | |
115 {%- macro apply_auto(property_id, auto_getter=none, auto_setter=none, auto_ident
ity="CSSValueAuto", compute_length=false) %} | |
116 {%- set property = properties[property_id] %} | |
117 {%- set auto_getter = auto_getter or "hasAuto" + property.camel_case_name %} | |
118 {%- set auto_setter = auto_setter or "setHasAuto" + property.camel_case_name %} | |
119 {{ declare_initial_function(property_id) }} | |
120 { | |
121 state.style()->{{auto_setter}}(); | |
122 } | |
123 | |
124 {{ declare_inherit_function(property_id) }} | |
125 { | |
126 if (state.parentStyle()->{{auto_getter}}()) | |
127 state.style()->{{auto_setter}}(); | |
128 else | |
129 {{ set_value(property) }}(state.parentStyle()->{{property.getter}}()); | |
130 } | |
131 | |
132 {{ declare_value_function(property_id) }} | |
133 { | |
134 if (!value->isPrimitiveValue()) | |
135 return; | |
136 | |
137 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
138 if (primitiveValue->getValueID() == {{auto_identity}}) | |
139 state.style()->{{auto_setter}}(); | |
140 else | |
141 {%- if compute_length %} | |
142 {{ set_value(property) }}(primitiveValue->computeLength<{{property.type_
name}}>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom())
); | |
143 {%- else %} | |
144 {{ set_value(property) }}(*primitiveValue); | |
145 {%- endif %} | |
146 } | |
147 {%- endmacro %} | |
148 | |
149 {{ apply_auto("CSSPropertyOrphans") }} | |
150 {{ apply_auto("CSSPropertyWebkitColumnCount") }} | |
151 {{ apply_auto("CSSPropertyWebkitColumnGap", auto_getter="hasNormalColumnGap", au
to_setter="setHasNormalColumnGap", auto_identity="CSSValueNormal", compute_lengt
h=true) }} | |
152 {{ apply_auto("CSSPropertyWebkitColumnWidth", compute_length=true) }} | |
153 {{ apply_auto("CSSPropertyWidows") }} | |
154 {{ apply_auto("CSSPropertyZIndex") }} | |
155 | |
156 {%- macro apply_value_border_image(property_id) %} | |
157 {{ declare_value_function(property_id) }} | |
158 { | |
159 {%- set property = properties[property_id] %} | |
160 NinePieceImage image; | |
161 {%- if property_id == "CSSPropertyWebkitMaskBoxImage" %} | |
162 image.setMaskDefaults(); | |
163 {%- endif %} | |
164 state.styleMap().mapNinePieceImage(state.style(), {{property_id}}, value, im
age); | |
165 {{ set_value(property) }}(image); | |
166 } | |
167 {%- endmacro %} | |
168 | |
169 {{ apply_value_border_image("CSSPropertyWebkitBorderImage") }} | |
170 {{ apply_value_border_image("CSSPropertyWebkitMaskBoxImage") }} | |
171 | |
172 {%- macro apply_border_image_modifier(property_id, modifier_type) %} | |
173 {%- set is_mask_box = "MaskBox" in property_id %} | |
174 {%- set getter = "maskBoxImage" if is_mask_box else "borderImage" %} | |
175 {%- set setter = "setMaskBoxImage" if is_mask_box else "setBorderImage" %} | |
176 {{ declare_initial_function(property_id) }} | |
177 { | |
178 NinePieceImage image(state.style()->{{getter}}()); | |
179 {%- if modifier_type == "Outset" %} | |
180 image.setOutset(LengthBox(0)); | |
181 {%- elif modifier_type == "Repeat" %} | |
182 image.setHorizontalRule(StretchImageRule); | |
183 image.setVerticalRule(StretchImageRule); | |
184 {%- elif modifier_type == "Slice" %} | |
185 // Masks have a different initial value for slices. Preserve the value of 0
for backwards compatibility. | |
186 image.setImageSlices(LengthBox({{ (["Length(100, Percent)"]*4) | join(", ")
if not is_mask_box }})); | |
187 image.setFill(false); | |
188 {%- elif modifier_type == "Width" %} | |
189 // Masks have a different initial value for widths. Preserve the value of 0
for backwards compatibility. | |
190 image.setBorderSlices(LengthBox({{ (["Length(1, Relative)"]*4) | join(", ")
if not is_mask_box }})); | |
191 {%- endif %} | |
192 state.style()->{{setter}}(image); | |
193 } | |
194 | |
195 {{ declare_inherit_function(property_id) }} | |
196 { | |
197 NinePieceImage image(state.style()->{{getter}}()); | |
198 {%- if modifier_type == "Outset" %} | |
199 image.copyOutsetFrom(state.parentStyle()->{{getter}}()); | |
200 {%- elif modifier_type == "Repeat" %} | |
201 image.copyRepeatFrom(state.parentStyle()->{{getter}}()); | |
202 {%- elif modifier_type == "Slice" %} | |
203 image.copyImageSlicesFrom(state.parentStyle()->{{getter}}()); | |
204 {%- elif modifier_type == "Width" %} | |
205 image.copyBorderSlicesFrom(state.parentStyle()->{{getter}}()); | |
206 {%- endif %} | |
207 state.style()->{{setter}}(image); | |
208 } | |
209 | |
210 {{ declare_value_function(property_id) }} | |
211 { | |
212 NinePieceImage image(state.style()->{{getter}}()); | |
213 {%- if modifier_type == "Outset" %} | |
214 image.setOutset(state.styleMap().mapNinePieceImageQuad(value)); | |
215 {%- elif modifier_type == "Repeat" %} | |
216 state.styleMap().mapNinePieceImageRepeat(value, image); | |
217 {%- elif modifier_type == "Slice" %} | |
218 state.styleMap().mapNinePieceImageSlice(value, image); | |
219 {%- elif modifier_type == "Width" %} | |
220 image.setBorderSlices(state.styleMap().mapNinePieceImageQuad(value)); | |
221 {%- endif %} | |
222 state.style()->{{setter}}(image); | |
223 } | |
224 {%- endmacro %} | |
225 | |
226 {{ apply_border_image_modifier("CSSPropertyBorderImageOutset", "Outset") }} | |
227 {{ apply_border_image_modifier("CSSPropertyBorderImageRepeat", "Repeat") }} | |
228 {{ apply_border_image_modifier("CSSPropertyBorderImageSlice", "Slice") }} | |
229 {{ apply_border_image_modifier("CSSPropertyBorderImageWidth", "Width") }} | |
230 {{ apply_border_image_modifier("CSSPropertyWebkitMaskBoxImageOutset", "Outset")
}} | |
231 {{ apply_border_image_modifier("CSSPropertyWebkitMaskBoxImageRepeat", "Repeat")
}} | |
232 {{ apply_border_image_modifier("CSSPropertyWebkitMaskBoxImageSlice", "Slice") }} | |
233 {{ apply_border_image_modifier("CSSPropertyWebkitMaskBoxImageWidth", "Width") }} | |
234 | |
235 {%- macro apply_value_border_image_source(property_id) %} | |
236 {{ declare_value_function(property_id) }} | |
237 { | |
238 {%- set property = properties[property_id] %} | |
239 {{ set_value(property) }}(state.styleImage({{property_id}}, value)); | |
240 } | |
241 {%- endmacro %} | |
242 | |
243 {{ apply_value_border_image_source("CSSPropertyBorderImageSource") }} | |
244 {{ apply_value_border_image_source("CSSPropertyWebkitMaskBoxImageSource") }} | |
245 | |
246 {%- macro apply_value_border_radius(property_id) %} | |
247 {{ declare_value_function(property_id) }} | |
248 { | |
249 {%- set property = properties[property_id] %} | |
250 if (!value->isPrimitiveValue()) | |
251 return; | |
252 | |
253 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
254 Pair* pair = primitiveValue->getPairValue(); | |
255 if (!pair || !pair->first() || !pair->second()) | |
256 return; | |
257 | |
258 Length radiusWidth = pair->first()->convertToLength<FixedIntegerConversion |
PercentConversion>(state.style(), state.rootElementStyle(), state.style()->effe
ctiveZoom()); | |
259 Length radiusHeight = pair->second()->convertToLength<FixedIntegerConversion
| PercentConversion>(state.style(), state.rootElementStyle(), state.style()->ef
fectiveZoom()); | |
260 int width = radiusWidth.value(); | |
261 int height = radiusHeight.value(); | |
262 if (width < 0 || height < 0) | |
263 return; | |
264 if (!width) | |
265 radiusHeight = radiusWidth; // Null out the other value. | |
266 else if (!height) | |
267 radiusWidth = radiusHeight; // Null out the other value. | |
268 | |
269 LengthSize size(radiusWidth, radiusHeight); | |
270 {{ set_value(property) }}(size); | |
271 } | |
272 {%- endmacro %} | |
273 | |
274 {{ apply_value_border_radius("CSSPropertyBorderBottomLeftRadius") }} | |
275 {{ apply_value_border_radius("CSSPropertyBorderBottomRightRadius") }} | |
276 {{ apply_value_border_radius("CSSPropertyBorderTopLeftRadius") }} | |
277 {{ apply_value_border_radius("CSSPropertyBorderTopRightRadius") }} | |
278 | |
279 {%- macro apply_color(property_id, default_getter="color", initial_color=none, i
nherit_color=false) %} | |
280 {%- set property = properties[property_id] %} | |
281 {%- set visited_link_setter = "setVisitedLink" + property.camel_case_name %} | |
282 {{ declare_initial_function(property_id) }} | |
283 { | |
284 StyleColor color = {{ initial_color or "StyleColor" -}}(); | |
285 if (state.applyPropertyToRegularStyle()) | |
286 {{ set_value(property) }}(color); | |
287 if (state.applyPropertyToVisitedLinkStyle()) | |
288 state.style()->{{visited_link_setter}}(color); | |
289 } | |
290 | |
291 {{ declare_inherit_function(property_id) }} | |
292 { | |
293 // Visited link style can never explicitly inherit from parent visited link
style so no separate getters are needed. | |
294 StyleColor color = state.parentStyle()->{{property.getter}}(); | |
295 if (!color.isValid()) | |
296 color = state.parentStyle()->{{default_getter}}(); | |
297 if (state.applyPropertyToRegularStyle()) | |
298 {{ set_value(property) }}(color); | |
299 if (state.applyPropertyToVisitedLinkStyle()) | |
300 state.style()->{{visited_link_setter}}(color); | |
301 } | |
302 | |
303 {{ declare_value_function(property_id) }} | |
304 { | |
305 if (!value->isPrimitiveValue()) | |
306 return; | |
307 | |
308 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
309 | |
310 {%- if inherit_color %} | |
311 if (primitiveValue->getValueID() == CSSValueCurrentcolor) { | |
312 applyInherit{{property_id}}(state); | |
313 return; | |
314 } | |
315 {%- endif %} | |
316 | |
317 if (state.applyPropertyToRegularStyle()) | |
318 {{ set_value(property) }}(state.document()->textLinkColors().colorFromPr
imitiveValue(primitiveValue)); | |
319 if (state.applyPropertyToVisitedLinkStyle()) | |
320 state.style()->{{visited_link_setter}}(state.document()->textLinkColors(
).colorFromPrimitiveValue(primitiveValue, state.element()->isLink() /* forVisite
dLink */)); | |
321 } | |
322 {%- endmacro %} | |
323 | |
324 {{ apply_color("CSSPropertyBackgroundColor", default_getter="invalidColor") }} | |
325 {{ apply_color("CSSPropertyBorderBottomColor") }} | |
326 {{ apply_color("CSSPropertyBorderLeftColor") }} | |
327 {{ apply_color("CSSPropertyBorderRightColor") }} | |
328 {{ apply_color("CSSPropertyBorderTopColor") }} | |
329 {{ apply_color("CSSPropertyColor", inherit_color=true, default_getter="invalidCo
lor", initial_color="RenderStyle::initialColor") }} | |
330 {{ apply_color("CSSPropertyOutlineColor") }} | |
331 {{ apply_color("CSSPropertyTextDecorationColor") }} | |
332 {{ apply_color("CSSPropertyWebkitColumnRuleColor") }} | |
333 {{ apply_color("CSSPropertyWebkitTextEmphasisColor") }} | |
334 {{ apply_color("CSSPropertyWebkitTextFillColor") }} | |
335 {{ apply_color("CSSPropertyWebkitTextStrokeColor") }} | |
336 | |
337 {%- macro apply_value_compute_length(property_id) %} | |
338 {{ declare_value_function(property_id) }} | |
339 { | |
340 {%- set property = properties[property_id] %} | |
341 if (!value->isPrimitiveValue()) | |
342 return; | |
343 | |
344 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
345 float zoom = state.style()->effectiveZoom(); | |
346 {{ set_value(property) }}(primitiveValue->computeLength<{{property.type_name
}}>(state.style(), state.rootElementStyle(), zoom)); | |
347 } | |
348 {%- endmacro %} | |
349 | |
350 {{ apply_value_compute_length("CSSPropertyOutlineOffset") }} | |
351 {{ apply_value_compute_length("CSSPropertyWebkitBorderHorizontalSpacing") }} | |
352 {{ apply_value_compute_length("CSSPropertyWebkitBorderVerticalSpacing") }} | |
353 {{ apply_value_compute_length("CSSPropertyWebkitTransformOriginZ") }} | |
354 | |
355 {%- macro apply_counter(property_id, action) %} | |
356 {%- set property = properties[property_id] %} | |
357 {{ declare_initial_function(property_id) }} { } | |
358 | |
359 {{ declare_inherit_function(property_id) }} | |
360 { | |
361 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); | |
362 CounterDirectiveMap& parentMap = state.parentStyle()->accessCounterDirective
s(); | |
363 | |
364 typedef CounterDirectiveMap::iterator Iterator; | |
365 Iterator end = parentMap.end(); | |
366 for (Iterator it = parentMap.begin(); it != end; ++it) { | |
367 CounterDirectives& directives = map.add(it->key, CounterDirectives()).it
erator->value; | |
368 directives.inherit{{action}}(it->value); | |
369 } | |
370 } | |
371 | |
372 {{ declare_value_function(property_id) }} | |
373 { | |
374 if (!value->isValueList()) | |
375 return; | |
376 | |
377 CSSValueList* list = toCSSValueList(value); | |
378 | |
379 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); | |
380 typedef CounterDirectiveMap::iterator Iterator; | |
381 | |
382 Iterator end = map.end(); | |
383 for (Iterator it = map.begin(); it != end; ++it) | |
384 it->value.clear{{action}}(); | |
385 | |
386 int length = list ? list->length() : 0; | |
387 for (int i = 0; i < length; ++i) { | |
388 CSSValue* currValue = list->itemWithoutBoundsCheck(i); | |
389 if (!currValue->isPrimitiveValue()) | |
390 continue; | |
391 | |
392 Pair* pair = toCSSPrimitiveValue(currValue)->getPairValue(); | |
393 if (!pair || !pair->first() || !pair->second()) | |
394 continue; | |
395 | |
396 AtomicString identifier = pair->first()->getStringValue(); | |
397 int value = pair->second()->getIntValue(); | |
398 CounterDirectives& directives = map.add(identifier, CounterDirectives())
.iterator->value; | |
399 {%- if action == "Reset" %} | |
400 directives.setResetValue(value); | |
401 {%- else %} | |
402 directives.addIncrementValue(value); | |
403 {%- endif %} | |
404 } | |
405 } | |
406 {%- endmacro %} | |
407 | |
408 {{ apply_counter("CSSPropertyCounterIncrement", "Increment") }} | |
409 {{ apply_counter("CSSPropertyCounterReset", "Reset") }} | |
410 | |
411 {%- macro apply_fill_layer(property_id, fill_type) %} | |
412 {%- set layer_type = "Background" if "Background" in property_id else "Mask" %} | |
413 {%- set fill_layer_type = layer_type + "FillLayer" %} | |
414 {%- set access_layers = "access" + layer_type + "Layers" %} | |
415 {%- set map_fill = "mapFill" + fill_type %} | |
416 {{ declare_initial_function(property_id) }} | |
417 { | |
418 FillLayer* currChild = state.style()->{{access_layers}}(); | |
419 currChild->set{{fill_type}}(FillLayer::initialFill{{fill_type}}({{fill_layer
_type}})); | |
420 for (currChild = currChild->next(); currChild; currChild = currChild->next()
) | |
421 currChild->clear{{fill_type}}(); | |
422 } | |
423 | |
424 {{ declare_inherit_function(property_id) }} | |
425 { | |
426 FillLayer* currChild = state.style()->{{access_layers}}(); | |
427 FillLayer* prevChild = 0; | |
428 const FillLayer* currParent = state.parentStyle()->{{layer_type|lower}}Layer
s(); | |
429 while (currParent && currParent->is{{fill_type}}Set()) { | |
430 if (!currChild) { | |
431 /* Need to make a new layer.*/ | |
432 currChild = new FillLayer({{fill_layer_type}}); | |
433 prevChild->setNext(currChild); | |
434 } | |
435 currChild->set{{fill_type}}(currParent->{{lower_first(fill_type)}}()); | |
436 prevChild = currChild; | |
437 currChild = prevChild->next(); | |
438 currParent = currParent->next(); | |
439 } | |
440 | |
441 while (currChild) { | |
442 /* Reset any remaining layers to not have the property set. */ | |
443 currChild->clear{{fill_type}}(); | |
444 currChild = currChild->next(); | |
445 } | |
446 } | |
447 | |
448 {{ declare_value_function(property_id) }} | |
449 { | |
450 FillLayer* currChild = state.style()->{{access_layers}}(); | |
451 FillLayer* prevChild = 0; | |
452 if (value->isValueList() && !value->isImageSetValue()) { | |
453 /* Walk each value and put it into a layer, creating new layers as neede
d. */ | |
454 CSSValueList* valueList = toCSSValueList(value); | |
455 for (unsigned int i = 0; i < valueList->length(); i++) { | |
456 if (!currChild) { | |
457 /* Need to make a new layer to hold this value */ | |
458 currChild = new FillLayer({{fill_layer_type}}); | |
459 prevChild->setNext(currChild); | |
460 } | |
461 state.styleMap().{{map_fill}}({{property_id}}, currChild, valueList-
>itemWithoutBoundsCheck(i)); | |
462 prevChild = currChild; | |
463 currChild = currChild->next(); | |
464 } | |
465 } else { | |
466 state.styleMap().{{map_fill}}({{property_id}}, currChild, value); | |
467 currChild = currChild->next(); | |
468 } | |
469 while (currChild) { | |
470 /* Reset all remaining layers to not have the property set. */ | |
471 currChild->clear{{fill_type}}(); | |
472 currChild = currChild->next(); | |
473 } | |
474 } | |
475 {%- endmacro %} | |
476 | |
477 {{ apply_fill_layer("CSSPropertyBackgroundAttachment", "Attachment") }} | |
478 {{ apply_fill_layer("CSSPropertyBackgroundBlendMode", "BlendMode") }} | |
479 {{ apply_fill_layer("CSSPropertyBackgroundClip", "Clip") }} | |
480 {{ apply_fill_layer("CSSPropertyBackgroundImage", "Image") }} | |
481 {{ apply_fill_layer("CSSPropertyBackgroundOrigin", "Origin") }} | |
482 {{ apply_fill_layer("CSSPropertyBackgroundPositionX", "XPosition") }} | |
483 {{ apply_fill_layer("CSSPropertyBackgroundPositionY", "YPosition") }} | |
484 {{ apply_fill_layer("CSSPropertyBackgroundRepeatX", "RepeatX") }} | |
485 {{ apply_fill_layer("CSSPropertyBackgroundRepeatY", "RepeatY") }} | |
486 {{ apply_fill_layer("CSSPropertyBackgroundSize", "Size") }} | |
487 {{ apply_fill_layer("CSSPropertyWebkitBackgroundComposite", "Composite") }} | |
488 {{ apply_fill_layer("CSSPropertyWebkitMaskClip", "Clip") }} | |
489 {{ apply_fill_layer("CSSPropertyWebkitMaskComposite", "Composite") }} | |
490 {{ apply_fill_layer("CSSPropertyWebkitMaskImage", "Image") }} | |
491 {{ apply_fill_layer("CSSPropertyWebkitMaskOrigin", "Origin") }} | |
492 {{ apply_fill_layer("CSSPropertyWebkitMaskPositionX", "XPosition") }} | |
493 {{ apply_fill_layer("CSSPropertyWebkitMaskPositionY", "YPosition") }} | |
494 {{ apply_fill_layer("CSSPropertyWebkitMaskRepeatX", "RepeatX") }} | |
495 {{ apply_fill_layer("CSSPropertyWebkitMaskRepeatY", "RepeatY") }} | |
496 {{ apply_fill_layer("CSSPropertyWebkitMaskSize", "Size") }} | |
497 | |
498 {%- macro apply_font(property_id, name_for_methods, initial, type_name) %} | |
499 {#- We specify the getters/setters here since they are on FontDescription | |
500 and not RenderStyle #} | |
501 {%- set getter = lower_first(name_for_methods) %} | |
502 {%- set setter = "set" + name_for_methods %} | |
503 {{ declare_initial_function(property_id) }} | |
504 { | |
505 state.fontBuilder().{{setter}}({{initial}}); | |
506 } | |
507 | |
508 {{ declare_inherit_function(property_id) }} | |
509 { | |
510 state.fontBuilder().{{setter}}(state.parentFontDescription().{{getter}}()); | |
511 } | |
512 | |
513 {{ declare_value_function(property_id) }} | |
514 { | |
515 if (!value->isPrimitiveValue()) | |
516 return; | |
517 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
518 state.fontBuilder().{{setter}}(static_cast<{{type_name}}>(*primitiveValue)); | |
519 } | |
520 {%- endmacro %} | |
521 | |
522 {{ apply_font("CSSPropertyFontStyle", "Italic", "FontItalicOff", "FontItalic") }
} | |
523 {{ apply_font("CSSPropertyFontVariant", "SmallCaps", "FontSmallCapsOff", "FontSm
allCaps") }} | |
524 {{ apply_font("CSSPropertyTextRendering", "TextRenderingMode", "AutoTextRenderin
g", "TextRenderingMode") }} | |
525 {{ apply_font("CSSPropertyWebkitFontKerning", "Kerning", "FontDescription::AutoK
erning", "FontDescription::Kerning") }} | |
526 {{ apply_font("CSSPropertyWebkitFontSmoothing", "FontSmoothing", "AutoSmoothing"
, "FontSmoothingMode") }} | |
527 | |
528 {%- macro apply_value_line_width(property_id) %} | |
529 {{ declare_value_function(property_id) }} | |
530 { | |
531 {%- set property = properties[property_id] %} | |
532 {%- set T = property.type_name %} | |
533 if (!value->isPrimitiveValue()) | |
534 return; | |
535 | |
536 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
537 CSSValueID valueID = primitiveValue->getValueID(); | |
538 {{ T }} length; | |
539 if (valueID == CSSValueThin) { | |
540 length = 1; | |
541 } else if (valueID == CSSValueMedium) { | |
542 length = 3; | |
543 } else if (valueID == CSSValueThick) { | |
544 length = 5; | |
545 } else if (valueID == CSSValueInvalid) { | |
546 float zoom = state.style()->effectiveZoom(); | |
547 // Any original result that was >= 1 should not be allowed to fall below
1. | |
548 // This keeps border lines from vanishing. | |
549 length = primitiveValue->computeLength<{{T}}>(state.style(), state.rootE
lementStyle(), zoom); | |
550 if (zoom < 1.0f && length < 1.0) { | |
551 {{ T }} originalLength = primitiveValue->computeLength<{{T}}>(state.
style(), state.rootElementStyle(), 1.0); | |
552 if (originalLength >= 1.0) | |
553 length = 1.0; | |
554 } | |
555 } else { | |
556 ASSERT_NOT_REACHED(); | |
557 length = 0; | |
558 } | |
559 {{ set_value(property) }}(length); | |
560 } | |
561 {%- endmacro %} | |
562 | |
563 {{ apply_value_line_width("CSSPropertyBorderBottomWidth") }} | |
564 {{ apply_value_line_width("CSSPropertyBorderLeftWidth") }} | |
565 {{ apply_value_line_width("CSSPropertyBorderRightWidth") }} | |
566 {{ apply_value_line_width("CSSPropertyBorderTopWidth") }} | |
567 {{ apply_value_line_width("CSSPropertyOutlineWidth") }} | |
568 {{ apply_value_line_width("CSSPropertyWebkitColumnRuleWidth") }} | |
569 | |
570 {%- macro apply_value_number(property_id, id_for_minus_one) %} | |
571 {{ declare_value_function(property_id) }} | |
572 { | |
573 {%- set property = properties[property_id] %} | |
574 if (!value->isPrimitiveValue()) | |
575 return; | |
576 | |
577 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
578 if (primitiveValue->getValueID() == {{id_for_minus_one}}) | |
579 {{ set_value(property) }}(-1); | |
580 else | |
581 {{ set_value(property) }}(primitiveValue->getValue<{{property.type_name}
}>(CSSPrimitiveValue::CSS_NUMBER)); | |
582 } | |
583 {%- endmacro %} | |
584 | |
585 {{ apply_value_number("CSSPropertyWebkitMarqueeRepetition", "CSSValueInfinite")
}} | |
586 | |
587 {%- macro apply_value_shape(property_id) %} | |
588 {{ declare_value_function(property_id) }} | |
589 { | |
590 {%- set property = properties[property_id] %} | |
591 if (value->isPrimitiveValue()) { | |
592 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
593 if (primitiveValue->getValueID() == CSSValueAuto) | |
594 {{ set_value(property) }}(0); | |
595 else if (primitiveValue->getValueID() == CSSValueOutsideShape) | |
596 {{ set_value(property) }}(ShapeValue::createOutsideValue()); | |
597 else if (primitiveValue->isShape()) { | |
598 {{ set_value(property) }}(ShapeValue::createShapeValue(basicShapeFor
Value(state, primitiveValue->getShapeValue()))); | |
599 } | |
600 } else if (value->isImageValue()) { | |
601 {{ set_value(property) }}(ShapeValue::createImageValue(state.styleImage(
{{property_id}}, value))); | |
602 } | |
603 } | |
604 {%- endmacro %} | |
605 | |
606 {{ apply_value_shape("CSSPropertyWebkitShapeInside") }} | |
607 {{ apply_value_shape("CSSPropertyWebkitShapeOutside") }} | |
608 | |
609 {%- macro apply_value_spacing(property_id) %} | |
610 {{ declare_value_function(property_id) }} | |
611 { | |
612 {%- set property = properties[property_id] %} | |
613 {%- set T = property.type_name %} | |
614 if (!value->isPrimitiveValue()) | |
615 return; | |
616 | |
617 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
618 {{ T }} length; | |
619 if (primitiveValue->getValueID() == CSSValueNormal) { | |
620 length = 0; | |
621 } else { | |
622 float zoom = state.useSVGZoomRules() ? 1.0f : state.style()->effectiveZo
om(); | |
623 length = primitiveValue->computeLength<{{T}}>(state.style(), state.rootE
lementStyle(), zoom); | |
624 } | |
625 {{ set_value(property) }}(length); | |
626 } | |
627 {%- endmacro %} | |
628 | |
629 {{ apply_value_spacing("CSSPropertyLetterSpacing") }} | |
630 {{ apply_value_spacing("CSSPropertyWordSpacing") }} | |
631 | |
632 {%- macro apply_value_string(property_id, id_for_none) %} | |
633 {{ declare_value_function(property_id) }} | |
634 { | |
635 {%- set property = properties[property_id] %} | |
636 if (!value->isPrimitiveValue()) | |
637 return; | |
638 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
639 if (primitiveValue->getValueID() == {{id_for_none}}) | |
640 {{ set_value(property) }}(nullAtom); | |
641 else | |
642 {{ set_value(property) }}(primitiveValue->getStringValue()); | |
643 } | |
644 {%- endmacro %} | |
645 | |
646 {{ apply_value_string("CSSPropertyWebkitHighlight", "CSSValueNone") }} | |
647 {{ apply_value_string("CSSPropertyWebkitHyphenateCharacter", "CSSValueAuto") }} | |
648 {{ apply_value_string("CSSPropertyWebkitLineGrid", "CSSValueNone") }} | |
649 {{ apply_value_string("CSSPropertyWebkitFlowFrom", "CSSValueNone") }} | |
650 {{ apply_value_string("CSSPropertyWebkitFlowInto", "CSSValueNone") }} | |
651 | |
652 } // namespace WebCore | |
OLD | NEW |