mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-28 21:26:22 +00:00
LibIDL+LibWeb: Support UTF-16 USVString
This commit is contained in:
parent
1375e6bf39
commit
49467d0583
Notes:
github-actions[bot]
2025-07-25 22:41:48 +00:00
Author: https://github.com/trflynn89
Commit: 49467d0583
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5608
Reviewed-by: https://github.com/gmta ✅
4 changed files with 9 additions and 3 deletions
|
@ -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"); }
|
||||
|
|
|
@ -244,6 +244,11 @@ JS::ThrowCompletionOr<String> to_usv_string(JS::VM& vm, JS::Value value)
|
|||
return TRY(value.to_utf16_string(vm)).to_well_formed_utf8();
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<Utf16String> 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<typename ReturnSteps>
|
||||
|
|
|
@ -25,6 +25,7 @@ JS::Completion call_user_object_operation(CallbackType& callback, String const&
|
|||
JS::ThrowCompletionOr<String> to_string(JS::VM&, JS::Value);
|
||||
JS::ThrowCompletionOr<Utf16String> to_utf16_string(JS::VM&, JS::Value);
|
||||
JS::ThrowCompletionOr<String> to_usv_string(JS::VM&, JS::Value);
|
||||
JS::ThrowCompletionOr<Utf16String> to_utf16_usv_string(JS::VM&, JS::Value);
|
||||
JS::ThrowCompletionOr<String> to_byte_string(JS::VM&, JS::Value);
|
||||
|
||||
enum class ExceptionBehavior {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue