1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +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

@ -4,15 +4,32 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/AbortControllerPrototype.h>
#include <LibWeb/DOM/AbortController.h>
#include <LibWeb/DOM/AbortSignal.h>
namespace Web::DOM {
// https://dom.spec.whatwg.org/#dom-abortcontroller-abortcontroller
AbortController::AbortController(HTML::Window& window)
: m_signal(JS::make_handle(*AbortSignal::create_with_global_object(window)))
JS::NonnullGCPtr<AbortController> AbortController::create_with_global_object(HTML::Window& window)
{
auto signal = AbortSignal::create_with_global_object(window);
return *window.heap().allocate<AbortController>(window.realm(), window, move(signal));
}
// https://dom.spec.whatwg.org/#dom-abortcontroller-abortcontroller
AbortController::AbortController(HTML::Window& window, JS::NonnullGCPtr<AbortSignal> signal)
: PlatformObject(window.realm())
, m_signal(move(signal))
{
set_prototype(&window.ensure_web_prototype<Bindings::AbortControllerPrototype>("AbortController"));
}
AbortController::~AbortController() = default;
void AbortController::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_signal.ptr());
}
// https://dom.spec.whatwg.org/#dom-abortcontroller-abort