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 |
11 import make_style_builder | 11 import make_style_builder |
12 | 12 |
13 from name_utilities import ( | 13 from name_utilities import ( |
14 enum_for_css_keyword, enum_type_name, enum_value_name, class_member_name, me
thod_name, | 14 enum_for_css_keyword, enum_type_name, enum_value_name, class_member_name, me
thod_name, |
15 class_name, join_name | 15 class_name, join_name |
16 ) | 16 ) |
17 from collections import defaultdict, OrderedDict | 17 from collections import defaultdict, OrderedDict |
18 from itertools import chain | 18 from itertools import chain |
19 | 19 |
20 # Heuristic ordering of types from largest to smallest, used to sort fields by t
heir alignment sizes. | 20 # Heuristic ordering of types from largest to smallest, used to sort fields by t
heir alignment sizes. |
21 # Specifying the exact alignment sizes for each type is impossible because it's
platform specific, | 21 # Specifying the exact alignment sizes for each type is impossible because it's
platform specific, |
22 # so we define an ordering instead. | 22 # so we define an ordering instead. |
23 # The ordering comes from the data obtained in: | 23 # The ordering comes from the data obtained in: |
24 # https://codereview.chromium.org/2841413002 | 24 # https://codereview.chromium.org/2841413002 |
25 # TODO(shend): Put alignment sizes into code form, rather than linking to a CL w
hich may disappear. | 25 # TODO(shend): Put alignment sizes into code form, rather than linking to a CL w
hich may disappear. |
26 ALIGNMENT_ORDER = [ | 26 ALIGNMENT_ORDER = [ |
27 'double', | 27 'double', |
28 'FillLayer', 'BorderData', # Aligns like a void * (can be 32 or 64 bits) | 28 'FillLayer', 'BorderData', # Aligns like a void * (can be 32 or 64 bits) |
29 'LengthBox', 'Length', 'float', | 29 'LengthBox', 'LengthSize', 'Length', 'float', |
30 'StyleColor', 'Color', 'unsigned', 'int', | 30 'StyleColor', 'Color', 'unsigned', 'int', |
31 'short', | 31 'short', |
32 'char', | 32 'char', |
33 'bool' | 33 'bool' |
34 ] | 34 ] |
35 | 35 |
36 # TODO(shend): Improve documentation and add docstrings. | 36 # TODO(shend): Improve documentation and add docstrings. |
37 | 37 |
38 | 38 |
39 def _flatten_list(x): | 39 def _flatten_list(x): |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 402 |
403 @template_expander.use_jinja('ComputedStyleBaseConstants.h.tmpl') | 403 @template_expander.use_jinja('ComputedStyleBaseConstants.h.tmpl') |
404 def generate_base_computed_style_constants(self): | 404 def generate_base_computed_style_constants(self): |
405 return { | 405 return { |
406 'properties': self._properties, | 406 'properties': self._properties, |
407 'enums': self._generated_enums, | 407 'enums': self._generated_enums, |
408 } | 408 } |
409 | 409 |
410 if __name__ == '__main__': | 410 if __name__ == '__main__': |
411 json5_generator.Maker(ComputedStyleBaseWriter).main() | 411 json5_generator.Maker(ComputedStyleBaseWriter).main() |
OLD | NEW |