diff options
author | Linus Groh <mail@linusgroh.de> | 2022-09-25 17:03:42 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-09-25 19:13:31 +0100 |
commit | ad04d7ac9b88ecea572cf517f6e01ccf1e95073d (patch) | |
tree | ed33bb942b1bdef7163972425057435a7d8eeaf9 /Userland/Libraries/LibWeb/Fetch/BodyInit.cpp | |
parent | c0eda779287d4b1305046164cd0a8ee5a5799e0b (diff) | |
download | serenity-ad04d7ac9b88ecea572cf517f6e01ccf1e95073d.zip |
LibWeb: Move ExceptionOr from DOM/ to WebIDL/
This is a concept fully defined in the Web IDL spec and doesn't belong
in the DOM directory/namespace - not even DOMException, despite the name
:^)
Diffstat (limited to 'Userland/Libraries/LibWeb/Fetch/BodyInit.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/BodyInit.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp index 6fb629d77a..8dae6b2a20 100644 --- a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp +++ b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp @@ -5,17 +5,17 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <LibWeb/DOM/ExceptionOr.h> #include <LibWeb/Fetch/BodyInit.h> #include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h> #include <LibWeb/HTML/Window.h> #include <LibWeb/URL/URLSearchParams.h> #include <LibWeb/WebIDL/AbstractOperations.h> +#include <LibWeb/WebIDL/ExceptionOr.h> namespace Web::Fetch { // https://fetch.spec.whatwg.org/#concept-bodyinit-extract -DOM::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, BodyInit const& object, bool keepalive) +WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, BodyInit const& object, bool keepalive) { auto& window = verify_cast<HTML::Window>(realm.global_object()); @@ -38,7 +38,7 @@ DOM::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, Bo // 6. Switch on object. // FIXME: Still need to support BufferSource and FormData TRY(object.visit( - [&](JS::Handle<FileAPI::Blob> const& blob) -> DOM::ExceptionOr<void> { + [&](JS::Handle<FileAPI::Blob> const& blob) -> WebIDL::ExceptionOr<void> { // FIXME: Set action to this step: read object. // Set source to object. source = blob; @@ -49,19 +49,19 @@ DOM::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, Bo type = blob->type().to_byte_buffer(); return {}; }, - [&](JS::Handle<JS::Object> const& buffer_source) -> DOM::ExceptionOr<void> { + [&](JS::Handle<JS::Object> const& buffer_source) -> WebIDL::ExceptionOr<void> { // Set source to a copy of the bytes held by object. source = TRY_OR_RETURN_OOM(window, WebIDL::get_buffer_source_copy(*buffer_source.cell())); return {}; }, - [&](JS::Handle<URL::URLSearchParams> const& url_search_params) -> DOM::ExceptionOr<void> { + [&](JS::Handle<URL::URLSearchParams> const& url_search_params) -> WebIDL::ExceptionOr<void> { // Set source to the result of running the application/x-www-form-urlencoded serializer with object’s list. source = url_search_params->to_string().to_byte_buffer(); // Set type to `application/x-www-form-urlencoded;charset=UTF-8`. type = TRY_OR_RETURN_OOM(window, ByteBuffer::copy("application/x-www-form-urlencoded;charset=UTF-8"sv.bytes())); return {}; }, - [&](String const& scalar_value_string) -> DOM::ExceptionOr<void> { + [&](String const& scalar_value_string) -> WebIDL::ExceptionOr<void> { // NOTE: AK::String is always UTF-8. // Set source to the UTF-8 encoding of object. source = scalar_value_string.to_byte_buffer(); @@ -69,14 +69,14 @@ DOM::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, Bo type = TRY_OR_RETURN_OOM(window, ByteBuffer::copy("text/plain;charset=UTF-8"sv.bytes())); return {}; }, - [&](JS::Handle<Streams::ReadableStream> const& stream) -> DOM::ExceptionOr<void> { + [&](JS::Handle<Streams::ReadableStream> const& stream) -> WebIDL::ExceptionOr<void> { // If keepalive is true, then throw a TypeError. if (keepalive) - return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Cannot extract body from stream when keepalive is set" }; + return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Cannot extract body from stream when keepalive is set" }; // If object is disturbed or locked, then throw a TypeError. if (stream->is_disturbed() || stream->is_locked()) - return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Cannot extract body from disturbed or locked stream" }; + return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Cannot extract body from disturbed or locked stream" }; return {}; })); |