1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 # You can obtain one at http://mozilla.org/MPL/2.0/.
7 FILE
= """/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */
9 /* processed file that defines entries for nsComputedDOMStyle, designed
10 to be #included in nsComputedDOMStyle.cpp */
12 static constexpr size_t kEntryIndices[eCSSProperty_COUNT] = {{
18 static constexpr Entry kEntries[eCSSProperty_COUNT] = {{
24 def generate(output
, dataFile
):
26 # Put prefixed properties after normal properties.
27 # The spec is unclear about this, and Blink doesn't have any sensible
28 # order at all, so it probably doesn't matter a lot. But originally
29 # Gecko put then later so we do so as well. See w3c/csswg-drafts#2827.
30 order
= p
.name
.startswith("-")
31 return (order
, p
.name
)
33 def has_cpp_getter(p
):
34 if not "ExposedOnGetCS" in p
.flags
:
36 if "SerializedByServo" in p
.flags
:
38 if p
.type() == "longhand" and "IsLogical" in p
.flags
:
44 return "DoGet" + p
.method
45 # Put a dummy getter here instead of nullptr because MSVC seems
46 # to have bug which ruins the table when we put nullptr for
47 # pointer-to-member-function. See bug 1471426.
50 properties
= runpy
.run_path(dataFile
)["data"]
56 non_aliases
= list(filter(lambda p
: p
.type() != "alias", properties
.values()))
57 for i
, p
in enumerate(sorted(non_aliases
, key
=order_key
)):
58 can_be_exposed
= "true" if "ExposedOnGetCS" in p
.flags
else "false"
60 "{{ eCSSProperty_{}, {}, &nsComputedDOMStyle::{}}}".format(
61 p
.id, can_be_exposed
, getter_entry(p
)
67 for i
, p
in enumerate(non_aliases
):
68 indices
.append(str(index_map
[p
.id]))
70 'static_assert(size_t(eCSSProperty_{}) == {}, "");'.format(p
.id, i
)
73 assert len(indices
) == len(entries
)
77 indices
=", ".join(indices
),
78 entries
=",\n ".join(entries
),
79 asserts
="\n".join(asserts
),