2014-08-10 07:06:46 +00:00
|
|
|
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
|
|
|
/* 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_Animation_h
|
|
|
|
#define mozilla_dom_Animation_h
|
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
2014-08-10 07:06:49 +00:00
|
|
|
#include "mozilla/StyleAnimationValue.h"
|
2014-08-10 07:06:48 +00:00
|
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
#include "mozilla/dom/Nullable.h"
|
2014-08-10 07:06:49 +00:00
|
|
|
#include "nsSMILKeySpline.h"
|
|
|
|
#include "nsStyleStruct.h" // for nsTimingFunction
|
2014-08-10 07:06:46 +00:00
|
|
|
|
|
|
|
struct JSContext;
|
|
|
|
|
|
|
|
namespace mozilla {
|
2014-08-10 07:06:49 +00:00
|
|
|
|
|
|
|
class ComputedTimingFunction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef nsTimingFunction::Type Type;
|
|
|
|
void Init(const nsTimingFunction &aFunction);
|
|
|
|
double GetValue(double aPortion) const;
|
|
|
|
const nsSMILKeySpline* GetFunction() const {
|
|
|
|
NS_ASSERTION(mType == nsTimingFunction::Function, "Type mismatch");
|
|
|
|
return &mTimingFunction;
|
|
|
|
}
|
|
|
|
Type GetType() const { return mType; }
|
|
|
|
uint32_t GetSteps() const { return mSteps; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Type mType;
|
|
|
|
nsSMILKeySpline mTimingFunction;
|
|
|
|
uint32_t mSteps;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AnimationPropertySegment
|
|
|
|
{
|
|
|
|
float mFromKey, mToKey;
|
|
|
|
StyleAnimationValue mFromValue, mToValue;
|
|
|
|
ComputedTimingFunction mTimingFunction;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AnimationProperty
|
|
|
|
{
|
|
|
|
nsCSSProperty mProperty;
|
|
|
|
InfallibleTArray<AnimationPropertySegment> mSegments;
|
|
|
|
};
|
|
|
|
|
2014-08-10 07:06:46 +00:00
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class Animation MOZ_FINAL : public nsWrapperCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit Animation(nsIDocument* aDocument)
|
|
|
|
: mDocument(aDocument)
|
|
|
|
{
|
|
|
|
SetIsDOMBinding();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(Animation)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(Animation)
|
|
|
|
|
|
|
|
nsIDocument* GetParentObject() const { return mDocument; }
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
|
|
|
|
2014-08-10 07:06:48 +00:00
|
|
|
void SetParentTime(Nullable<TimeDuration> aParentTime);
|
|
|
|
|
2014-08-10 07:06:49 +00:00
|
|
|
bool HasAnimationOfProperty(nsCSSProperty aProperty) const;
|
|
|
|
const InfallibleTArray<AnimationProperty>& Properties() const {
|
|
|
|
return mProperties;
|
|
|
|
}
|
|
|
|
InfallibleTArray<AnimationProperty>& Properties() {
|
|
|
|
return mProperties;
|
|
|
|
}
|
|
|
|
|
2014-08-10 07:06:46 +00:00
|
|
|
protected:
|
|
|
|
virtual ~Animation() { }
|
|
|
|
|
|
|
|
// We use a document for a parent object since the other likely candidate,
|
|
|
|
// the target element, can be empty.
|
|
|
|
nsRefPtr<nsIDocument> mDocument;
|
2014-08-10 07:06:48 +00:00
|
|
|
Nullable<TimeDuration> mParentTime;
|
2014-08-10 07:06:49 +00:00
|
|
|
|
|
|
|
InfallibleTArray<AnimationProperty> mProperties;
|
2014-08-10 07:06:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_Animation_h
|