2020-09-29 18:19:18 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-09-29 18:19:18 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-11-03 18:21:56 +03:30
|
|
|
#include <AK/StdLibExtras.h>
|
2020-09-29 18:19:18 +02:00
|
|
|
#include <LibCore/ElapsedTimer.h>
|
|
|
|
|
#include <LibWeb/Bindings/Wrappable.h>
|
|
|
|
|
#include <LibWeb/DOM/EventTarget.h>
|
2021-01-18 15:06:13 +01:00
|
|
|
#include <LibWeb/NavigationTiming/PerformanceTiming.h>
|
2020-09-29 18:19:18 +02:00
|
|
|
|
|
|
|
|
namespace Web::HighResolutionTime {
|
|
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
class Performance final : public DOM::EventTarget {
|
|
|
|
|
WEB_PLATFORM_OBJECT(Performance, DOM::EventTarget);
|
2020-09-29 18:19:18 +02:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
public:
|
|
|
|
|
virtual ~Performance() override;
|
2020-09-29 18:19:18 +02:00
|
|
|
|
|
|
|
|
double now() const { return m_timer.elapsed(); }
|
2020-09-29 18:31:07 +02:00
|
|
|
double time_origin() const;
|
2020-09-29 18:19:18 +02:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
JS::GCPtr<NavigationTiming::PerformanceTiming> timing() { return *m_timing; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
explicit Performance(HTML::Window&);
|
2021-01-18 15:06:13 +01:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
2020-09-29 18:19:18 +02:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
JS::NonnullGCPtr<HTML::Window> m_window;
|
2020-09-29 18:19:18 +02:00
|
|
|
|
|
|
|
|
Core::ElapsedTimer m_timer;
|
2021-01-18 15:06:13 +01:00
|
|
|
|
|
|
|
|
OwnPtr<NavigationTiming::PerformanceTiming> m_timing;
|
2020-09-29 18:19:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
2022-08-28 13:42:07 +02:00
|
|
|
|
|
|
|
|
WRAPPER_HACK(Performance, Web::HighResolutionTime)
|