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: */
|
2012-05-21 15:12:37 +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/. */
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
/* implementation of nsISMILType for use by <animateMotion> element */
|
|
|
|
|
|
|
|
#ifndef MOZILLA_SVGMOTIONSMILTYPE_H_
|
|
|
|
#define MOZILLA_SVGMOTIONSMILTYPE_H_
|
|
|
|
|
2013-11-18 05:29:06 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsISMILType.h"
|
|
|
|
|
|
|
|
class nsSMILValue;
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MotionRotateType: Enum to indicate the type of our "rotate" attribute.
|
|
|
|
*/
|
|
|
|
enum RotateType {
|
|
|
|
eRotateType_Explicit, // for e.g. rotate="45"/"45deg"/"0.785rad"
|
|
|
|
eRotateType_Auto, // for rotate="auto"
|
|
|
|
eRotateType_AutoReverse // for rotate="auto-reverse"
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SVGMotionSMILType: Implements the nsISMILType interface for SMIL animations
|
|
|
|
* from <animateMotion>.
|
|
|
|
*
|
|
|
|
* NOTE: Even though there's technically no "motion" attribute, we behave in
|
|
|
|
* many ways as if there were, for simplicity.
|
|
|
|
*/
|
|
|
|
class SVGMotionSMILType : public nsISMILType
|
|
|
|
{
|
2013-11-18 05:29:06 +04:00
|
|
|
typedef mozilla::gfx::Path Path;
|
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
public:
|
|
|
|
// Singleton for nsSMILValue objects to hold onto.
|
|
|
|
static SVGMotionSMILType sSingleton;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// nsISMILType Methods
|
|
|
|
// -------------------
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Init(nsSMILValue& aValue) const override;
|
|
|
|
virtual void Destroy(nsSMILValue& aValue) const override;
|
|
|
|
virtual nsresult Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const override;
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool IsEqual(const nsSMILValue& aLeft,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsSMILValue& aRight) const override;
|
2010-04-29 03:00:54 +04:00
|
|
|
virtual nsresult Add(nsSMILValue& aDest,
|
|
|
|
const nsSMILValue& aValueToAdd,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aCount) const override;
|
2010-04-29 03:00:54 +04:00
|
|
|
virtual nsresult SandwichAdd(nsSMILValue& aDest,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsSMILValue& aValueToAdd) const override;
|
2010-04-29 03:00:54 +04:00
|
|
|
virtual nsresult ComputeDistance(const nsSMILValue& aFrom,
|
|
|
|
const nsSMILValue& aTo,
|
2015-03-21 19:28:04 +03:00
|
|
|
double& aDistance) const override;
|
2010-04-29 03:00:54 +04:00
|
|
|
virtual nsresult Interpolate(const nsSMILValue& aStartVal,
|
|
|
|
const nsSMILValue& aEndVal,
|
|
|
|
double aUnitDistance,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsSMILValue& aResult) const override;
|
2010-04-29 03:00:54 +04:00
|
|
|
public:
|
|
|
|
// Used to generate a transform matrix from an <animateMotion> nsSMILValue.
|
2014-01-21 01:52:04 +04:00
|
|
|
static gfx::Matrix CreateMatrix(const nsSMILValue& aSMILVal);
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
// Used to generate a nsSMILValue for the point at the given distance along
|
|
|
|
// the given path.
|
2013-11-18 05:29:06 +04:00
|
|
|
static nsSMILValue ConstructSMILValue(Path* aPath,
|
2010-04-29 03:00:54 +04:00
|
|
|
float aDist,
|
|
|
|
RotateType aRotateType,
|
|
|
|
float aRotateAngle);
|
|
|
|
|
|
|
|
private:
|
2013-08-12 18:13:34 +04:00
|
|
|
// Private constructor: prevent instances beyond my singleton.
|
2016-07-09 00:39:53 +03:00
|
|
|
constexpr SVGMotionSMILType() {}
|
2010-04-29 03:00:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // MOZILLA_SVGMOTIONSMILTYPE_H_
|