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 e3df4bf9c3dafbc99d2cbebf1f6be21fdcda0154..bc911a7357cf4cea154f0cff036db30dabefbcec 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 |
@@ -17,9 +17,9 @@ from name_utilities import ( |
from collections import OrderedDict, defaultdict |
-# Temporary hard-coded list of fields that are not CSS properties. |
+# Temporary hard-coded list of extra fields. |
# TODO(shend): Put this into its own JSON5 file. |
-NONPROPERTIES = [ |
+EXTRA_FIELDS = [ |
{'name': 'IsLink', 'field_template': 'monotonic_flag', |
'inherited': False, 'independent': False, 'default_value': False}, |
{'name': 'OriginalDisplay', 'field_template': 'keyword', 'default_value': 'inline', |
@@ -249,7 +249,7 @@ def _create_inherited_flag_field(property_): |
) |
-def _create_fields(field_role, properties): |
+def _create_fields(properties): |
""" |
Create ComputedStyle fields from properties or nonproperties and return a list of Field objects. |
""" |
@@ -262,6 +262,10 @@ def _create_fields(field_role, properties): |
if property_['independent']: |
fields.append(_create_inherited_flag_field(property_)) |
+ # TODO(shend): Get rid of the property/nonproperty field roles. |
+ # If the field has_custom_compare_and_copy, then it does not appear in |
+ # ComputedStyle::operator== and ComputedStyle::CopyNonInheritedFromCached. |
+ field_role = 'nonproperty' if property_['has_custom_compare_and_copy'] else 'property' |
fields.append(_create_field(field_role, property_)) |
return fields |
@@ -303,18 +307,6 @@ def _pack_fields(fields): |
class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter): |
def __init__(self, json5_file_path): |
super(ComputedStyleBaseWriter, self).__init__(json5_file_path) |
- self._outputs = { |
- 'ComputedStyleBase.h': self.generate_base_computed_style_h, |
- 'ComputedStyleBase.cpp': self.generate_base_computed_style_cpp, |
- 'ComputedStyleBaseConstants.h': self.generate_base_computed_style_constants, |
- } |
- |
- # TODO(shend): Remove this once we move NONPROPERTIES to its own JSON file, |
- # since the JSON5 reader will handle missing fields and defaults. |
- nonproperties = [defaultdict(lambda: None, item) for item in NONPROPERTIES] |
- |
- for property_ in nonproperties: |
- self._apply_property_naming_defaults(property_) |
# Ignore shorthand properties |
for property_ in self._properties.values(): |
@@ -322,19 +314,34 @@ class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter): |
assert not property_['longhands'], \ |
"Shorthand '{}' cannot have a field_template.".format(property_['name']) |
- property_values = [value for value in self._properties.values() if not value['longhands']] |
+ css_properties = [value for value in self._properties.values() if not value['longhands']] |
- for property_ in property_values: |
- # Override the type name when field_type_path is specified |
- if property_['field_type_path']: |
- property_['type_name'] = property_['field_type_path'].split('/')[-1] |
+ for property_ in css_properties: |
+ # All CSS properties have generated comparison and copy. |
+ property_['has_custom_compare_and_copy'] = False |
alancutter (OOO until 2018)
2017/04/19 04:40:15
# All CSS properties that are generated do not hav
shend
2017/04/19 07:20:30
Done.
|
# CSS properties are not allowed to explicitly specify their field_size. |
property_['field_size'] = None |
- self._generated_enums = _create_enums(property_values + nonproperties) |
+ # TODO(shend): Remove this once we move EXTRA_FIELDS to its own JSON file, |
+ # since the JSON5 reader will handle missing fields and defaults. |
+ extra_fields = [defaultdict(lambda: None, item) for item in EXTRA_FIELDS] |
- all_fields = (_create_fields('property', property_values) + |
- _create_fields('nonproperty', nonproperties)) |
+ for property_ in extra_fields: |
+ # TODO(shend): Remove the line below once we move EXTRA_FIELDS to its |
+ # own file which would enforce defaults. |
+ property_['has_custom_compare_and_copy'] = True |
+ self._apply_property_naming_defaults(property_) |
+ |
+ all_properties = css_properties + extra_fields |
+ |
+ # Override the type name when field_type_path is specified |
+ for property_ in all_properties: |
+ if property_['field_type_path']: |
+ property_['type_name'] = property_['field_type_path'].split('/')[-1] |
+ |
+ self._generated_enums = _create_enums(all_properties) |
+ |
+ all_fields = _create_fields(all_properties) |
# Separate the normal fields from the bit fields |
bit_fields = [field for field in all_fields if field.is_bit_field] |
@@ -371,8 +378,12 @@ 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(all_properties) |
+ self._outputs = { |
+ 'ComputedStyleBase.h': self.generate_base_computed_style_h, |
+ 'ComputedStyleBase.cpp': self.generate_base_computed_style_cpp, |
+ 'ComputedStyleBaseConstants.h': self.generate_base_computed_style_constants, |
+ } |
@template_expander.use_jinja('ComputedStyleBase.h.tmpl') |
def generate_base_computed_style_h(self): |