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

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

Issue 26414004: Move core/scripts to build/scripts so that platform can use them. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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
(Empty)
1 {% from "macros.tmpl" import wrap_with_condition, license -%}
2 {{ license() }}
3
4 #include "config.h"
5 #include "core/css/resolver/StyleBuilder.h"
6
7 #include "StyleBuilderFunctions.h"
8 #include "core/css/CSSPrimitiveValueMappings.h"
9 #include "core/css/resolver/StyleResolverState.h"
10
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.
13
14 {%- macro set_value(property) %}
15 {%- if property.svg -%}
16 state.style()->accessSVGStyle()->{{property.setter}}
17 {%- else -%}
18 state.style()->{{property.setter}}
19 {%- endif %}
20 {%- endmacro %}
21
22 namespace WebCore {
23
24 {%- for property_id, property in properties.items() if not property.use_handlers _for %}
25 {%- call wrap_with_condition(property.condition) %}
26 {%- set apply_type = property.apply_type %}
27
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 {%- else %}
34 {{ set_value(property) }}(RenderStyle::{{property.initial}}());
35 {%- endif %}
36 }
37 {% endif %}
38
39 {%- if not property.custom_inherit %}
40 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat e)
41 {
42 {%- if property.svg %}
43 {{ set_value(property) }}(state.parentStyle()->svgStyle()->{{property.getter }}());
44 {%- else %}
45 {{ set_value(property) }}(state.parentStyle()->{{property.getter}}());
46 {%- endif %}
47 }
48 {% endif %}
49
50 {%- if not property.custom_value %}
51 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, CSSValue* value)
52 {
53 {%- if property.converter %}
54 {{ set_value(property) }}(StyleBuilderConverter::{{property.converter}}(stat e, value));
55 {%- else %}
56 {{ set_value(property) }}(static_cast<{{property.type_name}}>(*toCSSPrimitiv eValue(value)));
57 {%- endif %}
58 }
59 {% endif %}
60
61 {%- endcall %}
62 {%- endfor %}
63
64 bool StyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& sta te, CSSValue* value, bool isInitial, bool isInherit) {
65 switch(property) {
66 {%- for property_id, property in properties.items() %}
67 {%- set used_property = properties[property.use_handlers_for] or property %}
68 {%- set used_property_id = used_property.property_id %}
69 {%- call wrap_with_condition(used_property.condition) %}
70 case {{ property_id }}:
71 if (isInitial)
72 StyleBuilderFunctions::applyInitial{{ used_property_id }}(state);
73 else if (isInherit)
74 StyleBuilderFunctions::applyInherit{{ used_property_id }}(state);
75 else
76 StyleBuilderFunctions::applyValue{{ used_property_id }}(state, value );
77 return true;
78 {%- endcall %}
79 {% endfor %}
80 default:
81 return false;
82 }
83 }
84
85 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698