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 06db1ccf8955b601cf9bc14ab90506d0584a2b95..c103cd9202edf0d00e5de3b2617a29c0294bdd71 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 |
@@ -30,10 +30,13 @@ class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter): |
enum_values = [k.title() for k in property['keywords']] |
self._computed_enums[enum_name] = enum_values |
- # A list of fields |
+ # A list of fields. |
Field = namedtuple('Field', [ |
# Name of field member variable |
'name', |
+ # Name of field in method names |
+ 'upper_camel_name', |
+ 'lower_camel_name', |
# Property field is for |
'property', |
# Field storage type |
@@ -42,9 +45,23 @@ class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter): |
'size', |
# Default value for field |
'default_value', |
+ # Which comparison functions to include this field in. |
+ 'comparison_function_independent_inherited', |
+ 'comparison_function_non_independent_inherited', |
+ 'comparison_function_non_inherited', |
+ # Which copy functions to include this field in. |
+ 'copy_function_inherit', |
+ 'copy_function_non_inherited_cache', |
+ # If this field is independent, this is the field that stores the bit |
+ # for whether this field was inherited or not. |
+ 'inherited_flag_field', |
]) |
self._fields = [] |
+ # Property name -> [fields for this property]. |
+ self._fields_per_property = {} |
for property in self._properties.values(): |
+ fields_for_property = [] |
+ # Only generate keyword-only properties for now. |
if property['keyword_only']: |
# From the Blink style guide: Other data members should be prefixed by "m_". [names-data-members] |
field_name = 'm_' + property['lower_camel_name'] |
@@ -52,13 +69,43 @@ class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter): |
type_name = property['type_name'] |
# For now, assume the default value is the first enum value. |
default_value = type_name + '::' + self._computed_enums[type_name][0] |
- self._fields.append(Field( |
+ |
+ inherited_flag_field = None |
+ if property['independent']: |
+ inherited_flag_field = Field( |
+ name=field_name + 'IsInherited', |
+ upper_camel_name=property['upper_camel_name'] + 'IsInherited', |
+ lower_camel_name=property['lower_camel_name'] + 'IsInherited', |
+ property=property, |
+ type='bool', |
+ size=1, |
+ default_value='true', |
+ comparison_function_independent_inherited=False, |
+ comparison_function_non_independent_inherited=False, |
+ comparison_function_non_inherited=False, |
+ copy_function_inherit=False, |
+ copy_function_non_inherited_cache=True, |
+ inherited_flag_field=None, |
+ ) |
+ fields_for_property.append(inherited_flag_field) |
+ |
+ fields_for_property.append(Field( |
name=field_name, |
+ upper_camel_name=property['upper_camel_name'], |
+ lower_camel_name=property['lower_camel_name'], |
property=property, |
type=type_name, |
size=int(math.ceil(bits_needed)), |
default_value=default_value, |
+ comparison_function_independent_inherited=property['inherited'] and property['independent'], |
+ comparison_function_non_independent_inherited=property['inherited'] and not property['independent'], |
+ comparison_function_non_inherited=not property['inherited'], |
+ copy_function_inherit=property['inherited'], |
+ copy_function_non_inherited_cache=not property['inherited'], |
+ inherited_flag_field=inherited_flag_field |
)) |
+ self._fields += fields_for_property |
+ self._fields_per_property[property['name']] = fields_for_property |
@template_expander.use_jinja('ComputedStyleBase.h.tmpl') |
def generate_base_computed_style_h(self): |
@@ -66,6 +113,7 @@ class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter): |
'properties': self._properties, |
'enums': self._computed_enums, |
'fields': self._fields, |
+ 'fields_per_property': self._fields_per_property, |
} |
@template_expander.use_jinja('ComputedStyleBase.cpp.tmpl') |