| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import math | 6 import math |
| 7 import sys | 7 import sys |
| 8 | 8 |
| 9 import in_generator | 9 import in_generator |
| 10 import template_expander | 10 import template_expander |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 'ComputedStyleBaseConstants.h': self.generate_base_computed_style_co
nstants, | 76 'ComputedStyleBaseConstants.h': self.generate_base_computed_style_co
nstants, |
| 77 } | 77 } |
| 78 | 78 |
| 79 # A map of enum name -> list of enum values | 79 # A map of enum name -> list of enum values |
| 80 self._computed_enums = {} | 80 self._computed_enums = {} |
| 81 for property in self._properties.values(): | 81 for property in self._properties.values(): |
| 82 # Only generate enums for keyword properties that use the default fi
eld_storage_type. | 82 # Only generate enums for keyword properties that use the default fi
eld_storage_type. |
| 83 if property['keyword_only'] and property['field_storage_type'] is No
ne: | 83 if property['keyword_only'] and property['field_storage_type'] is No
ne: |
| 84 enum_name = property['type_name'] | 84 enum_name = property['type_name'] |
| 85 # From the Blink style guide: Enum members should use InterCaps
with an initial capital letter. [names-enum-members] | 85 # From the Blink style guide: Enum members should use InterCaps
with an initial capital letter. [names-enum-members] |
| 86 enum_values = [camel_case(k) for k in property['keywords']] | 86 enum_values = [('k' + camel_case(k)) for k in property['keywords
']] |
| 87 self._computed_enums[enum_name] = enum_values | 87 self._computed_enums[enum_name] = enum_values |
| 88 | 88 |
| 89 # A list of all the fields to be generated. | 89 # A list of all the fields to be generated. |
| 90 all_fields = [] | 90 all_fields = [] |
| 91 for property in self._properties.values(): | 91 for property in self._properties.values(): |
| 92 if property['keyword_only']: | 92 if property['keyword_only']: |
| 93 property_name = property['name_for_methods'] | 93 property_name = property['name_for_methods'] |
| 94 property_name_lower = property_name[0].lower() + property_name[1
:] | 94 property_name_lower = property_name[0].lower() + property_name[1
:] |
| 95 | 95 |
| 96 # From the Blink style guide: Other data members should be prefi
xed by "m_". [names-data-members] | 96 # From the Blink style guide: Other data members should be prefi
xed by "m_". [names-data-members] |
| (...skipping 10 matching lines...) Expand all Loading... |
| 107 # For now, the getter name should match the field name. Later, g
etter names | 107 # For now, the getter name should match the field name. Later, g
etter names |
| 108 # will start with an uppercase letter, so if they conflict with
the type name, | 108 # will start with an uppercase letter, so if they conflict with
the type name, |
| 109 # add 'get' to the front. | 109 # add 'get' to the front. |
| 110 getter_method_name = property_name_lower | 110 getter_method_name = property_name_lower |
| 111 if type_name == property_name: | 111 if type_name == property_name: |
| 112 getter_method_name = 'get' + property_name | 112 getter_method_name = 'get' + property_name |
| 113 | 113 |
| 114 assert property['initial_keyword'] is not None, \ | 114 assert property['initial_keyword'] is not None, \ |
| 115 ('MakeComputedStyleBase requires an initial keyword for keyw
ord_only values, none specified ' | 115 ('MakeComputedStyleBase requires an initial keyword for keyw
ord_only values, none specified ' |
| 116 'for property ' + property['name']) | 116 'for property ' + property['name']) |
| 117 default_value = type_name + '::' + camel_case(property['initial_
keyword']) | 117 default_value = type_name + '::k' + camel_case(property['initial
_keyword']) |
| 118 | 118 |
| 119 # If the property is independent, add the single-bit sized isInh
erited flag | 119 # If the property is independent, add the single-bit sized isInh
erited flag |
| 120 # to the list of Fields as well. | 120 # to the list of Fields as well. |
| 121 if property['independent']: | 121 if property['independent']: |
| 122 field_name_suffix_upper = property_name + 'IsInherited' | 122 field_name_suffix_upper = property_name + 'IsInherited' |
| 123 field_name_suffix_lower = property_name_lower + 'IsInherited
' | 123 field_name_suffix_lower = property_name_lower + 'IsInherited
' |
| 124 all_fields.append(Field( | 124 all_fields.append(Field( |
| 125 'inherited_flag', | 125 'inherited_flag', |
| 126 name='m_' + field_name_suffix_lower, | 126 name='m_' + field_name_suffix_lower, |
| 127 property_name=property['name'], | 127 property_name=property['name'], |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 def generate_base_computed_style_constants(self): | 226 def generate_base_computed_style_constants(self): |
| 227 return { | 227 return { |
| 228 'properties': self._properties, | 228 'properties': self._properties, |
| 229 'enums': self._computed_enums, | 229 'enums': self._computed_enums, |
| 230 'fields': self._fields, | 230 'fields': self._fields, |
| 231 'expected_total_field_bytes': self._expected_total_field_bytes, | 231 'expected_total_field_bytes': self._expected_total_field_bytes, |
| 232 } | 232 } |
| 233 | 233 |
| 234 if __name__ == '__main__': | 234 if __name__ == '__main__': |
| 235 in_generator.Maker(ComputedStyleBaseWriter).main(sys.argv) | 235 in_generator.Maker(ComputedStyleBaseWriter).main(sys.argv) |
| OLD | NEW |