// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
{% from 'templates/macros.tmpl' import source_files_for_generated_file %}
{% from 'core/css/properties/templates/style_builder_functions.tmpl' import style_builder_functions %}
{{source_files_for_generated_file(template_file, input_files)}}
{% set namespace = 'css_longhand' if is_longhand else 'css_shorthand' %}
{% set include = 'longhands.h' if is_longhand else 'shorthands.h' %}
#include "third_party/blink/renderer/core/css/properties/{{include}}"
#include "third_party/blink/renderer/core/css/css_custom_ident_value.h"
#include "third_party/blink/renderer/core/css/css_identifier_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value_mappings.h"
#include "third_party/blink/renderer/core/css/css_value_list.h"
#include "third_party/blink/renderer/core/css/css_value_pair.h"
#include "third_party/blink/renderer/core/css/properties/css_direction_aware_resolver.h"
#include "third_party/blink/renderer/core/css/properties/style_building_utils.h"
#include "third_party/blink/renderer/core/css/resolver/font_builder.h"
#include "third_party/blink/renderer/core/css/resolver/style_builder_converter.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/style/style_svg_resource.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink {
namespace {{namespace}} {
{% for property in properties %}
{% set class_name = property.name.to_upper_camel_case() %}
{% set is_alias = property.alias_for %}
{% set exposed_property = property.ultimate_property %}
// {{property.name}}
{% macro return_none_if_alternative_exposed(alternative) %}
{% if alternative.alternative %}
{{return_none_if_alternative_exposed(alternative.alternative)}}
{% endif %}
if (RuntimeEnabledFeatures::{{alternative.runtime_flag}}Enabled(execution_context)) {
// {{alternative.name}}
return CSSExposure::kNone;
}
{%- endmacro %}
{% if not property.known_exposed %}
CSSExposure {{class_name}}::Exposure(const ExecutionContext* execution_context) const {
{% if property.alternative %}
{{return_none_if_alternative_exposed(property.alternative)|indent(2)}}
{% endif %}
{% if property.runtime_flag %}
if (!RuntimeEnabledFeatures::{{property.runtime_flag}}Enabled(execution_context)) {
return CSSExposure::kNone;
}
{% endif %}
{% if property.is_internal %}
return CSSExposure::kUA;
{% else %}
return CSSExposure::kWeb;
{% endif %}
}
{% endif %}
const char* {{class_name}}::GetPropertyName() const {
return "{{exposed_property.name}}";
}
const WTF::AtomicString& {{class_name}}::GetPropertyNameAtomicString() const {
DEFINE_STATIC_LOCAL(const AtomicString, name, ("{{exposed_property.name}}"));
return name;
}
const char* {{class_name}}::GetJSPropertyName() const {
return "{{exposed_property.name.to_lower_camel_case()}}";
}
{% if not is_alias %}
{% if property.surrogate_for %}
const CSSProperty* {{class_name}}::SurrogateFor(WritingDirectionMode) const {
return &GetCSSProperty{{property.surrogate_for.name.to_upper_camel_case()}}();
}
{% endif %}
{% if property.logical_property_group %}
{% set group = property.logical_property_group %}
{% set group_name = group.name.to_upper_camel_case() %}
{% set resolver_name = group.resolver_name.to_upper_camel_case() %}
{% if group.is_logical %}
const CSSProperty* {{class_name}}::SurrogateFor(
WritingDirectionMode writing_direction) const {
return &ResolveDirectionAwarePropertyInternal(writing_direction);
}
const CSSProperty& {{class_name}}::ResolveDirectionAwarePropertyInternal(
WritingDirectionMode writing_direction) const {
return CSSDirectionAwareResolver::Resolve{{resolver_name}}(writing_direction,
CSSDirectionAwareResolver::Physical{{group_name}}Mapping());
}
bool {{class_name}}::IsInSameLogicalPropertyGroupWithDifferentMappingLogic(
CSSPropertyID id) const {
return CSSDirectionAwareResolver::Physical{{group_name}}Mapping().Contains(id);
}
{% else %}
bool {{class_name}}::IsInSameLogicalPropertyGroupWithDifferentMappingLogic(
CSSPropertyID id) const {
return CSSDirectionAwareResolver::Logical{{group_name}}Mapping().Contains(id);
}
{% endif %}
{% endif %}
{{style_builder_functions(property)}}
{% endif %} {# not is_alias #}
{% endfor %} {# properties #}
} // namespace {{namespace}}
} // namespace blink