summaryrefslogtreecommitdiffstats
path: root/layout/style/ServoCSSPropList.mako.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /layout/style/ServoCSSPropList.mako.py
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/style/ServoCSSPropList.mako.py')
-rw-r--r--layout/style/ServoCSSPropList.mako.py168
1 files changed, 168 insertions, 0 deletions
diff --git a/layout/style/ServoCSSPropList.mako.py b/layout/style/ServoCSSPropList.mako.py
new file mode 100644
index 0000000000..9d0a447820
--- /dev/null
+++ b/layout/style/ServoCSSPropList.mako.py
@@ -0,0 +1,168 @@
+# 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", "flags", "pref"]
+
+ def __init__(self, *args):
+ _assign_slots(self, args)
+
+ @staticmethod
+ def type():
+ return "longhand"
+
+
+class Shorthand(object):
+ __slots__ = ["name", "method", "id", "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", "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.
+ 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
+
+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",
+
+ # Resolved value should be zero when the column-rule-style is none.
+ "column-rule-width",
+
+ # 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",
+ "line-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":
+ # FIXME: Need to serialize a value interpolated with currentcolor
+ # properly to be able to use text-decoration, and figure out what to do
+ # with relative mask urls.
+ return prop.name != "text-decoration" and prop.name != "mask"
+ # 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 prop.type() == "longhand":
+ return not is_internal(prop)
+ # TODO: bug 137688 / https://github.com/w3c/csswg-drafts/issues/2529
+ if prop.type() == "shorthand":
+ return "SHORTHAND_IN_GETCS" in prop.flags
+
+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 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}", [${flags(prop)}], ${pref(prop)}),
+ % endfor
+
+ % for prop in data.shorthands:
+ Shorthand("${prop.name}", "${prop.camel_case}", "${prop.ident}", [${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}", [], ${pref(prop)}),
+ % endfor
+]