mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:07:44 +00:00
LibWeb: Make IdleDeadline GC-allocated
This commit is contained in:
parent
8f2a711132
commit
915a240944
5 changed files with 22 additions and 22 deletions
|
@ -6,18 +6,21 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/RequestIdleCallback/IdleDeadline.h>
|
||||
|
||||
namespace Web::RequestIdleCallback {
|
||||
|
||||
NonnullRefPtr<IdleDeadline> IdleDeadline::create(bool did_timeout)
|
||||
JS::NonnullGCPtr<IdleDeadline> IdleDeadline::create(HTML::Window& window, bool did_timeout)
|
||||
{
|
||||
return adopt_ref(*new IdleDeadline(did_timeout));
|
||||
return *window.heap().allocate<IdleDeadline>(window.realm(), window, did_timeout);
|
||||
}
|
||||
|
||||
IdleDeadline::IdleDeadline(bool did_timeout)
|
||||
: m_did_timeout(did_timeout)
|
||||
IdleDeadline::IdleDeadline(HTML::Window& window, bool did_timeout)
|
||||
: PlatformObject(window.realm())
|
||||
, m_did_timeout(did_timeout)
|
||||
{
|
||||
set_prototype(&window.cached_web_prototype("IdleDeadline"));
|
||||
}
|
||||
|
||||
IdleDeadline::~IdleDeadline() = default;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -8,27 +8,26 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <LibWeb/Bindings/Wrappable.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
|
||||
namespace Web::RequestIdleCallback {
|
||||
|
||||
class IdleDeadline final
|
||||
: public RefCounted<IdleDeadline>
|
||||
, public Bindings::Wrappable {
|
||||
public:
|
||||
using WrapperType = Bindings::IdleDeadlineWrapper;
|
||||
using AllowOwnPtr = TrueType;
|
||||
class IdleDeadline final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(IdleDeadline, Bindings::PlatformObject);
|
||||
|
||||
static NonnullRefPtr<IdleDeadline> create(bool did_timeout = false);
|
||||
public:
|
||||
static JS::NonnullGCPtr<IdleDeadline> create(HTML::Window&, bool did_timeout = false);
|
||||
virtual ~IdleDeadline() override;
|
||||
|
||||
double time_remaining() const;
|
||||
bool did_timeout() const { return m_did_timeout; }
|
||||
|
||||
private:
|
||||
IdleDeadline(bool did_timeout);
|
||||
IdleDeadline(HTML::Window&, bool did_timeout);
|
||||
|
||||
bool m_did_timeout { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
WRAPPER_HACK(IdleDeadline, Web::RequestIdleCallback)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue