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

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

Issue 21625003: StyleBuilder should not know about StyleResolver. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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/StyleResolver.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 %}
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 ASSERT_NOT_REACHED(); 69 ASSERT_NOT_REACHED();
70 } 70 }
71 {{ set_value(property) }}(length); 71 {{ set_value(property) }}(length);
72 {%- endmacro %} 72 {%- endmacro %}
73 73
74 {%- for property_id, property in properties.items() if not property.use_handlers _for %} 74 {%- for property_id, property in properties.items() if not property.use_handlers _for %}
75 {%- call wrap_with_condition(property.condition) %} 75 {%- call wrap_with_condition(property.condition) %}
76 {%- set apply_type = property.apply_type %} 76 {%- set apply_type = property.apply_type %}
77 77
78 {%- if not property.custom_initial %} 78 {%- if not property.custom_initial %}
79 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolver* styleReso lver, StyleResolverState& state) 79 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat e)
80 { 80 {
81 {%- if property.svg %} 81 {%- if property.svg %}
82 {{ set_value(property) }}(SVGRenderStyle::{{property.initial}}()); 82 {{ set_value(property) }}(SVGRenderStyle::{{property.initial}}());
83 {%- else %} 83 {%- else %}
84 {{ set_value(property) }}(RenderStyle::{{property.initial}}()); 84 {{ set_value(property) }}(RenderStyle::{{property.initial}}());
85 {%- endif %} 85 {%- endif %}
86 } 86 }
87 {% endif %} 87 {% endif %}
88 88
89 {%- if not property.custom_inherit %} 89 {%- if not property.custom_inherit %}
90 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolver* styleReso lver, StyleResolverState& state) 90 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat e)
91 { 91 {
92 {%- if property.svg %} 92 {%- if property.svg %}
93 {{ set_value(property) }}(state.parentStyle()->svgStyle()->{{property.getter }}()); 93 {{ set_value(property) }}(state.parentStyle()->svgStyle()->{{property.getter }}());
94 {%- else %} 94 {%- else %}
95 {{ set_value(property) }}(state.parentStyle()->{{property.getter}}()); 95 {{ set_value(property) }}(state.parentStyle()->{{property.getter}}());
96 {%- endif %} 96 {%- endif %}
97 } 97 }
98 {% endif %} 98 {% endif %}
99 99
100 {%- if not property.custom_value %} 100 {%- if not property.custom_value %}
101 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolver* styleResolv er, StyleResolverState& state, CSSValue* value) 101 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, CSSValue* value)
102 { 102 {
103 {%- if apply_type == "length" %} 103 {%- if apply_type == "length" %}
104 {{ apply_value_length(property) }} 104 {{ apply_value_length(property) }}
105 {%- else %} 105 {%- else %}
106 {{ set_value(property) }}(static_cast<{{property.type_name}}>(*toCSSPrimitiv eValue(value))); 106 {{ set_value(property) }}(static_cast<{{property.type_name}}>(*toCSSPrimitiv eValue(value)));
107 {%- endif %} 107 {%- endif %}
108 } 108 }
109 {% endif %} 109 {% endif %}
110 110
111 {%- endcall %} 111 {%- endcall %}
112 {%- endfor %} 112 {%- endfor %}
113 113
114 bool StyleBuilder::applyProperty(CSSPropertyID property, StyleResolver* styleRes olver, StyleResolverState& state, CSSValue* value, bool isInitial, bool isInheri t) { 114 bool StyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& sta te, CSSValue* value, bool isInitial, bool isInherit) {
115 switch(property) { 115 switch(property) {
116 {%- for property_id, property in properties.items() %} 116 {%- for property_id, property in properties.items() %}
117 {%- set used_property = properties[property.use_handlers_for] or property %} 117 {%- set used_property = properties[property.use_handlers_for] or property %}
118 {%- set used_property_id = used_property.property_id %} 118 {%- set used_property_id = used_property.property_id %}
119 {%- call wrap_with_condition(used_property.condition) %} 119 {%- call wrap_with_condition(used_property.condition) %}
120 case {{ property_id }}: 120 case {{ property_id }}:
121 if (isInitial) 121 if (isInitial)
122 StyleBuilderFunctions::applyInitial{{ used_property_id }}(styleResol ver, state); 122 StyleBuilderFunctions::applyInitial{{ used_property_id }}(state);
123 else if (isInherit) 123 else if (isInherit)
124 StyleBuilderFunctions::applyInherit{{ used_property_id }}(styleResol ver, state); 124 StyleBuilderFunctions::applyInherit{{ used_property_id }}(state);
125 else 125 else
126 StyleBuilderFunctions::applyValue{{ used_property_id }}(styleResolve r, state, value); 126 StyleBuilderFunctions::applyValue{{ used_property_id }}(state, value );
127 return true; 127 return true;
128 {%- endcall %} 128 {%- endcall %}
129 {% endfor %} 129 {% endfor %}
130 default: 130 default:
131 return false; 131 return false;
132 } 132 }
133 } 133 }
134 134
135 } // namespace WebCore 135 } // namespace WebCore
136 136
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698