mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:27:45 +00:00
LibJS: Replace standalone js_string() with PrimitiveString::create()
Note that js_rope_string() has been folded into this, the old name was misleading - it would not always create a rope string, only if both sides are not empty strings. Use a three-argument create() overload instead.
This commit is contained in:
parent
5db38d7ba1
commit
525f22d018
144 changed files with 656 additions and 672 deletions
|
@ -236,10 +236,10 @@ JS::MarkedVector<JS::Value> cross_origin_own_property_keys(Variant<Bindings::Loc
|
|||
|
||||
// 2. For each e of CrossOriginProperties(O), append e.[[Property]] to keys.
|
||||
for (auto& entry : cross_origin_properties(object))
|
||||
keys.append(JS::js_string(vm, move(entry.property)));
|
||||
keys.append(JS::PrimitiveString::create(vm, move(entry.property)));
|
||||
|
||||
// 3. Return the concatenation of keys and « "then", @@toStringTag, @@hasInstance, @@isConcatSpreadable ».
|
||||
keys.append(JS::js_string(vm, vm.names.then.as_string()));
|
||||
keys.append(JS::PrimitiveString::create(vm, vm.names.then.as_string()));
|
||||
keys.append(vm.well_known_symbol_to_string_tag());
|
||||
keys.append(vm.well_known_symbol_has_instance());
|
||||
keys.append(vm.well_known_symbol_is_concat_spreadable());
|
||||
|
|
|
@ -185,7 +185,7 @@ bool DOMStringMap::delete_existing_named_property(DeprecatedString const& name)
|
|||
|
||||
JS::Value DOMStringMap::named_item_value(FlyString const& name) const
|
||||
{
|
||||
return js_string(vm(), determine_value_of_named_property(name));
|
||||
return JS::PrimitiveString::create(vm(), determine_value_of_named_property(name));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1252,7 +1252,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::prompt)
|
|||
auto response = impl->prompt_impl(message, default_);
|
||||
if (response.is_null())
|
||||
return JS::js_null();
|
||||
return JS::js_string(vm, response);
|
||||
return JS::PrimitiveString::create(vm, response);
|
||||
}
|
||||
|
||||
static JS::ThrowCompletionOr<TimerHandler> make_timer_handler(JS::VM& vm, JS::Value handler)
|
||||
|
@ -1406,7 +1406,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::atob)
|
|||
// decode_base64() returns a byte string. LibJS uses UTF-8 for strings. Use Latin1Decoder to convert bytes 128-255 to UTF-8.
|
||||
auto decoder = TextCodec::decoder_for("windows-1252");
|
||||
VERIFY(decoder);
|
||||
return JS::js_string(vm, decoder->to_utf8(decoded.value()));
|
||||
return JS::PrimitiveString::create(vm, decoder->to_utf8(decoded.value()));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(Window::btoa)
|
||||
|
@ -1424,7 +1424,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::btoa)
|
|||
}
|
||||
|
||||
auto encoded = encode_base64(byte_string.span());
|
||||
return JS::js_string(vm, move(encoded));
|
||||
return JS::PrimitiveString::create(vm, move(encoded));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus
|
||||
|
@ -1752,7 +1752,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::scroll_by)
|
|||
options = JS::Object::create(realm, nullptr);
|
||||
MUST(options->set("left", vm.argument(0), ShouldThrowExceptions::No));
|
||||
MUST(options->set("top", vm.argument(1), ShouldThrowExceptions::No));
|
||||
MUST(options->set("behavior", JS::js_string(vm, "auto"), ShouldThrowExceptions::No));
|
||||
MUST(options->set("behavior", JS::PrimitiveString::create(vm, "auto"), ShouldThrowExceptions::No));
|
||||
}
|
||||
|
||||
auto left_value = TRY(options->get("left"));
|
||||
|
@ -1845,7 +1845,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::structured_clone)
|
|||
JS_DEFINE_NATIVE_FUNCTION(Window::origin_getter)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
return JS::js_string(vm, impl->associated_document().origin().serialize());
|
||||
return JS::PrimitiveString::create(vm, impl->associated_document().origin().serialize());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(Window::local_storage_getter)
|
||||
|
@ -1863,7 +1863,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::session_storage_getter)
|
|||
JS_DEFINE_NATIVE_FUNCTION(Window::name_getter)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
return JS::js_string(vm, impl->name());
|
||||
return JS::PrimitiveString::create(vm, impl->name());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(Window::name_setter)
|
||||
|
|
|
@ -233,7 +233,7 @@ JS::ThrowCompletionOr<JS::MarkedVector<JS::Value>> WindowProxy::internal_own_pro
|
|||
// 5. Repeat while index < maxProperties,
|
||||
for (size_t i = 0; i < max_properties; ++i) {
|
||||
// 1. Add ! ToString(index) as the last element of keys.
|
||||
keys.append(JS::js_string(vm, DeprecatedString::number(i)));
|
||||
keys.append(JS::PrimitiveString::create(vm, DeprecatedString::number(i)));
|
||||
|
||||
// 2. Increment index by 1.
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue