From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- widget/SystemTimeConverter.h | 235 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 widget/SystemTimeConverter.h (limited to 'widget/SystemTimeConverter.h') diff --git a/widget/SystemTimeConverter.h b/widget/SystemTimeConverter.h new file mode 100644 index 0000000000..4a074d573f --- /dev/null +++ b/widget/SystemTimeConverter.h @@ -0,0 +1,235 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef SystemTimeConverter_h +#define SystemTimeConverter_h + +#include +#include +#include "mozilla/TimeStamp.h" + +namespace mozilla { + +// Utility class that converts time values represented as an unsigned integral +// number of milliseconds from one time source (e.g. a native event time) to +// corresponding mozilla::TimeStamp objects. +// +// This class handles wrapping of integer values and skew between the time +// source and mozilla::TimeStamp values. +// +// It does this by using an historical reference time recorded in both time +// scales (i.e. both as a numerical time value and as a TimeStamp). +// +// For performance reasons, this class is careful to minimize calls to the +// native "current time" function (e.g. gdk_x11_server_get_time) since this can +// be slow. +template +class SystemTimeConverter { + public: + SystemTimeConverter() + : mReferenceTime(Time(0)), + mReferenceTimeStamp() // Initializes to the null timestamp + , + mLastBackwardsSkewCheck(Time(0)), + kTimeRange(std::numeric_limits