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

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

Issue 2794853002: Separate CSSValueID mappings generator from ComputedStyleBase generator. (Closed)
Patch Set: Fix build.gn Created 3 years, 8 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
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import json5_generator
7 import template_expander
8 import make_style_builder
9
10 from name_utilities import enum_for_css_keyword, enum_value_name
11
12
13 class CSSValueIDMappingsWriter(make_style_builder.StyleBuilderWriter):
14 def __init__(self, json5_file_path):
15 super(CSSValueIDMappingsWriter, self).__init__(json5_file_path)
16 self._outputs = {
17 'CSSValueIDMappingsGenerated.h': self.generate_css_value_mappings,
18 }
19
20 @template_expander.use_jinja('CSSValueIDMappingsGenerated.h.tmpl')
21 def generate_css_value_mappings(self):
22 mappings = {}
23 include_paths = []
24 for property_ in self._properties.values():
25 if property_['field_template'] == 'keyword':
26 if property_['field_type_path']:
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
32 mappings[type_name] = {
33 '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']],
35 }
36
37 return {
38 'include_paths': list(sorted(include_paths)),
39 'mappings': mappings,
40 }
41
42 if __name__ == '__main__':
43 json5_generator.Maker(CSSValueIDMappingsWriter).main()
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/build/scripts/make_computed_style_base.py ('k') | third_party/WebKit/Source/core/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698