Bug 1674776 - Update DocumentTimeline::mLastRefreshDriverTime outside 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
This commit is contained in:
Hiroyuki Ikezoe 2020-12-14 23:55:06 +00:00
Родитель 33455e97a9
Коммит bc1eb2e0f6
4 изменённых файлов: 17 добавлений и 7 удалений

Просмотреть файл

@ -49,6 +49,8 @@ DocumentTimeline::DocumentTimeline(Document* aDocument,
if (mDocument) {
mDocument->Timelines().insertBack(this);
}
// Ensure mLastRefreshDriverTime is valid.
UpdateLastRefreshDriverTime();
}
DocumentTimeline::~DocumentTimeline() {
@ -97,11 +99,16 @@ 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();
// Always return the same object to benefit from return-value optimization.
TimeStamp result =
!refreshTime.IsNull() ? refreshTime : mLastRefreshDriverTime;
@ -125,8 +132,6 @@ TimeStamp DocumentTimeline::GetCurrentTimeStamp() const {
if (!refreshTime.IsNull()) {
mLastRefreshDriverTime = refreshTime;
}
return result;
}
Nullable<TimeDuration> DocumentTimeline::ToTimelineTime(

Просмотреть файл

@ -68,6 +68,8 @@ class DocumentTimeline final : public AnimationTimeline,
Document* GetDocument() const override { return mDocument; }
void UpdateLastRefreshDriverTime();
protected:
TimeStamp GetCurrentTimeStamp() const;
nsRefreshDriver* GetRefreshDriver() const;
@ -81,7 +83,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;

Просмотреть файл

@ -953,6 +953,12 @@ bool EffectCompositor::PreTraverseInSubtree(ServoTraversalFlags aFlags,
}
}
if (foundElementsNeedingRestyle) {
// Update the last refresh driver time in the timeline to avoid mutating it
// during parallel styling.
mPresContext->Document()->Timeline()->UpdateLastRefreshDriverTime();
}
return foundElementsNeedingRestyle;
}

Просмотреть файл

@ -266,9 +266,6 @@ extern "C" const char* __tsan_default_suppressions() {
"race:VRShMem::PullSystemState\n"
"race:VRShMem::PushSystemState\n"
// Bug 1674776
"race:DocumentTimeline::GetCurrentTimeAsDuration\n"
// Bug 1674835
"race:nsHttpTransaction::ReadSegments\n"
"race:nsHttpTransaction::SecurityInfo\n"