2018-04-16 07:08:20 +03:00
|
|
|
# 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 https://mozilla.org/MPL/2.0/.
|
|
|
|
|
2018-05-04 06:44:51 +03:00
|
|
|
def _assign_slots(obj, args):
|
|
|
|
for i, attr in enumerate(obj.__slots__):
|
|
|
|
setattr(obj, attr, args[i])
|
|
|
|
|
|
|
|
|
|
|
|
class Longhand(object):
|
|
|
|
__slots__ = ["name", "method", "id", "flags", "pref"]
|
|
|
|
|
|
|
|
def __init__(self, *args):
|
|
|
|
_assign_slots(self, args)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def type():
|
|
|
|
return "longhand"
|
|
|
|
|
|
|
|
|
|
|
|
class Shorthand(object):
|
2018-05-04 08:17:05 +03:00
|
|
|
__slots__ = ["name", "method", "id", "flags", "pref", "subprops"]
|
2018-05-04 06:44:51 +03:00
|
|
|
|
|
|
|
def __init__(self, *args):
|
|
|
|
_assign_slots(self, args)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def type():
|
|
|
|
return "shorthand"
|
|
|
|
|
|
|
|
|
|
|
|
class Alias(object):
|
|
|
|
__slots__ = ["name", "method", "alias_id", "prop_id", "flags", "pref"]
|
|
|
|
|
|
|
|
def __init__(self, *args):
|
|
|
|
_assign_slots(self, args)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def type():
|
|
|
|
return "alias"
|
|
|
|
|
2018-04-16 07:08:20 +03:00
|
|
|
<%!
|
|
|
|
# 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):
|
|
|
|
if prop.name.startswith("-"):
|
|
|
|
return prop.name[prop.name.find("-", 1) + 1:]
|
|
|
|
return prop.name
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
OTHER_INTERNALS = [
|
|
|
|
"-moz-context-properties",
|
|
|
|
"-moz-control-character-visibility",
|
|
|
|
]
|
|
|
|
return prop.name in OTHER_INTERNALS
|
|
|
|
|
2018-05-04 06:44:51 +03:00
|
|
|
def method(prop):
|
|
|
|
if prop.name == "float":
|
|
|
|
return "CssFloat"
|
|
|
|
if prop.name.startswith("-x-"):
|
|
|
|
return prop.camel_case[1:]
|
|
|
|
return prop.camel_case
|
|
|
|
|
2018-04-16 07:08:20 +03:00
|
|
|
def flags(prop):
|
|
|
|
result = []
|
|
|
|
if prop.explicitly_enabled_in_chrome():
|
2018-04-26 08:00:50 +03:00
|
|
|
result.append("EnabledInUASheetsAndChrome")
|
2018-04-16 07:08:20 +03:00
|
|
|
elif prop.explicitly_enabled_in_ua_sheets():
|
2018-04-26 08:00:50 +03:00
|
|
|
result.append("EnabledInUASheets")
|
2018-04-16 07:08:20 +03:00
|
|
|
if is_internal(prop):
|
2018-04-26 08:00:50 +03:00
|
|
|
result.append("Internal")
|
2018-04-16 07:08:20 +03:00
|
|
|
if prop.enabled_in == "":
|
2018-04-26 08:00:50 +03:00
|
|
|
result.append("Inaccessible")
|
2018-04-20 12:13:16 +03:00
|
|
|
if "GETCS_NEEDS_LAYOUT_FLUSH" in prop.flags:
|
2018-04-26 08:00:50 +03:00
|
|
|
result.append("GetCSNeedsLayoutFlush")
|
2018-04-20 13:32:57 +03:00
|
|
|
if "CAN_ANIMATE_ON_COMPOSITOR" in prop.flags:
|
2018-04-26 08:00:50 +03:00
|
|
|
result.append("CanAnimateOnCompositor")
|
|
|
|
return ", ".join('"CSSPropFlags::{}"'.format(flag) for flag in result)
|
2018-04-16 07:08:20 +03:00
|
|
|
|
|
|
|
def pref(prop):
|
|
|
|
if prop.gecko_pref:
|
|
|
|
return '"' + prop.gecko_pref + '"'
|
|
|
|
return '""'
|
2018-05-04 08:17:05 +03:00
|
|
|
|
|
|
|
def sub_properties(prop):
|
|
|
|
return ", ".join('"{}"'.format(p.ident) for p in prop.sub_properties)
|
2018-04-16 07:08:20 +03:00
|
|
|
%>
|
|
|
|
|
2018-05-04 06:44:51 +03:00
|
|
|
data = [
|
2018-04-16 07:08:20 +03:00
|
|
|
% for prop in sorted(data.longhands, key=order_key):
|
2018-05-04 06:44:51 +03:00
|
|
|
Longhand("${prop.name}", "${method(prop)}", "${prop.ident}", [${flags(prop)}], ${pref(prop)}),
|
2018-04-16 07:08:20 +03:00
|
|
|
% endfor
|
|
|
|
|
|
|
|
% for prop in sorted(data.shorthands, key=order_key):
|
2018-05-04 08:17:05 +03:00
|
|
|
Shorthand("${prop.name}", "${prop.camel_case}", "${prop.ident}", [${flags(prop)}], ${pref(prop)},
|
|
|
|
[${sub_properties(prop)}]),
|
2018-04-16 07:08:20 +03:00
|
|
|
% endfor
|
|
|
|
|
|
|
|
% for prop in sorted(data.all_aliases(), key=lambda x: x.name):
|
2018-05-04 06:44:51 +03:00
|
|
|
Alias("${prop.name}", "${prop.camel_case}", "${prop.ident}", "${prop.original.ident}", [], ${pref(prop)}),
|
2018-04-16 07:08:20 +03:00
|
|
|
% endfor
|
|
|
|
]
|