Index: third_party/WebKit/Source/build/scripts/make_css_property_equality.py |
diff --git a/third_party/WebKit/Source/build/scripts/make_css_property_equality.py b/third_party/WebKit/Source/build/scripts/make_css_property_equality.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..bfef448a098baa3c2cf57360637b7eec55f5eb77 |
--- /dev/null |
+++ b/third_party/WebKit/Source/build/scripts/make_css_property_equality.py |
@@ -0,0 +1,56 @@ |
+#!/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. |
+ |
+from collections import defaultdict |
+import sys |
+ |
+import css_properties |
+import in_generator |
+from name_utilities import enum_for_css_property |
+from name_utilities import lower_first |
+import template_expander |
+ |
+ |
+class CSSPropertyEqualityWriter(css_properties.CSSProperties): |
+ filters = { |
+ 'lower_first': lower_first, |
+ } |
+ |
+ def __init__(self, in_file_path): |
+ super(CSSPropertyEqualityWriter, self).__init__(in_file_path) |
+ |
+ def set_if_none(property, key, value): |
+ if property[key] is None: |
+ property[key] = value |
+ |
+ for property in self._properties.values(): |
+ upper_camel = property['upper_camel_name'] |
Timothy Loh
2016/05/24 05:38:35
probably any of the stuff copied from other files
|
+ set_if_none(property, 'name_for_methods', upper_camel.replace('Webkit', '')) |
+ name = property['name_for_methods'] |
+ simple_type_name = str(property['type_name']).split('::')[-1] |
+ set_if_none(property, 'getter', lower_first(name) if simple_type_name != name else 'get' + name) |
+ |
+ for property in self._properties.values(): |
+ property['longhand_property_ids'] = map(enum_for_css_property, property['longhands'].split(';')) |
+ |
+ self._outputs = { |
+ 'CSSPropertyEquality.cpp': self.generate_property_equality, |
+ 'CSSPropertyEqualityCustom.h': self.generate_property_equality_custom_header, |
+ } |
+ |
+ @template_expander.use_jinja('CSSPropertyEquality.cpp.tmpl') |
+ def generate_property_equality(self): |
+ return { |
+ 'properties': self._properties, |
+ } |
+ |
+ @template_expander.use_jinja('CSSPropertyEqualityCustom.h.tmpl') |
+ def generate_property_equality_custom_header(self): |
+ return { |
+ 'properties': self._properties, |
+ } |
+ |
+if __name__ == '__main__': |
+ in_generator.Maker(CSSPropertyEqualityWriter).main(sys.argv) |