mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:47:34 +00:00
LibJS+Everywhere: Rename Value::to_string to to_deprecated_string
This commit is contained in:
parent
8f5bdce8e7
commit
afeb7273cc
68 changed files with 193 additions and 193 deletions
|
@ -52,7 +52,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> AudioConstructor::construct(
|
|||
// 4. If src is given, then set an attribute value for audio using "src" and src.
|
||||
// (This will cause the user agent to invoke the object's resource selection algorithm before returning.)
|
||||
if (!src_value.is_undefined()) {
|
||||
auto src = TRY(src_value.to_string(vm));
|
||||
auto src = TRY(src_value.to_deprecated_string(vm));
|
||||
MUST(audio->set_attribute(HTML::AttributeNames::src, move(src)));
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::escape)
|
|||
if (!vm.argument_count())
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::BadArgCountAtLeastOne, "CSS.escape");
|
||||
|
||||
auto identifier = TRY(vm.argument(0).to_string(vm));
|
||||
auto identifier = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
return JS::PrimitiveString::create(vm, Web::CSS::serialize_an_identifier(identifier));
|
||||
}
|
||||
|
||||
|
@ -44,13 +44,13 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::supports)
|
|||
|
||||
if (vm.argument_count() >= 2) {
|
||||
// When the supports(property, value) method is invoked with two arguments property and value:
|
||||
auto property_name = TRY(vm.argument(0).to_string(vm));
|
||||
auto property_name = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
// If property is an ASCII case-insensitive match for any defined CSS property that the UA supports,
|
||||
// and value successfully parses according to that property’s grammar, return true.
|
||||
auto property = CSS::property_id_from_string(property_name);
|
||||
if (property != CSS::PropertyID::Invalid) {
|
||||
auto value_string = TRY(vm.argument(1).to_string(vm));
|
||||
auto value_string = TRY(vm.argument(1).to_deprecated_string(vm));
|
||||
if (parse_css_value({}, value_string, property))
|
||||
return JS::Value(true);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::supports)
|
|||
return JS::Value(false);
|
||||
} else {
|
||||
// When the supports(conditionText) method is invoked with a single conditionText argument:
|
||||
auto supports_text = TRY(vm.argument(0).to_string(vm));
|
||||
auto supports_text = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
// If conditionText, parsed and evaluated as a <supports-condition>, would return true, return true.
|
||||
if (auto supports = parse_css_supports({}, supports_text); supports && supports->matches())
|
||||
|
|
|
@ -61,7 +61,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
return JS::make_handle(static_cast<Request&>(arg0_object));
|
||||
}
|
||||
}
|
||||
return TRY(arg0.to_string(vm));
|
||||
return TRY(arg0.to_deprecated_string(vm));
|
||||
};
|
||||
Variant<JS::Handle<Request>, DeprecatedString> input = TRY(arg0_to_variant(arg0));
|
||||
auto arg1 = vm.argument(1);
|
||||
|
@ -89,7 +89,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (is<JS::ArrayBuffer>(body_property_value_object))
|
||||
return JS::make_handle(body_property_value_object);
|
||||
}
|
||||
return TRY(body_property_value.to_string(vm));
|
||||
return TRY(body_property_value.to_deprecated_string(vm));
|
||||
};
|
||||
Optional<Variant<JS::Handle<ReadableStream>, JS::Handle<Blob>, JS::Handle<JS::Object>, JS::Handle<URLSearchParams>, DeprecatedString>> body_value;
|
||||
if (!body_property_value.is_nullish())
|
||||
|
@ -102,7 +102,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (!cache_property_value.is_undefined()) {
|
||||
RequestCache cache_value { RequestCache::Default };
|
||||
if (!cache_property_value.is_undefined()) {
|
||||
auto cache_property_value_string = TRY(cache_property_value.to_string(vm));
|
||||
auto cache_property_value_string = TRY(cache_property_value.to_deprecated_string(vm));
|
||||
if (cache_property_value_string == "only-if-cached"sv)
|
||||
cache_value = RequestCache::OnlyIfCached;
|
||||
else if (cache_property_value_string == "default"sv)
|
||||
|
@ -126,7 +126,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (!credentials_property_value.is_undefined()) {
|
||||
RequestCredentials credentials_value { RequestCredentials::Omit };
|
||||
if (!credentials_property_value.is_undefined()) {
|
||||
auto credentials_property_value_string = TRY(credentials_property_value.to_string(vm));
|
||||
auto credentials_property_value_string = TRY(credentials_property_value.to_deprecated_string(vm));
|
||||
if (credentials_property_value_string == "same-origin"sv)
|
||||
credentials_value = RequestCredentials::SameOrigin;
|
||||
else if (credentials_property_value_string == "include"sv)
|
||||
|
@ -144,7 +144,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (!duplex_property_value.is_undefined()) {
|
||||
RequestDuplex duplex_value { RequestDuplex::Half };
|
||||
if (!duplex_property_value.is_undefined()) {
|
||||
auto duplex_property_value_string = TRY(duplex_property_value.to_string(vm));
|
||||
auto duplex_property_value_string = TRY(duplex_property_value.to_deprecated_string(vm));
|
||||
if (duplex_property_value_string == "half"sv)
|
||||
duplex_value = RequestDuplex::Half;
|
||||
else
|
||||
|
@ -187,7 +187,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (next_item2.is_null() && false) {
|
||||
sequence_item2 = DeprecatedString::empty();
|
||||
} else {
|
||||
sequence_item2 = TRY(next_item2.to_string(vm));
|
||||
sequence_item2 = TRY(next_item2.to_deprecated_string(vm));
|
||||
}
|
||||
sequence_item1.append(sequence_item2);
|
||||
}
|
||||
|
@ -206,14 +206,14 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (key1.is_null() && false) {
|
||||
typed_key1 = DeprecatedString::empty();
|
||||
} else {
|
||||
typed_key1 = TRY(key1.to_string(vm));
|
||||
typed_key1 = TRY(key1.to_deprecated_string(vm));
|
||||
}
|
||||
auto value1 = TRY(headers_property_value_object.get(property_key1));
|
||||
DeprecatedString typed_value1;
|
||||
if (value1.is_null() && false) {
|
||||
typed_value1 = DeprecatedString::empty();
|
||||
} else {
|
||||
typed_value1 = TRY(value1.to_string(vm));
|
||||
typed_value1 = TRY(value1.to_deprecated_string(vm));
|
||||
}
|
||||
record_union_type.set(typed_key1, typed_value1);
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (integrity_property_value.is_null() && false)
|
||||
integrity_value = DeprecatedString::empty();
|
||||
else
|
||||
integrity_value = TRY(integrity_property_value.to_string(vm));
|
||||
integrity_value = TRY(integrity_property_value.to_deprecated_string(vm));
|
||||
}
|
||||
init.integrity = integrity_value;
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (method_property_value.is_null() && false)
|
||||
method_value = DeprecatedString::empty();
|
||||
else
|
||||
method_value = TRY(method_property_value.to_string(vm));
|
||||
method_value = TRY(method_property_value.to_deprecated_string(vm));
|
||||
}
|
||||
init.method = method_value;
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (!mode_property_value.is_undefined()) {
|
||||
RequestMode mode_value { RequestMode::Navigate };
|
||||
if (!mode_property_value.is_undefined()) {
|
||||
auto mode_property_value_string = TRY(mode_property_value.to_string(vm));
|
||||
auto mode_property_value_string = TRY(mode_property_value.to_deprecated_string(vm));
|
||||
if (mode_property_value_string == "navigate"sv)
|
||||
mode_value = RequestMode::Navigate;
|
||||
else if (mode_property_value_string == "same-origin"sv)
|
||||
|
@ -287,7 +287,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (!redirect_property_value.is_undefined()) {
|
||||
RequestRedirect redirect_value { RequestRedirect::Follow };
|
||||
if (!redirect_property_value.is_undefined()) {
|
||||
auto redirect_property_value_string = TRY(redirect_property_value.to_string(vm));
|
||||
auto redirect_property_value_string = TRY(redirect_property_value.to_deprecated_string(vm));
|
||||
if (redirect_property_value_string == "follow"sv)
|
||||
redirect_value = RequestRedirect::Follow;
|
||||
else if (redirect_property_value_string == "manual"sv)
|
||||
|
@ -308,7 +308,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (referrer_property_value.is_null() && false)
|
||||
referrer_value = DeprecatedString::empty();
|
||||
else
|
||||
referrer_value = TRY(referrer_property_value.to_string(vm));
|
||||
referrer_value = TRY(referrer_property_value.to_deprecated_string(vm));
|
||||
}
|
||||
init.referrer = referrer_value;
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (!referrer_policy_property_value.is_undefined()) {
|
||||
ReferrerPolicy referrer_policy_value { ReferrerPolicy::Empty };
|
||||
if (!referrer_policy_property_value.is_undefined()) {
|
||||
auto referrer_policy_property_value_string = TRY(referrer_policy_property_value.to_string(vm));
|
||||
auto referrer_policy_property_value_string = TRY(referrer_policy_property_value.to_deprecated_string(vm));
|
||||
if (referrer_policy_property_value_string == ""sv)
|
||||
referrer_policy_value = ReferrerPolicy::Empty;
|
||||
else if (referrer_policy_property_value_string == "same-origin"sv)
|
||||
|
|
|
@ -109,7 +109,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_setter)
|
|||
// FIXME: 1. If this's relevant Document is null, then return.
|
||||
|
||||
// 2. Parse the given value relative to the entry settings object. If that failed, throw a TypeError exception.
|
||||
auto new_href = TRY(vm.argument(0).to_string(vm));
|
||||
auto new_href = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto href_url = window.associated_document().parse_url(new_href);
|
||||
if (!href_url.is_valid())
|
||||
return vm.throw_completion<JS::URIError>(DeprecatedString::formatted("Invalid URL '{}'", new_href));
|
||||
|
@ -247,7 +247,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::reload)
|
|||
JS_DEFINE_NATIVE_FUNCTION(LocationObject::replace)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
|
||||
auto url = TRY(vm.argument(0).to_string(vm));
|
||||
auto url = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
// FIXME: This needs spec compliance work.
|
||||
window.did_call_location_replace({}, move(url));
|
||||
return JS::js_undefined();
|
||||
|
|
|
@ -49,7 +49,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> OptionConstructor::construct
|
|||
|
||||
// 3. If text is not the empty string, then append to option a new Text node whose data is text.
|
||||
if (vm.argument_count() > 0) {
|
||||
auto text = TRY(vm.argument(0).to_string(vm));
|
||||
auto text = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
if (!text.is_empty()) {
|
||||
auto new_text_node = vm.heap().allocate<DOM::Text>(realm, document, text);
|
||||
MUST(option_element->append_child(*new_text_node));
|
||||
|
@ -58,7 +58,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> OptionConstructor::construct
|
|||
|
||||
// 4. If value is given, then set an attribute value for option using "value" and value.
|
||||
if (vm.argument_count() > 1) {
|
||||
auto value = TRY(vm.argument(1).to_string(vm));
|
||||
auto value = TRY(vm.argument(1).to_deprecated_string(vm));
|
||||
MUST(option_element->set_attribute(HTML::AttributeNames::value, value));
|
||||
}
|
||||
|
||||
|
|
|
@ -353,7 +353,7 @@ JS::ThrowCompletionOr<bool> CSSStyleDeclaration::internal_set(JS::PropertyKey co
|
|||
if (property_id == CSS::PropertyID::Invalid)
|
||||
return Base::internal_set(name, value, receiver);
|
||||
|
||||
auto css_text = TRY(value.to_string(vm));
|
||||
auto css_text = TRY(value.to_deprecated_string(vm));
|
||||
|
||||
TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return set_property(property_id, css_text); }));
|
||||
return true;
|
||||
|
|
|
@ -1203,17 +1203,17 @@ JS_DEFINE_NATIVE_FUNCTION(Window::open)
|
|||
// optional USVString url = ""
|
||||
DeprecatedString url = "";
|
||||
if (!vm.argument(0).is_undefined())
|
||||
url = TRY(vm.argument(0).to_string(vm));
|
||||
url = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
// optional DOMString target = "_blank"
|
||||
DeprecatedString target = "_blank";
|
||||
if (!vm.argument(1).is_undefined())
|
||||
target = TRY(vm.argument(1).to_string(vm));
|
||||
target = TRY(vm.argument(1).to_deprecated_string(vm));
|
||||
|
||||
// optional [LegacyNullToEmptyString] DOMString features = "")
|
||||
DeprecatedString features = "";
|
||||
if (!vm.argument(2).is_nullish())
|
||||
features = TRY(vm.argument(2).to_string(vm));
|
||||
features = TRY(vm.argument(2).to_deprecated_string(vm));
|
||||
|
||||
return TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return impl->open_impl(url, target, features); }));
|
||||
}
|
||||
|
@ -1227,7 +1227,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::alert)
|
|||
auto* impl = TRY(impl_from(vm));
|
||||
DeprecatedString message = "";
|
||||
if (vm.argument_count())
|
||||
message = TRY(vm.argument(0).to_string(vm));
|
||||
message = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
impl->alert_impl(message);
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
@ -1237,7 +1237,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::confirm)
|
|||
auto* impl = TRY(impl_from(vm));
|
||||
DeprecatedString message = "";
|
||||
if (!vm.argument(0).is_undefined())
|
||||
message = TRY(vm.argument(0).to_string(vm));
|
||||
message = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
return JS::Value(impl->confirm_impl(message));
|
||||
}
|
||||
|
||||
|
@ -1247,9 +1247,9 @@ JS_DEFINE_NATIVE_FUNCTION(Window::prompt)
|
|||
DeprecatedString message = "";
|
||||
DeprecatedString default_ = "";
|
||||
if (!vm.argument(0).is_undefined())
|
||||
message = TRY(vm.argument(0).to_string(vm));
|
||||
message = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
if (!vm.argument(1).is_undefined())
|
||||
default_ = TRY(vm.argument(1).to_string(vm));
|
||||
default_ = TRY(vm.argument(1).to_deprecated_string(vm));
|
||||
auto response = impl->prompt_impl(message, default_);
|
||||
if (response.is_null())
|
||||
return JS::js_null();
|
||||
|
@ -1260,7 +1260,7 @@ static JS::ThrowCompletionOr<TimerHandler> make_timer_handler(JS::VM& vm, JS::Va
|
|||
{
|
||||
if (handler.is_function())
|
||||
return JS::make_handle(vm.heap().allocate_without_realm<WebIDL::CallbackType>(handler.as_function(), HTML::incumbent_settings_object()));
|
||||
return TRY(handler.to_string(vm));
|
||||
return TRY(handler.to_deprecated_string(vm));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
|
||||
|
@ -1400,7 +1400,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::atob)
|
|||
{
|
||||
if (!vm.argument_count())
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::BadArgCountOne, "atob");
|
||||
auto deprecated_string = TRY(vm.argument(0).to_string(vm));
|
||||
auto deprecated_string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto string = String::from_utf8(deprecated_string).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// must throw an "InvalidCharacterError" DOMException if data contains any character whose code point is greater than U+00FF
|
||||
|
@ -1428,7 +1428,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::btoa)
|
|||
{
|
||||
if (!vm.argument_count())
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::BadArgCountOne, "btoa");
|
||||
auto string = TRY(vm.argument(0).to_string(vm));
|
||||
auto string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
Vector<u8> byte_string;
|
||||
byte_string.ensure_capacity(string.length());
|
||||
|
@ -1665,7 +1665,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::get_selection)
|
|||
JS_DEFINE_NATIVE_FUNCTION(Window::match_media)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
auto media = TRY(vm.argument(0).to_string(vm));
|
||||
auto media = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
return impl->match_media_impl(move(media));
|
||||
}
|
||||
|
||||
|
@ -1721,7 +1721,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::scroll)
|
|||
|
||||
auto behavior_string_value = TRY(options->get("behavior"));
|
||||
if (!behavior_string_value.is_undefined())
|
||||
behavior_string = TRY(behavior_string_value.to_string(vm));
|
||||
behavior_string = TRY(behavior_string_value.to_deprecated_string(vm));
|
||||
if (behavior_string != "smooth" && behavior_string != "auto")
|
||||
return vm.throw_completion<JS::TypeError>("Behavior is not one of 'smooth' or 'auto'");
|
||||
|
||||
|
@ -1784,7 +1784,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::scroll_by)
|
|||
top = top + static_cast<double>(current_scroll_position.y());
|
||||
|
||||
auto behavior_string_value = TRY(options->get("behavior"));
|
||||
auto behavior_string = behavior_string_value.is_undefined() ? "auto" : TRY(behavior_string_value.to_string(vm));
|
||||
auto behavior_string = behavior_string_value.is_undefined() ? "auto" : TRY(behavior_string_value.to_deprecated_string(vm));
|
||||
if (behavior_string != "smooth" && behavior_string != "auto")
|
||||
return vm.throw_completion<JS::TypeError>("Behavior is not one of 'smooth' or 'auto'");
|
||||
ScrollBehavior behavior = (behavior_string == "smooth") ? ScrollBehavior::Smooth : ScrollBehavior::Auto;
|
||||
|
@ -1841,7 +1841,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::outer_height_getter)
|
|||
JS_DEFINE_NATIVE_FUNCTION(Window::post_message)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
auto target_origin = TRY(vm.argument(1).to_string(vm));
|
||||
auto target_origin = TRY(vm.argument(1).to_deprecated_string(vm));
|
||||
TRY(Bindings::throw_dom_exception_if_needed(vm, [&] {
|
||||
return impl->post_message_impl(vm.argument(0), target_origin);
|
||||
}));
|
||||
|
@ -1884,7 +1884,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::name_getter)
|
|||
JS_DEFINE_NATIVE_FUNCTION(Window::name_setter)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
impl->set_name(TRY(vm.argument(0).to_string(vm)));
|
||||
impl->set_name(TRY(vm.argument(0).to_deprecated_string(vm)));
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ JS::ThrowCompletionOr<WebGLContextAttributes> convert_value_to_context_attribute
|
|||
WebGLPowerPreference power_preference_value { WebGLPowerPreference::Default };
|
||||
|
||||
if (!power_preference.is_undefined()) {
|
||||
auto power_preference_string = TRY(power_preference.to_string(vm));
|
||||
auto power_preference_string = TRY(power_preference.to_deprecated_string(vm));
|
||||
|
||||
if (power_preference_string == "high-performance"sv)
|
||||
power_preference_value = WebGLPowerPreference::HighPerformance;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue