| Index: Source/devtools/scripts/generate_supported_css.py
|
| diff --git a/Source/devtools/scripts/generate_supported_css.py b/Source/devtools/scripts/generate_supported_css.py
|
| index 2883c943332d2495aa4524c54279cd215a7ae724..a99e3140132dbd14ef7099e741e4464f78276e73 100755
|
| --- a/Source/devtools/scripts/generate_supported_css.py
|
| +++ b/Source/devtools/scripts/generate_supported_css.py
|
| @@ -34,51 +34,22 @@ except ImportError:
|
|
|
| import sys
|
|
|
| -cssProperties = {}
|
|
|
| -
|
| -def filterCommentsAndEmptyLines(lines):
|
| - result = []
|
| - for line in lines:
|
| - if len(line.strip()) > 0 and line[:2] != "//":
|
| - result.append(line.strip())
|
| - return result
|
| -
|
| -
|
| -def fillPropertiesFromFile(fileName):
|
| - with open(fileName, "r") as f:
|
| - lines = f.readlines()
|
| - lines = filterCommentsAndEmptyLines(lines)
|
| - for line in lines:
|
| - if not "alias_for" in line:
|
| - cssProperties[line] = []
|
| -
|
| -
|
| -def fillCSSShorthandsFromFile(fileName):
|
| - with open(fileName, "r") as f:
|
| - lines = f.readlines()
|
| - lines = filterCommentsAndEmptyLines(lines)
|
| - for line in lines:
|
| - # Every line is:
|
| - # <property-name>[ longhands=<longhand 1>;<longhand 2>;<longhand 3>,runtimeEnabledShorthand=<runtime flag name>]
|
| - # There might be a runtime flag declaration at the end of the list followed by a comma.
|
| - if "," in line:
|
| - line = line[:line.index(",")]
|
| - shorthand = line[:line.index(" ")]
|
| - longhands = line[line.index("=") + 1:].split(";")
|
| - cssProperties[shorthand] = longhands
|
| -
|
| -fillPropertiesFromFile(sys.argv[1])
|
| -fillPropertiesFromFile(sys.argv[2])
|
| -fillCSSShorthandsFromFile(sys.argv[3])
|
| -
|
| -# Reformat from map into list.
|
| -reformat = []
|
| -for name, longhands in cssProperties.items():
|
| - entry = {"name": name}
|
| - if len(longhands) > 0:
|
| - entry["longhands"] = longhands
|
| - reformat.append(entry)
|
| -
|
| -with open(sys.argv[4], "w") as f:
|
| - f.write("WebInspector.CSSMetadata.initializeWithSupportedProperties(%s);" % json.dumps(reformat))
|
| +def properties_from_file(file_name):
|
| + properties = []
|
| + with open(file_name, "r") as f:
|
| + for line in f:
|
| + line = line.strip()
|
| + if not line or line.startswith("//") or "alias_for" in line:
|
| + continue
|
| + name = line.partition(" ")[0]
|
| + entry = {"name": name}
|
| + longhands = line.partition("longhands=")[2]
|
| + if longhands:
|
| + entry["longhands"] = longhands.split(";")
|
| + properties.append(entry)
|
| + return properties
|
| +
|
| +properties = properties_from_file(sys.argv[1])
|
| +with open(sys.argv[2], "w") as f:
|
| + f.write("WebInspector.CSSMetadata.initializeWithSupportedProperties(%s);" % json.dumps(properties))
|
|
|