2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-05-13 11:22:12 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_AnimationTimeline_h
|
|
|
|
#define mozilla_dom_AnimationTimeline_h
|
|
|
|
|
2015-04-10 04:34:22 +03:00
|
|
|
#include "nsISupports.h"
|
2014-05-13 11:22:12 +04:00
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2015-04-28 10:41:09 +03:00
|
|
|
#include "js/TypeDecls.h"
|
2015-04-10 04:34:22 +03:00
|
|
|
#include "mozilla/AnimationUtils.h"
|
2014-05-13 11:22:12 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2015-04-28 10:41:09 +03:00
|
|
|
#include "nsHashKeys.h"
|
2015-01-26 20:08:51 +03:00
|
|
|
#include "nsIGlobalObject.h"
|
2015-04-28 10:41:09 +03:00
|
|
|
#include "nsTHashtable.h"
|
2014-05-13 11:22:12 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-07-11 03:49:32 +03:00
|
|
|
class Animation;
|
|
|
|
|
2015-04-10 04:34:22 +03:00
|
|
|
class AnimationTimeline
|
|
|
|
: public nsISupports
|
|
|
|
, public nsWrapperCache
|
2014-05-13 11:22:12 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-04-10 04:34:22 +03:00
|
|
|
explicit AnimationTimeline(nsIGlobalObject* aWindow)
|
|
|
|
: mWindow(aWindow)
|
2014-05-13 11:22:12 +04:00
|
|
|
{
|
2015-01-26 20:08:51 +03:00
|
|
|
MOZ_ASSERT(mWindow);
|
2014-05-13 11:22:12 +04:00
|
|
|
}
|
|
|
|
|
2014-12-18 02:42:41 +03:00
|
|
|
protected:
|
|
|
|
virtual ~AnimationTimeline() { }
|
|
|
|
|
|
|
|
public:
|
2015-04-10 04:34:22 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AnimationTimeline)
|
2014-05-13 11:22:12 +04:00
|
|
|
|
2015-04-10 04:34:22 +03:00
|
|
|
nsIGlobalObject* GetParentObject() const { return mWindow; }
|
2014-05-13 11:22:12 +04:00
|
|
|
|
2015-06-15 05:05:43 +03:00
|
|
|
typedef nsTArray<nsRefPtr<Animation>> AnimationSequence;
|
|
|
|
|
2014-10-20 08:55:45 +04:00
|
|
|
// AnimationTimeline methods
|
2015-04-10 04:34:22 +03:00
|
|
|
virtual Nullable<TimeDuration> GetCurrentTime() const = 0;
|
2015-06-15 05:05:43 +03:00
|
|
|
void GetAnimations(AnimationSequence& aAnimations);
|
2014-05-13 11:22:12 +04:00
|
|
|
|
2014-10-20 08:55:45 +04:00
|
|
|
// Wrapper functions for AnimationTimeline DOM methods when called from
|
|
|
|
// script.
|
2015-04-10 04:34:22 +03:00
|
|
|
Nullable<double> GetCurrentTimeAsDouble() const {
|
|
|
|
return AnimationUtils::TimeDurationToDouble(GetCurrentTime());
|
2015-01-09 01:57:58 +03:00
|
|
|
}
|
2014-12-22 03:35:42 +03:00
|
|
|
|
2015-04-28 05:17:10 +03:00
|
|
|
/**
|
|
|
|
* Returns true if the times returned by GetCurrentTime() are convertible
|
|
|
|
* to and from wallclock-based TimeStamp (e.g. from TimeStamp::Now()) values
|
|
|
|
* using ToTimelineTime() and ToTimeStamp().
|
|
|
|
*
|
|
|
|
* Typically this is true, but it will be false in the case when this
|
|
|
|
* timeline has no refresh driver or is tied to a refresh driver under test
|
|
|
|
* control.
|
|
|
|
*/
|
|
|
|
virtual bool TracksWallclockTime() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a TimeStamp to the equivalent value in timeline time.
|
|
|
|
* Note that when TracksWallclockTime() is false, 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.
|
|
|
|
*/
|
|
|
|
virtual Nullable<TimeDuration> ToTimelineTime(const TimeStamp&
|
|
|
|
aTimeStamp) const = 0;
|
|
|
|
|
|
|
|
virtual TimeStamp ToTimeStamp(const TimeDuration& aTimelineTime) const = 0;
|
|
|
|
|
2015-04-28 10:41:09 +03:00
|
|
|
void AddAnimation(Animation& aAnimation);
|
|
|
|
void RemoveAnimation(Animation& aAnimation);
|
|
|
|
|
2014-08-30 10:11:57 +04:00
|
|
|
protected:
|
2015-01-26 20:08:51 +03:00
|
|
|
nsCOMPtr<nsIGlobalObject> mWindow;
|
2015-04-28 10:41:09 +03:00
|
|
|
|
|
|
|
// Animations observing this timeline
|
|
|
|
typedef nsTHashtable<nsRefPtrHashKey<dom::Animation>> AnimationSet;
|
|
|
|
AnimationSet mAnimations;
|
2014-05-13 11:22:12 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_AnimationTimeline_h
|