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

Side by Side Diff: Source/build/scripts/make_css_shorthands.py

Issue 216803002: Implement all shorthand property. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed parseAnimationProperty Created 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
2
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.
3 import sys
4
5 from in_file import InFile
6 import in_generator
7 import template_expander
8
9
10 class CSSShorthandsInWriter(in_generator.Writer):
11 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.
12 defaults = {
13 'alias_for': None,
14 'is_internal': False,
15 }
16 _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.
17
18 def __init__(self, file_paths):
19 in_generator.Writer.__init__(self, file_paths[1:])
20 self._outputs = {(self.class_name + ".in"): self.generate_implementation }
21
22 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.
23 if len(properties) > 1024:
24 print "ERROR : There is more than 1024 CSS Properties, you need to u pdate CSSProperty.h/StylePropertyMetadata m_propertyID accordingly."
25 exit(1)
26
27 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.
28 for property in properties:
29 # 'all' should not contain internal properties.
30 if property['name'].startswith('-internal-'):
31 continue
32 # 'all' should not contain properties in _except_properties.
33 if property['name'] in self._except_properties:
34 continue
35 css_properties.append(property['name'])
36
37 in_file = InFile.load_from_files([file_paths[0]], {'longhands': "", 'run timeEnabledShorthand': 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.
38 self._properties = in_file.name_dictionaries
39 shorthand_properties = filter(lambda property: property['longhands'], se lf._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.
40 shorthands = set([property["name"] for property in shorthand_properties] )
41 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".
42
43 @template_expander.use_jinja("CSSShorthands.in.tmpl")
44 def generate_implementation(self):
45 return {
46 "properties": self._properties,
47 "all_longhands": self._all_longhands,
48 }
49
50
51 if __name__ == "__main__":
52 in_generator.Maker(CSSShorthandsInWriter).main(sys.argv)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698