mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1207028 - Add method to get a CSS property's sorted order position based on its IDL name. r=bzbarsky
This commit is contained in:
parent
bce2fb5b16
commit
3ae47121cf
@ -22,18 +22,25 @@ properties = sorted(properties, cmp=property_compare)
|
||||
for i, p in enumerate(properties):
|
||||
p["index"] = i
|
||||
|
||||
# Record each property's IDL name.
|
||||
for p in properties:
|
||||
if "CSS_PROPERTY_INTERNAL" in p["flags"]:
|
||||
p["idlname"] = None
|
||||
else:
|
||||
idl_name = p["prop"]
|
||||
if not idl_name.startswith("Moz"):
|
||||
idl_name = idl_name[0].lower() + idl_name[1:]
|
||||
p["idlname"] = idl_name
|
||||
|
||||
def generate_idl_names(properties):
|
||||
names = []
|
||||
for p in properties:
|
||||
if p["proptype"] is "alias":
|
||||
continue
|
||||
if "CSS_PROPERTY_INTERNAL" in p["flags"]:
|
||||
if p["idlname"] is None:
|
||||
names.append(" nullptr, // %s" % p["name"])
|
||||
else:
|
||||
idl_name = p["prop"]
|
||||
if not idl_name.startswith("Moz"):
|
||||
idl_name = idl_name[0].lower() + idl_name[1:]
|
||||
names.append(' "%s",' % idl_name)
|
||||
names.append(' "%s",' % p["idlname"])
|
||||
return "\n".join(names)
|
||||
|
||||
def generate_assertions(properties):
|
||||
@ -46,13 +53,29 @@ def generate_assertions(properties):
|
||||
'properties in nsCSSProperty order");')
|
||||
return "\n".join(map(lambda p: msg % (enum(p), p["index"]), properties))
|
||||
|
||||
def generate_idl_name_positions(properties):
|
||||
# Skip aliases.
|
||||
ps = filter(lambda p: p["proptype"] is not "alias", properties)
|
||||
|
||||
# Sort alphabetically by IDL name.
|
||||
ps = sorted(ps, key=lambda p: p["idlname"])
|
||||
|
||||
# Annotate entries with the sorted position.
|
||||
ps = [(p, position) for position, p in enumerate(ps)]
|
||||
|
||||
# Sort back to nsCSSProperty order.
|
||||
ps = sorted(ps, key=lambda (p, position): p["index"])
|
||||
|
||||
return ",\n".join(map(lambda (p, position): " %d" % position, ps))
|
||||
|
||||
cppFile = open(sys.argv[1], "r")
|
||||
cppTemplate = cppFile.read()
|
||||
cppFile.close()
|
||||
|
||||
substitutions = {
|
||||
"idl_names": generate_idl_names(properties),
|
||||
"assertions": generate_assertions(properties)
|
||||
"assertions": generate_assertions(properties),
|
||||
"idl_name_positions": generate_idl_name_positions(properties),
|
||||
}
|
||||
print ("/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */\n\n" +
|
||||
string.Template(cppTemplate).substitute(substitutions))
|
||||
|
@ -528,6 +528,21 @@ public:
|
||||
return kIDLNameTable[aProperty];
|
||||
}
|
||||
|
||||
private:
|
||||
static const int32_t kIDLNameSortPositionTable[eCSSProperty_COUNT];
|
||||
|
||||
public:
|
||||
/**
|
||||
* Returns the position of the specified property in a list of all
|
||||
* properties sorted by their IDL name.
|
||||
*/
|
||||
static int32_t PropertyIDLNameSortPosition(nsCSSProperty aProperty)
|
||||
{
|
||||
MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT,
|
||||
"out of range");
|
||||
return kIDLNameSortPositionTable[aProperty];
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
static bool IsEnabled(nsCSSProperty aProperty) {
|
||||
|
@ -10,4 +10,8 @@ const char* const nsCSSProps::kIDLNameTable[eCSSProperty_COUNT] = {
|
||||
${idl_names}
|
||||
};
|
||||
|
||||
const int32_t nsCSSProps::kIDLNameSortPositionTable[eCSSProperty_COUNT] = {
|
||||
${idl_name_positions}
|
||||
};
|
||||
|
||||
${assertions}
|
||||
|
Loading…
Reference in New Issue
Block a user