Files
palemoon27/layout/style/GenerateCSSPropsGenerated.py
T
roytam1 2b652f0b52 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1195098. Null check for blurred source surface. r=mstange (4578ca815e)
- Bug 1155828. Follow up bug to correct indentation. r=mstange (7b1ccb079e)
- Bug 1181028. Log assert error. r=me (a09801af89)
- Bug 1181028. Delete assertion to create equivalent draw targets during box shadow creation. r=mstange (de7ffd0412)
- Bug 1209649. Take into account border radius sizes for min inset box shadow. r=mstange (992619654c)
- Bug 1178971 - Added function to draw dashed table borders to replace loop currently used to individually draw each dash. r=mstange (1a0ef8e26d)
- Bug 1198708 - Part 1: Store exact timing-function type on nsTimingFunction and ComputedTimingFunction. r=birtles (03636015d2)
- Bug 1198708 - Part 2: Factor out computed nsTimingFunction serialization to public utility methods. r=birtles (11069efa45)
- Bug 1198708 - Part 3: Serialize computed {transition,animation}-timing-function using their specified values. r=birtles (67b033f452)
- Bug 1198708 - Part 4: Don't include start/end keyword in serialized specified {transition,animation}-timing-function value if it was omitted. r=birtles (e1b4225025)
- Bug 1198708 - Part 5: Add method to serialize a ComputedTimingFunction. r=birtles (c48edd3c1c)
- Bug 1198708 - Part 6: Implement KeyframeEffectReadOnly.getFrames(). r=birtles,bzbarsky (9cc9001e8d)
- Bug 1198708 - Part 7: Tests. r=birtles (8668bdbed3)
- Bug 1206569 - Part 4: Add method to get a CSS property's IDL name. r=bzbarsky (f9d94c27e4)
- Bug 1207028 - Add method to get a CSS property's sorted order position based on its IDL name. r=bzbarsky (a856d46e67)
- Bug 1188095 - Don't pause media elements on 'graphene'; r=baku (aae8063137)
- Bug 1111201: Check for OOM when calling an asm.js function with new; r=evilpie (e5973dd6b8)
- Bug 1178793 - Throw on OOB atomics access, interpreter+Ion. r=luke (d974def281)
- Bug 1084248 - no undefined behavior, take 2. r=waldo (0c0c00f90f)
- Bug 1084248 - safe for races, take 2. r=waldo (85629fd1e6)
2022-09-01 10:03:18 +08:00

82 lines
2.7 KiB
Python

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import sys
import string
properties = [{"name":p[0], "prop":p[1], "id":p[2],
"flags":p[3], "pref":p[4], "proptype":p[5]}
for (i, p) in enumerate(eval(sys.stdin.read()))]
# Sort the list so that longhand and logical properties are intermingled
# first, shorthand properties follow, then aliases appear last. This matches
# the order of the nsCSSProperty enum.
def property_compare(x, y):
property_order = {"longhand": 0, "logical": 0, "shorthand": 1, "alias": 2}
return property_order[x["proptype"]] - property_order[y["proptype"]]
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 p["idlname"] is None:
names.append(" nullptr, // %s" % p["name"])
else:
names.append(' "%s",' % p["idlname"])
return "\n".join(names)
def generate_assertions(properties):
def enum(p):
if p["proptype"] is "alias":
return "eCSSPropertyAlias_%s" % p["prop"]
else:
return "eCSSProperty_%s" % p["id"]
msg = ('static_assert(%s == %d, "GenerateCSSPropsGenerated.py did not list '
'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),
"idl_name_positions": generate_idl_name_positions(properties),
}
print ("/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */\n\n" +
string.Template(cppTemplate).substitute(substitutions))