Chromium Code Reviews| Index: third_party/WebKit/Source/build/scripts/make_css_value_id_mappings.py |
| diff --git a/third_party/WebKit/Source/build/scripts/make_css_value_id_mappings.py b/third_party/WebKit/Source/build/scripts/make_css_value_id_mappings.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..c484242e346f6ed6cd828bd15a41c72bcd2b54d5 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/build/scripts/make_css_value_id_mappings.py |
| @@ -0,0 +1,43 @@ |
| +#!/usr/bin/env python |
| +# Copyright 2017 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import json5_generator |
| +import template_expander |
| +import make_style_builder |
| + |
| +from name_utilities import enum_for_css_keyword, enum_value_name |
| + |
| + |
| +class CSSValueIDMappingsWriter(make_style_builder.StyleBuilderWriter): |
| + def __init__(self, json5_file_path): |
| + super(CSSValueIDMappingsWriter, self).__init__(json5_file_path) |
| + self._outputs = { |
| + 'CSSValueIDMappingsGenerated.h': self.generate_css_value_mappings, |
| + } |
| + |
| + self._mappings = {} |
| + self._include_paths = [] |
| + for property_ in self._properties.values(): |
| + if property_['field_template'] == 'keyword': |
| + if property_['field_type_path']: |
| + type_name = property_['field_type_path'].split('/')[-1] |
| + self._include_paths.append(property_['field_type_path'] + '.h') |
|
Bugs Nash
2017/04/03 23:58:55
this population of self._include_paths didn't seem
shend
2017/04/04 03:16:32
It occurred previously, but it was being shared wi
|
| + else: |
| + type_name = property_['type_name'] |
| + |
| + self._mappings[type_name] = { |
| + 'default_value': enum_value_name(property_['default_value']), |
| + 'mapping': [(enum_value_name(k), enum_for_css_keyword(k)) for k in property_['keywords']], |
| + } |
| + |
| + @template_expander.use_jinja('CSSValueIDMappingsGenerated.h.tmpl') |
| + def generate_css_value_mappings(self): |
|
Bugs Nash
2017/04/03 23:58:55
this function name is no longer accurate - it does
shend
2017/04/04 03:16:32
I moved the generation code back down to this meth
|
| + return { |
| + 'include_paths': list(sorted(self._include_paths)), |
| + 'mappings': self._mappings, |
| + } |
| + |
| +if __name__ == '__main__': |
| + json5_generator.Maker(CSSValueIDMappingsWriter).main() |