| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 groups[field.group_name].append(field) | 182 groups[field.group_name].append(field) |
| 183 | 183 |
| 184 no_group = groups.pop(None) | 184 no_group = groups.pop(None) |
| 185 subgroups = [Group(group_name, [], _reorder_fields(fields)) for group_name,
fields in groups.items()] | 185 subgroups = [Group(group_name, [], _reorder_fields(fields)) for group_name,
fields in groups.items()] |
| 186 return Group('', subgroups=subgroups, fields=_reorder_fields(no_group)) | 186 return Group('', subgroups=subgroups, fields=_reorder_fields(no_group)) |
| 187 | 187 |
| 188 | 188 |
| 189 def _create_diff_groups_map(diff_function_inputs, root_group): | 189 def _create_diff_groups_map(diff_function_inputs, root_group): |
| 190 diff_functions_map = {} | 190 diff_functions_map = {} |
| 191 for entry in diff_function_inputs: | 191 for entry in diff_function_inputs: |
| 192 diff_functions_map[entry['name']] = _create_diff_groups(entry['fields'],
root_group) | 192 diff_functions_map[entry['name']] = _create_diff_groups(entry['fields'],
entry['map_of_expressions'], root_group) |
| 193 return diff_functions_map | 193 return diff_functions_map |
| 194 | 194 |
| 195 | 195 |
| 196 def _create_diff_groups(fields_to_diff, root_group): | 196 def _create_diff_groups(fields_to_diff, map_of_expressions, root_group): |
| 197 diff_group = DiffGroup(root_group.member_name) | 197 diff_group = DiffGroup(root_group.member_name) |
| 198 for subgroup in root_group.subgroups: | 198 for subgroup in root_group.subgroups: |
| 199 if any(field.property_name in fields_to_diff for field in subgroup.all_f
ields): | 199 if any(field.property_name in (fields_to_diff + map_of_expressions.value
s()) for field in subgroup.all_fields): |
| 200 diff_group.subgroups.append(_create_diff_groups(fields_to_diff, subg
roup)) | 200 diff_group.subgroups.append(_create_diff_groups(fields_to_diff, map_
of_expressions, subgroup)) |
| 201 for field in root_group.fields: | 201 for field in root_group.fields: |
| 202 if field.property_name in fields_to_diff: | 202 if field.property_name in fields_to_diff: |
| 203 diff_group.expressions.append(field.getter_expression) | 203 diff_group.expressions.append(field.getter_expression) |
| 204 for expression, property_ in map_of_expressions.iteritems(): |
| 205 if property_ == field.property_name: |
| 206 diff_group.expressions.append(expression) |
| 204 return diff_group | 207 return diff_group |
| 205 | 208 |
| 206 | 209 |
| 207 def _create_enums(properties): | 210 def _create_enums(properties): |
| 208 """ | 211 """ |
| 209 Returns an OrderedDict of enums to be generated, enum name -> [list of enum
values] | 212 Returns an OrderedDict of enums to be generated, enum name -> [list of enum
values] |
| 210 """ | 213 """ |
| 211 enums = {} | 214 enums = {} |
| 212 for property_ in properties: | 215 for property_ in properties: |
| 213 # Only generate enums for keyword properties that use the default field_
type_path. | 216 # Only generate enums for keyword properties that use the default field_
type_path. |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 434 |
| 432 @template_expander.use_jinja('ComputedStyleBaseConstants.h.tmpl') | 435 @template_expander.use_jinja('ComputedStyleBaseConstants.h.tmpl') |
| 433 def generate_base_computed_style_constants(self): | 436 def generate_base_computed_style_constants(self): |
| 434 return { | 437 return { |
| 435 'properties': self._properties, | 438 'properties': self._properties, |
| 436 'enums': self._generated_enums, | 439 'enums': self._generated_enums, |
| 437 } | 440 } |
| 438 | 441 |
| 439 if __name__ == '__main__': | 442 if __name__ == '__main__': |
| 440 json5_generator.Maker(ComputedStyleBaseWriter).main() | 443 json5_generator.Maker(ComputedStyleBaseWriter).main() |
| OLD | NEW |