blob: 94b468d233c1b729746b2cfbb55697a7bc861a8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
{% from "macros.tmpl" import wrap_with_condition, license -%}
{{ license() }}
#include "config.h"
#include "core/css/resolver/StyleBuilder.h"
#include "StyleBuilderFunctions.h"
#include "core/css/CSSPrimitiveValueMappings.h"
#include "core/css/resolver/StyleResolverState.h"
// FIXME: currently we're just generating a switch statement, but we should
// test other variations for performance once we have more properties here.
{%- macro set_value(property) %}
{%- if property.svg -%}
state.style()->accessSVGStyle()->{{property.setter}}
{%- else -%}
state.style()->{{property.setter}}
{%- endif %}
{%- endmacro %}
namespace WebCore {
{%- for property_id, property in properties.items() if not property.use_handlers_for %}
{%- call wrap_with_condition(property.condition) %}
{%- set apply_type = property.apply_type %}
{%- if not property.custom_initial %}
void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& state)
{
{%- if property.svg %}
{{ set_value(property) }}(SVGRenderStyle::{{property.initial}}());
{%- else %}
{{ set_value(property) }}(RenderStyle::{{property.initial}}());
{%- endif %}
}
{% endif %}
{%- if not property.custom_inherit %}
void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& state)
{
{%- if property.svg %}
{{ set_value(property) }}(state.parentStyle()->svgStyle()->{{property.getter}}());
{%- else %}
{{ set_value(property) }}(state.parentStyle()->{{property.getter}}());
{%- endif %}
}
{% endif %}
{%- if not property.custom_value %}
void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, CSSValue* value)
{
{%- if property.converter %}
{{ set_value(property) }}(StyleBuilderConverter::{{property.converter}}(state, value));
{%- else %}
{{ set_value(property) }}(static_cast<{{property.type_name}}>(*toCSSPrimitiveValue(value)));
{%- endif %}
}
{% endif %}
{%- endcall %}
{%- endfor %}
bool StyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& state, CSSValue* value, bool isInitial, bool isInherit) {
switch(property) {
{%- for property_id, property in properties.items() %}
{%- set used_property = properties[property.use_handlers_for] or property %}
{%- set used_property_id = used_property.property_id %}
{%- call wrap_with_condition(used_property.condition) %}
case {{ property_id }}:
if (isInitial)
StyleBuilderFunctions::applyInitial{{ used_property_id }}(state);
else if (isInherit)
StyleBuilderFunctions::applyInherit{{ used_property_id }}(state);
else
StyleBuilderFunctions::applyValue{{ used_property_id }}(state, value);
return true;
{%- endcall %}
{% endfor %}
default:
return false;
}
}
} // namespace WebCore
|