mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-11-08 09:11:01 +00:00
LibJS+LibWeb+WebContent: Port JS::PropertyKey to UTF-16
This has quite a lot of fall out. But the majority of it is just type or UDL substitution, where the changes just fall through to other function calls. By changing property key storage to UTF-16, the main affected areas are: * NativeFunction names must now be UTF-16 * Bytecode identifiers must now be UTF-16 * Module/binding names must now be UTF-16
This commit is contained in:
parent
cd276235d7
commit
0efa98a57a
Notes:
github-actions[bot]
2025-08-05 11:08:30 +00:00
Author: https://github.com/trflynn89
Commit: 0efa98a57a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5698
131 changed files with 766 additions and 726 deletions
|
|
@ -287,7 +287,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AesCbcParams::from_value(J
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto iv_value = TRY(object.get("iv"_fly_string));
|
||||
auto iv_value = TRY(object.get("iv"_utf16_fly_string));
|
||||
if (!iv_value.is_object() || !(is<JS::TypedArrayBase>(iv_value.as_object()) || is<JS::ArrayBuffer>(iv_value.as_object()) || is<JS::DataView>(iv_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
auto iv = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(iv_value.as_object()));
|
||||
|
|
@ -301,12 +301,12 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AesCtrParams::from_value(J
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto iv_value = TRY(object.get("counter"_fly_string));
|
||||
auto iv_value = TRY(object.get("counter"_utf16_fly_string));
|
||||
if (!iv_value.is_object() || !(is<JS::TypedArrayBase>(iv_value.as_object()) || is<JS::ArrayBuffer>(iv_value.as_object()) || is<JS::DataView>(iv_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
auto iv = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(iv_value.as_object()));
|
||||
|
||||
auto length_value = TRY(object.get("length"_fly_string));
|
||||
auto length_value = TRY(object.get("length"_utf16_fly_string));
|
||||
auto length = TRY(length_value.to_u8(vm));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new AesCtrParams { iv, length });
|
||||
|
|
@ -318,22 +318,22 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AesGcmParams::from_value(J
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto iv_value = TRY(object.get("iv"_fly_string));
|
||||
auto iv_value = TRY(object.get("iv"_utf16_fly_string));
|
||||
if (!iv_value.is_object() || !(is<JS::TypedArrayBase>(iv_value.as_object()) || is<JS::ArrayBuffer>(iv_value.as_object()) || is<JS::DataView>(iv_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
auto iv = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(iv_value.as_object()));
|
||||
|
||||
auto maybe_additional_data = Optional<ByteBuffer> {};
|
||||
if (MUST(object.has_property("additionalData"_fly_string))) {
|
||||
auto additional_data_value = TRY(object.get("additionalData"_fly_string));
|
||||
if (MUST(object.has_property("additionalData"_utf16_fly_string))) {
|
||||
auto additional_data_value = TRY(object.get("additionalData"_utf16_fly_string));
|
||||
if (!additional_data_value.is_object() || !(is<JS::TypedArrayBase>(additional_data_value.as_object()) || is<JS::ArrayBuffer>(additional_data_value.as_object()) || is<JS::DataView>(additional_data_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
maybe_additional_data = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(additional_data_value.as_object()));
|
||||
}
|
||||
|
||||
auto maybe_tag_length = Optional<u8> {};
|
||||
if (MUST(object.has_property("tagLength"_fly_string))) {
|
||||
auto tag_length_value = TRY(object.get("tagLength"_fly_string));
|
||||
if (MUST(object.has_property("tagLength"_utf16_fly_string))) {
|
||||
auto tag_length_value = TRY(object.get("tagLength"_utf16_fly_string));
|
||||
maybe_tag_length = TRY(tag_length_value.to_u8(vm));
|
||||
}
|
||||
|
||||
|
|
@ -346,15 +346,15 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> HKDFParams::from_value(JS:
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash_value = TRY(object.get("hash"_utf16_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
auto salt_value = TRY(object.get("salt"_fly_string));
|
||||
auto salt_value = TRY(object.get("salt"_utf16_fly_string));
|
||||
if (!salt_value.is_object() || !(is<JS::TypedArrayBase>(salt_value.as_object()) || is<JS::ArrayBuffer>(salt_value.as_object()) || is<JS::DataView>(salt_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
auto salt = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(salt_value.as_object()));
|
||||
|
||||
auto info_value = TRY(object.get("info"_fly_string));
|
||||
auto info_value = TRY(object.get("info"_utf16_fly_string));
|
||||
if (!info_value.is_object() || !(is<JS::TypedArrayBase>(info_value.as_object()) || is<JS::ArrayBuffer>(info_value.as_object()) || is<JS::DataView>(info_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
auto info = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(info_value.as_object()));
|
||||
|
|
@ -368,17 +368,17 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> PBKDF2Params::from_value(J
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto salt_value = TRY(object.get("salt"_fly_string));
|
||||
auto salt_value = TRY(object.get("salt"_utf16_fly_string));
|
||||
|
||||
if (!salt_value.is_object() || !(is<JS::TypedArrayBase>(salt_value.as_object()) || is<JS::ArrayBuffer>(salt_value.as_object()) || is<JS::DataView>(salt_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
|
||||
auto salt = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(salt_value.as_object()));
|
||||
|
||||
auto iterations_value = TRY(object.get("iterations"_fly_string));
|
||||
auto iterations_value = TRY(object.get("iterations"_utf16_fly_string));
|
||||
auto iterations = TRY(iterations_value.to_u32(vm));
|
||||
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash_value = TRY(object.get("hash"_utf16_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new PBKDF2Params { salt, iterations, hash });
|
||||
|
|
@ -390,10 +390,10 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaKeyGenParams::from_valu
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto modulus_length_value = TRY(object.get("modulusLength"_fly_string));
|
||||
auto modulus_length_value = TRY(object.get("modulusLength"_utf16_fly_string));
|
||||
auto modulus_length = TRY(modulus_length_value.to_u32(vm));
|
||||
|
||||
auto public_exponent_value = TRY(object.get("publicExponent"_fly_string));
|
||||
auto public_exponent_value = TRY(object.get("publicExponent"_utf16_fly_string));
|
||||
GC::Ptr<JS::Uint8Array> public_exponent;
|
||||
|
||||
if (!public_exponent_value.is_object() || !is<JS::Uint8Array>(public_exponent_value.as_object()))
|
||||
|
|
@ -410,10 +410,10 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaHashedKeyGenParams::fro
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto modulus_length_value = TRY(object.get("modulusLength"_fly_string));
|
||||
auto modulus_length_value = TRY(object.get("modulusLength"_utf16_fly_string));
|
||||
auto modulus_length = TRY(modulus_length_value.to_u32(vm));
|
||||
|
||||
auto public_exponent_value = TRY(object.get("publicExponent"_fly_string));
|
||||
auto public_exponent_value = TRY(object.get("publicExponent"_utf16_fly_string));
|
||||
GC::Ptr<JS::Uint8Array> public_exponent;
|
||||
|
||||
if (!public_exponent_value.is_object() || !is<JS::Uint8Array>(public_exponent_value.as_object()))
|
||||
|
|
@ -421,7 +421,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaHashedKeyGenParams::fro
|
|||
|
||||
public_exponent = static_cast<JS::Uint8Array&>(public_exponent_value.as_object());
|
||||
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash_value = TRY(object.get("hash"_utf16_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new RsaHashedKeyGenParams { modulus_length, big_integer_from_api_big_integer(public_exponent), hash });
|
||||
|
|
@ -433,7 +433,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaHashedImportParams::fro
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash_value = TRY(object.get("hash"_utf16_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new RsaHashedImportParams { hash });
|
||||
|
|
@ -445,7 +445,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaOaepParams::from_value(
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto label_value = TRY(object.get("label"_fly_string));
|
||||
auto label_value = TRY(object.get("label"_utf16_fly_string));
|
||||
|
||||
ByteBuffer label;
|
||||
if (!label_value.is_nullish()) {
|
||||
|
|
@ -465,7 +465,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaPssParams::from_value(J
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto salt_length_value = TRY(object.get("saltLength"_fly_string));
|
||||
auto salt_length_value = TRY(object.get("saltLength"_utf16_fly_string));
|
||||
auto salt_length = TRY(salt_length_value.to_u32(vm));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new RsaPssParams { salt_length });
|
||||
|
|
@ -477,7 +477,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> EcdsaParams::from_value(JS
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash_value = TRY(object.get("hash"_utf16_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new EcdsaParams { hash });
|
||||
|
|
@ -489,7 +489,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> EcKeyGenParams::from_value
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto curve_value = TRY(object.get("namedCurve"_fly_string));
|
||||
auto curve_value = TRY(object.get("namedCurve"_utf16_fly_string));
|
||||
auto curve = TRY(curve_value.to_string(vm));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new EcKeyGenParams { curve });
|
||||
|
|
@ -501,7 +501,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AesKeyGenParams::from_valu
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto length_value = TRY(object.get("length"_fly_string));
|
||||
auto length_value = TRY(object.get("length"_utf16_fly_string));
|
||||
auto length = TRY(length_value.to_u16(vm));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new AesKeyGenParams { length });
|
||||
|
|
@ -513,7 +513,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AesDerivedKeyParams::from_
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto length_value = TRY(object.get("length"_fly_string));
|
||||
auto length_value = TRY(object.get("length"_utf16_fly_string));
|
||||
auto length = TRY(length_value.to_u16(vm));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new AesDerivedKeyParams { length });
|
||||
|
|
@ -525,7 +525,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> EcdhKeyDeriveParams::from_
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto key_value = TRY(object.get("public"_fly_string));
|
||||
auto key_value = TRY(object.get("public"_utf16_fly_string));
|
||||
auto key_object = TRY(key_value.to_object(vm));
|
||||
|
||||
if (!is<CryptoKey>(*key_object)) {
|
||||
|
|
@ -543,7 +543,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> EcKeyImportParams::from_va
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto named_curve_value = TRY(object.get("namedCurve"_fly_string));
|
||||
auto named_curve_value = TRY(object.get("namedCurve"_utf16_fly_string));
|
||||
auto named_curve = TRY(named_curve_value.to_string(vm));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new EcKeyImportParams { named_curve });
|
||||
|
|
@ -555,12 +555,12 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> HmacImportParams::from_val
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash_value = TRY(object.get("hash"_utf16_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
auto maybe_length = Optional<WebIDL::UnsignedLong> {};
|
||||
if (MUST(object.has_property("length"_fly_string))) {
|
||||
auto length_value = TRY(object.get("length"_fly_string));
|
||||
if (MUST(object.has_property("length"_utf16_fly_string))) {
|
||||
auto length_value = TRY(object.get("length"_utf16_fly_string));
|
||||
maybe_length = TRY(length_value.to_u32(vm));
|
||||
}
|
||||
|
||||
|
|
@ -573,12 +573,12 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> HmacKeyGenParams::from_val
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash_value = TRY(object.get("hash"_utf16_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
auto maybe_length = Optional<WebIDL::UnsignedLong> {};
|
||||
if (MUST(object.has_property("length"_fly_string))) {
|
||||
auto length_value = TRY(object.get("length"_fly_string));
|
||||
if (MUST(object.has_property("length"_utf16_fly_string))) {
|
||||
auto length_value = TRY(object.get("length"_utf16_fly_string));
|
||||
maybe_length = TRY(length_value.to_u32(vm));
|
||||
}
|
||||
|
||||
|
|
@ -592,8 +592,8 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> Ed448Params::from_value(JS
|
|||
auto& object = value.as_object();
|
||||
|
||||
auto maybe_context = Optional<ByteBuffer> {};
|
||||
if (MUST(object.has_property("context"_fly_string))) {
|
||||
auto context_value = TRY(object.get("context"_fly_string));
|
||||
if (MUST(object.has_property("context"_utf16_fly_string))) {
|
||||
auto context_value = TRY(object.get("context"_utf16_fly_string));
|
||||
if (!context_value.is_object() || !(is<JS::TypedArrayBase>(context_value.as_object()) || is<JS::ArrayBuffer>(context_value.as_object()) || is<JS::DataView>(context_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
maybe_context = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(context_value.as_object()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue