diff --git a/Libraries/LibIDL/Types.h b/Libraries/LibIDL/Types.h index 9a271a1198f..790b85a9d52 100644 --- a/Libraries/LibIDL/Types.h +++ b/Libraries/LibIDL/Types.h @@ -119,7 +119,7 @@ public: // https://webidl.spec.whatwg.org/#idl-symbol bool is_symbol() const { return is_plain() && m_name == "symbol"; } - bool is_string() const { return is_plain() && m_name.is_one_of("ByteString", "CSSOMString", "DOMString", "Utf16DOMString", "USVString"); } + bool is_string() const { return is_plain() && m_name.is_one_of("ByteString", "CSSOMString", "DOMString", "Utf16DOMString", "USVString", "Utf16USVString"); } // https://webidl.spec.whatwg.org/#dfn-integer-type bool is_integer() const { return is_plain() && m_name.is_one_of("byte", "octet", "short", "unsigned short", "long", "unsigned long", "long long", "unsigned long long"); } diff --git a/Libraries/LibWeb/WebIDL/AbstractOperations.cpp b/Libraries/LibWeb/WebIDL/AbstractOperations.cpp index 365f18922fe..10c475316f8 100644 --- a/Libraries/LibWeb/WebIDL/AbstractOperations.cpp +++ b/Libraries/LibWeb/WebIDL/AbstractOperations.cpp @@ -244,6 +244,11 @@ JS::ThrowCompletionOr to_usv_string(JS::VM& vm, JS::Value value) return TRY(value.to_utf16_string(vm)).to_well_formed_utf8(); } +JS::ThrowCompletionOr to_utf16_usv_string(JS::VM& vm, JS::Value value) +{ + return TRY(value.to_utf16_string(vm)).to_well_formed(); +} + // https://webidl.spec.whatwg.org/#invoke-a-callback-function // https://whatpr.org/webidl/1437.html#invoke-a-callback-function template diff --git a/Libraries/LibWeb/WebIDL/AbstractOperations.h b/Libraries/LibWeb/WebIDL/AbstractOperations.h index d08a968993d..b69da91c0cd 100644 --- a/Libraries/LibWeb/WebIDL/AbstractOperations.h +++ b/Libraries/LibWeb/WebIDL/AbstractOperations.h @@ -25,6 +25,7 @@ JS::Completion call_user_object_operation(CallbackType& callback, String const& JS::ThrowCompletionOr to_string(JS::VM&, JS::Value); JS::ThrowCompletionOr to_utf16_string(JS::VM&, JS::Value); JS::ThrowCompletionOr to_usv_string(JS::VM&, JS::Value); +JS::ThrowCompletionOr to_utf16_usv_string(JS::VM&, JS::Value); JS::ThrowCompletionOr to_byte_string(JS::VM&, JS::Value); enum class ExceptionBehavior { diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 8fefac9e272..3582cbbfd97 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -426,8 +426,8 @@ static void generate_to_string(SourceGenerator& scoped_generator, ParameterType scoped_generator.set("string_suffix", "_string"sv); } - if (parameter.type->name() == "USVString") - scoped_generator.set("to_string", "to_usv_string"sv); + if (parameter.type->name().is_one_of("USVString"sv, "Utf16USVString"sv)) + scoped_generator.set("to_string", is_utf16_string ? "to_utf16_usv_string"sv : "to_usv_string"sv); else if (parameter.type->name() == "ByteString") scoped_generator.set("to_string", "to_byte_string"sv); else