/* * Copyright (c) 2021, Luke Wilde * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include namespace Web::DOM { JS_DEFINE_ALLOCATOR(AbortController); WebIDL::ExceptionOr> AbortController::construct_impl(JS::Realm& realm) { auto signal = TRY(AbortSignal::construct_impl(realm)); return realm.create(realm, move(signal)); } // https://dom.spec.whatwg.org/#dom-abortcontroller-abortcontroller AbortController::AbortController(JS::Realm& realm, JS::NonnullGCPtr signal) : PlatformObject(realm) , m_signal(move(signal)) { } AbortController::~AbortController() = default; void AbortController::initialize(JS::Realm& realm) { Base::initialize(realm); WEB_SET_PROTOTYPE_FOR_INTERFACE(AbortController); } void AbortController::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(m_signal); } // https://dom.spec.whatwg.org/#dom-abortcontroller-abort void AbortController::abort(JS::Value reason) { // The abort(reason) method steps are to signal abort on this’s signal with reason if it is given. m_signal->signal_abort(reason); } }