Bug 1892041 - Part 1: Update test262 features. r=spidermonkey-reviewers,dminor
[gecko.git] / dom / performance / PerformancePaintTiming.cpp
blob83eed065659f41a11a1e8b2759cfb7e709dc9a02
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 "PerformancePaintTiming.h"
8 #include "Performance.h"
9 #include "MainThreadUtils.h"
10 #include "mozilla/dom/PerformanceMeasureBinding.h"
11 #include "nsRFPService.h"
13 using namespace mozilla::dom;
15 NS_IMPL_CYCLE_COLLECTION_INHERITED(PerformancePaintTiming, PerformanceEntry,
16 mPerformance)
18 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PerformancePaintTiming)
19 NS_INTERFACE_MAP_END_INHERITING(PerformanceEntry)
21 NS_IMPL_ADDREF_INHERITED(PerformancePaintTiming, PerformanceEntry)
22 NS_IMPL_RELEASE_INHERITED(PerformancePaintTiming, PerformanceEntry)
24 PerformancePaintTiming::PerformancePaintTiming(Performance* aPerformance,
25 const nsAString& aName,
26 const TimeStamp& aStartTime)
27 : PerformanceEntry(aPerformance->GetParentObject(), aName, u"paint"_ns),
28 mPerformance(aPerformance),
29 mRawStartTime(aStartTime) {}
31 PerformancePaintTiming::~PerformancePaintTiming() = default;
33 JSObject* PerformancePaintTiming::WrapObject(
34 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
35 return PerformancePaintTiming_Binding::Wrap(aCx, this, aGivenProto);
38 DOMHighResTimeStamp PerformancePaintTiming::StartTime() const {
39 if (mCachedStartTime.isNothing()) {
40 DOMHighResTimeStamp rawValue =
41 mPerformance->GetDOMTiming()->TimeStampToDOMHighRes(mRawStartTime);
42 mCachedStartTime.emplace(nsRFPService::ReduceTimePrecisionAsMSecs(
43 rawValue, mPerformance->GetRandomTimelineSeed(),
44 mPerformance->GetRTPCallerType()));
46 return mCachedStartTime.value();
49 size_t PerformancePaintTiming::SizeOfIncludingThis(
50 mozilla::MallocSizeOf aMallocSizeOf) const {
51 return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);