author Xidorn Quan <>
Mon, 16 Apr 2018 14:08:20 +1000
changeset 467832 4d3a028edaed24c108b999488531331ac4db066d
permissions -rw-r--r--
Bug 1452542 part 5 - Generate property list from Servo data. r=emilio,froydnj With this change, we first generate a data file from Servo data, and then use this data to generate ServoCSSPropList.h. This change itself serves as a checkpoint with a runtime check that all information generated from Servo side matches what we have in the Gecko side. Following patches will start replacing uses of nsCSSPropList.h with either the data file or the header file. The reason that it generates data file rather than header directly is that, many users of PythonCSSProps.h invokes C++ preprocessor manually to extract data from nsCSSPropList.h without passing in search paths, so it is non-trivial to replace the use of nsCSSPropList.h there with a generated header. Generating a Python data file would hopefully simplify those users rather than adding more complexity to them. I also thought about generating JSON rather than plain Python file, but JSON doesn't allow trailing comma in array, which makes it less pretty to generate via mako template. MozReview-Commit-ID: CwK2oL88r6F

# 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

# nsCSSPropertyID of longhands and shorthands is ordered alphabetically
# with vendor prefixes removed. Note that aliases use their alias name
# as order key directly because they may be duplicate without prefix.
def order_key(prop):
        return["-", 1) + 1:]

# See bug 1454823 for situation of internal flag.
def is_internal(prop):
    # A property which is not controlled by pref and not enabled in
    # content by default is an internal property.
    if not prop.gecko_pref and not prop.enabled_in_content():
        return True
    # There are some special cases we may want to remove eventually.
    return in OTHER_INTERNALS

def flags(prop):
    result = []
    if prop.explicitly_enabled_in_chrome():
    elif prop.explicitly_enabled_in_ua_sheets():
    if is_internal(prop):
    if prop.enabled_in == "":
    return ", ".join('"{}"'.format(flag) for flag in result)

def pref(prop):
    if prop.gecko_pref:
        return '"' + prop.gecko_pref + '"'
    return '""'

    % for prop in sorted(data.longhands, key=order_key):
        % if == "float":
        % elif"-x-"):
        % else:
        % endif
    % endfor

    % for prop in sorted(data.shorthands, key=order_key):
    % endfor

    % for prop in sorted(data.all_aliases(), key=lambda x:
        ("${prop.ident}", "${prop.original.ident}"),
    % endfor