OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 sys | 6 import sys |
7 | 7 |
8 import css_properties | 8 import css_properties |
9 import json5_generator | 9 import json5_generator |
10 from name_utilities import lower_first | 10 from name_utilities import lower_first |
11 import template_expander | 11 import template_expander |
12 | 12 |
13 | 13 |
14 class CSSPropertyMetadataWriter(css_properties.CSSProperties): | 14 class CSSPropertyMetadataWriter(css_properties.CSSProperties): |
15 filters = { | 15 filters = { |
16 'lower_first': lower_first, | 16 'lower_first': lower_first, |
17 } | 17 } |
18 | 18 |
19 def __init__(self, json5_file_path): | 19 def __init__(self, json5_file_path): |
20 super(CSSPropertyMetadataWriter, self).__init__(json5_file_path) | 20 super(CSSPropertyMetadataWriter, self).__init__(json5_file_path) |
21 self._outputs = {'CSSPropertyMetadata.cpp': self.generate_css_property_m
etadata_cpp} | 21 self._outputs = { |
| 22 'CSSPropertyMetadata.cpp': |
| 23 self.generate_css_property_metadata_cpp |
| 24 } |
| 25 for property_value in self._properties.values(): |
| 26 property_value['supports_percentage'] = ( |
| 27 'Percent' in property_value['typedom_types']) |
22 | 28 |
23 @template_expander.use_jinja('CSSPropertyMetadata.cpp.tmpl', filters=filters
) | 29 @template_expander.use_jinja('CSSPropertyMetadata.cpp.tmpl', filters=filters
) |
24 def generate_css_property_metadata_cpp(self): | 30 def generate_css_property_metadata_cpp(self): |
25 return { | 31 return { |
26 'properties_including_aliases': self._properties_including_aliases, | 32 'properties_including_aliases': self._properties_including_aliases, |
27 'switches': [('is_descriptor', 'IsDescriptor'), | 33 'switches': [('is_descriptor', 'IsDescriptor'), |
28 ('is_property', 'IsProperty'), | 34 ('is_property', 'IsProperty'), |
29 ('interpolable', 'IsInterpolableProperty'), | 35 ('interpolable', 'IsInterpolableProperty'), |
30 ('inherited', 'IsInheritedProperty'), | 36 ('inherited', 'IsInheritedProperty'), |
31 ('supports_percentage', 'PropertySupportsPercentage'), | 37 ('supports_percentage', 'PropertySupportsPercentage'), |
32 ], | 38 ], |
33 'first_enum_value': self._first_enum_value, | 39 'first_enum_value': self._first_enum_value, |
34 } | 40 } |
35 | 41 |
36 | 42 |
37 if __name__ == '__main__': | 43 if __name__ == '__main__': |
38 json5_generator.Maker(CSSPropertyMetadataWriter).main() | 44 json5_generator.Maker(CSSPropertyMetadataWriter).main() |
OLD | NEW |