OLD | NEW |
1 {% from "macros.tmpl" import lower_first %} | 1 {% from "macros.tmpl" import lower_first %} |
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" |
11 | 11 |
12 #include "CSSValueKeywords.h" | 12 #include "CSSValueKeywords.h" |
13 #include "core/animation/css/CSSAnimationDataList.h" | 13 #include "core/animation/css/CSSAnimationDataList.h" |
14 #include "core/css/BasicShapeFunctions.h" | 14 #include "core/css/BasicShapeFunctions.h" |
15 #include "core/css/CSSPrimitiveValueMappings.h" | 15 #include "core/css/CSSPrimitiveValueMappings.h" |
16 #include "core/css/Pair.h" | 16 #include "core/css/Pair.h" |
17 #include "core/css/resolver/StyleResolverState.h" | 17 #include "core/css/resolver/StyleResolverState.h" |
18 | 18 |
19 {# FIXME: factor macros out into a separate library #} | |
20 {% macro declare_initial_function(property_id) %} | 19 {% macro declare_initial_function(property_id) %} |
21 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat
e) | 20 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat
e) |
22 {%- endmacro %} | 21 {%- endmacro %} |
23 {% macro declare_inherit_function(property_id) %} | 22 {% macro declare_inherit_function(property_id) %} |
24 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat
e) | 23 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat
e) |
25 {%- endmacro %} | 24 {%- endmacro %} |
26 {% macro declare_value_function(property_id) %} | 25 {% macro declare_value_function(property_id) %} |
27 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state,
CSSValue* value) | 26 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state,
CSSValue* value) |
28 {%- endmacro %} | 27 {%- endmacro %} |
29 // FIXME: This is duplicated in StyleBuilder.cpp.tmpl, but we'll move the | |
30 // function definitions there over to here later. | |
31 {% macro set_value(property) %} | 28 {% macro set_value(property) %} |
32 {% if property.svg %} | 29 {% if property.svg %} |
33 state.style()->accessSVGStyle()->{{property.setter}} | 30 state.style()->accessSVGStyle()->{{property.setter}} |
| 31 {%- elif property.font %} |
| 32 state.fontBuilder().{{property.setter}} |
34 {%- else %} | 33 {%- else %} |
35 state.style()->{{property.setter}} | 34 state.style()->{{property.setter}} |
36 {%- endif %} | 35 {%- endif %} |
37 {% endmacro %} | 36 {% endmacro %} |
38 | 37 |
39 namespace WebCore { | 38 namespace WebCore { |
40 {# FIXME: remove excess newline #} | |
41 | 39 |
| 40 {% for property_id, property in properties.items() if not property.use_handlers_
for %} |
| 41 {% set apply_type = property.apply_type %} |
| 42 {% if not property.custom_initial %} |
| 43 {{declare_initial_function(property_id)}} |
| 44 { |
| 45 {% if property.svg %} |
| 46 {{set_value(property)}}(SVGRenderStyle::{{property.initial}}()); |
| 47 {% elif property.font %} |
| 48 {{set_value(property)}}(FontBuilder::{{property.initial}}()); |
| 49 {% else %} |
| 50 {{set_value(property)}}(RenderStyle::{{property.initial}}()); |
| 51 {% endif %} |
| 52 } |
| 53 |
| 54 {% endif %} |
| 55 {% if not property.custom_inherit %} |
| 56 {{declare_inherit_function(property_id)}} |
| 57 { |
| 58 {% if property.svg %} |
| 59 {{set_value(property)}}(state.parentStyle()->svgStyle()->{{property.getter}}
()); |
| 60 {% elif property.font %} |
| 61 {{set_value(property)}}(state.parentFontDescription().{{property.getter}}())
; |
| 62 {% else %} |
| 63 {{set_value(property)}}(state.parentStyle()->{{property.getter}}()); |
| 64 {% endif %} |
| 65 } |
| 66 |
| 67 {% endif %} |
| 68 {% if not property.custom_value %} |
| 69 {{declare_value_function(property_id)}} |
| 70 { |
| 71 {% if property.converter %} |
| 72 {{set_value(property)}}(StyleBuilderConverter::{{property.converter}}(state,
value)); |
| 73 {% else %} |
| 74 {{set_value(property)}}(static_cast<{{property.type_name}}>(*toCSSPrimitiveV
alue(value))); |
| 75 {% endif %} |
| 76 } |
| 77 |
| 78 {% endif %} |
| 79 {% endfor %} |
42 | 80 |
43 {% macro apply_animation(property_id, attribute, animation) %} | 81 {% macro apply_animation(property_id, attribute, animation) %} |
44 {{declare_initial_function(property_id)}} | 82 {{declare_initial_function(property_id)}} |
45 { | 83 { |
46 CSSAnimationDataList* list = state.style()->access{{animation}}(); | 84 CSSAnimationDataList* list = state.style()->access{{animation}}(); |
47 if (list->isEmpty()) | 85 if (list->isEmpty()) |
48 list->append(CSSAnimationData::create()); | 86 list->append(CSSAnimationData::create()); |
49 list->animation(0)->set{{attribute}}(CSSAnimationData::initialAnimation{{att
ribute}}()); | 87 list->animation(0)->set{{attribute}}(CSSAnimationData::initialAnimation{{att
ribute}}()); |
50 {% if property_id == "CSSPropertyWebkitTransitionProperty" %} | 88 {% if property_id == "CSSPropertyWebkitTransitionProperty" %} |
51 list->animation(0)->setAnimationMode(CSSAnimationData::AnimateAll); | 89 list->animation(0)->setAnimationMode(CSSAnimationData::AnimateAll); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 | 499 |
462 if (shape) | 500 if (shape) |
463 {{set_value(property)}}(ShapeValue::createShapeValue(shape.release()
, cssBox)); | 501 {{set_value(property)}}(ShapeValue::createShapeValue(shape.release()
, cssBox)); |
464 else if (cssBox != BoxMissing) | 502 else if (cssBox != BoxMissing) |
465 {{set_value(property)}}(ShapeValue::createBoxShapeValue(cssBox)); | 503 {{set_value(property)}}(ShapeValue::createBoxShapeValue(cssBox)); |
466 } | 504 } |
467 } | 505 } |
468 {% endmacro %} | 506 {% endmacro %} |
469 {{apply_value_shape('CSSPropertyShapeOutside')}} | 507 {{apply_value_shape('CSSPropertyShapeOutside')}} |
470 } // namespace WebCore | 508 } // namespace WebCore |
OLD | NEW |