Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: Source/build/scripts/templates/StyleBuilder.cpp.tmpl

Issue 236673002: Simplify whitespace handling in build/ Jinja templates (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: One more FIXME Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 {% macro set_value(property) %}
14 {%- macro set_value(property) %} 14 {% if property.svg %}
15 {%- if property.svg -%} 15 state.style()->accessSVGStyle()->{{property.setter}}
16 state.style()->accessSVGStyle()->{{property.setter}} 16 {%- elif property.font %}
17 {%- elif property.font -%} 17 state.fontBuilder().{{property.setter}}
18 state.fontBuilder().{{property.setter}} 18 {%- else %}
19 {%- else -%} 19 state.style()->{{property.setter}}
20 state.style()->{{property.setter}}
21 {%- endif %} 20 {%- endif %}
22 {%- endmacro %} 21 {% endmacro %}
23 22
24 namespace WebCore { 23 namespace WebCore {
25 24 {# FIXME: add blank line #}
26 {%- for property_id, property in properties.items() if not property.use_handlers _for %} 25 {% for property_id, property in properties.items() if not property.use_handlers_ for %}
27 {%- call wrap_with_condition(property.condition) %} 26 {% call wrap_with_condition(property.condition) %}
28 {%- set apply_type = property.apply_type %} 27 {% set apply_type = property.apply_type %}
29 28 {% if not property.custom_initial %}
30 {%- if not property.custom_initial %}
31 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat e) 29 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat e)
32 { 30 {
33 {%- if property.svg %} 31 {% if property.svg %}
34 {{ set_value(property) }}(SVGRenderStyle::{{property.initial}}()); 32 {{set_value(property)}}(SVGRenderStyle::{{property.initial}}());
35 {%- elif property.font %} 33 {% elif property.font %}
36 {{ set_value(property) }}(FontBuilder::{{property.initial}}()); 34 {{set_value(property)}}(FontBuilder::{{property.initial}}());
37 {%- else %} 35 {% else %}
38 {{ set_value(property) }}(RenderStyle::{{property.initial}}()); 36 {{set_value(property)}}(RenderStyle::{{property.initial}}());
39 {%- endif %} 37 {% endif %}
40 } 38 }
39
41 {% endif %} 40 {% endif %}
42 41 {% if not property.custom_inherit %}
43 {%- if not property.custom_inherit %}
44 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat e) 42 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat e)
45 { 43 {
46 {%- if property.svg %} 44 {% if property.svg %}
47 {{ set_value(property) }}(state.parentStyle()->svgStyle()->{{property.getter }}()); 45 {{set_value(property)}}(state.parentStyle()->svgStyle()->{{property.getter}} ());
48 {%- elif property.font %} 46 {% elif property.font %}
49 {{ set_value(property) }}(state.parentFontDescription().{{property.getter}}( )); 47 {{set_value(property)}}(state.parentFontDescription().{{property.getter}}()) ;
50 {%- else %} 48 {% else %}
51 {{ set_value(property) }}(state.parentStyle()->{{property.getter}}()); 49 {{set_value(property)}}(state.parentStyle()->{{property.getter}}());
52 {%- endif %} 50 {% endif %}
53 } 51 }
52
54 {% endif %} 53 {% endif %}
55 54 {% if not property.custom_value %}
56 {%- if not property.custom_value %}
57 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, CSSValue* value) 55 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, CSSValue* value)
58 { 56 {
59 {%- if property.converter %} 57 {% if property.converter %}
60 {{ set_value(property) }}(StyleBuilderConverter::{{property.converter}}(stat e, value)); 58 {{ set_value(property) }}(StyleBuilderConverter::{{property.converter}}(stat e, value));
61 {%- elif property.font %} 59 {% elif property.font %}
62 if (!value->isPrimitiveValue()) 60 if (!value->isPrimitiveValue())
63 return; 61 return;
64 {{ set_value(property) }}(static_cast<{{property.type_name}}>(*toCSSPrimitiv eValue(value))); 62 {{set_value(property)}}(static_cast<{{property.type_name}}>(*toCSSPrimitiveV alue(value)));
65 {%- else %} 63 {% else %}
66 {{ set_value(property) }}(static_cast<{{property.type_name}}>(*toCSSPrimitiv eValue(value))); 64 {{set_value(property)}}(static_cast<{{property.type_name}}>(*toCSSPrimitiveV alue(value)));
67 {%- endif %} 65 {% endif %}
68 } 66 }
67
69 {% endif %} 68 {% endif %}
70 69 {% endcall %}
71 {%- endcall %} 70 {% endfor %}
72 {%- endfor %}
73 71
74 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) {
75 switch(property) { 73 switch(property) {
76 {%- for property_id, property in properties.items() %} 74 {% for property_id, property in properties.items() %}
77 {%- set used_property = properties[property.use_handlers_for] or property %} 75 {% set used_property = properties[property.use_handlers_for] or property %}
78 {%- set used_property_id = used_property.property_id %} 76 {% set used_property_id = used_property.property_id %}
79 {%- call wrap_with_condition(used_property.condition) %} 77 {% call wrap_with_condition(used_property.condition) %}
80 case {{ property_id }}: 78 case {{ property_id }}:
81 if (isInitial) 79 if (isInitial)
82 StyleBuilderFunctions::applyInitial{{ used_property_id }}(state); 80 StyleBuilderFunctions::applyInitial{{ used_property_id }}(state);
83 else if (isInherit) 81 else if (isInherit)
84 StyleBuilderFunctions::applyInherit{{ used_property_id }}(state); 82 StyleBuilderFunctions::applyInherit{{ used_property_id }}(state);
85 else 83 else
86 StyleBuilderFunctions::applyValue{{ used_property_id }}(state, value ); 84 StyleBuilderFunctions::applyValue{{ used_property_id }}(state, value );
87 return true; 85 return true;
88 {%- endcall %} 86
89 {% endfor %} 87 {% endcall %}
88 {% endfor %}
90 default: 89 default:
91 return false; 90 return false;
92 } 91 }
93 } 92 }
94 93
95 } // namespace WebCore 94 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/build/scripts/templates/SettingsMacros.h.tmpl ('k') | Source/build/scripts/templates/StyleBuilderFunctions.cpp.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698