Bug 1891710: part 2) Enable <Element-outerHTML.html> WPT for Trusted Types. r=smaug
[gecko.git] / gfx / layers / SampleTime.cpp
blobfd87b669f0df127431015bb55c8a470b9d6d933d
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "SampleTime.h"
9 namespace mozilla {
10 namespace layers {
12 SampleTime::SampleTime() : mType(eNull) {}
14 /*static*/
15 SampleTime SampleTime::FromVsync(const TimeStamp& aTime) {
16 MOZ_ASSERT(!aTime.IsNull());
17 return SampleTime(eVsync, aTime);
20 /*static*/
21 SampleTime SampleTime::FromNow() { return SampleTime(eNow, TimeStamp::Now()); }
23 /*static*/
24 SampleTime SampleTime::FromTest(const TimeStamp& aTime) {
25 MOZ_ASSERT(!aTime.IsNull());
26 return SampleTime(eTest, aTime);
29 bool SampleTime::IsNull() const { return mType == eNull; }
31 SampleTime::TimeType SampleTime::Type() const { return mType; }
33 const TimeStamp& SampleTime::Time() const { return mTime; }
35 bool SampleTime::operator==(const SampleTime& aOther) const {
36 return mTime == aOther.mTime;
39 bool SampleTime::operator!=(const SampleTime& aOther) const {
40 return !(*this == aOther);
43 bool SampleTime::operator<(const SampleTime& aOther) const {
44 return mTime < aOther.mTime;
47 bool SampleTime::operator<=(const SampleTime& aOther) const {
48 return mTime <= aOther.mTime;
51 bool SampleTime::operator>(const SampleTime& aOther) const {
52 return mTime > aOther.mTime;
55 bool SampleTime::operator>=(const SampleTime& aOther) const {
56 return mTime >= aOther.mTime;
59 SampleTime SampleTime::operator+(const TimeDuration& aDuration) const {
60 return SampleTime(mType, mTime + aDuration);
63 SampleTime SampleTime::operator-(const TimeDuration& aDuration) const {
64 return SampleTime(mType, mTime - aDuration);
67 TimeDuration SampleTime::operator-(const SampleTime& aOther) const {
68 return mTime - aOther.mTime;
71 SampleTime::SampleTime(TimeType aType, const TimeStamp& aTime)
72 : mType(aType), mTime(aTime) {}
74 } // namespace layers
75 } // namespace mozilla