mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09: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
Notes:
sideshowbarker
2024-07-17 17:48:51 +09:00
Author: https://github.com/linusg
Commit: 0706f0d487
Pull-request: https://github.com/SerenityOS/serenity/pull/12936
Reviewed-by: https://github.com/awesomekling ✅
6 changed files with 15 additions and 15 deletions
|
@ -98,7 +98,6 @@ set(SOURCES
|
|||
DOM/StaticRange.cpp
|
||||
DOM/Text.cpp
|
||||
DOM/Text.idl
|
||||
DOM/Timer.cpp
|
||||
DOMParsing/InnerHTML.cpp
|
||||
DOMTreeModel.cpp
|
||||
Dump.cpp
|
||||
|
@ -213,6 +212,7 @@ set(SOURCES
|
|||
HTML/SyntaxHighlighter/SyntaxHighlighter.cpp
|
||||
HTML/TagNames.cpp
|
||||
HTML/TextMetrics.cpp
|
||||
HTML/Timer.cpp
|
||||
HTML/Window.cpp
|
||||
HTML/Worker.cpp
|
||||
HTML/WorkerDebugConsoleClient.cpp
|
||||
|
|
|
@ -119,7 +119,6 @@ class ShadowRoot;
|
|||
class StaticNodeList;
|
||||
class StaticRange;
|
||||
class Text;
|
||||
class Timer;
|
||||
enum class QuirksMode;
|
||||
struct EventListenerOptions;
|
||||
struct AddEventListenerOptions;
|
||||
|
@ -234,6 +233,7 @@ class WorkerDebugConsoleClient;
|
|||
class Storage;
|
||||
class SubmitEvent;
|
||||
class TextMetrics;
|
||||
class Timer;
|
||||
class Window;
|
||||
class WindowEnvironmentSettingsObject;
|
||||
class Worker;
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
*/
|
||||
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibWeb/DOM/Timer.h>
|
||||
#include <LibWeb/HTML/Timer.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));
|
||||
}
|
||||
|
||||
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_id(id)
|
||||
{
|
|
@ -11,20 +11,20 @@
|
|||
#include <LibCore/Forward.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
namespace Web::HTML {
|
||||
|
||||
class Timer final : public RefCounted<Timer> {
|
||||
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();
|
||||
|
||||
void start();
|
||||
|
||||
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;
|
||||
HTML::Window& m_window;
|
||||
Window& m_window;
|
||||
i32 m_id { 0 };
|
||||
};
|
||||
|
|
@ -15,7 +15,6 @@
|
|||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/DOM/EventDispatcher.h>
|
||||
#include <LibWeb/DOM/Timer.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||
#include <LibWeb/HTML/MessageEvent.h>
|
||||
|
@ -23,6 +22,7 @@
|
|||
#include <LibWeb/HTML/Scripting/ClassicScript.h>
|
||||
#include <LibWeb/HTML/Scripting/ExceptionReporter.h>
|
||||
#include <LibWeb/HTML/Storage.h>
|
||||
#include <LibWeb/HTML/Timer.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/HighResolutionTime/Performance.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
|
@ -174,7 +174,7 @@ void Window::clear_interval(i32 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);
|
||||
}
|
||||
|
@ -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.
|
||||
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);
|
||||
timer->start();
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
|
||||
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; }
|
||||
|
||||
|
@ -127,7 +127,7 @@ private:
|
|||
WeakPtr<Bindings::WindowObject> m_wrapper;
|
||||
|
||||
IDAllocator m_timer_id_allocator;
|
||||
HashMap<int, NonnullRefPtr<DOM::Timer>> m_timers;
|
||||
HashMap<int, NonnullRefPtr<Timer>> m_timers;
|
||||
|
||||
NonnullOwnPtr<HighResolutionTime::Performance> m_performance;
|
||||
NonnullRefPtr<Crypto::Crypto> m_crypto;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue