2021-09-17 01:42:36 +02:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2021-2022, Andreas Kling <andreas@ladybird.org>
|
2022-03-31 21:55:01 +02:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2021-09-17 01:42:36 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-09-04 13:26:36 +02:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2021-09-17 01:42:36 +02:00
|
|
|
|
|
|
|
|
namespace Web::RequestIdleCallback {
|
|
|
|
|
|
2022-09-04 13:26:36 +02:00
|
|
|
class IdleDeadline final : public Bindings::PlatformObject {
|
|
|
|
|
WEB_PLATFORM_OBJECT(IdleDeadline, Bindings::PlatformObject);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(IdleDeadline);
|
2021-09-17 01:42:36 +02:00
|
|
|
|
2022-09-04 13:26:36 +02:00
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
[[nodiscard]] static GC::Ref<IdleDeadline> create(JS::Realm&, bool did_timeout = false);
|
2021-09-17 01:42:36 +02:00
|
|
|
virtual ~IdleDeadline() override;
|
|
|
|
|
|
2022-03-31 21:55:01 +02:00
|
|
|
double time_remaining() const;
|
2021-09-17 01:42:36 +02:00
|
|
|
bool did_timeout() const { return m_did_timeout; }
|
|
|
|
|
|
|
|
|
|
private:
|
LibWeb: Remove unecessary dependence on Window from assorted classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct Crypto, Encoding, HRT, IntersectionObserver,
NavigationTiming, Page, RequestIdleCallback, Selection, Streams, URL,
and XML classes.
2022-09-25 18:11:21 -06:00
|
|
|
IdleDeadline(JS::Realm&, bool did_timeout);
|
2021-09-17 01:42:36 +02:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2021-09-17 01:42:36 +02:00
|
|
|
bool m_did_timeout { false };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|