mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 10:55:07 +00:00

This isn't perfect (especially the global object situation in activate_event_handler), but I believe it's in a much more complete state now :^) This fixes the issue of crashing in prepare_for_ordinary_call with the `i < m_size` crash, as it now uses the IDL callback functions which requires the Environment Settings Object. The environment settings object for the callback is fetched at the time the callback is created, for example, WrapperGenerator gets the incumbent settings object for the callback at the time of wrapping. This allows us to remove passing in ScriptExecutionContext into EventTarget's constructor. With this, we can now drop ScriptExecutionContext.
44 lines
1 KiB
C++
44 lines
1 KiB
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Forward.h>
|
|
#include <LibCore/Forward.h>
|
|
#include <LibJS/Heap/Handle.h>
|
|
#include <LibJS/Runtime/FunctionObject.h>
|
|
#include <LibWeb/Forward.h>
|
|
|
|
namespace Web::DOM {
|
|
|
|
class Timer final : public RefCounted<Timer> {
|
|
public:
|
|
enum class Type {
|
|
Interval,
|
|
Timeout,
|
|
};
|
|
|
|
static NonnullRefPtr<Timer> create_interval(Window&, int milliseconds, NonnullOwnPtr<Bindings::CallbackType> callback);
|
|
static NonnullRefPtr<Timer> create_timeout(Window&, int milliseconds, NonnullOwnPtr<Bindings::CallbackType> callback);
|
|
|
|
~Timer();
|
|
|
|
i32 id() const { return m_id; }
|
|
Type type() const { return m_type; }
|
|
|
|
Bindings::CallbackType& callback() { return *m_callback; }
|
|
|
|
private:
|
|
Timer(Window&, Type, int ms, NonnullOwnPtr<Bindings::CallbackType> callback);
|
|
|
|
Window& m_window;
|
|
RefPtr<Core::Timer> m_timer;
|
|
Type m_type;
|
|
int m_id { 0 };
|
|
NonnullOwnPtr<Bindings::CallbackType> m_callback;
|
|
};
|
|
|
|
}
|