1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

LibWeb: Make PerformanceTiming GC-allocated

This commit is contained in:
Andreas Kling 2022-08-31 19:12:11 +02:00
parent 8c90e08e0b
commit 5f4d4ffe39
6 changed files with 31 additions and 15 deletions

View file

@ -10,13 +10,13 @@
#include <LibWeb/DOM/EventDispatcher.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/HighResolutionTime/Performance.h>
#include <LibWeb/NavigationTiming/PerformanceTiming.h>
namespace Web::HighResolutionTime {
Performance::Performance(HTML::Window& window)
: DOM::EventTarget(window.realm())
, m_window(window)
, m_timing(make<NavigationTiming::PerformanceTiming>(window))
{
set_prototype(&window.ensure_web_prototype<Bindings::PerformancePrototype>("Performance"));
m_timer.start();
@ -28,6 +28,14 @@ void Performance::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_window.ptr());
visitor.visit(m_timing.ptr());
}
JS::GCPtr<NavigationTiming::PerformanceTiming> Performance::timing()
{
if (!m_timing)
m_timing = heap().allocate<NavigationTiming::PerformanceTiming>(realm(), *m_window);
return m_timing;
}
double Performance::time_origin() const