1// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5{% from 'templates/macros.tmpl' import source_files_for_generated_file %}
6{% from 'core/css/properties/templates/style_builder_functions.tmpl' import style_builder_functions %}
7{{source_files_for_generated_file(template_file, input_files)}}
8
9{% set namespace = 'css_longhand' if is_longhand else 'css_shorthand' %}
10{% set include = 'longhands.h' if is_longhand else 'shorthands.h' %}
11
12#include "third_party/blink/renderer/core/css/properties/{{include}}"
13
14#include "third_party/blink/renderer/core/css/css_custom_ident_value.h"
15#include "third_party/blink/renderer/core/css/css_identifier_value.h"
16#include "third_party/blink/renderer/core/css/css_primitive_value.h"
17#include "third_party/blink/renderer/core/css/css_primitive_value_mappings.h"
18#include "third_party/blink/renderer/core/css/css_value_list.h"
19#include "third_party/blink/renderer/core/css/css_value_pair.h"
20#include "third_party/blink/renderer/core/css/properties/css_direction_aware_resolver.h"
21#include "third_party/blink/renderer/core/css/properties/style_building_utils.h"
22#include "third_party/blink/renderer/core/css/resolver/font_builder.h"
23#include "third_party/blink/renderer/core/css/resolver/style_builder_converter.h"
24#include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
25#include "third_party/blink/renderer/core/execution_context/execution_context.h"
26#include "third_party/blink/renderer/core/style/computed_style.h"
27#include "third_party/blink/renderer/core/style/style_svg_resource.h"
28#include "third_party/blink/renderer/core/style/svg_computed_style.h"
29#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
30
31namespace blink {
32namespace {{namespace}} {
33
34{% for property in properties %}
35{% set class_name = property.name.to_upper_camel_case() %}
36{% set is_alias = property.alias_for %}
37// {{property.name}}
38
39  {% if property.is_internal or property.runtime_flag and not property.in_origin_trial%}
40CSSExposure {{class_name}}::Exposure() const {
41    {% if property.runtime_flag %}
42  if (!RuntimeEnabledFeatures::{{property.runtime_flag}}Enabled())
43    return CSSExposure::kNone;
44    {% endif %}
45    {% if property.is_internal %}
46  return CSSExposure::kUA;
47    {% else %}
48  return CSSExposure::kWeb;
49    {% endif %}
50}
51  {% endif %}
52
53  {% if property.in_origin_trial %}
54CSSExposure {{class_name}}::Exposure(const ExecutionContext* execution_context) const {
55  if (!RuntimeEnabledFeatures::{{property.runtime_flag}}Enabled(execution_context))
56    return CSSExposure::kNone;
57  return CSSExposure::kWeb;
58}
59  {% endif %}
60
61const char* {{class_name}}::GetPropertyName() const {
62  return "{{property.name}}";
63}
64
65const WTF::AtomicString& {{class_name}}::GetPropertyNameAtomicString() const {
66  DEFINE_STATIC_LOCAL(const AtomicString, name, ("{{property.name}}"));
67  return name;
68}
69
70const char* {{class_name}}::GetJSPropertyName() const {
71  return "{{class_name[0].lower() + class_name[1:]}}";
72}
73  {% if not is_alias %}
74  {% if property.visited_property %}
75const CSSProperty* {{class_name}}::GetVisitedProperty() const {
76  return &Get{{property.visited_property.property_id}}();
77}
78  {% endif %}
79  {% if property.unvisited_property %}
80const CSSProperty* {{class_name}}::GetUnvisitedProperty() const {
81  return &Get{{property.unvisited_property.property_id}}();
82}
83  {% endif %}
84
85  {% if property.surrogate_for %}
86const CSSProperty* {{class_name}}::SurrogateFor(TextDirection direction,
87    blink::WritingMode writing_mode) const {
88  return &GetCSSProperty{{property.surrogate_for.name.to_upper_camel_case()}}();
89}
90  {% endif %}
91  {% if property.direction_aware_options %}
92    {% set options = property.direction_aware_options %}
93    {% set resolver_name = options.resolver_name.to_upper_camel_case() %}
94    {% set physical_group_name = options.physical_group_name.to_upper_camel_case() %}
95const CSSProperty* {{class_name}}::SurrogateFor(TextDirection direction,
96    blink::WritingMode writing_mode) const {
97  return &ResolveDirectionAwareProperty(direction, writing_mode);
98}
99
100const CSSProperty& {{class_name}}::ResolveDirectionAwareProperty(
101    TextDirection direction,
102    blink::WritingMode writing_mode) const {
103  return CSSDirectionAwareResolver::Resolve{{resolver_name}}(direction, writing_mode,
104      CSSDirectionAwareResolver::{{physical_group_name}}Group());
105}
106  {% endif %}
107
108{{style_builder_functions(property)}}
109  {% endif %} {# not is_alias #}
110{% endfor %} {# properties #}
111
112}  // namespace {{namespace}}
113}  // namespace blink
114