Bug 1771337 [wpt PR 34217] - Convert `popup=popup` to `popup=auto` or just `popup...
[gecko.git] / dom / performance / PerformancePaintTiming.cpp
blobeb13be95f994b9e9e43ab816d84f5b31acd63a30
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->IsSystemPrincipal(),
45 mPerformance->CrossOriginIsolated()));
47 return mCachedStartTime.value();
50 size_t PerformancePaintTiming::SizeOfIncludingThis(
51 mozilla::MallocSizeOf aMallocSizeOf) const {
52 return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);