ladybird/Userland/Libraries/LibWeb/DOM/AbortController.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.1 KiB
C++

/*
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/RefCounted.h>
#include <AK/Weakable.h>
#include <LibWeb/Bindings/Wrappable.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 {
public:
using WrapperType = Bindings::AbortControllerWrapper;
static NonnullRefPtr<AbortController> create_with_global_object(HTML::Window& window)
{
return adopt_ref(*new AbortController(window));
}
virtual ~AbortController() override = default;
// https://dom.spec.whatwg.org/#dom-abortcontroller-signal
JS::NonnullGCPtr<AbortSignal> signal() const { return *m_signal; }
void abort(JS::Value reason);
private:
explicit AbortController(HTML::Window&);
// https://dom.spec.whatwg.org/#abortcontroller-signal
JS::Handle<AbortSignal> m_signal;
};
}