ladybird/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h
Andrew Kaster a492e2018d Userland: Silence warnings from ElapsedTimer::elapsed() type change
We changed elapsed() to return i64 instead of int as that's what
AK::Time::to_milliseconds() returns, causing a bunch of implicit lossy
conversions in callers. Clean those up with a mix of type changes and
casts.
2023-01-07 14:51:04 +01:00

36 lines
810 B
C++

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