1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 06:57:35 +00:00

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
:^)
This commit is contained in:
Linus Groh 2022-09-25 17:03:42 +01:00
parent c0eda77928
commit ad04d7ac9b
107 changed files with 441 additions and 440 deletions

View file

@ -21,7 +21,6 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/EventDispatcher.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/IDLEventListener.h>
#include <LibWeb/Fetch/BodyInit.h>
#include <LibWeb/Fetch/Infrastructure/HTTP.h>
@ -34,6 +33,7 @@
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Page/Page.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
#include <LibWeb/XHR/EventNames.h>
#include <LibWeb/XHR/ProgressEvent.h>
#include <LibWeb/XHR/XMLHttpRequest.h>
@ -80,7 +80,7 @@ void XMLHttpRequest::fire_progress_event(String const& event_name, u64 transmitt
}
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-responsetext
DOM::ExceptionOr<String> XMLHttpRequest::response_text() const
WebIDL::ExceptionOr<String> XMLHttpRequest::response_text() const
{
// 1. If thiss response type is not the empty string or "text", then throw an "InvalidStateError" DOMException.
if (m_response_type != Bindings::XMLHttpRequestResponseType::Empty && m_response_type != Bindings::XMLHttpRequestResponseType::Text)
@ -94,7 +94,7 @@ DOM::ExceptionOr<String> XMLHttpRequest::response_text() const
}
// https://xhr.spec.whatwg.org/#response
DOM::ExceptionOr<JS::Value> XMLHttpRequest::response()
WebIDL::ExceptionOr<JS::Value> XMLHttpRequest::response()
{
// 1. If thiss response type is the empty string or "text", then:
if (m_response_type == Bindings::XMLHttpRequestResponseType::Empty || m_response_type == Bindings::XMLHttpRequestResponseType::Text) {
@ -139,7 +139,7 @@ DOM::ExceptionOr<JS::Value> XMLHttpRequest::response()
// 7. Otherwise, if thiss response type is "document", set a document response for this.
else if (m_response_type == Bindings::XMLHttpRequestResponseType::Document) {
// FIXME: Implement this.
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "XHR Document type not implemented" };
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "XHR Document type not implemented" };
}
// 8. Otherwise:
else {
@ -269,7 +269,7 @@ Optional<StringView> XMLHttpRequest::get_final_encoding() const
}
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-setrequestheader
DOM::ExceptionOr<void> XMLHttpRequest::set_request_header(String const& name_string, String const& value_string)
WebIDL::ExceptionOr<void> XMLHttpRequest::set_request_header(String const& name_string, String const& value_string)
{
auto name = name_string.to_byte_buffer();
auto value = value_string.to_byte_buffer();
@ -312,13 +312,13 @@ DOM::ExceptionOr<void> XMLHttpRequest::set_request_header(String const& name_str
}
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-open
DOM::ExceptionOr<void> XMLHttpRequest::open(String const& method_string, String const& url)
WebIDL::ExceptionOr<void> XMLHttpRequest::open(String const& method_string, String const& url)
{
// 8. If the async argument is omitted, set async to true, and set username and password to null.
return open(method_string, url, true, {}, {});
}
DOM::ExceptionOr<void> XMLHttpRequest::open(String const& method_string, String const& url, bool async, String const& username, String const& password)
WebIDL::ExceptionOr<void> XMLHttpRequest::open(String const& method_string, String const& url, bool async, String const& username, String const& password)
{
auto method = method_string.to_byte_buffer();
@ -395,7 +395,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::open(String const& method_string, String
}
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send
DOM::ExceptionOr<void> XMLHttpRequest::send(Optional<Fetch::XMLHttpRequestBodyInit> body)
WebIDL::ExceptionOr<void> XMLHttpRequest::send(Optional<Fetch::XMLHttpRequestBodyInit> body)
{
auto& vm = this->vm();
auto& realm = *vm.current_realm();
@ -548,7 +548,7 @@ String XMLHttpRequest::get_all_response_headers() const
}
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-overridemimetype
DOM::ExceptionOr<void> XMLHttpRequest::override_mime_type(String const& mime)
WebIDL::ExceptionOr<void> XMLHttpRequest::override_mime_type(String const& mime)
{
// 1. If thiss state is loading or done, then throw an "InvalidStateError" DOMException.
if (m_ready_state == ReadyState::Loading || m_ready_state == ReadyState::Done)
@ -565,7 +565,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::override_mime_type(String const& mime)
}
// https://xhr.spec.whatwg.org/#ref-for-dom-xmlhttprequest-timeout%E2%91%A2
DOM::ExceptionOr<void> XMLHttpRequest::set_timeout(u32 timeout)
WebIDL::ExceptionOr<void> XMLHttpRequest::set_timeout(u32 timeout)
{
// 1. If the current global object is a Window object and thiss synchronous flag is set,
// then throw an "InvalidAccessError" DOMException.