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

Unified 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 side-by-side diff with in-line comments
Download patch
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()
« 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