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

Side by Side Diff: Source/devtools/scripts/generate_supported_css.py

Issue 410953002: Merge CSSProperties.in and CSSShorthands.in (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@infiles
Patch Set: Created 6 years, 5 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
« no previous file with comments | « Source/devtools/devtools.gyp ('k') | Tools/Scripts/webkitpy/w3c/test_converter.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2014 Google Inc. All rights reserved. 2 # Copyright (c) 2014 Google Inc. All rights reserved.
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 for line in lines: 52 for line in lines:
53 if not "alias_for" in line: 53 if not "alias_for" in line:
54 cssProperties[line] = [] 54 cssProperties[line] = []
55 55
56 56
57 def fillCSSShorthandsFromFile(fileName): 57 def fillCSSShorthandsFromFile(fileName):
58 with open(fileName, "r") as f: 58 with open(fileName, "r") as f:
59 lines = f.readlines() 59 lines = f.readlines()
60 lines = filterCommentsAndEmptyLines(lines) 60 lines = filterCommentsAndEmptyLines(lines)
61 for line in lines: 61 for line in lines:
62 # Every line is: 62 # Format for shorthands is:
63 # <property-name>[ longhands=<longhand 1>;<longhand 2>;<longhand 3>,run timeEnabledShorthand=<runtime flag name>] 63 # <property-name>[ longhands=<longhand 1>;<longhand 2>;<longhand 3>]
64 # There might be a runtime flag declaration at the end of the list follo wed by a comma. 64 shorthand = line.partition(" ")[0]
65 if "," in line: 65 longhands = line.partition("longhands=")[2]
lushnikov 2014/07/24 08:08:35 I've just found the following in CSSProperties.in:
Timothy Loh 2014/07/24 08:27:43 The way str.partition works means that the |longha
lushnikov 2014/07/24 09:26:30 My bad. One more thing: this relies on "longhands"
Timothy Loh 2014/07/25 03:36:47 Sure, done. FYI the followup patch https://coderev
66 line = line[:line.index(",")] 66 if longhands:
67 shorthand = line[:line.index(" ")] 67 cssProperties[shorthand] = longhands.split(";")
68 longhands = line[line.index("=") + 1:].split(";")
69 cssProperties[shorthand] = longhands
70 68
71 fillPropertiesFromFile(sys.argv[1]) 69 fillPropertiesFromFile(sys.argv[1])
72 fillPropertiesFromFile(sys.argv[2]) 70 fillPropertiesFromFile(sys.argv[2])
73 fillCSSShorthandsFromFile(sys.argv[3]) 71 fillCSSShorthandsFromFile(sys.argv[3])
74 72
75 # Reformat from map into list. 73 # Reformat from map into list.
76 reformat = [] 74 reformat = []
77 for name, longhands in cssProperties.items(): 75 for name, longhands in cssProperties.items():
78 entry = {"name": name} 76 entry = {"name": name}
79 if len(longhands) > 0: 77 if len(longhands) > 0:
80 entry["longhands"] = longhands 78 entry["longhands"] = longhands
81 reformat.append(entry) 79 reformat.append(entry)
82 80
83 with open(sys.argv[4], "w") as f: 81 with open(sys.argv[4], "w") as f:
84 f.write("WebInspector.CSSMetadata.initializeWithSupportedProperties(%s);" % json.dumps(reformat)) 82 f.write("WebInspector.CSSMetadata.initializeWithSupportedProperties(%s);" % json.dumps(reformat))
OLDNEW
« no previous file with comments | « Source/devtools/devtools.gyp ('k') | Tools/Scripts/webkitpy/w3c/test_converter.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698