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" | 8 #include "core/css/CSSPrimitiveValueMappings.h" |
9 #include "core/css/resolver/StyleResolverState.h" | 9 #include "core/css/resolver/StyleResolverState.h" |
10 | 10 |
11 // FIXME: currently we're just generating a switch statement, but we should | 11 // FIXME: currently we're just generating a switch statement, but we should |
12 // test other variations for performance once we have more properties here. | 12 // test other variations for performance once we have more properties here. |
13 | 13 |
14 {%- macro set_value(property) %} | 14 {%- macro set_value(property) %} |
15 {%- if property.svg -%} | 15 {%- if property.svg -%} |
16 state.style()->accessSVGStyle()->{{property.setter}} | 16 state.style()->accessSVGStyle()->{{property.setter}} |
17 {%- else -%} | 17 {%- else -%} |
18 state.style()->{{property.setter}} | 18 state.style()->{{property.setter}} |
19 {%- endif %} | 19 {%- endif %} |
Timothy Loh
2014/03/04 05:58:22
I'd probably put state.fontBuilder().{{property.se
dglazkov
2014/03/05 04:05:19
Done.
| |
20 {%- endmacro %} | 20 {%- endmacro %} |
21 | 21 |
22 namespace WebCore { | 22 namespace WebCore { |
23 | 23 |
24 {%- for property_id, property in properties.items() if not property.use_handlers _for %} | 24 {%- for property_id, property in properties.items() if not property.use_handlers _for %} |
25 {%- call wrap_with_condition(property.condition) %} | 25 {%- call wrap_with_condition(property.condition) %} |
26 {%- set apply_type = property.apply_type %} | 26 {%- set apply_type = property.apply_type %} |
27 | 27 |
28 {%- if not property.custom_initial %} | 28 {%- if not property.custom_initial %} |
29 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat e) | 29 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat e) |
30 { | 30 { |
31 {%- if property.svg %} | 31 {%- if property.svg %} |
32 {{ set_value(property) }}(SVGRenderStyle::{{property.initial}}()); | 32 {{ set_value(property) }}(SVGRenderStyle::{{property.initial}}()); |
33 {%- elif property.font %} | |
34 state.fontBuilder().{{property.setter}}(FontBuilder::{{property.initial}}()) ; | |
33 {%- else %} | 35 {%- else %} |
34 {{ set_value(property) }}(RenderStyle::{{property.initial}}()); | 36 {{ set_value(property) }}(RenderStyle::{{property.initial}}()); |
35 {%- endif %} | 37 {%- endif %} |
36 } | 38 } |
37 {% endif %} | 39 {% endif %} |
38 | 40 |
39 {%- if not property.custom_inherit %} | 41 {%- if not property.custom_inherit %} |
40 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat e) | 42 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat e) |
41 { | 43 { |
42 {%- if property.svg %} | 44 {%- if property.svg %} |
43 {{ set_value(property) }}(state.parentStyle()->svgStyle()->{{property.getter }}()); | 45 {{ set_value(property) }}(state.parentStyle()->svgStyle()->{{property.getter }}()); |
46 {%- elif property.font %} | |
47 state.fontBuilder().{{property.setter}}(state.parentFontDescription().{{prop erty.getter}}()); | |
44 {%- else %} | 48 {%- else %} |
45 {{ set_value(property) }}(state.parentStyle()->{{property.getter}}()); | 49 {{ set_value(property) }}(state.parentStyle()->{{property.getter}}()); |
46 {%- endif %} | 50 {%- endif %} |
47 } | 51 } |
48 {% endif %} | 52 {% endif %} |
49 | 53 |
50 {%- if not property.custom_value %} | 54 {%- if not property.custom_value %} |
51 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, CSSValue* value) | 55 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, CSSValue* value) |
52 { | 56 { |
53 {%- if property.converter %} | 57 {%- if property.converter %} |
54 {{ set_value(property) }}(StyleBuilderConverter::{{property.converter}}(stat e, value)); | 58 {{ set_value(property) }}(StyleBuilderConverter::{{property.converter}}(stat e, value)); |
59 {%- elif property.font %} | |
60 if (!value->isPrimitiveValue()) | |
Timothy Loh
2014/03/04 05:58:22
Can we see if removing this branch doesn't break a
dglazkov
2014/03/05 04:05:19
Will do next!
| |
61 return; | |
62 state.fontBuilder().{{property.setter}}(static_cast<{{property.type_name}}>( *toCSSPrimitiveValue(value))); | |
55 {%- else %} | 63 {%- else %} |
56 {{ set_value(property) }}(static_cast<{{property.type_name}}>(*toCSSPrimitiv eValue(value))); | 64 {{ set_value(property) }}(static_cast<{{property.type_name}}>(*toCSSPrimitiv eValue(value))); |
57 {%- endif %} | 65 {%- endif %} |
58 } | 66 } |
59 {% endif %} | 67 {% endif %} |
60 | 68 |
61 {%- endcall %} | 69 {%- endcall %} |
62 {%- endfor %} | 70 {%- endfor %} |
63 | 71 |
64 bool StyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& sta te, CSSValue* value, bool isInitial, bool isInherit) { | 72 bool StyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& sta te, CSSValue* value, bool isInitial, bool isInherit) { |
(...skipping 11 matching lines...) Expand all Loading... | |
76 StyleBuilderFunctions::applyValue{{ used_property_id }}(state, value ); | 84 StyleBuilderFunctions::applyValue{{ used_property_id }}(state, value ); |
77 return true; | 85 return true; |
78 {%- endcall %} | 86 {%- endcall %} |
79 {% endfor %} | 87 {% endfor %} |
80 default: | 88 default: |
81 return false; | 89 return false; |
82 } | 90 } |
83 } | 91 } |
84 | 92 |
85 } // namespace WebCore | 93 } // namespace WebCore |
OLD | NEW |