2020-03-21 14:17:18 -03:00
|
|
|
/*
|
2022-02-25 13:30:39 -03:00
|
|
|
* Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
|
2021-09-27 12:10:56 -03:00
|
|
|
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
2020-03-21 14:17:18 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-03-21 14:17:18 -03:00
|
|
|
*/
|
|
|
|
|
|
2021-04-24 08:54:24 -03:00
|
|
|
#include <LibWeb/Bindings/CloseEventWrapper.h>
|
2021-09-27 12:10:56 -03:00
|
|
|
#include <LibWeb/Bindings/CustomEventWrapper.h>
|
2020-03-21 14:17:18 -03:00
|
|
|
#include <LibWeb/Bindings/EventWrapper.h>
|
2020-08-10 19:07:16 -03:00
|
|
|
#include <LibWeb/Bindings/EventWrapperFactory.h>
|
2021-09-27 18:22:21 -03:00
|
|
|
#include <LibWeb/Bindings/KeyboardEventWrapper.h>
|
2021-10-04 13:41:35 -03:00
|
|
|
#include <LibWeb/Bindings/MediaQueryListEventWrapper.h>
|
2021-04-24 08:54:24 -03:00
|
|
|
#include <LibWeb/Bindings/MessageEventWrapper.h>
|
2020-03-21 14:17:18 -03:00
|
|
|
#include <LibWeb/Bindings/MouseEventWrapper.h>
|
2021-09-27 13:20:16 -03:00
|
|
|
#include <LibWeb/Bindings/PageTransitionEventWrapper.h>
|
|
|
|
|
#include <LibWeb/Bindings/ProgressEventWrapper.h>
|
2021-10-11 08:59:45 -03:00
|
|
|
#include <LibWeb/Bindings/PromiseRejectionEventWrapper.h>
|
2021-09-27 13:20:16 -03:00
|
|
|
#include <LibWeb/Bindings/SubmitEventWrapper.h>
|
2020-03-21 14:17:18 -03:00
|
|
|
|
2021-09-27 13:20:16 -03:00
|
|
|
namespace Web::Bindings {
|
2020-03-21 14:17:18 -03:00
|
|
|
|
2020-07-26 14:37:56 -03:00
|
|
|
EventWrapper* wrap(JS::GlobalObject& global_object, DOM::Event& event)
|
2020-03-21 14:17:18 -03:00
|
|
|
{
|
2021-09-27 12:10:56 -03:00
|
|
|
if (is<DOM::CustomEvent>(event))
|
|
|
|
|
return static_cast<CustomEventWrapper*>(wrap_impl(global_object, static_cast<DOM::CustomEvent&>(event)));
|
2021-10-04 13:41:35 -03:00
|
|
|
if (is<CSS::MediaQueryListEvent>(event))
|
|
|
|
|
return static_cast<MediaQueryListEventWrapper*>(wrap_impl(global_object, static_cast<CSS::MediaQueryListEvent&>(event)));
|
2021-04-24 08:54:24 -03:00
|
|
|
if (is<HTML::CloseEvent>(event))
|
|
|
|
|
return static_cast<CloseEventWrapper*>(wrap_impl(global_object, static_cast<HTML::CloseEvent&>(event)));
|
2021-09-27 13:20:16 -03:00
|
|
|
if (is<HTML::MessageEvent>(event))
|
|
|
|
|
return static_cast<MessageEventWrapper*>(wrap_impl(global_object, static_cast<HTML::MessageEvent&>(event)));
|
|
|
|
|
if (is<HTML::PageTransitionEvent>(event))
|
|
|
|
|
return static_cast<PageTransitionEventWrapper*>(wrap_impl(global_object, static_cast<HTML::PageTransitionEvent&>(event)));
|
2021-10-11 08:59:45 -03:00
|
|
|
if (is<HTML::PromiseRejectionEvent>(event))
|
|
|
|
|
return static_cast<PromiseRejectionEventWrapper*>(wrap_impl(global_object, static_cast<HTML::PromiseRejectionEvent&>(event)));
|
2021-09-27 13:20:16 -03:00
|
|
|
if (is<HTML::SubmitEvent>(event))
|
|
|
|
|
return static_cast<SubmitEventWrapper*>(wrap_impl(global_object, static_cast<HTML::SubmitEvent&>(event)));
|
2021-09-27 18:22:21 -03:00
|
|
|
if (is<UIEvents::KeyboardEvent>(event))
|
|
|
|
|
return static_cast<KeyboardEventWrapper*>(wrap_impl(global_object, static_cast<UIEvents::KeyboardEvent&>(event)));
|
2021-01-01 14:12:33 -03:00
|
|
|
if (is<UIEvents::MouseEvent>(event))
|
2020-07-28 12:21:23 -03:00
|
|
|
return static_cast<MouseEventWrapper*>(wrap_impl(global_object, static_cast<UIEvents::MouseEvent&>(event)));
|
2021-09-27 13:20:16 -03:00
|
|
|
if (is<XHR::ProgressEvent>(event))
|
|
|
|
|
return static_cast<ProgressEventWrapper*>(wrap_impl(global_object, static_cast<XHR::ProgressEvent&>(event)));
|
2022-02-25 13:30:39 -03:00
|
|
|
if (is<UIEvents::UIEvent>(event))
|
|
|
|
|
return static_cast<UIEventWrapper*>(wrap_impl(global_object, static_cast<UIEvents::UIEvent&>(event)));
|
2020-06-23 11:57:39 -03:00
|
|
|
return static_cast<EventWrapper*>(wrap_impl(global_object, event));
|
2020-03-21 14:17:18 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|