PerformancePaintTiming.h (1858B)
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/. */ 6 7 #ifndef mozilla_dom_PerformancePaintTiming_h___ 8 #define mozilla_dom_PerformancePaintTiming_h___ 9 10 #include "mozilla/dom/PerformanceEntry.h" 11 #include "mozilla/dom/PerformancePaintTimingBinding.h" 12 13 namespace mozilla::dom { 14 15 class Performance; 16 17 // https://w3c.github.io/paint-timing/#sec-PerformancePaintTiming 18 // Unlike timeToContentfulPaint, this timing is generated during 19 // displaylist building, when a frame is contentful, we collect 20 // the timestamp. Whereas, timeToContentfulPaint uses a compositor-side 21 // timestamp. 22 class PerformancePaintTiming final : public PerformanceEntry { 23 public: 24 PerformancePaintTiming(Performance* aPerformance, const nsAString& aName, 25 const TimeStamp& aStartTime); 26 27 NS_DECL_ISUPPORTS_INHERITED 28 29 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PerformancePaintTiming, 30 PerformanceEntry) 31 32 JSObject* WrapObject(JSContext* aCx, 33 JS::Handle<JSObject*> aGivenProto) override; 34 35 DOMHighResTimeStamp StartTime() const override; 36 DOMHighResTimeStamp PaintTime() const { return StartTime(); } 37 Nullable<DOMHighResTimeStamp> GetPresentationTime() const { return nullptr; } 38 39 size_t SizeOfIncludingThis( 40 mozilla::MallocSizeOf aMallocSizeOf) const override; 41 42 private: 43 ~PerformancePaintTiming(); 44 RefPtr<Performance> mPerformance; 45 46 const TimeStamp mRawStartTime; 47 mutable Maybe<DOMHighResTimeStamp> mCachedStartTime; 48 }; 49 50 } // namespace mozilla::dom 51 52 #endif /* mozilla_dom_PerformanacePaintTiming_h___ */