1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12: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

@ -9,7 +9,7 @@
#include <AK/Optional.h>
#include <AK/StdLibExtras.h>
#include <LibJS/Runtime/VM.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::Bindings {
@ -17,7 +17,7 @@ template<typename>
constexpr bool IsExceptionOr = false;
template<typename T>
constexpr bool IsExceptionOr<DOM::ExceptionOr<T>> = true;
constexpr bool IsExceptionOr<WebIDL::ExceptionOr<T>> = true;
template<typename>
constexpr bool IsThrowCompletionOr = false;
@ -33,7 +33,7 @@ struct ExtractExceptionOrValueType {
};
template<typename T>
struct ExtractExceptionOrValueType<DOM::ExceptionOr<T>> {
struct ExtractExceptionOrValueType<WebIDL::ExceptionOr<T>> {
using Type = T;
};
@ -48,22 +48,22 @@ struct ExtractExceptionOrValueType<void> {
};
template<>
struct ExtractExceptionOrValueType<DOM::ExceptionOr<Empty>> {
struct ExtractExceptionOrValueType<WebIDL::ExceptionOr<Empty>> {
using Type = JS::Value;
};
template<>
struct ExtractExceptionOrValueType<DOM::ExceptionOr<void>> {
struct ExtractExceptionOrValueType<WebIDL::ExceptionOr<void>> {
using Type = JS::Value;
};
ALWAYS_INLINE JS::Completion dom_exception_to_throw_completion(auto&& vm, auto&& exception)
{
return exception.visit(
[&](DOM::SimpleException const& exception) {
[&](WebIDL::SimpleException const& exception) {
switch (exception.type) {
#define E(x) \
case DOM::SimpleExceptionType::x: \
#define E(x) \
case WebIDL::SimpleExceptionType::x: \
return vm.template throw_completion<JS::x>(exception.message);
ENUMERATE_SIMPLE_WEBIDL_EXCEPTION_TYPES(E)