Index: third_party/WebKit/Source/build/scripts/make_css_property_descriptor.py |
diff --git a/third_party/WebKit/Source/build/scripts/make_css_property_descriptor.py b/third_party/WebKit/Source/build/scripts/make_css_property_descriptor.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..1501df4692f7deb23a5f172faf8f4eaaa5b9cd01 |
--- /dev/null |
+++ b/third_party/WebKit/Source/build/scripts/make_css_property_descriptor.py |
@@ -0,0 +1,53 @@ |
+#!/usr/bin/env python |
+# Copyright 2016 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 sys |
+ |
+import in_generator |
+import template_expander |
+import make_style_builder |
+ |
+ |
+class CSSPropertyAPIWriter(make_style_builder.StyleBuilderWriter): |
+ def __init__(self, in_file_path): |
+ super(CSSPropertyAPIWriter, self).__init__(in_file_path) |
+ self._outputs = { |
+ 'CSSPropertyDescriptor.cpp': self.generate_property_descriptor_h, |
+ } |
+ |
+ # Stores a list of all the property classnames. |
+ self._api_classnames = [] |
+ |
+ # Stores a list of all CSS properties which have an index 'api_array_index'. |
+ self._properties_by_index = [] |
+ |
+ for property in self._properties.values(): |
+ if property['api_class'] is not None: |
+ if property['api_class'] is True: |
+ # This property had the generated_api_class flag set in CSSProperties.in, |
+ # but did not specify a class name. |
+ self._api_classnames.append(property['upper_camel_name']) |
+ elif isinstance(property['api_class'], str): |
+ # This property has a specified class name. |
+ self._api_classnames.append(property['api_class']) |
+ self._properties_by_index.append(property) |
+ |
+ # Sort classnames and remove duplicates. |
+ self._api_classnames = sorted(list(set(self._api_classnames))) |
alancutter (OOO until 2018)
2016/12/12 00:00:04
No need for list().
aazzam
2016/12/12 04:05:40
done :)
|
+ |
+ # Adding indexes to all of the properties, which specifies the order in which the properties |
+ # are stored and accessed in the cssPropertyDescriptors array in CSSPropertyDescriptors.cpp. |
sashab
2016/12/09 00:58:25
Beautiful!! This whole file is awesome!
|
+ for i, property in enumerate(self._properties_by_index): |
+ property['api_array_index'] = i + 1 |
+ |
+ @template_expander.use_jinja('CSSPropertyDescriptor.cpp.tmpl') |
+ def generate_property_descriptor_h(self): |
+ return { |
+ 'classnames': self._api_classnames, |
+ 'properties': self._properties_by_index, |
alancutter (OOO until 2018)
2016/12/12 00:00:04
Use the same names between the script and the temp
aazzam
2016/12/12 04:05:40
done :)
|
+ } |
+ |
+if __name__ == '__main__': |
+ in_generator.Maker(CSSPropertyAPIWriter).main(sys.argv) |