blob: 044e63508de51e48c3296070b69f01309ff1b033 [file] [log] [blame]
{% from 'templates/macros.tmpl' import license, source_files_for_generated_file %}
{% from 'core/css/properties/templates/style_builder_functions.tmpl' import set_value, convert_and_set_value %}
{#
This file is for property handlers which use the templating engine to
reduce (handwritten) code duplication.
The `properties' dict can be used to access a property's parameters in
jinja2 templates (i.e. setter, getter, initial, type_name)
TODO(meade): Delete this file once all StyleBuilderFunction generation
is moved to the CSSProperty.
#}
{{source_files_for_generated_file(template_file, input_files)}}
#include "third_party/blink/renderer/core/style_builder_functions.h"
#include "third_party/blink/renderer/core/animation/css/css_animation_data.h"
#include "third_party/blink/renderer/core/css/basic_shape_functions.h"
#include "third_party/blink/renderer/core/css/css_content_distribution_value.h"
#include "third_party/blink/renderer/core/css/css_custom_ident_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value_mappings.h"
#include "third_party/blink/renderer/core/css/css_uri_value.h"
#include "third_party/blink/renderer/core/css/css_value_pair.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
#include "third_party/blink/renderer/core/css_value_keywords.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
{% macro declare_initial_function(property_id) %}
void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& state)
{%- endmacro %}
{% macro declare_inherit_function(property_id) %}
void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& state)
{%- endmacro %}
{% macro declare_value_function(property_id) %}
void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, const CSSValue& value)
{%- endmacro %}
{% macro set_is_inherited(property) %}
state.Style()->{{property.is_inherited_setter}}
{%- endmacro %}
namespace blink {
{% for property in properties if property.should_declare_functions
and not property.use_property_class_in_stylebuilder
and not property.style_builder_template %}
{% if property.style_builder_generate_initial %}
{{declare_initial_function(property.property_id)}} {
{% if property.svg %}
{{set_value(property)}}(SVGComputedStyle::{{property.initial}}());
{% elif property.font %}
{{set_value(property)}}(FontBuilder::{{property.initial}}());
{% else %}
{{set_value(property)}}(ComputedStyleInitialValues::{{property.initial}}());
{% endif %}
{% if property.independent %}
{{set_is_inherited(property)}}(false);
{% endif %}
}
{% endif %}
{% if property.style_builder_generate_inherit %}
{{declare_inherit_function(property.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 %}
{% if property.independent %}
{{set_is_inherited(property)}}(true);
{% endif %}
}
{% endif %}
{% if property.style_builder_generate_value %}
{{declare_value_function(property.property_id)}} {
{{convert_and_set_value(property)}}
{% if property.independent %}
{{set_is_inherited(property)}}(false);
{% endif %}
}
{% endif %}
{% endfor %}
} // namespace blink