1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:57:35 +00:00

LibWeb: Add the IdleDeadline interface from the RequestIdleCallback spec

This commit is contained in:
Andreas Kling 2021-09-17 01:42:36 +02:00
parent 64df30230d
commit 11bb6e045f
6 changed files with 83 additions and 1 deletions

View file

@ -439,7 +439,7 @@ int main(int argc, char** argv)
return 1;
}
if (namespace_.is_one_of("CSS", "DOM", "HTML", "UIEvents", "HighResolutionTime", "NavigationTiming", "SVG", "XHR", "URL")) {
if (namespace_.is_one_of("CSS", "DOM", "HTML", "UIEvents", "HighResolutionTime", "NavigationTiming", "RequestIdleCallback", "SVG", "XHR", "URL")) {
StringBuilder builder;
builder.append(namespace_);
builder.append("::");
@ -966,6 +966,8 @@ static void generate_header(IDL::Interface const& interface)
# include <LibWeb/HighResolutionTime/@name@.h>
#elif __has_include(<LibWeb/NavigationTiming/@name@.h>)
# include <LibWeb/NavigationTiming/@name@.h>
#elif __has_include(<LibWeb/RequestIdleCallback/@name@.h>)
# include <LibWeb/RequestIdleCallback/@name@.h>
#elif __has_include(<LibWeb/SVG/@name@.h>)
# include <LibWeb/SVG/@name@.h>
#elif __has_include(<LibWeb/XHR/@name@.h>)
@ -1099,6 +1101,7 @@ void generate_implementation(IDL::Interface const& interface)
using namespace Web::CSS;
using namespace Web::DOM;
using namespace Web::HTML;
using namespace Web::RequestIdleCallback;
namespace Web::Bindings {
@ -1235,6 +1238,8 @@ void generate_constructor_implementation(IDL::Interface const& interface)
# include <LibWeb/HighResolutionTime/@name@.h>
#elif __has_include(<LibWeb/NavigationTiming/@name@.h>)
# include <LibWeb/NavigationTiming/@name@.h>
#elif __has_include(<LibWeb/RequestIdleCallback/@name@.h>)
# include <LibWeb/RequestIdleCallback/@name@.h>
#elif __has_include(<LibWeb/SVG/@name@.h>)
# include <LibWeb/SVG/@name@.h>
#elif __has_include(<LibWeb/XHR/@name@.h>)
@ -1247,6 +1252,7 @@ void generate_constructor_implementation(IDL::Interface const& interface)
using namespace Web::CSS;
using namespace Web::DOM;
using namespace Web::HTML;
using namespace Web::RequestIdleCallback;
namespace Web::Bindings {
@ -1507,6 +1513,8 @@ void generate_prototype_implementation(IDL::Interface const& interface)
# include <LibWeb/HighResolutionTime/@name@.h>
#elif __has_include(<LibWeb/NavigationTiming/@name@.h>)
# include <LibWeb/NavigationTiming/@name@.h>
#elif __has_include(<LibWeb/RequestIdleCallback/@name@.h>)
# include <LibWeb/RequestIdleCallback/@name@.h>
#elif __has_include(<LibWeb/SVG/@name@.h>)
# include <LibWeb/SVG/@name@.h>
#elif __has_include(<LibWeb/XHR/@name@.h>)
@ -1520,6 +1528,7 @@ using namespace Web::CSS;
using namespace Web::DOM;
using namespace Web::HTML;
using namespace Web::NavigationTiming;
using namespace Web::RequestIdleCallback;
using namespace Web::XHR;
using namespace Web::URL;

View file

@ -221,6 +221,7 @@ set(SOURCES
Page/Page.cpp
Painting/BorderPainting.cpp
Painting/StackingContext.cpp
RequestIdleCallback/IdleDeadline.cpp
SVG/AttributeNames.cpp
SVG/SVGElement.cpp
SVG/SVGGeometryElement.cpp
@ -414,6 +415,7 @@ libweb_js_wrapper(HTML/SubmitEvent)
libweb_js_wrapper(HTML/WebSocket)
libweb_js_wrapper(HighResolutionTime/Performance)
libweb_js_wrapper(NavigationTiming/PerformanceTiming)
libweb_js_wrapper(RequestIdleCallback/IdleDeadline)
libweb_js_wrapper(SVG/SVGElement)
libweb_js_wrapper(SVG/SVGGeometryElement)
libweb_js_wrapper(SVG/SVGGraphicsElement)

View file

@ -153,6 +153,10 @@ namespace Web::NavigationTiming {
class PerformanceTiming;
}
namespace Web::RequestIdleCallback {
class IdleDeadline;
}
namespace Web::SVG {
class SVGElement;
class SVGGeometryElement;
@ -302,6 +306,7 @@ class HTMLTrackElementWrapper;
class HTMLUListElementWrapper;
class HTMLUnknownElementWrapper;
class HTMLVideoElementWrapper;
class IdleDeadlineWrapper;
class ImageDataWrapper;
class LocationObject;
class MediaQueryListWrapper;

View file

@ -0,0 +1,26 @@
/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/RequestIdleCallback/IdleDeadline.h>
namespace Web::RequestIdleCallback {
NonnullRefPtr<IdleDeadline> IdleDeadline::create(double time_remaining, bool did_timeout)
{
return adopt_ref(*new IdleDeadline(time_remaining, did_timeout));
}
IdleDeadline::IdleDeadline(double time_remaining, bool did_timeout)
: m_time_remaining(time_remaining)
, m_did_timeout(did_timeout)
{
}
IdleDeadline::~IdleDeadline()
{
}
}

View file

@ -0,0 +1,34 @@
/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/StdLibExtras.h>
#include <LibWeb/Bindings/Wrappable.h>
namespace Web::RequestIdleCallback {
class IdleDeadline final
: public RefCounted<IdleDeadline>
, public Bindings::Wrappable {
public:
using WrapperType = Bindings::IdleDeadlineWrapper;
using AllowOwnPtr = TrueType;
static NonnullRefPtr<IdleDeadline> create(double time_remaining, bool did_timeout);
virtual ~IdleDeadline() override;
double time_remaining() const { return m_time_remaining; }
bool did_timeout() const { return m_did_timeout; }
private:
IdleDeadline(double time_remaining, bool did_timeout);
double m_time_remaining { 0 };
bool m_did_timeout { false };
};
}

View file

@ -0,0 +1,6 @@
[Exposed=Window] interface IdleDeadline {
double timeRemaining();
readonly attribute boolean didTimeout;
};