1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:47:34 +00:00

LibWeb: Make AbortController GC-allocated

This commit is contained in:
Andreas Kling 2022-09-02 14:59:27 +02:00
parent 18ca15b2cc
commit b8d485e6f0
4 changed files with 33 additions and 23 deletions

View file

@ -6,29 +6,19 @@
#pragma once
#include <AK/RefCounted.h>
#include <AK/Weakable.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/AbortSignal.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/Window.h>
namespace Web::DOM {
// https://dom.spec.whatwg.org/#abortcontroller
class AbortController final
: public RefCounted<AbortController>
, public Weakable<AbortController>
, public Bindings::Wrappable {
class AbortController final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(AbortController, Bindings::PlatformObject);
public:
using WrapperType = Bindings::AbortControllerWrapper;
static JS::NonnullGCPtr<AbortController> create_with_global_object(HTML::Window&);
static NonnullRefPtr<AbortController> create_with_global_object(HTML::Window& window)
{
return adopt_ref(*new AbortController(window));
}
virtual ~AbortController() override = default;
virtual ~AbortController() override;
// https://dom.spec.whatwg.org/#dom-abortcontroller-signal
JS::NonnullGCPtr<AbortSignal> signal() const { return *m_signal; }
@ -36,10 +26,14 @@ public:
void abort(JS::Value reason);
private:
explicit AbortController(HTML::Window&);
AbortController(HTML::Window&, JS::NonnullGCPtr<AbortSignal>);
virtual void visit_edges(Cell::Visitor&) override;
// https://dom.spec.whatwg.org/#abortcontroller-signal
JS::Handle<AbortSignal> m_signal;
JS::NonnullGCPtr<AbortSignal> m_signal;
};
}
WRAPPER_HACK(AbortController, Web::DOM)