mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1112480 part 5 - Add AnimationTimeline::IsUnderTestControl; r=jwatt
Earlier in this patch series we added AnimationPlayer::StartOnNextTick which takes a ready time parameter expressed in timeline time. In order to call this method when painting finishes we need to convert the TimeStamp recorded when painting finished to a timeline time. However, when the timeline is driven by a refresh driver under test control we can no longer meaningfully do this conversion since there is no correspondence between the notion of time used to record the time when painting finished (wallclock time) and the notion of time used by the timeline (which has been arbitrarily adjusted by test code). We need a way to detect this situation so that we know not to call ToTimelineTime in that case. Alternatively, we could make ToTimelineTime automatically return a null value when its refresh driver is under test control. However, in this situation ToTimelineTime can still actually be used to convert a TimeStamp to a timeline time as long as the TimeStamp is from the same refresh driver. Indeed, GetCurrentTime does exactly that. So if we were to go down that route we would have to provide a way for GetCurrentTime to work around that restriction. For now, this patch puts the onus on the caller of ToTimelineTime to check if the timeline is under test control first (unless they are passing a TimeStamp from the same refresh driver, in which case there is no need to check).
This commit is contained in:
parent
c58bc94deb
commit
c6c61dd8ec
@ -12,9 +12,9 @@
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsRefreshDriver.h"
|
||||
|
||||
struct JSContext;
|
||||
class nsRefreshDriver;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -47,6 +47,11 @@ public:
|
||||
// script.
|
||||
Nullable<double> GetCurrentTimeAsDouble() const;
|
||||
|
||||
// Converts a TimeStamp to the equivalent value in timeline time.
|
||||
// Note that when IsUnderTestControl() is true, there is no correspondence
|
||||
// between timeline time and wallclock time. In such a case, passing a
|
||||
// timestamp from TimeStamp::Now() to this method will not return a
|
||||
// meaningful result.
|
||||
Nullable<TimeDuration> ToTimelineTime(const TimeStamp& aTimeStamp) const;
|
||||
TimeStamp ToTimeStamp(const TimeDuration& aTimelineTime) const;
|
||||
|
||||
@ -66,6 +71,16 @@ public:
|
||||
void FastForward(const TimeStamp& aTimeStamp);
|
||||
|
||||
nsRefreshDriver* GetRefreshDriver() const;
|
||||
// Returns true if this timeline is driven by a refresh driver that is
|
||||
// under test control. In such a case, there is no correspondence between
|
||||
// TimeStamp values returned by the refresh driver and wallclock time.
|
||||
// As a result, passing a value from TimeStamp::Now() to ToTimelineTime()
|
||||
// would not return a meaningful result.
|
||||
bool IsUnderTestControl() const
|
||||
{
|
||||
nsRefreshDriver* refreshDriver = GetRefreshDriver();
|
||||
return refreshDriver && refreshDriver->IsTestControllingRefreshesEnabled();
|
||||
}
|
||||
|
||||
protected:
|
||||
TimeStamp GetCurrentTimeStamp() const;
|
||||
|
Loading…
Reference in New Issue
Block a user