Truly independent web browser
Meta: Support CSSOMString in the Rust bindings
Andreas Klingf0dbb0d23f0c
diff --git a/Meta/Generators/libweb_bindings/rust_overloads.py b/Meta/Generators/libweb_bindings/rust_overloads.pyindex 5f4a2592608..3b68bf1d6fa 100644--- a/Meta/Generators/libweb_bindings/rust_overloads.py+++ b/Meta/Generators/libweb_bindings/rust_overloads.py@@ -37,7 +37,7 @@ from Utils.webidl_parser import IDLUnionTypefrom Utils.webidl_parser import Interfacefrom Utils.webidl_parser import Operation-STRING_TYPES = {"ByteString", "DOMString", "USVString"}+STRING_TYPES = {"ByteString", "CSSOMString", "DOMString", "USVString"}INTEGER_TYPES = {"byte","octet",diff --git a/Meta/Generators/libweb_bindings/rust_to_idl_value.py b/Meta/Generators/libweb_bindings/rust_to_idl_value.pyindex 09fa9832a4d..c319c27daec 100644--- a/Meta/Generators/libweb_bindings/rust_to_idl_value.py+++ b/Meta/Generators/libweb_bindings/rust_to_idl_value.py@@ -53,7 +53,10 @@ from Utils.webidl_parser import IDLUnionTypefrom Utils.webidl_parser import Interfacefrom Utils.webidl_parser import OperationParameter-STRING_TYPES = ("DOMString", "USVString")+# NB: CSSOMString is a string type that an implementation chooses, https://drafts.csswg.org/cssom/#cssomstring-type,+# and it is a DOMString here, as it is in the C++ bindings.+DOM_STRING_TYPES = ("CSSOMString", "DOMString")+STRING_TYPES = (*DOM_STRING_TYPES, "USVString")def buffer_source_rules(idl_type: IDLType, parameter_attributes: dict[str, str]) -> str:@@ -86,7 +89,7 @@ def rust_to_idl_value(f"{what} has the type {idl_type} with [{integer_attribute}], which the Rust bindings only handle on ""integer types")- if "LegacyNullToEmptyString" in attributes and (idl_type.nullable or name != "DOMString"):+ if "LegacyNullToEmptyString" in attributes and (idl_type.nullable or name not in DOM_STRING_TYPES):raise UnsupportedByRustBindings(f"{what} has the type {idl_type} with [LegacyNullToEmptyString], which applies to DOMString only")@@ -114,7 +117,7 @@ def rust_to_idl_value(raise UnsupportedByRustBindings(f"{what} has the type {idl_type}, which the Rust bindings do not convert to yet")- if name == "DOMString":+ if name in DOM_STRING_TYPES:if "LegacyNullToEmptyString" in attributes:return f"to_dom_string_treating_null_as_empty(vm, {value})"return f"to_dom_string(vm, {value})"diff --git a/Meta/Generators/libweb_bindings/rust_types.py b/Meta/Generators/libweb_bindings/rust_types.pyindex 5f03b589c99..52f2c07796c 100644--- a/Meta/Generators/libweb_bindings/rust_types.py+++ b/Meta/Generators/libweb_bindings/rust_types.py@@ -65,6 +65,7 @@ FLOATING_POINT_TYPES = {"float": "f32", "unrestricted float": "f32", "double": "# The types whose values are plain data, with the Rust type of their values. None of these Rust types is or holds a# cell, which holds_cells() relies on.PLAIN_DATA_TYPES = {+ "CSSOMString": "Utf16String","DOMString": "Utf16String","USVString": "UsvString","boolean": "bool",