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/.
8 def generate(output
, dataFile
):
10 """/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */
12 /* processed file that defines entries for nsComputedDOMStyle, designed
13 to be #included in nsComputedDOMStyle.cpp */
15 static constexpr Entry kEntries[] = {
19 def exposed_on_getcs(p
):
20 return "ExposedOnGetCS" in p
.flags
23 # Put prefixed properties after normal properties.
24 # The spec is unclear about this, and Blink doesn't have any sensible
25 # order at all, so it probably doesn't matter a lot. But originally
26 # Gecko put then later so we do so as well. See w3c/csswg-drafts#2827.
27 order
= p
.name
.startswith("-")
28 return (order
, p
.name
)
30 def has_cpp_getter(p
):
31 if "SerializedByServo" in p
.flags
:
33 if p
.type() == "longhand" and "IsLogical" in p
.flags
:
37 # Some special cases we may get rid of later. See bug 1471423.
39 if p
.id.startswith("margin_"):
40 return "{}Width".format(p
.method
)
41 if p
.id.startswith("_moz_"):
45 if p
.id.startswith("_moz_outline_radius_"):
46 method
= method
.replace("left", "Left")
47 method
= method
.replace("right", "Right")
52 return "DoGet" + method(p
)
53 # Put a dummy getter here instead of nullptr because MSVC seems
54 # to have bug which ruins the table when we put nullptr for
55 # pointer-to-member-function. See bug 1471426.
58 properties
= runpy
.run_path(dataFile
)["data"]
59 properties
= filter(exposed_on_getcs
, properties
)
61 TEMPLATE
= " {{ eCSSProperty_{}, &nsComputedDOMStyle::{} }},\n"
62 for p
in sorted(properties
, key
=order_key
):
63 output
.write(TEMPLATE
.format(p
.id, getter_entry(p
)))