1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 17:15:09 +00:00
serenity/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h
Andreas Kling 6f433c8656 LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.

There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
2022-09-06 00:27:09 +02:00

42 lines
983 B
C++

/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/StdLibExtras.h>
#include <LibCore/ElapsedTimer.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/NavigationTiming/PerformanceTiming.h>
namespace Web::HighResolutionTime {
class Performance final : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(Performance, DOM::EventTarget);
public:
virtual ~Performance() override;
double now() const { return m_timer.elapsed(); }
double time_origin() const;
JS::GCPtr<NavigationTiming::PerformanceTiming> timing() { return *m_timing; }
private:
explicit Performance(HTML::Window&);
virtual void visit_edges(Cell::Visitor&) override;
JS::NonnullGCPtr<HTML::Window> m_window;
Core::ElapsedTimer m_timer;
OwnPtr<NavigationTiming::PerformanceTiming> m_timing;
};
}
WRAPPER_HACK(Performance, Web::HighResolutionTime)