Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: third_party/WebKit/Source/build/scripts/make_computed_style_base.py

Issue 2811253002: Extract default naming logic in StyleBuilderWriter to a method. (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/build/scripts/make_computed_style_base.py
diff --git a/third_party/WebKit/Source/build/scripts/make_computed_style_base.py b/third_party/WebKit/Source/build/scripts/make_computed_style_base.py
index fbb0aff6366e0d9a2d3d65e2eb8eb658f45d8fde..e3df4bf9c3dafbc99d2cbebf1f6be21fdcda0154 100755
--- a/third_party/WebKit/Source/build/scripts/make_computed_style_base.py
+++ b/third_party/WebKit/Source/build/scripts/make_computed_style_base.py
@@ -14,7 +14,7 @@ from name_utilities import (
enum_for_css_keyword, enum_type_name, enum_value_name, class_member_name, method_name,
join_name
)
-from collections import OrderedDict
+from collections import OrderedDict, defaultdict
# Temporary hard-coded list of fields that are not CSS properties.
@@ -311,15 +311,10 @@ class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter):
# TODO(shend): Remove this once we move NONPROPERTIES to its own JSON file,
# since the JSON5 reader will handle missing fields and defaults.
- for property_ in NONPROPERTIES:
- property_['name_for_methods'] = property_['name']
- if 'field_type_path' not in property_:
- property_['field_type_path'] = None
- if 'type_name' not in property_:
- property_['type_name'] = 'E' + enum_type_name(property_['name_for_methods'])
- property_['getter'] = method_name(property_['name_for_methods'])
- property_['setter'] = method_name(join_name('set', property_['name_for_methods']))
- property_['initial'] = method_name(join_name('initial', property_['name_for_methods']))
+ nonproperties = [defaultdict(lambda: None, item) for item in NONPROPERTIES]
alancutter (OOO until 2018) 2017/04/19 04:36:35 Not sure I'm in favour of a defaultdict. This make
shend 2017/04/19 05:26:05 Done in an explicit loop now.
+
+ for property_ in nonproperties:
+ self._apply_property_naming_defaults(property_)
# Ignore shorthand properties
for property_ in self._properties.values():
@@ -336,10 +331,10 @@ class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter):
# CSS properties are not allowed to explicitly specify their field_size.
property_['field_size'] = None
- self._generated_enums = _create_enums(property_values + NONPROPERTIES)
+ self._generated_enums = _create_enums(property_values + nonproperties)
all_fields = (_create_fields('property', property_values) +
- _create_fields('nonproperty', NONPROPERTIES))
+ _create_fields('nonproperty', nonproperties))
# Separate the normal fields from the bit fields
bit_fields = [field for field in all_fields if field.is_bit_field]
@@ -376,7 +371,7 @@ class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter):
for field in bucket:
self._fields.append(field)
- self._include_paths = _get_include_paths(property_values + NONPROPERTIES)
+ self._include_paths = _get_include_paths(property_values + nonproperties)
@template_expander.use_jinja('ComputedStyleBase.h.tmpl')

Powered by Google App Engine
This is Rietveld 408576698