Skip to content

Commit

Permalink
LibWeb: Remove dom_ from dom_exception_to_throw_completion
Browse files Browse the repository at this point in the history
We're not converting `WebIDL::DOMException`, but `WebIDL::Exception`
instead.
  • Loading branch information
gmta committed Nov 4, 2024
1 parent f5971c5 commit 0126630
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/Bindings/ExceptionOrUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct ExtractExceptionOrValueType<WebIDL::ExceptionOr<void>> {

}

ALWAYS_INLINE JS::Completion dom_exception_to_throw_completion(JS::VM& vm, auto&& exception)
ALWAYS_INLINE JS::Completion exception_to_throw_completion(JS::VM& vm, auto&& exception)
{
return exception.visit(
[&](WebIDL::SimpleException const& exception) {
Expand Down Expand Up @@ -97,7 +97,7 @@ JS::ThrowCompletionOr<Ret> throw_dom_exception_if_needed(JS::VM& vm, F&& fn)
auto&& result = fn();

if (result.is_exception())
return dom_exception_to_throw_completion(vm, result.exception());
return exception_to_throw_completion(vm, result.exception());

if constexpr (requires(T v) { v.value(); })
return result.value();
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
// 10. If the previous step threw an exception, then:
if (url.is_exception()) {
// 1. Let completion be Completion Record { [[Type]]: throw, [[Value]]: resolutionError, [[Target]]: empty }.
auto completion = dom_exception_to_throw_completion(main_thread_vm(), url.exception());
auto completion = exception_to_throw_completion(main_thread_vm(), url.exception());

// 2. Perform FinishLoadingImportedModule(referrer, moduleRequest, payload, completion).
HTML::TemporaryExecutionContext context { *module_map_realm };
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/CSS/FontFaceSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> FontFaceSet::load(Strin
auto result = find_matching_font_faces(realm, font_face_set, font, text);
if (result.is_error()) {
HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
return;
}

Expand Down
26 changes: 13 additions & 13 deletions Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ JS::NonnullGCPtr<WebIDL::Promise> SubtleCrypto::encrypt(AlgorithmIdentifier cons
// 10. Let ciphertext be the result of performing the encrypt operation specified by normalizedAlgorithm using algorithm and key and with data as plaintext.
auto cipher_text = normalized_algorithm.methods->encrypt(*normalized_algorithm.parameter, key, data);
if (cipher_text.is_error()) {
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), cipher_text.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), cipher_text.release_error()).release_value().value());
return;
}

Expand Down Expand Up @@ -223,7 +223,7 @@ JS::NonnullGCPtr<WebIDL::Promise> SubtleCrypto::decrypt(AlgorithmIdentifier cons
// 10. Let plaintext be the result of performing the decrypt operation specified by normalizedAlgorithm using algorithm and key and with data as ciphertext.
auto plain_text = normalized_algorithm.methods->decrypt(*normalized_algorithm.parameter, key, data);
if (plain_text.is_error()) {
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), plain_text.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), plain_text.release_error()).release_value().value());
return;
}

Expand Down Expand Up @@ -271,7 +271,7 @@ JS::NonnullGCPtr<WebIDL::Promise> SubtleCrypto::digest(AlgorithmIdentifier const
auto result = algorithm_object.methods->digest(*algorithm_object.parameter, data_buffer);

if (result.is_exception()) {
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
return;
}

Expand Down Expand Up @@ -312,7 +312,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::generate_
auto result_or_error = normalized_algorithm.methods->generate_key(*normalized_algorithm.parameter, extractable, key_usages);

if (result_or_error.is_error()) {
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), result_or_error.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), result_or_error.release_error()).release_value().value());
return;
}
auto result = result_or_error.release_value();
Expand Down Expand Up @@ -393,7 +393,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::import_ke
// specified by normalizedAlgorithm using keyData, algorithm, format, extractable and usages.
auto maybe_result = normalized_algorithm.methods->import_key(*normalized_algorithm.parameter, format, real_key_data.downcast<CryptoKey::InternalKeyData>(), extractable, key_usages);
if (maybe_result.is_error()) {
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), maybe_result.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), maybe_result.release_error()).release_value().value());
return;
}
auto result = maybe_result.release_value();
Expand Down Expand Up @@ -439,7 +439,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::export_ke
// FIXME: Stash the AlgorithmMethods on the KeyAlgorithm
auto normalized_algorithm_or_error = normalize_an_algorithm(realm, algorithm.name(), "exportKey"_string);
if (normalized_algorithm_or_error.is_error()) {
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), normalized_algorithm_or_error.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), normalized_algorithm_or_error.release_error()).release_value().value());
return;
}
auto normalized_algorithm = normalized_algorithm_or_error.release_value();
Expand All @@ -453,7 +453,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::export_ke
// 7. Let result be the result of performing the export key operation specified by the [[algorithm]] internal slot of key using key and format.
auto result_or_error = normalized_algorithm.methods->export_key(format, key);
if (result_or_error.is_error()) {
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), result_or_error.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), result_or_error.release_error()).release_value().value());
return;
}

Expand Down Expand Up @@ -510,7 +510,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::sign(Algo
// 10. Let result be the result of performing the sign operation specified by normalizedAlgorithm using key and algorithm and with data as message.
auto result = normalized_algorithm.methods->sign(*normalized_algorithm.parameter, key, data);
if (result.is_error()) {
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
return;
}

Expand Down Expand Up @@ -574,7 +574,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::verify(Al
// 11. Let result be the result of performing the verify operation specified by normalizedAlgorithm using key, algorithm and signature and with data as message.
auto result = normalized_algorithm.methods->verify(*normalized_algorithm.parameter, key, signature, data);
if (result.is_error()) {
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
return;
}

Expand Down Expand Up @@ -621,7 +621,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::derive_bi
// 9. Let result be the result of creating an ArrayBuffer containing the result of performing the derive bits operation specified by normalizedAlgorithm using baseKey, algorithm and length.
auto result = normalized_algorithm.methods->derive_bits(*normalized_algorithm.parameter, base_key, length);
if (result.is_error()) {
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
return;
}

Expand Down Expand Up @@ -682,7 +682,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::derive_ke
// 13. Let length be the result of performing the get key length algorithm specified by normalizedDerivedKeyAlgorithmLength using derivedKeyType.
auto length_result = normalized_derived_key_algorithm_length.methods->get_key_length(*normalized_derived_key_algorithm_length.parameter);
if (length_result.is_error()) {
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), length_result.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), length_result.release_error()).release_value().value());
return;
}

Expand All @@ -701,14 +701,14 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::derive_ke
// 14. Let secret be the result of performing the derive bits operation specified by normalizedAlgorithm using key, algorithm and length.
auto secret = normalized_algorithm.methods->derive_bits(*normalized_algorithm.parameter, base_key, length);
if (secret.is_error()) {
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), secret.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), secret.release_error()).release_value().value());
return;
}

// 15. Let result be the result of performing the import key operation specified by normalizedDerivedKeyAlgorithmImport using "raw" as format, secret as keyData, derivedKeyType as algorithm and using extractable and usages.
auto result = normalized_derived_key_algorithm_import.methods->import_key(*normalized_derived_key_algorithm_import.parameter, Bindings::KeyFormat::Raw, secret.release_value()->buffer(), extractable, key_usages);
if (result.is_error()) {
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/Fetch/FetchMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ JS::NonnullGCPtr<WebIDL::Promise> fetch(JS::VM& vm, RequestInfo const& input, Re
// as arguments. If this throws an exception, reject p with it and return p.
auto exception_or_request_object = Request::construct_impl(realm, input, init);
if (exception_or_request_object.is_exception()) {
auto throw_completion = Bindings::dom_exception_to_throw_completion(vm, exception_or_request_object.exception());
auto throw_completion = Bindings::exception_to_throw_completion(vm, exception_or_request_object.exception());
WebIDL::reject_promise(realm, promise_capability, *throw_completion.value());
return promise_capability;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void FetchedDataReceiver::on_data_received(ReadonlyBytes bytes)

// 1. Pull from bytes buffer into stream.
if (auto result = Streams::readable_stream_pull_from_bytes(m_stream, move(bytes)); result.is_error()) {
auto throw_completion = Bindings::dom_exception_to_throw_completion(m_stream->vm(), result.release_error());
auto throw_completion = Bindings::exception_to_throw_completion(m_stream->vm(), result.release_error());

dbgln("FetchedDataReceiver: Stream error pulling bytes");
HTML::report_exception(throw_completion, m_stream->realm());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void Body::fully_read(JS::Realm& realm, Web::Fetch::Infrastructure::Body::Proces
HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
auto reader_or_exception = Streams::acquire_readable_stream_default_reader(*m_stream);
if (reader_or_exception.is_exception()) {
auto throw_completion = Bindings::dom_exception_to_throw_completion(realm.vm(), reader_or_exception.release_error());
auto throw_completion = Bindings::exception_to_throw_completion(realm.vm(), reader_or_exception.release_error());
error_steps(throw_completion.release_value().value());
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ void HTMLParser::handle_in_head(HTMLToken& token)
// If an exception is thrown, then catch it, report the exception, insert an element at the adjusted insertion location with template, and return.
auto result = declarative_shadow_host_element.attach_a_shadow_root(mode, clonable, serializable, delegates_focus, Bindings::SlotAssignmentMode::Named);
if (result.is_error()) {
report_exception(Bindings::dom_exception_to_throw_completion(vm(), result.release_error()), realm());
report_exception(Bindings::exception_to_throw_completion(vm(), result.release_error()), realm());
insert_an_element_at_the_adjusted_insertion_location(template_);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void ImportMapParseResult::register_import_map(Window& global)
{
// 1. If result's error to rethrow is not null, then report the exception given by result's error to rethrow and return.
if (m_error_to_rethrow.has_value()) {
auto completion = Web::Bindings::dom_exception_to_throw_completion(global.vm(), m_error_to_rethrow.value());
auto completion = Web::Bindings::exception_to_throw_completion(global.vm(), m_error_to_rethrow.value());
HTML::report_exception(completion, global.realm());
return;
}
Expand Down
12 changes: 6 additions & 6 deletions Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ class DefaultStreamTeeReadRequest final : public ReadRequest {

// 2. If cloneResult is an abrupt completion,
if (clone_result.is_exception()) {
auto completion = Bindings::dom_exception_to_throw_completion(m_realm->vm(), clone_result.release_error());
auto completion = Bindings::exception_to_throw_completion(m_realm->vm(), clone_result.release_error());

// 1. Perform ! ReadableStreamDefaultControllerError(branch1.[[controller]], cloneResult.[[Value]]).
readable_stream_default_controller_error(controller1, completion.value().value());
Expand Down Expand Up @@ -732,7 +732,7 @@ class ByteStreamTeeDefaultReadRequest final : public ReadRequest {

// 2. If cloneResult is an abrupt completion,
if (clone_result.is_exception()) {
auto completion = Bindings::dom_exception_to_throw_completion(m_realm->vm(), clone_result.release_error());
auto completion = Bindings::exception_to_throw_completion(m_realm->vm(), clone_result.release_error());

// 1. Perform ! ReadableByteStreamControllerError(branch1.[[controller]], cloneResult.[[Value]]).
readable_byte_stream_controller_error(controller1, completion.value().value());
Expand Down Expand Up @@ -896,7 +896,7 @@ class ByteStreamTeeBYOBReadRequest final : public ReadIntoRequest {

// 2. If cloneResult is an abrupt completion,
if (clone_result.is_exception()) {
auto completion = Bindings::dom_exception_to_throw_completion(m_realm->vm(), clone_result.release_error());
auto completion = Bindings::exception_to_throw_completion(m_realm->vm(), clone_result.release_error());

// 1. Perform ! ReadableByteStreamControllerError(byobBranch.[[controller]], cloneResult.[[Value]]).
readable_byte_stream_controller_error(byob_controller, completion.value().value());
Expand Down Expand Up @@ -1849,7 +1849,7 @@ void readable_byte_stream_controller_pull_into(ReadableByteStreamController& con
// 8. If bufferResult is an abrupt completion,
if (buffer_result.is_exception()) {
// 1. Perform readIntoRequest’s error steps, given bufferResult.[[Value]].
auto throw_completion = Bindings::dom_exception_to_throw_completion(vm, buffer_result.exception());
auto throw_completion = Bindings::exception_to_throw_completion(vm, buffer_result.exception());
read_into_request.on_error(*throw_completion.release_value());

// 2. Return.
Expand Down Expand Up @@ -4804,7 +4804,7 @@ void set_up_transform_stream_default_controller_from_transformer(TransformStream

// 2. If result is an abrupt completion, return a promise rejected with result.[[Value]].
if (result.is_error()) {
auto throw_completion = Bindings::dom_exception_to_throw_completion(vm, result.exception());
auto throw_completion = Bindings::exception_to_throw_completion(vm, result.exception());
return WebIDL::create_rejected_promise(realm, *throw_completion.release_value());
}

Expand Down Expand Up @@ -4892,7 +4892,7 @@ WebIDL::ExceptionOr<void> transform_stream_default_controller_enqueue(TransformS

// 5. If enqueueResult is an abrupt completion,
if (enqueue_result.is_error()) {
auto throw_completion = Bindings::dom_exception_to_throw_completion(vm, enqueue_result.exception());
auto throw_completion = Bindings::exception_to_throw_completion(vm, enqueue_result.exception());

// 1. Perform ! TransformStreamErrorWritableAndUnblockWrite(stream, enqueueResult.[[Value]]).
transform_stream_error_writable_and_unblock_write(*stream, throw_completion.value().value());
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ JS::NonnullGCPtr<WebIDL::Promise> compile_potential_webassembly_response(JS::VM&
// 8. Consume response’s body as an ArrayBuffer, and let bodyPromise be the result.
auto body_promise_or_error = response_object.array_buffer();
if (body_promise_or_error.is_error()) {
auto throw_completion = Bindings::dom_exception_to_throw_completion(realm.vm(), body_promise_or_error.release_error());
auto throw_completion = Bindings::exception_to_throw_completion(realm.vm(), body_promise_or_error.release_error());
WebIDL::reject_promise(realm, return_value, *throw_completion.value());
return JS::js_undefined();
}
Expand Down
Loading

0 comments on commit 0126630

Please sign in to comment.