mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 11:09:18 +00:00
LibJS: Make Completion.[[Value]] non-optional
Instead, just use js_undefined() whenever the [[Value]] field is unused. This avoids a whole bunch of presence checks.
This commit is contained in:
parent
c0600c4353
commit
de424d6879
Notes:
github-actions[bot]
2025-04-05 09:21:48 +00:00
Author: https://github.com/awesomekling
Commit: de424d6879
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4232
65 changed files with 225 additions and 250 deletions
|
@ -1850,8 +1850,8 @@ GC::Ptr<DOM::Document> Navigable::evaluate_javascript_url(URL::URL const& url, U
|
|||
String result;
|
||||
|
||||
// 9. If evaluationStatus is a normal completion, and evaluationStatus.[[Value]] is a String, then set result to evaluationStatus.[[Value]].
|
||||
if (evaluation_status.type() == JS::Completion::Type::Normal && evaluation_status.value().has_value() && evaluation_status.value()->is_string()) {
|
||||
result = evaluation_status.value()->as_string().utf8_string();
|
||||
if (evaluation_status.type() == JS::Completion::Type::Normal && evaluation_status.value().is_string()) {
|
||||
result = evaluation_status.value().as_string().utf8_string();
|
||||
} else {
|
||||
// 10. Otherwise, return null.
|
||||
return nullptr;
|
||||
|
|
|
@ -1143,7 +1143,7 @@ bool Navigation::inner_navigate_event_firing_algorithm(
|
|||
// 1. Append the result of invoking handler with an empty arguments list to promisesList.
|
||||
auto result = WebIDL::invoke_callback(handler, {});
|
||||
// This *should* be equivalent to converting a promise to a promise capability
|
||||
promises_list.append(WebIDL::create_resolved_promise(realm, result.value().value()));
|
||||
promises_list.append(WebIDL::create_resolved_promise(realm, result.value()));
|
||||
}
|
||||
|
||||
// 3. If promisesList's size is 0, then set promisesList to « a promise resolved with undefined ».
|
||||
|
|
|
@ -82,7 +82,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors, GC::Ptr<JS::Envi
|
|||
|
||||
// 2. Check if we can run script with realm. If this returns "do not run" then return NormalCompletion(empty).
|
||||
if (can_run_script(realm) == RunScriptDecision::DoNotRun)
|
||||
return JS::normal_completion({});
|
||||
return JS::normal_completion(JS::js_undefined());
|
||||
|
||||
// 3. Prepare to run script given realm.
|
||||
prepare_to_run_script(realm);
|
||||
|
@ -112,7 +112,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors, GC::Ptr<JS::Envi
|
|||
clean_up_after_running_script(realm);
|
||||
|
||||
// 2. Rethrow evaluationStatus.[[Value]].
|
||||
return JS::throw_completion(*evaluation_status.value());
|
||||
return JS::throw_completion(evaluation_status.value());
|
||||
}
|
||||
|
||||
// 2. If rethrow errors is true and script's muted errors is true, then:
|
||||
|
@ -129,7 +129,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors, GC::Ptr<JS::Envi
|
|||
|
||||
// 1. Report an exception given by evaluationStatus.[[Value]] for realms's global object.
|
||||
auto& window_or_worker = as<WindowOrWorkerGlobalScopeMixin>(realm.global_object());
|
||||
window_or_worker.report_an_exception(*evaluation_status.value());
|
||||
window_or_worker.report_an_exception(evaluation_status.value());
|
||||
|
||||
// 2. Clean up after running script with realm.
|
||||
clean_up_after_running_script(realm);
|
||||
|
|
|
@ -56,8 +56,7 @@ void report_exception_to_console(JS::Value value, JS::Realm& realm, ErrorInPromi
|
|||
void report_exception(JS::Completion const& throw_completion, JS::Realm& realm)
|
||||
{
|
||||
VERIFY(throw_completion.type() == JS::Completion::Type::Throw);
|
||||
VERIFY(throw_completion.value().has_value());
|
||||
report_exception_to_console(*throw_completion.value(), realm, ErrorInPromise::No);
|
||||
report_exception_to_console(throw_completion.value(), realm, ErrorInPromise::No);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -843,7 +843,7 @@ void fetch_descendants_of_and_link_a_module_script(JS::Realm& realm,
|
|||
|
||||
// If this throws an exception, set result's error to rethrow to that exception.
|
||||
if (linking_result.is_throw_completion())
|
||||
module_script.set_error_to_rethrow(linking_result.release_error().value().value());
|
||||
module_script.set_error_to_rethrow(linking_result.release_error().value());
|
||||
|
||||
// 2. Run onComplete given moduleScript.
|
||||
on_complete->function()(module_script);
|
||||
|
|
|
@ -57,8 +57,7 @@ void ImportMapParseResult::visit_edges(Visitor& visitor)
|
|||
visitor.visit(exception);
|
||||
},
|
||||
[&](JS::Completion const& completion) {
|
||||
if (completion.value().has_value())
|
||||
visitor.visit(completion.value().value());
|
||||
visitor.visit(completion.value());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue