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

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: 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 {%- 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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698