Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: third_party/WebKit/Source/build/scripts/make_css_value_id_mappings.py

Issue 2904483003: Replace "field_type_path" with "include_paths" in CSSProperties.json5. (Closed)
Patch Set: Rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2017 The Chromium Authors. All rights reserved. 2 # Copyright 2017 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 json5_generator 6 import json5_generator
7 import template_expander 7 import template_expander
8 import make_style_builder 8 import make_style_builder
9 9
10 from name_utilities import enum_for_css_keyword, enum_value_name 10 from name_utilities import enum_for_css_keyword, enum_value_name
11 11
12 12
13 class CSSValueIDMappingsWriter(make_style_builder.StyleBuilderWriter): 13 class CSSValueIDMappingsWriter(make_style_builder.StyleBuilderWriter):
14 def __init__(self, json5_file_path): 14 def __init__(self, json5_file_path):
15 super(CSSValueIDMappingsWriter, self).__init__(json5_file_path) 15 super(CSSValueIDMappingsWriter, self).__init__(json5_file_path)
16 self._outputs = { 16 self._outputs = {
17 'CSSValueIDMappingsGenerated.h': self.generate_css_value_mappings, 17 'CSSValueIDMappingsGenerated.h': self.generate_css_value_mappings,
18 } 18 }
19 19
20 @template_expander.use_jinja('CSSValueIDMappingsGenerated.h.tmpl') 20 @template_expander.use_jinja('CSSValueIDMappingsGenerated.h.tmpl')
21 def generate_css_value_mappings(self): 21 def generate_css_value_mappings(self):
22 mappings = {} 22 mappings = {}
23 include_paths = [] 23 include_paths = set()
24 for property_ in self._properties.values(): 24 for property_ in self._properties.values():
25 if property_['field_template'] == 'keyword': 25 if property_['field_template'] == 'keyword':
26 if property_['field_type_path']: 26 include_paths.update(property_['include_paths'])
27 type_name = property_['field_type_path'].split('/')[-1]
28 include_paths.append(property_['field_type_path'] + '.h')
29 else:
30 type_name = property_['type_name']
31 27
32 mappings[type_name] = { 28 mappings[property_['type_name']] = {
33 'default_value': enum_value_name(property_['default_value']) , 29 'default_value': enum_value_name(property_['default_value']) ,
34 'mapping': [(enum_value_name(k), enum_for_css_keyword(k)) fo r k in property_['keywords']], 30 'mapping': [(enum_value_name(k), enum_for_css_keyword(k)) fo r k in property_['keywords']],
35 } 31 }
36 32
37 return { 33 return {
38 'include_paths': list(sorted(include_paths)), 34 'include_paths': list(sorted(include_paths)),
39 'mappings': mappings, 35 'mappings': mappings,
40 } 36 }
41 37
42 if __name__ == '__main__': 38 if __name__ == '__main__':
43 json5_generator.Maker(CSSValueIDMappingsWriter).main() 39 json5_generator.Maker(CSSValueIDMappingsWriter).main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698