Commit 0874c9c7 authored by timloh@chromium.org's avatar timloh@chromium.org

Move default StyleBuilderFunctions handlers from StyleBuilder.cpp to StyleBuilderFunctions.cpp

Some of the StyleBuilderFunctions handlers were being defined in
StyleBuilder.cpp. This patch cleans moves them to the correct place and
makes some minor clean-ups inside (removing the unused condition check
and a redundant isPrimitiveValue check).

Review URL: https://codereview.chromium.org/236763002

git-svn-id: svn://svn.chromium.org/blink/trunk@171443 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b6be07c3
......@@ -46,7 +46,6 @@ class StyleBuilderWriter(in_generator.Writer):
'custom_value': [True, False],
}
defaults = {
'condition': None,
'name_for_methods': None,
'use_handlers_for': None,
'svg': False,
......
......@@ -5,69 +5,12 @@
#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}}
{%- elif property.font %}
state.fontBuilder().{{property.setter}}
{%- else %}
state.style()->{{property.setter}}
{%- endif %}
{% endmacro %}
namespace WebCore {
{# FIXME: add blank line #}
{% 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}}());
{% elif property.font %}
{{set_value(property)}}(FontBuilder::{{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}}());
{% elif property.font %}
{{set_value(property)}}(state.parentFontDescription().{{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));
{% elif property.font %}
if (!value->isPrimitiveValue())
return;
{{set_value(property)}}(static_cast<{{property.type_name}}>(*toCSSPrimitiveValue(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) {
......
......@@ -16,7 +16,6 @@
#include "core/css/Pair.h"
#include "core/css/resolver/StyleResolverState.h"
{# FIXME: factor macros out into a separate library #}
{% macro declare_initial_function(property_id) %}
void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& state)
{%- endmacro %}
......@@ -26,19 +25,58 @@ void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat
{% macro declare_value_function(property_id) %}
void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, CSSValue* value)
{%- endmacro %}
// FIXME: This is duplicated in StyleBuilder.cpp.tmpl, but we'll move the
// function definitions there over to here later.
{% macro set_value(property) %}
{% if property.svg %}
state.style()->accessSVGStyle()->{{property.setter}}
{%- elif property.font %}
state.fontBuilder().{{property.setter}}
{%- else %}
state.style()->{{property.setter}}
{%- endif %}
{% endmacro %}
namespace WebCore {
{# FIXME: remove excess newline #}
{% for property_id, property in properties.items() if not property.use_handlers_for %}
{% set apply_type = property.apply_type %}
{% if not property.custom_initial %}
{{declare_initial_function(property_id)}}
{
{% if property.svg %}
{{set_value(property)}}(SVGRenderStyle::{{property.initial}}());
{% elif property.font %}
{{set_value(property)}}(FontBuilder::{{property.initial}}());
{% else %}
{{set_value(property)}}(RenderStyle::{{property.initial}}());
{% endif %}
}
{% endif %}
{% if not property.custom_inherit %}
{{declare_inherit_function(property_id)}}
{
{% if property.svg %}
{{set_value(property)}}(state.parentStyle()->svgStyle()->{{property.getter}}());
{% elif property.font %}
{{set_value(property)}}(state.parentFontDescription().{{property.getter}}());
{% else %}
{{set_value(property)}}(state.parentStyle()->{{property.getter}}());
{% endif %}
}
{% endif %}
{% if not property.custom_value %}
{{declare_value_function(property_id)}}
{
{% if property.converter %}
{{set_value(property)}}(StyleBuilderConverter::{{property.converter}}(state, value));
{% else %}
{{set_value(property)}}(static_cast<{{property.type_name}}>(*toCSSPrimitiveValue(value)));
{% endif %}
}
{% endif %}
{% endfor %}
{% macro apply_animation(property_id, attribute, animation) %}
{{declare_initial_function(property_id)}}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment