1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 15:55:09 +00:00
serenity/Userland/Libraries/LibWeb/XHR/XMLHttpRequestEventTarget.h
Andreas Kling 6f433c8656 LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.

There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
2022-09-06 00:27:09 +02:00

45 lines
1.3 KiB
C++

/*
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/DOM/EventDispatcher.h>
#include <LibWeb/DOM/EventTarget.h>
namespace Web::XHR {
#define ENUMERATE_XML_HTTP_REQUEST_EVENT_TARGET_EVENT_HANDLERS(E) \
E(onloadstart, XHR::EventNames::loadstart) \
E(onprogress, XHR::EventNames::progress) \
E(onabort, XHR::EventNames::abort) \
E(onerror, XHR::EventNames::error) \
E(onload, XHR::EventNames::load) \
E(ontimeout, XHR::EventNames::timeout) \
E(onloadend, XHR::EventNames::loadend)
class XMLHttpRequestEventTarget : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(XMLHttpRequestEventTarget, DOM::EventTarget);
public:
virtual ~XMLHttpRequestEventTarget() override {};
#undef __ENUMERATE
#define __ENUMERATE(attribute_name, event_name) \
void set_##attribute_name(Bindings::CallbackType*); \
Bindings::CallbackType* attribute_name();
ENUMERATE_XML_HTTP_REQUEST_EVENT_TARGET_EVENT_HANDLERS(__ENUMERATE)
#undef __ENUMERATE
protected:
XMLHttpRequestEventTarget(JS::Realm& realm)
: DOM::EventTarget(realm)
{
}
};
}
WRAPPER_HACK(XMLHttpRequestEventTarget, Web::XHR)