Commit 92f2bfa3 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

Remove old StyleBuilder and related code.

All properties are now Ribbonized, so we don't need to generate a massive
switch statement anymore.

R=futhark@chromium.org

      another code generated.

Note: make_style_builder.py has been kept, because it's actually imported
Bug: 751354
Change-Id: I952fc4e30dff3f42ed0e926cd7e4d7ab60705794
Reviewed-on: https://chromium-review.googlesource.com/1076328
Commit-Queue: Anders Ruud <andruud@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562579}
parent b356f98c
...@@ -102,8 +102,7 @@ class CSSPropertiesWriter(CSSPropertyBaseWriter): ...@@ -102,8 +102,7 @@ class CSSPropertiesWriter(CSSPropertyBaseWriter):
property_['style_builder_declare'] = ( property_['style_builder_declare'] = (
property_['is_property'] and property_['is_property'] and
not property_['longhands'] and not property_['longhands'])
not property_['style_builder_legacy'])
if not property_['style_builder_declare']: if not property_['style_builder_declare']:
for x in ['initial', 'inherit', 'value']: for x in ['initial', 'inherit', 'value']:
......
...@@ -7,7 +7,6 @@ import math ...@@ -7,7 +7,6 @@ import math
import json5_generator import json5_generator
import template_expander import template_expander
import make_style_builder
import keyword_utils import keyword_utils
import bisect import bisect
......
...@@ -32,28 +32,18 @@ import types ...@@ -32,28 +32,18 @@ import types
from core.css import css_properties from core.css import css_properties
import json5_generator import json5_generator
import template_expander
def calculate_apply_functions_to_declare(property_): def calculate_apply_functions_to_declare(property_):
property_['should_declare_functions'] = \ property_['should_declare_functions'] = \
not property_['longhands'] \ not property_['longhands'] \
and property_['is_property'] and property_['is_property']
property_['use_property_class_in_stylebuilder'] = \ property_['use_property_class_in_stylebuilder'] = \
property_['should_declare_functions'] \ property_['should_declare_functions']
and not property_['style_builder_legacy']
class StyleBuilderWriter(json5_generator.Writer): class StyleBuilderWriter(json5_generator.Writer):
def __init__(self, json5_file_paths, output_dir): def __init__(self, json5_file_paths, output_dir):
super(StyleBuilderWriter, self).__init__([], output_dir) super(StyleBuilderWriter, self).__init__([], output_dir)
self._outputs = {
'style_builder_functions.h': self.generate_style_builder_functions_h,
'style_builder_functions.cc':
self.generate_style_builder_functions_cpp,
'style_builder.cc': self.generate_style_builder,
}
self._json5_properties = css_properties.CSSProperties(json5_file_paths) self._json5_properties = css_properties.CSSProperties(json5_file_paths)
self._input_files = json5_file_paths self._input_files = json5_file_paths
...@@ -66,29 +56,5 @@ class StyleBuilderWriter(json5_generator.Writer): ...@@ -66,29 +56,5 @@ class StyleBuilderWriter(json5_generator.Writer):
def css_properties(self): def css_properties(self):
return self._json5_properties return self._json5_properties
@template_expander.use_jinja('templates/style_builder_functions.h.tmpl')
def generate_style_builder_functions_h(self):
return {
'input_files': self._input_files,
'properties': self._properties,
}
@template_expander.use_jinja('templates/style_builder_functions.cc.tmpl')
def generate_style_builder_functions_cpp(self):
return {
'input_files': self._input_files,
'properties': self._properties,
'properties_by_id': self._json5_properties.properties_by_id,
}
@template_expander.use_jinja('templates/style_builder.cc.tmpl')
def generate_style_builder(self):
return {
'input_files': self._input_files,
'properties': self._properties,
'properties_by_id': self._json5_properties.properties_by_id,
}
if __name__ == '__main__': if __name__ == '__main__':
json5_generator.Maker(StyleBuilderWriter).main() json5_generator.Maker(StyleBuilderWriter).main()
{% from 'templates/macros.tmpl' import license, source_files_for_generated_file %}
{{license()}}
{{source_files_for_generated_file(template_file, input_files)}}
#include "third_party/blink/renderer/core/css/resolver/style_builder.h"
#include "third_party/blink/renderer/core/css/css_property_value.h"
#include "third_party/blink/renderer/core/css/properties/longhand.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/style_builder_functions.h"
namespace blink {
// TODO(crbug.com/751354): Delete this method and call property class methods
// directly using CSSProperty::Get() once all StyleBuilderFunctions have been
// moved to property classes.
void StyleBuilder::ApplyProperty(const CSSProperty& property,
StyleResolverState& state,
const CSSValue& value,
bool isInitial,
bool isInherit) {
switch (property.PropertyID()) {
{% for input_property in properties if input_property.should_declare_functions %}
{% set property_id = input_property.property_id %}
{% if input_property.use_property_class_in_stylebuilder %}
case {{input_property.property_id}}:
if (isInitial)
ToLonghand(Get{{property_id}}()).ApplyInitial(state);
else if (isInherit)
ToLonghand(Get{{property_id}}()).ApplyInherit(state);
else
ToLonghand(Get{{property_id}}()).ApplyValue(state, value);
return;
{% else %}
case {{input_property.property_id}}:
if (isInitial)
StyleBuilderFunctions::applyInitial{{property_id}}(state);
else if (isInherit)
StyleBuilderFunctions::applyInherit{{property_id}}(state);
else
StyleBuilderFunctions::applyValue{{property_id}}(state, value);
return;
{% endif %}
{% endfor %}
case CSSPropertyVariable:
DCHECK(!isInitial);
DCHECK(!isInherit);
ToLonghand(property).ApplyValue(state, value);
return;
default:
NOTREACHED();
}
}
} // namespace blink
{% 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
{% from 'templates/macros.tmpl' import license, source_files_for_generated_file %}
{{license()}}
{{source_files_for_generated_file(template_file, input_files)}}
#ifndef BLINK_CORE_STYLE_BUILDER_FUNCTIONS_H_
#define BLINK_CORE_STYLE_BUILDER_FUNCTIONS_H_
#include "third_party/blink/renderer/core/css/resolver/style_builder_converter.h"
namespace blink {
class CSSValue;
class StyleResolverState;
// TODO(crbug.com/751354): Delete this class once all StyleBuilderFunctions
// have been moved to property classes.
class StyleBuilderFunctions {
public:
{% for property in properties if property.should_declare_functions
and not property.use_property_class_in_stylebuilder %}
static void applyInitial{{property.property_id}}(StyleResolverState&);
static void applyInherit{{property.property_id}}(StyleResolverState&);
static void applyValue{{property.property_id}}(StyleResolverState&, const CSSValue&);
{% endfor %}
};
} // namespace blink
#endif // BLINK_CORE_STYLE_BUILDER_FUNCTIONS_H_
...@@ -1130,20 +1130,6 @@ css_properties("make_core_generated_style_property_shorthand") { ...@@ -1130,20 +1130,6 @@ css_properties("make_core_generated_style_property_shorthand") {
] ]
} }
css_properties("make_core_generated_style_builder") {
script = "../build/scripts/make_style_builder.py"
other_inputs = [
"../build/scripts/templates/style_builder.cc.tmpl",
"../build/scripts/templates/style_builder_functions.cc.tmpl",
"../build/scripts/templates/style_builder_functions.h.tmpl",
]
outputs = [
"$blink_core_output_dir/style_builder.cc",
"$blink_core_output_dir/style_builder_functions.h",
"$blink_core_output_dir/style_builder_functions.cc",
]
}
css_properties("make_core_generated_cssom_types") { css_properties("make_core_generated_cssom_types") {
script = "../build/scripts/core/css/make_cssom_types.py" script = "../build/scripts/core/css/make_cssom_types.py"
other_inputs = [ other_inputs = [
...@@ -1531,7 +1517,6 @@ targets_generating_sources = [ ...@@ -1531,7 +1517,6 @@ targets_generating_sources = [
":make_core_generated_media_feature_names", ":make_core_generated_media_feature_names",
":make_core_generated_media_type_names", ":make_core_generated_media_type_names",
":make_core_generated_origin_trials", ":make_core_generated_origin_trials",
":make_core_generated_style_builder",
":make_core_generated_style_property_shorthand", ":make_core_generated_style_property_shorthand",
":make_core_generated_svg_names", ":make_core_generated_svg_names",
":make_core_generated_xlink_names", ":make_core_generated_xlink_names",
......
...@@ -81,13 +81,6 @@ ...@@ -81,13 +81,6 @@
valid_type: "dict" valid_type: "dict"
}, },
// Set this to true if we do not support generation of style builder
// functions in the CSSProperty subclasses (yet).
style_builder_legacy: {
default: false,
value_type: "bool"
},
// - is_descriptor // - is_descriptor
// Whether it is a CSS descriptor. Descriptors define the characteristics of // Whether it is a CSS descriptor. Descriptors define the characteristics of
// an at-rule. E.g. @viewport is an at-rule, and width is a valid descriptor // an at-rule. E.g. @viewport is an at-rule, and width is a valid descriptor
...@@ -276,8 +269,8 @@ ...@@ -276,8 +269,8 @@
// The remaining arguments are used for the StyleBuilder and allow us to // The remaining arguments are used for the StyleBuilder and allow us to
// succinctly describe how to apply properties. When default handlers are // succinctly describe how to apply properties. When default handlers are
// not sufficient, we should prefer to use converter, and failing that // not sufficient, we should prefer to use converter, and failing that
// define custom property handlers in StyleBuilderCustom.cpp. We only should // define custom property handlers in CSSProperty subclasses. We should only
// use style_builder_functions.cc.tmpl to define handlers when there are // use style_builder_functions.tmpl to define handlers when there are
// multiple properties requiring the same handling, but converter doesn't // multiple properties requiring the same handling, but converter doesn't
// suffice. // suffice.
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/style/style_inherited_variables.h" #include "third_party/blink/renderer/core/style/style_inherited_variables.h"
#include "third_party/blink/renderer/core/style/style_non_inherited_variables.h" #include "third_party/blink/renderer/core/style/style_non_inherited_variables.h"
#include "third_party/blink/renderer/core/style_builder_functions.h"
#include "third_party/blink/renderer/core/style_property_shorthand.h" #include "third_party/blink/renderer/core/style_property_shorthand.h"
#include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/blink/renderer/platform/wtf/vector.h"
......
...@@ -48,13 +48,6 @@ class CORE_EXPORT StyleBuilder { ...@@ -48,13 +48,6 @@ class CORE_EXPORT StyleBuilder {
static void ApplyProperty(const CSSProperty&, static void ApplyProperty(const CSSProperty&,
StyleResolverState&, StyleResolverState&,
const CSSValue&); const CSSValue&);
private:
static void ApplyProperty(const CSSProperty&,
StyleResolverState&,
const CSSValue&,
bool is_initial,
bool is_inherit);
}; };
} // namespace blink } // namespace blink
......
...@@ -42,49 +42,11 @@ ...@@ -42,49 +42,11 @@
#include <utility> #include <utility>
#include "third_party/blink/renderer/core/animation/css/css_animations.h" #include "third_party/blink/renderer/core/animation/css/css_animations.h"
#include "third_party/blink/renderer/core/css/css_counter_value.h" #include "third_party/blink/renderer/core/css/properties/longhand.h"
#include "third_party/blink/renderer/core/css/css_cursor_image_value.h"
#include "third_party/blink/renderer/core/css/css_custom_property_declaration.h"
#include "third_party/blink/renderer/core/css/css_function_value.h"
#include "third_party/blink/renderer/core/css/css_grid_template_areas_value.h"
#include "third_party/blink/renderer/core/css/css_image_set_value.h"
#include "third_party/blink/renderer/core/css/css_layout_function_value.h"
#include "third_party/blink/renderer/core/css/css_pending_substitution_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value_mappings.h"
#include "third_party/blink/renderer/core/css/css_property_value_set.h"
#include "third_party/blink/renderer/core/css/css_resolution_units.h"
#include "third_party/blink/renderer/core/css/css_value_id_mappings.h"
#include "third_party/blink/renderer/core/css/css_variable_reference_value.h"
#include "third_party/blink/renderer/core/css/properties/css_property.h"
#include "third_party/blink/renderer/core/css/property_registration.h"
#include "third_party/blink/renderer/core/css/property_registry.h"
#include "third_party/blink/renderer/core/css/resolver/css_variable_resolver.h" #include "third_party/blink/renderer/core/css/resolver/css_variable_resolver.h"
#include "third_party/blink/renderer/core/css/resolver/element_style_resources.h"
#include "third_party/blink/renderer/core/css/resolver/filter_operation_resolver.h"
#include "third_party/blink/renderer/core/css/resolver/font_builder.h"
#include "third_party/blink/renderer/core/css/resolver/style_builder.h" #include "third_party/blink/renderer/core/css/resolver/style_builder.h"
#include "third_party/blink/renderer/core/css/style_rule.h" #include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
#include "third_party/blink/renderer/core/css_property_names.h"
#include "third_party/blink/renderer/core/css_value_keywords.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/use_counter.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/core/style/content_data.h"
#include "third_party/blink/renderer/core/style/counter_content.h"
#include "third_party/blink/renderer/core/style/quotes_data.h"
#include "third_party/blink/renderer/core/style/style_generated_image.h"
#include "third_party/blink/renderer/core/style/style_inherited_variables.h"
#include "third_party/blink/renderer/core/style/style_non_inherited_variables.h"
#include "third_party/blink/renderer/core/style/svg_computed_style.h"
#include "third_party/blink/renderer/core/style_builder_functions.h"
#include "third_party/blink/renderer/core/style_property_shorthand.h"
#include "third_party/blink/renderer/platform/fonts/font_description.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink { namespace blink {
...@@ -166,7 +128,16 @@ void StyleBuilder::ApplyProperty(const CSSProperty& property, ...@@ -166,7 +128,16 @@ void StyleBuilder::ApplyProperty(const CSSProperty& property,
is_initial = true; is_initial = true;
} }
StyleBuilder::ApplyProperty(property, state, value, is_initial, is_inherit); // CSSPropertyVariable currently handles initial/inherit inside ApplyValue.
DCHECK(id != CSSPropertyVariable || !is_initial);
DCHECK(id != CSSPropertyVariable || !is_inherit);
if (is_initial)
ToLonghand(property).ApplyInitial(state);
else if (is_inherit)
ToLonghand(property).ApplyInherit(state);
else
ToLonghand(property).ApplyValue(state, value);
} }
} // namespace blink } // namespace blink
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