Skip to content

Commit

Permalink
Bug 1674776 - Update DocumentTimeline::mLastRefreshDriverTime outside…
Browse files Browse the repository at this point in the history
… parallel styling. r=boris,decoder

Note that we can probably use mLastRefreshDriverTime directly in
DocumentTimeline::GetCurrentTimeStamp(), i.e. we don't need to use the refresh
driver there, but I'd preserve the current behavior.

Differential Revision: https://phabricator.services.mozilla.com/D97823
  • Loading branch information
hiikezoe committed Mar 28, 2022
1 parent 47637cd commit a04b6f2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
11 changes: 9 additions & 2 deletions dom/animation/DocumentTimeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ DocumentTimeline::DocumentTimeline(Document* aDocument,
if (mDocument) {
mDocument->Timelines().insertBack(this);
}
// Ensure mLastRefreshDriverTime is valid.
UpdateLastRefreshDriverTime();
}

DocumentTimeline::~DocumentTimeline() {
Expand Down Expand Up @@ -97,6 +99,12 @@ bool DocumentTimeline::TracksWallclockTime() const {
}

TimeStamp DocumentTimeline::GetCurrentTimeStamp() const {
nsRefreshDriver* refreshDriver = GetRefreshDriver();
return refreshDriver ? refreshDriver->MostRecentRefresh()
: mLastRefreshDriverTime;
}

void DocumentTimeline::UpdateLastRefreshDriverTime() {
nsRefreshDriver* refreshDriver = GetRefreshDriver();
TimeStamp refreshTime =
refreshDriver ? refreshDriver->MostRecentRefresh() : TimeStamp();
Expand Down Expand Up @@ -125,8 +133,6 @@ TimeStamp DocumentTimeline::GetCurrentTimeStamp() const {
if (!refreshTime.IsNull()) {
mLastRefreshDriverTime = refreshTime;
}

return result;
}

Nullable<TimeDuration> DocumentTimeline::ToTimelineTime(
Expand Down Expand Up @@ -182,6 +188,7 @@ void DocumentTimeline::MostRecentRefreshTimeUpdated() {
}

void DocumentTimeline::WillRefresh(mozilla::TimeStamp aTime) {
UpdateLastRefreshDriverTime();
MostRecentRefreshTimeUpdated();
}

Expand Down
4 changes: 3 additions & 1 deletion dom/animation/DocumentTimeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class DocumentTimeline final : public AnimationTimeline,

Document* GetDocument() const override { return mDocument; }

void UpdateLastRefreshDriverTime();

bool IsMonotonicallyIncreasing() const override { return true; }

protected:
Expand All @@ -83,7 +85,7 @@ class DocumentTimeline final : public AnimationTimeline,
// The most recently used refresh driver time. This is used in cases where
// we don't have a refresh driver (e.g. because we are in a display:none
// iframe).
mutable TimeStamp mLastRefreshDriverTime;
TimeStamp mLastRefreshDriverTime;
bool mIsObservingRefreshDriver;

TimeDuration mOriginTime;
Expand Down
7 changes: 7 additions & 0 deletions dom/base/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13236,6 +13236,13 @@ void Document::SetNavigationTiming(nsDOMNavigationTiming* aTiming) {
if (!mLoadingTimeStamp.IsNull() && mTiming) {
mTiming->SetDOMLoadingTimeStamp(GetDocumentURI(), mLoadingTimeStamp);
}

// If there's already the DocumentTimeline instance, tell it since the
// DocumentTimeline is based on both the navigation start time stamp and the
// refresh driver timestamp.
if (mDocumentTimeline) {
mDocumentTimeline->UpdateLastRefreshDriverTime();
}
}

nsContentList* Document::ImageMapList() {
Expand Down
3 changes: 0 additions & 3 deletions mozglue/build/TsanOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ extern "C" const char* __tsan_default_suppressions() {
"race:VRShMem::PullBrowserState\n"
"race:VRShMem::PushBrowserState\n"

// Bug 1674776
"race:DocumentTimeline::GetCurrentTimeAsDuration\n"

// Bug 1607588
"race:nssToken_Destroy\n"
"race:nssSlot_GetToken\n"
Expand Down

0 comments on commit a04b6f2

Please sign in to comment.