Chromium Code Reviews| Index: Source/build/scripts/make_css_shorthands.py |
| diff --git a/Source/build/scripts/make_css_shorthands.py b/Source/build/scripts/make_css_shorthands.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..c21bd7d312bb564d0549c1aedb8edb8d0c7b5589 |
| --- /dev/null |
| +++ b/Source/build/scripts/make_css_shorthands.py |
| @@ -0,0 +1,52 @@ |
| +#!/usr/bin/env python |
| + |
|
Nils Barth (inactive)
2014/04/03 06:27:06
Could you add a module doc string?
"""This does XX
tasak
2014/05/12 14:33:27
Done.
|
| +import sys |
| + |
| +from in_file import InFile |
| +import in_generator |
| +import template_expander |
| + |
| + |
| +class CSSShorthandsInWriter(in_generator.Writer): |
| + class_name = "CSSShorthands" |
|
Nils Barth (inactive)
2014/04/03 06:27:06
Please use quotes consistently, preferably single
tasak
2014/05/12 14:33:27
Done.
|
| + defaults = { |
| + 'alias_for': None, |
| + 'is_internal': False, |
| + } |
| + _except_properties = set(['all', 'direction', 'unicode-bidi']) |
|
Nils Barth (inactive)
2014/04/03 06:27:06
This can be a module-level constant, and should be
tasak
2014/05/12 14:33:27
Done.
|
| + |
| + def __init__(self, file_paths): |
| + in_generator.Writer.__init__(self, file_paths[1:]) |
| + self._outputs = {(self.class_name + ".in"): self.generate_implementation} |
| + |
| + properties = filter(lambda property: not property['alias_for'], self.in_file.name_dictionaries) |
|
Nils Barth (inactive)
2014/04/03 06:27:06
Could you use a list comprehension instead?
(Also
tasak
2014/05/12 14:33:27
Done.
|
| + if len(properties) > 1024: |
| + print "ERROR : There is more than 1024 CSS Properties, you need to update CSSProperty.h/StylePropertyMetadata m_propertyID accordingly." |
| + exit(1) |
| + |
| + css_properties = [] |
|
Nils Barth (inactive)
2014/04/03 06:27:06
Again, list comprehension:
css_property = [css_pro
tasak
2014/05/12 14:33:27
Done.
|
| + for property in properties: |
| + # 'all' should not contain internal properties. |
| + if property['name'].startswith('-internal-'): |
| + continue |
| + # 'all' should not contain properties in _except_properties. |
| + if property['name'] in self._except_properties: |
| + continue |
| + css_properties.append(property['name']) |
| + |
| + in_file = InFile.load_from_files([file_paths[0]], {'longhands': "", 'runtimeEnabledShorthand': None}, {}, None) |
|
Nils Barth (inactive)
2014/04/03 06:27:06
Could you add some line breaks to the argument lis
tasak
2014/05/12 14:33:27
Done.
|
| + self._properties = in_file.name_dictionaries |
| + shorthand_properties = filter(lambda property: property['longhands'], self._properties) |
|
Nils Barth (inactive)
2014/04/03 06:27:06
List comprehension, can merge with set line.
...an
tasak
2014/05/12 14:33:27
Done.
|
| + shorthands = set([property["name"] for property in shorthand_properties]) |
| + self._all_longhands = ';'.join([property for property in css_properties if property not in shorthands]) |
|
Nils Barth (inactive)
2014/04/03 06:27:06
You don't need the []: you can just write:
join(p
tasak
2014/05/12 14:33:27
I see. I did "assign a list here".
|
| + |
| + @template_expander.use_jinja("CSSShorthands.in.tmpl") |
| + def generate_implementation(self): |
| + return { |
| + "properties": self._properties, |
| + "all_longhands": self._all_longhands, |
| + } |
| + |
| + |
| +if __name__ == "__main__": |
| + in_generator.Maker(CSSShorthandsInWriter).main(sys.argv) |