Bug 1963464 - Initial implementation of PaintTimingMixin for the PaintTiming and LCP entries r=sefeng,webidl

This patch implements PaintTimingMixin with only the `paintTime`, without the
`presentationTime`. The presentationTime property is nullable in the spec and
the browsers might choose to not implement it. We would like to implement it
in the future, but we will do that as a follow-up.

Differential Revision: https://phabricator.services.mozilla.com/D247305
This commit is contained in:
Nazım Can Altınova
2025-05-02 15:43:28 +00:00
committed by canaltinova@gmail.com
parent e57af4a3ae
commit f6513849ba
6 changed files with 25 additions and 0 deletions

View File

@@ -90,6 +90,8 @@ class LargestContentfulPaint final : public PerformanceEntry {
DOMHighResTimeStamp RenderTime() const; DOMHighResTimeStamp RenderTime() const;
DOMHighResTimeStamp LoadTime() const; DOMHighResTimeStamp LoadTime() const;
DOMHighResTimeStamp StartTime() const override; DOMHighResTimeStamp StartTime() const override;
DOMHighResTimeStamp PaintTime() const { return RenderTime(); }
Nullable<DOMHighResTimeStamp> GetPresentationTime() const { return nullptr; }
unsigned long Size() const { return mSize; } unsigned long Size() const { return mSize; }
void GetId(nsAString& aId) const { void GetId(nsAString& aId) const {

View File

@@ -33,6 +33,8 @@ class PerformancePaintTiming final : public PerformanceEntry {
JS::Handle<JSObject*> aGivenProto) override; JS::Handle<JSObject*> aGivenProto) override;
DOMHighResTimeStamp StartTime() const override; DOMHighResTimeStamp StartTime() const override;
DOMHighResTimeStamp PaintTime() const { return StartTime(); }
Nullable<DOMHighResTimeStamp> GetPresentationTime() const { return nullptr; }
size_t SizeOfIncludingThis( size_t SizeOfIncludingThis(
mozilla::MallocSizeOf aMallocSizeOf) const override; mozilla::MallocSizeOf aMallocSizeOf) const override;

View File

@@ -0,0 +1,16 @@
/* -*- Mode: IDL; 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/.
*
* The origin of this IDL file is
* https://w3c.github.io/paint-timing/#sec-PaintTimingMixin
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface mixin PaintTimingMixin {
readonly attribute DOMHighResTimeStamp paintTime;
readonly attribute DOMHighResTimeStamp? presentationTime;
};

View File

@@ -21,3 +21,5 @@ interface LargestContentfulPaint : PerformanceEntry {
readonly attribute Element? element; readonly attribute Element? element;
[Default] object toJSON(); [Default] object toJSON();
}; };
LargestContentfulPaint includes PaintTimingMixin;

View File

@@ -14,3 +14,5 @@
interface PerformancePaintTiming : PerformanceEntry interface PerformancePaintTiming : PerformanceEntry
{ {
}; };
PerformancePaintTiming includes PaintTimingMixin;

View File

@@ -801,6 +801,7 @@ WEBIDL_FILES = [
"OscillatorNode.webidl", "OscillatorNode.webidl",
"PaintRequest.webidl", "PaintRequest.webidl",
"PaintRequestList.webidl", "PaintRequestList.webidl",
"PaintTimingMixin.webidl",
"PaintWorkletGlobalScope.webidl", "PaintWorkletGlobalScope.webidl",
"PannerNode.webidl", "PannerNode.webidl",
"ParentNode.webidl", "ParentNode.webidl",