blob: 2751ccf1647cd21ca00dcd9977e7bcd33ae0cb39 [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// 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)}}
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTIES_{{property.namespace_group.upper()}}_{{property_filename|upper}}_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTIES_{{property.namespace_group.upper()}}_{{property_filename|upper}}_H_
{% for include in includes %}
#include "{{include}}"
{% endfor %}
namespace blink {
namespace CSS{{property.namespace_group}} {
{% if property.is_property %}
// Implements the '{{property.name}}' CSS property
{% else %}
// Implements the '{{property.name}}' CSS descriptor
{% endif %}
// See src/third_party/WebKit/Source/core/css/properties/README.md
{% if property.alias_for != None%}
class {{property_classname}} final : public CSSUnresolvedProperty {
public:
constexpr {{property_classname}}() : CSSUnresolvedProperty() {}
{% else %}
class {{property_classname}} final : public {{property.namespace_group}} {
public:
constexpr {{property_classname}}() : {{property.namespace_group}}() {}
{% endif %}
{% if property.is_internal %}
bool IsEnabled() const override { return false; }
{% elif property.runtime_flag %}
bool IsEnabled() const override {
return RuntimeEnabledFeatures::{{property.runtime_flag}}Enabled();
}
{% endif %}
const char* GetPropertyName() const override { return "{{property.name}}"; }
const WTF::AtomicString& GetPropertyNameAtomicString() const override {
DEFINE_STATIC_LOCAL(const AtomicString, name, ("{{property.name}}"));
return name;
}
const WTF::String GetJSPropertyName() const override {
return WTF::String("{{property_classname[0].lower() + property_classname[1:]}}");
}
{% if property.alias_for == None %}
CSSPropertyID PropertyID() const override { return {{property.property_id}}; }
{%if property.layout_dependent %}
bool IsLayoutDependentProperty() const override { return true; }
bool IsLayoutDependent(const ComputedStyle*, LayoutObject*) const override;
{% endif %}
{% for property_method in property.property_methods %}
{{property_method.return_type}} {{property_method.name}}{{property_method.parameters}} const override;
{% endfor %}
{% if property.interpolable %}
bool IsInterpolable() const override { return true; }
{% endif %}
{% if property.inherited %}
bool IsInherited() const override { return true; }
{% endif %}
{% if property.compositable %}
bool IsCompositableProperty() const override { return true; }
{% endif %}
{% if property.separator != None %}
bool IsRepeated() const override { return true; }
char RepetitionSeparator() const override { return '{{property.separator}}'; }
{% endif %}
{% if property.is_descriptor %}
bool IsDescriptor() const override { return true; }
{% endif %}
{% if 'Percent' in property.typedom_types %}
bool SupportsPercentage() const override { return true; }
{% endif %}
{% if not property.is_property %}
bool IsProperty() const override { return false; }
{% endif %}
{% if not property.affected_by_all %}
bool IsAffectedByAll() const override { return false; }
{% endif %}
{% if property.valid_for_visited_link %}
bool IsValidForVisitedLink() const override { return true; }
{% endif %}
{% if property.direction_aware_options %}
const CSSValue* CSSValueFromComputedStyleInternal(
const ComputedStyle& ,
const SVGComputedStyle&,
const LayoutObject*,
Node*,
bool allow_visited_style) const override {
// Directional properties are resolved by resolveDirectionAwareProperty()
// before calling CSSValueFromComputedStyleInternal.
NOTREACHED();
return nullptr;
}
{% if property.direction_aware_options.logical_side == "width" %}
const CSSProperty& ResolveDirectionAwareProperty(
TextDirection direction,
blink::WritingMode writing_mode) const override {
if (IsHorizontalWritingMode(writing_mode))
return Get{{property.direction_aware_options.shorthand_for_physical_side}}Width();
return Get{{property.direction_aware_options.shorthand_for_physical_side}}Height();
}
{% elif property.direction_aware_options.logical_side == "height" %}
const CSSProperty& ResolveDirectionAwareProperty(
TextDirection direction,
blink::WritingMode writing_mode) const override {
if (IsHorizontalWritingMode(writing_mode))
return Get{{property.direction_aware_options.shorthand_for_physical_side}}Height();
return Get{{property.direction_aware_options.shorthand_for_physical_side}}Width();
}
{% else %}
const CSSProperty& ResolveDirectionAwareProperty(
TextDirection direction,
blink::WritingMode writing_mode) const override {
return Resolve{{property.direction_aware_options.logical_side[0].upper() + property.direction_aware_options.logical_side[1:]}}ToPhysicalProperty(
direction,
writing_mode,
{{property.direction_aware_options.shorthand_for_physical_side}}());
}
{% endif %}
{% endif %}
{% if property.style_builder_declare %}
// Style builder functions
{{style_builder_functions(property, true)}}
{%- endif %}
{% endif %}
};
} // namespace CSS{{property.namespace_group}}
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTIES_{{property.namespace_group.upper()}}_{{property_filename|upper}}_H_