tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit ce3e1fa55d6b309f327655f9d047e811cd76c0c7
parent bc732e77b57e7512a01f80664eb18f553633982b
Author: Nazım Can Altınova <canaltinova@gmail.com>
Date:   Wed, 19 Nov 2025 14:36:01 +0000

Bug 2000426 - Round the event timing duration while it's being requested r=smaug

This patch is not strictly necessary after the previous patch, but I
believe that this is the right thing to do. RawDuration method should
return the non-rounded version always for us to use in other
computations, and we should round it only when we need to return it
to the user.

Differential Revision: https://phabricator.services.mozilla.com/D273026

Diffstat:
Mdom/performance/PerformanceEventTiming.h | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/dom/performance/PerformanceEventTiming.h b/dom/performance/PerformanceEventTiming.h @@ -73,9 +73,7 @@ class PerformanceEventTiming final nsINode* GetTarget() const; void SetDuration(const DOMHighResTimeStamp aDuration) { - // Round the duration to the nearest 8ms. - // https://w3c.github.io/event-timing/#set-event-timing-entry-duration - mDuration = Some(std::round(aDuration / 8) * 8); + mDuration = Some(aDuration); } // nsRFPService::ReduceTimePrecisionAsMSecs might causes @@ -85,8 +83,12 @@ class PerformanceEventTiming final DOMHighResTimeStamp Duration() const override { if (mCachedDuration.isNothing()) { + // Round the duration to the nearest 8ms. + // https://w3c.github.io/event-timing/#set-event-timing-entry-duration + DOMHighResTimeStamp roundedDuration = + std::round(mDuration.valueOr(0) / 8) * 8; mCachedDuration.emplace(nsRFPService::ReduceTimePrecisionAsMSecs( - mDuration.valueOr(0), mPerformance->GetRandomTimelineSeed(), + roundedDuration, mPerformance->GetRandomTimelineSeed(), mPerformance->GetRTPCallerType())); } return mCachedDuration.value();