| 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 json5_generator | 9 import json5_generator |
| 10 import template_expander | 10 import template_expander |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 super(ComputedStyleBaseWriter, self).__init__(json5_file_path) | 305 super(ComputedStyleBaseWriter, self).__init__(json5_file_path) |
| 306 self._outputs = { | 306 self._outputs = { |
| 307 'ComputedStyleBase.h': self.generate_base_computed_style_h, | 307 'ComputedStyleBase.h': self.generate_base_computed_style_h, |
| 308 'ComputedStyleBase.cpp': self.generate_base_computed_style_cpp, | 308 'ComputedStyleBase.cpp': self.generate_base_computed_style_cpp, |
| 309 'ComputedStyleBaseConstants.h': self.generate_base_computed_style_co
nstants, | 309 'ComputedStyleBaseConstants.h': self.generate_base_computed_style_co
nstants, |
| 310 } | 310 } |
| 311 | 311 |
| 312 # TODO(shend): Remove this once we move NONPROPERTIES to its own JSON fi
le, | 312 # TODO(shend): Remove this once we move NONPROPERTIES to its own JSON fi
le, |
| 313 # since the JSON5 reader will handle missing fields and defaults. | 313 # since the JSON5 reader will handle missing fields and defaults. |
| 314 for property_ in NONPROPERTIES: | 314 for property_ in NONPROPERTIES: |
| 315 property_['name_for_methods'] = property_['name'] | 315 for parameter in self.json5_file.parameters: |
| 316 if 'field_type_path' not in property_: | 316 if parameter not in property_: |
| 317 property_['field_type_path'] = None | 317 property_[parameter] = None |
| 318 if 'type_name' not in property_: | 318 |
| 319 property_['type_name'] = 'E' + enum_type_name(property_['name_fo
r_methods']) | 319 for property_ in NONPROPERTIES: |
| 320 property_['getter'] = method_name(property_['name_for_methods']) | 320 make_style_builder.apply_property_naming_defaults(property_) |
| 321 property_['setter'] = method_name(join_name('set', property_['name_f
or_methods'])) | |
| 322 property_['initial'] = method_name(join_name('initial', property_['n
ame_for_methods'])) | |
| 323 | 321 |
| 324 # Ignore shorthand properties | 322 # Ignore shorthand properties |
| 325 for property_ in self._properties.values(): | 323 for property_ in self._properties.values(): |
| 326 if property_['field_template'] is not None: | 324 if property_['field_template'] is not None: |
| 327 assert not property_['longhands'], \ | 325 assert not property_['longhands'], \ |
| 328 "Shorthand '{}' cannot have a field_template.".format(proper
ty_['name']) | 326 "Shorthand '{}' cannot have a field_template.".format(proper
ty_['name']) |
| 329 | 327 |
| 330 property_values = [value for value in self._properties.values() if not v
alue['longhands']] | 328 property_values = [value for value in self._properties.values() if not v
alue['longhands']] |
| 331 | 329 |
| 332 for property_ in property_values: | 330 for property_ in property_values: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 @template_expander.use_jinja('ComputedStyleBaseConstants.h.tmpl') | 398 @template_expander.use_jinja('ComputedStyleBaseConstants.h.tmpl') |
| 401 def generate_base_computed_style_constants(self): | 399 def generate_base_computed_style_constants(self): |
| 402 return { | 400 return { |
| 403 'properties': self._properties, | 401 'properties': self._properties, |
| 404 'enums': self._generated_enums, | 402 'enums': self._generated_enums, |
| 405 'fields': self._fields, | 403 'fields': self._fields, |
| 406 } | 404 } |
| 407 | 405 |
| 408 if __name__ == '__main__': | 406 if __name__ == '__main__': |
| 409 json5_generator.Maker(ComputedStyleBaseWriter).main() | 407 json5_generator.Maker(ComputedStyleBaseWriter).main() |
| OLD | NEW |