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

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

Issue 186403002: Make font-related CSS properties less custom. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed comments. Created 6 years, 9 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
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 {%- elif property.font -%}
18 state.fontBuilder().{{property.setter}}
17 {%- else -%} 19 {%- else -%}
18 state.style()->{{property.setter}} 20 state.style()->{{property.setter}}
19 {%- endif %} 21 {%- endif %}
20 {%- endmacro %} 22 {%- endmacro %}
21 23
22 namespace WebCore { 24 namespace WebCore {
23 25
24 {%- for property_id, property in properties.items() if not property.use_handlers _for %} 26 {%- for property_id, property in properties.items() if not property.use_handlers _for %}
25 {%- call wrap_with_condition(property.condition) %} 27 {%- call wrap_with_condition(property.condition) %}
26 {%- set apply_type = property.apply_type %} 28 {%- set apply_type = property.apply_type %}
27 29
28 {%- if not property.custom_initial %} 30 {%- if not property.custom_initial %}
29 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat e) 31 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat e)
30 { 32 {
31 {%- if property.svg %} 33 {%- if property.svg %}
32 {{ set_value(property) }}(SVGRenderStyle::{{property.initial}}()); 34 {{ set_value(property) }}(SVGRenderStyle::{{property.initial}}());
35 {%- elif property.font %}
36 {{ set_value(property) }}(FontBuilder::{{property.initial}}());
33 {%- else %} 37 {%- else %}
34 {{ set_value(property) }}(RenderStyle::{{property.initial}}()); 38 {{ set_value(property) }}(RenderStyle::{{property.initial}}());
35 {%- endif %} 39 {%- endif %}
36 } 40 }
37 {% endif %} 41 {% endif %}
38 42
39 {%- if not property.custom_inherit %} 43 {%- if not property.custom_inherit %}
40 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat e) 44 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat e)
41 { 45 {
42 {%- if property.svg %} 46 {%- if property.svg %}
43 {{ set_value(property) }}(state.parentStyle()->svgStyle()->{{property.getter }}()); 47 {{ set_value(property) }}(state.parentStyle()->svgStyle()->{{property.getter }}());
48 {%- elif property.font %}
49 {{ set_value(property) }}(state.parentFontDescription().{{property.getter}}( ));
44 {%- else %} 50 {%- else %}
45 {{ set_value(property) }}(state.parentStyle()->{{property.getter}}()); 51 {{ set_value(property) }}(state.parentStyle()->{{property.getter}}());
46 {%- endif %} 52 {%- endif %}
47 } 53 }
48 {% endif %} 54 {% endif %}
49 55
50 {%- if not property.custom_value %} 56 {%- if not property.custom_value %}
51 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, CSSValue* value) 57 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, CSSValue* value)
52 { 58 {
53 {%- if property.converter %} 59 {%- if property.converter %}
54 {{ set_value(property) }}(StyleBuilderConverter::{{property.converter}}(stat e, value)); 60 {{ set_value(property) }}(StyleBuilderConverter::{{property.converter}}(stat e, value));
61 {%- elif property.font %}
62 if (!value->isPrimitiveValue())
63 return;
64 {{ set_value(property) }}(static_cast<{{property.type_name}}>(*toCSSPrimitiv eValue(value)));
55 {%- else %} 65 {%- else %}
56 {{ set_value(property) }}(static_cast<{{property.type_name}}>(*toCSSPrimitiv eValue(value))); 66 {{ set_value(property) }}(static_cast<{{property.type_name}}>(*toCSSPrimitiv eValue(value)));
57 {%- endif %} 67 {%- endif %}
58 } 68 }
59 {% endif %} 69 {% endif %}
60 70
61 {%- endcall %} 71 {%- endcall %}
62 {%- endfor %} 72 {%- endfor %}
63 73
64 bool StyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& sta te, CSSValue* value, bool isInitial, bool isInherit) { 74 bool StyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& sta te, CSSValue* value, bool isInitial, bool isInherit) {
(...skipping 11 matching lines...) Expand all
76 StyleBuilderFunctions::applyValue{{ used_property_id }}(state, value ); 86 StyleBuilderFunctions::applyValue{{ used_property_id }}(state, value );
77 return true; 87 return true;
78 {%- endcall %} 88 {%- endcall %}
79 {% endfor %} 89 {% endfor %}
80 default: 90 default:
81 return false; 91 return false;
82 } 92 }
83 } 93 }
84 94
85 } // namespace WebCore 95 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/build/scripts/make_style_builder.py ('k') | Source/build/scripts/templates/StyleBuilderFunctions.cpp.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698