1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# 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/.
def _assign_slots(obj, args):
for i, attr in enumerate(obj.__slots__):
setattr(obj, attr, args[i])
class Longhand(object):
__slots__ = ["name", "method", "id", "rules", "flags", "pref"]
def __init__(self, *args):
_assign_slots(self, args)
@staticmethod
def type():
return "longhand"
class Shorthand(object):
__slots__ = ["name", "method", "id", "rules", "flags", "pref", "subprops"]
def __init__(self, *args):
_assign_slots(self, args)
@staticmethod
def type():
return "shorthand"
class Alias(object):
__slots__ = ["name", "method", "alias_id", "prop_id", "rules", "flags", "pref"]
def __init__(self, *args):
_assign_slots(self, args)
@staticmethod
def type():
return "alias"
<%!
# 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.
return not prop.gecko_pref and not prop.enabled_in_content()
def method(prop):
if prop.name == "float":
return "CssFloat"
if prop.name.startswith("-x-"):
return prop.camel_case[1:]
return prop.camel_case
# TODO(emilio): Get this to zero.
LONGHANDS_NOT_SERIALIZED_WITH_SERVO = [
# Servo serializes one value when both are the same, a few tests expect two.
"border-spacing",
# These resolve auto to zero in a few cases, but not all.
"max-height",
"max-width",
"min-height",
"min-width",
# resistfingerprinting stuff.
"-moz-osx-font-smoothing",
# Layout dependent.
"width",
"height",
"grid-template-rows",
"grid-template-columns",
"perspective-origin",
"transform-origin",
"transform",
"top",
"right",
"bottom",
"left",
"border-top-width",
"border-right-width",
"border-bottom-width",
"border-left-width",
"margin-top",
"margin-right",
"margin-bottom",
"margin-left",
"padding-top",
"padding-right",
"padding-bottom",
"padding-left",
]
def serialized_by_servo(prop):
if prop.type() == "shorthand" or prop.type() == "alias":
return True
# Keywords are all fine, except -moz-osx-font-smoothing, which does
# resistfingerprinting stuff.
if prop.keyword and prop.name != "-moz-osx-font-smoothing":
return True
return prop.name not in LONGHANDS_NOT_SERIALIZED_WITH_SERVO
def exposed_on_getcs(prop):
if "Style" not in prop.rule_types_allowed_names():
return False
if is_internal(prop):
return False
return True
def rules(prop):
return ", ".join('"{}"'.format(rule) for rule in prop.rule_types_allowed_names())
def flags(prop):
result = []
if prop.explicitly_enabled_in_chrome():
result.append("EnabledInUASheetsAndChrome")
elif prop.explicitly_enabled_in_ua_sheets():
result.append("EnabledInUASheets")
if is_internal(prop):
result.append("Internal")
if prop.enabled_in == "":
result.append("Inaccessible")
if "CAN_ANIMATE_ON_COMPOSITOR" in prop.flags:
result.append("CanAnimateOnCompositor")
if exposed_on_getcs(prop):
result.append("ExposedOnGetCS")
if prop.type() == "shorthand" and "SHORTHAND_IN_GETCS" in prop.flags:
result.append("ShorthandUnconditionallyExposedOnGetCS")
if serialized_by_servo(prop):
result.append("SerializedByServo")
if prop.type() == "longhand" and prop.logical:
result.append("IsLogical")
return ", ".join('"{}"'.format(flag) for flag in result)
def pref(prop):
if prop.gecko_pref:
return '"' + prop.gecko_pref + '"'
return '""'
def sub_properties(prop):
return ", ".join('"{}"'.format(p.ident) for p in prop.sub_properties)
%>
data = [
% for prop in data.longhands:
Longhand("${prop.name}", "${method(prop)}", "${prop.ident}", [${rules(prop)}], [${flags(prop)}], ${pref(prop)}),
% endfor
% for prop in data.shorthands:
Shorthand("${prop.name}", "${prop.camel_case}", "${prop.ident}", [${rules(prop)}], [${flags(prop)}], ${pref(prop)},
[${sub_properties(prop)}]),
% endfor
% for prop in data.all_aliases():
Alias("${prop.name}", "${prop.camel_case}", "${prop.ident}", "${prop.original.ident}", [${rules(prop)}], [${flags(prop)}], ${pref(prop)}),
% endfor
]
|