Bug 1443943 Do not clamp/jitter event timestamps if it's a system principal r=baku

MozReview-Commit-ID: KvVJpvu4elN

--HG--
extra : rebase_source : fb2369944951ed9fbe9da6b6633b5dcf7f335449
This commit is contained in:
Tom Ritter 2018-03-09 10:00:23 -06:00
Родитель 6d43fef7f0
Коммит d6e36d7aab
2 изменённых файлов: 17 добавлений и 11 удалений

25
dom/events/Event.cpp Normal file → Executable file
Просмотреть файл

@ -1095,10 +1095,14 @@ Event::DefaultPrevented(CallerType aCallerType) const
}
double
Event::TimeStampImpl() const
Event::TimeStamp()
{
if (!sReturnHighResTimeStamp) {
return static_cast<double>(mEvent->mTime);
// In the situation where you have set a very old, not-very-supported
// non-default preference, we will always reduce the precision,
// regardless of system principal or not.
double ret = static_cast<double>(mEvent->mTime);
return nsRFPService::ReduceTimePrecisionAsMSecs(ret);
}
if (mEvent->mTimeStamp.IsNull()) {
@ -1120,19 +1124,22 @@ Event::TimeStampImpl() const
return 0.0;
}
return perf->GetDOMTiming()->TimeStampToDOMHighRes(mEvent->mTimeStamp);
double ret = perf->GetDOMTiming()->TimeStampToDOMHighRes(mEvent->mTimeStamp);
MOZ_ASSERT(mOwner->PrincipalOrNull());
if (nsContentUtils::IsSystemPrincipal(mOwner->PrincipalOrNull()))
return ret;
return nsRFPService::ReduceTimePrecisionAsMSecs(ret);
}
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
return workerPrivate->TimeStampToDOMHighRes(mEvent->mTimeStamp);
}
double ret = workerPrivate->TimeStampToDOMHighRes(mEvent->mTimeStamp);
if (workerPrivate->UsesSystemPrincipal())
return ret;
double
Event::TimeStamp() const
{
return nsRFPService::ReduceTimePrecisionAsMSecs(TimeStampImpl());
return nsRFPService::ReduceTimePrecisionAsMSecs(ret);
}
NS_IMETHODIMP

3
dom/events/Event.h Normal file → Executable file
Просмотреть файл

@ -65,7 +65,6 @@ private:
void ConstructorInit(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent);
double TimeStampImpl() const;
public:
static Event* FromSupports(nsISupports* aSupports)
@ -255,7 +254,7 @@ public:
return mEvent->mFlags.mIsSynthesizedForTests;
}
double TimeStamp() const;
double TimeStamp();
EventTarget* GetOriginalTarget() const;
EventTarget* GetExplicitOriginalTarget() const;