| OLD | NEW |
| 1 {% from "macros.tmpl" import wrap_with_condition, license %} | 1 {% from "macros.tmpl" import wrap_with_condition, license %} |
| 2 {{ license() }} | 2 {{ license() }} |
| 3 | 3 |
| 4 #include "config.h" | 4 #include "config.h" |
| 5 #include "core/css/resolver/StyleBuilder.h" | 5 #include "core/css/resolver/StyleBuilder.h" |
| 6 | 6 |
| 7 #include "StyleBuilderFunctions.h" | 7 #include "StyleBuilderFunctions.h" |
| 8 #include "core/css/CSSPrimitiveValueMappings.h" | |
| 9 #include "core/css/resolver/StyleResolverState.h" | 8 #include "core/css/resolver/StyleResolverState.h" |
| 10 | 9 |
| 11 // FIXME: currently we're just generating a switch statement, but we should | 10 // FIXME: currently we're just generating a switch statement, but we should |
| 12 // test other variations for performance once we have more properties here. | 11 // test other variations for performance once we have more properties here. |
| 13 {% macro set_value(property) %} | |
| 14 {% if property.svg %} | |
| 15 state.style()->accessSVGStyle()->{{property.setter}} | |
| 16 {%- elif property.font %} | |
| 17 state.fontBuilder().{{property.setter}} | |
| 18 {%- else %} | |
| 19 state.style()->{{property.setter}} | |
| 20 {%- endif %} | |
| 21 {% endmacro %} | |
| 22 | 12 |
| 23 namespace WebCore { | 13 namespace WebCore { |
| 24 {# FIXME: add blank line #} | |
| 25 {% for property_id, property in properties.items() if not property.use_handlers_
for %} | |
| 26 {% call wrap_with_condition(property.condition) %} | |
| 27 {% set apply_type = property.apply_type %} | |
| 28 {% if not property.custom_initial %} | |
| 29 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat
e) | |
| 30 { | |
| 31 {% if property.svg %} | |
| 32 {{set_value(property)}}(SVGRenderStyle::{{property.initial}}()); | |
| 33 {% elif property.font %} | |
| 34 {{set_value(property)}}(FontBuilder::{{property.initial}}()); | |
| 35 {% else %} | |
| 36 {{set_value(property)}}(RenderStyle::{{property.initial}}()); | |
| 37 {% endif %} | |
| 38 } | |
| 39 | |
| 40 {% endif %} | |
| 41 {% if not property.custom_inherit %} | |
| 42 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat
e) | |
| 43 { | |
| 44 {% if property.svg %} | |
| 45 {{set_value(property)}}(state.parentStyle()->svgStyle()->{{property.getter}}
()); | |
| 46 {% elif property.font %} | |
| 47 {{set_value(property)}}(state.parentFontDescription().{{property.getter}}())
; | |
| 48 {% else %} | |
| 49 {{set_value(property)}}(state.parentStyle()->{{property.getter}}()); | |
| 50 {% endif %} | |
| 51 } | |
| 52 | |
| 53 {% endif %} | |
| 54 {% if not property.custom_value %} | |
| 55 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state,
CSSValue* value) | |
| 56 { | |
| 57 {% if property.converter %} | |
| 58 {{ set_value(property) }}(StyleBuilderConverter::{{property.converter}}(stat
e, value)); | |
| 59 {% elif property.font %} | |
| 60 if (!value->isPrimitiveValue()) | |
| 61 return; | |
| 62 {{set_value(property)}}(static_cast<{{property.type_name}}>(*toCSSPrimitiveV
alue(value))); | |
| 63 {% else %} | |
| 64 {{set_value(property)}}(static_cast<{{property.type_name}}>(*toCSSPrimitiveV
alue(value))); | |
| 65 {% endif %} | |
| 66 } | |
| 67 | |
| 68 {% endif %} | |
| 69 {% endcall %} | |
| 70 {% endfor %} | |
| 71 | 14 |
| 72 bool StyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& sta
te, CSSValue* value, bool isInitial, bool isInherit) { | 15 bool StyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& sta
te, CSSValue* value, bool isInitial, bool isInherit) { |
| 73 switch(property) { | 16 switch(property) { |
| 74 {% for property_id, property in properties.items() %} | 17 {% for property_id, property in properties.items() %} |
| 75 {% set used_property = properties[property.use_handlers_for] or property %} | 18 {% set used_property = properties[property.use_handlers_for] or property %} |
| 76 {% set used_property_id = used_property.property_id %} | 19 {% set used_property_id = used_property.property_id %} |
| 77 {% call wrap_with_condition(used_property.condition) %} | 20 {% call wrap_with_condition(used_property.condition) %} |
| 78 case {{ property_id }}: | 21 case {{ property_id }}: |
| 79 if (isInitial) | 22 if (isInitial) |
| 80 StyleBuilderFunctions::applyInitial{{ used_property_id }}(state); | 23 StyleBuilderFunctions::applyInitial{{ used_property_id }}(state); |
| 81 else if (isInherit) | 24 else if (isInherit) |
| 82 StyleBuilderFunctions::applyInherit{{ used_property_id }}(state); | 25 StyleBuilderFunctions::applyInherit{{ used_property_id }}(state); |
| 83 else | 26 else |
| 84 StyleBuilderFunctions::applyValue{{ used_property_id }}(state, value
); | 27 StyleBuilderFunctions::applyValue{{ used_property_id }}(state, value
); |
| 85 return true; | 28 return true; |
| 86 | 29 |
| 87 {% endcall %} | 30 {% endcall %} |
| 88 {% endfor %} | 31 {% endfor %} |
| 89 default: | 32 default: |
| 90 return false; | 33 return false; |
| 91 } | 34 } |
| 92 } | 35 } |
| 93 | 36 |
| 94 } // namespace WebCore | 37 } // namespace WebCore |
| OLD | NEW |