mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 10:17:41 +00:00
LibWeb: Move Timer from DOM directory & namespace to HTML
Timers are part of the HTML spec. :^) https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
This commit is contained in:
parent
1422bd45eb
commit
0706f0d487
6 changed files with 15 additions and 15 deletions
|
@ -98,7 +98,6 @@ set(SOURCES
|
||||||
DOM/StaticRange.cpp
|
DOM/StaticRange.cpp
|
||||||
DOM/Text.cpp
|
DOM/Text.cpp
|
||||||
DOM/Text.idl
|
DOM/Text.idl
|
||||||
DOM/Timer.cpp
|
|
||||||
DOMParsing/InnerHTML.cpp
|
DOMParsing/InnerHTML.cpp
|
||||||
DOMTreeModel.cpp
|
DOMTreeModel.cpp
|
||||||
Dump.cpp
|
Dump.cpp
|
||||||
|
@ -213,6 +212,7 @@ set(SOURCES
|
||||||
HTML/SyntaxHighlighter/SyntaxHighlighter.cpp
|
HTML/SyntaxHighlighter/SyntaxHighlighter.cpp
|
||||||
HTML/TagNames.cpp
|
HTML/TagNames.cpp
|
||||||
HTML/TextMetrics.cpp
|
HTML/TextMetrics.cpp
|
||||||
|
HTML/Timer.cpp
|
||||||
HTML/Window.cpp
|
HTML/Window.cpp
|
||||||
HTML/Worker.cpp
|
HTML/Worker.cpp
|
||||||
HTML/WorkerDebugConsoleClient.cpp
|
HTML/WorkerDebugConsoleClient.cpp
|
||||||
|
|
|
@ -119,7 +119,6 @@ class ShadowRoot;
|
||||||
class StaticNodeList;
|
class StaticNodeList;
|
||||||
class StaticRange;
|
class StaticRange;
|
||||||
class Text;
|
class Text;
|
||||||
class Timer;
|
|
||||||
enum class QuirksMode;
|
enum class QuirksMode;
|
||||||
struct EventListenerOptions;
|
struct EventListenerOptions;
|
||||||
struct AddEventListenerOptions;
|
struct AddEventListenerOptions;
|
||||||
|
@ -234,6 +233,7 @@ class WorkerDebugConsoleClient;
|
||||||
class Storage;
|
class Storage;
|
||||||
class SubmitEvent;
|
class SubmitEvent;
|
||||||
class TextMetrics;
|
class TextMetrics;
|
||||||
|
class Timer;
|
||||||
class Window;
|
class Window;
|
||||||
class WindowEnvironmentSettingsObject;
|
class WindowEnvironmentSettingsObject;
|
||||||
class Worker;
|
class Worker;
|
||||||
|
|
|
@ -5,17 +5,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibCore/Timer.h>
|
#include <LibCore/Timer.h>
|
||||||
#include <LibWeb/DOM/Timer.h>
|
#include <LibWeb/HTML/Timer.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/HTML/Window.h>
|
||||||
|
|
||||||
namespace Web::DOM {
|
namespace Web::HTML {
|
||||||
|
|
||||||
NonnullRefPtr<Timer> Timer::create(HTML::Window& window, i32 milliseconds, Function<void()> callback, i32 id)
|
NonnullRefPtr<Timer> Timer::create(Window& window, i32 milliseconds, Function<void()> callback, i32 id)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new Timer(window, milliseconds, move(callback), id));
|
return adopt_ref(*new Timer(window, milliseconds, move(callback), id));
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer::Timer(HTML::Window& window, i32 milliseconds, Function<void()> callback, i32 id)
|
Timer::Timer(Window& window, i32 milliseconds, Function<void()> callback, i32 id)
|
||||||
: m_window(window)
|
: m_window(window)
|
||||||
, m_id(id)
|
, m_id(id)
|
||||||
{
|
{
|
|
@ -11,20 +11,20 @@
|
||||||
#include <LibCore/Forward.h>
|
#include <LibCore/Forward.h>
|
||||||
#include <LibWeb/Forward.h>
|
#include <LibWeb/Forward.h>
|
||||||
|
|
||||||
namespace Web::DOM {
|
namespace Web::HTML {
|
||||||
|
|
||||||
class Timer final : public RefCounted<Timer> {
|
class Timer final : public RefCounted<Timer> {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<Timer> create(HTML::Window& window, i32 milliseconds, Function<void()> callback, i32 id);
|
static NonnullRefPtr<Timer> create(Window& window, i32 milliseconds, Function<void()> callback, i32 id);
|
||||||
~Timer();
|
~Timer();
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Timer(HTML::Window& window, i32 milliseconds, Function<void()> callback, i32 id);
|
Timer(Window& window, i32 milliseconds, Function<void()> callback, i32 id);
|
||||||
|
|
||||||
RefPtr<Core::Timer> m_timer;
|
RefPtr<Core::Timer> m_timer;
|
||||||
HTML::Window& m_window;
|
Window& m_window;
|
||||||
i32 m_id { 0 };
|
i32 m_id { 0 };
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/DOM/Event.h>
|
#include <LibWeb/DOM/Event.h>
|
||||||
#include <LibWeb/DOM/EventDispatcher.h>
|
#include <LibWeb/DOM/EventDispatcher.h>
|
||||||
#include <LibWeb/DOM/Timer.h>
|
|
||||||
#include <LibWeb/HTML/BrowsingContext.h>
|
#include <LibWeb/HTML/BrowsingContext.h>
|
||||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||||
#include <LibWeb/HTML/MessageEvent.h>
|
#include <LibWeb/HTML/MessageEvent.h>
|
||||||
|
@ -23,6 +22,7 @@
|
||||||
#include <LibWeb/HTML/Scripting/ClassicScript.h>
|
#include <LibWeb/HTML/Scripting/ClassicScript.h>
|
||||||
#include <LibWeb/HTML/Scripting/ExceptionReporter.h>
|
#include <LibWeb/HTML/Scripting/ExceptionReporter.h>
|
||||||
#include <LibWeb/HTML/Storage.h>
|
#include <LibWeb/HTML/Storage.h>
|
||||||
|
#include <LibWeb/HTML/Timer.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/HTML/Window.h>
|
||||||
#include <LibWeb/HighResolutionTime/Performance.h>
|
#include <LibWeb/HighResolutionTime/Performance.h>
|
||||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||||
|
@ -174,7 +174,7 @@ void Window::clear_interval(i32 id)
|
||||||
m_timers.remove(id);
|
m_timers.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::deallocate_timer_id(Badge<DOM::Timer>, i32 id)
|
void Window::deallocate_timer_id(Badge<Timer>, i32 id)
|
||||||
{
|
{
|
||||||
m_timer_id_allocator.deallocate(id);
|
m_timer_id_allocator.deallocate(id);
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ i32 Window::run_timer_initialization_steps(Bindings::TimerHandler handler, i32 t
|
||||||
};
|
};
|
||||||
|
|
||||||
// 13. Run steps after a timeout given global, "setTimeout/setInterval", timeout, completionStep, and id.
|
// 13. Run steps after a timeout given global, "setTimeout/setInterval", timeout, completionStep, and id.
|
||||||
auto timer = DOM::Timer::create(*this, timeout, move(completion_step), id);
|
auto timer = Timer::create(*this, timeout, move(completion_step), id);
|
||||||
m_timers.set(id, timer);
|
m_timers.set(id, timer);
|
||||||
timer->start();
|
timer->start();
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ public:
|
||||||
|
|
||||||
void set_wrapper(Badge<Bindings::WindowObject>, Bindings::WindowObject&);
|
void set_wrapper(Badge<Bindings::WindowObject>, Bindings::WindowObject&);
|
||||||
|
|
||||||
void deallocate_timer_id(Badge<DOM::Timer>, i32);
|
void deallocate_timer_id(Badge<Timer>, i32);
|
||||||
|
|
||||||
HighResolutionTime::Performance& performance() { return *m_performance; }
|
HighResolutionTime::Performance& performance() { return *m_performance; }
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ private:
|
||||||
WeakPtr<Bindings::WindowObject> m_wrapper;
|
WeakPtr<Bindings::WindowObject> m_wrapper;
|
||||||
|
|
||||||
IDAllocator m_timer_id_allocator;
|
IDAllocator m_timer_id_allocator;
|
||||||
HashMap<int, NonnullRefPtr<DOM::Timer>> m_timers;
|
HashMap<int, NonnullRefPtr<Timer>> m_timers;
|
||||||
|
|
||||||
NonnullOwnPtr<HighResolutionTime::Performance> m_performance;
|
NonnullOwnPtr<HighResolutionTime::Performance> m_performance;
|
||||||
NonnullRefPtr<Crypto::Crypto> m_crypto;
|
NonnullRefPtr<Crypto::Crypto> m_crypto;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue