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 2f2f84f8b0a5a85ef7683a4e2a3da410df3fec50..0619916238813022ba1e82a7ff88a57bdb63a932 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 |
@@ -37,9 +37,12 @@ class Field(object): |
'name', |
# Name of property field is for |
'property_name', |
- # Internal field storage type (storage_type_path can be None) |
- 'storage_type', |
- 'storage_type_path', |
+ # Affects how the field is generated (keyword, primitive, external) |
meade_UTC10
2017/02/13 06:46:24
How does it affect it? What are the valid values?
shend
2017/02/16 02:48:58
Added explanations in the JSON5. Made naming consi
|
+ 'template', |
+ # Path to predefined class for overriding generated types. |
+ 'type_path', |
+ # Name of the type (e.g. EClear, int) |
+ 'type_name', |
meade_UTC10
2017/02/13 06:46:24
Could you describe the relationship between these?
shend
2017/02/16 02:48:58
Added comment to refer readers to the JSON5 file,
|
# Bits needed for storage |
'size', |
# Default value for field |
@@ -51,17 +54,17 @@ class Field(object): |
'resetter_method_name', |
]) |
- def __init__(self, field_family, **kwargs): |
+ def __init__(self, role, **kwargs): |
# Values common to all fields |
# Set attributes from the keyword arguments |
for attrib in Field.REQUIRED_ATTRIBUTES: |
setattr(self, attrib, kwargs.pop(attrib)) |
- # Field family: one of these must be true |
- self.is_property = field_family == 'property' |
- self.is_inherited_flag = field_family == 'inherited_flag' |
+ # Field role: one of these must be true |
+ self.is_property = role == 'property' |
+ self.is_inherited_flag = role == 'inherited_flag' |
assert (self.is_property, self.is_inherited_flag).count(True) == 1, \ |
- 'Field family has to be exactly one of: property, inherited_flag' |
+ 'Field role has to be exactly one of: property, inherited_flag' |
if self.is_property: |
self.is_inherited = kwargs.pop('inherited') |
@@ -82,8 +85,8 @@ def _create_enums(properties): |
""" |
enums = {} |
for property_ in properties: |
- # Only generate enums for keyword properties that use the default field_storage_type. |
- if property_['keyword_only'] and property_['field_storage_type'] is None: |
+ # Only generate enums for keyword properties that use the default field_type_path. |
+ if property_['field_template'] == 'keyword' and property_['field_type_path'] is None: |
enum_name = property_['type_name'] |
# From the Blink style guide: Enum members should use InterCaps with an initial capital letter. [names-enum-members] |
enum_values = [('k' + camel_case(k)) for k in property_['keywords']] |
@@ -109,15 +112,15 @@ def _create_property_field(property_): |
# From the Blink style guide: Other data members should be prefixed by "m_". [names-data-members] |
field_name = 'm_' + property_name_lower |
- bits_needed = math.log(len(property_['keywords']), 2) |
+ bits_needed = math.log(len(property_['keywords']), 2) # TODO: implement for non-enums |
# Separate the type path from the type name, if specified. |
- if property_['field_storage_type']: |
- type_path = property_['field_storage_type'] |
+ if property_['field_type_path']: |
+ type_path = property_['field_type_path'] |
type_name = type_path.split('/')[-1] |
else: |
- type_name = property_['type_name'] |
type_path = None |
+ type_name = property_['type_name'] |
# For now, the getter name should match the field name. Later, getter names |
# will start with an uppercase letter, so if they conflict with the type name, |
@@ -127,19 +130,19 @@ def _create_property_field(property_): |
getter_method_name = 'get' + property_name |
assert property_['initial_keyword'] is not None, \ |
- ('MakeComputedStyleBase requires an initial keyword for keyword_only values, none specified ' |
+ ('MakeComputedStyleBase requires an initial keyword for keyword fields, none specified ' |
'for property ' + property_['name']) |
default_value = type_name + '::k' + camel_case(property_['initial_keyword']) |
- # Add the property itself as a member variable. |
return Field( |
'property', |
name=field_name, |
property_name=property_['name'], |
inherited=property_['inherited'], |
independent=property_['independent'], |
- storage_type=type_name, |
- storage_type_path=type_path, |
+ template=property_['field_template'], |
+ type_path=type_path, |
+ type_name=type_name, |
size=int(math.ceil(bits_needed)), |
default_value=default_value, |
getter_method_name=getter_method_name, |
@@ -165,8 +168,9 @@ def _create_inherited_flag_field(property_): |
'inherited_flag', |
name='m_' + field_name_suffix_lower, |
property_name=property_['name'], |
- storage_type='bool', |
- storage_type_path=None, |
+ template='primitive', |
+ type_path=None, |
+ type_name='bool', |
size=1, |
default_value='true', |
getter_method_name=field_name_suffix_lower, |
@@ -182,8 +186,8 @@ def _create_fields(properties): |
""" |
fields = [] |
for property_ in properties: |
- # Keywords only means we generate an enum field. |
- if property_['keyword_only']: |
+ # Only generate properties that have a field type |
+ if property_['field_template'] is not None: |
# If the property is independent, add the single-bit sized isInherited flag |
# to the list of Fields as well. |
if property_['independent']: |