| 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..1809ec0e94b3b75a08addc9ea80326568d983160
|
| --- /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,
|
| + }
|
| +
|
| + @template_expander.use_jinja('CSSValueIDMappingsGenerated.h.tmpl')
|
| + def generate_css_value_mappings(self):
|
| + mappings = {}
|
| + 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]
|
| + include_paths.append(property_['field_type_path'] + '.h')
|
| + else:
|
| + type_name = property_['type_name']
|
| +
|
| + 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']],
|
| + }
|
| +
|
| + return {
|
| + 'include_paths': list(sorted(include_paths)),
|
| + 'mappings': mappings,
|
| + }
|
| +
|
| +if __name__ == '__main__':
|
| + json5_generator.Maker(CSSValueIDMappingsWriter).main()
|
|
|