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
|
|
|
|
|
|
|
#ifndef MOZILLA_SVGMOTIONSMILANIMATIONFUNCTION_H_
|
|
|
|
#define MOZILLA_SVGMOTIONSMILANIMATIONFUNCTION_H_
|
|
|
|
|
2013-11-18 05:29:06 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsSMILAnimationFunction.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "SVGMotionSMILType.h" // for RotateType
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2012-01-26 13:57:21 +04:00
|
|
|
class nsAttrValue;
|
|
|
|
class nsIAtom;
|
|
|
|
class nsIContent;
|
|
|
|
class nsISMILAttr;
|
|
|
|
class nsSMILValue;
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
namespace dom {
|
|
|
|
class SVGMPathElement;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2013-01-05 05:50:22 +04:00
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// SVGMotionSMILAnimationFunction
|
|
|
|
//
|
|
|
|
// Subclass of nsSMILAnimationFunction to support a few extra features offered
|
|
|
|
// by the <animateMotion> element.
|
|
|
|
//
|
2015-03-21 19:28:04 +03:00
|
|
|
class SVGMotionSMILAnimationFunction final : public nsSMILAnimationFunction
|
2010-04-29 03:00:54 +04:00
|
|
|
{
|
2013-11-18 05:29:06 +04:00
|
|
|
typedef mozilla::gfx::Path Path;
|
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
public:
|
|
|
|
SVGMotionSMILAnimationFunction();
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool SetAttr(nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsresult* aParseResult = nullptr) override;
|
|
|
|
virtual bool UnsetAttr(nsIAtom* aAttribute) override;
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
// Method to allow our owner-element to signal us when our <mpath>
|
|
|
|
// has changed or been added/removed. When that happens, we need to
|
|
|
|
// mark ourselves as changed so we'll get recomposed, and mark our path data
|
|
|
|
// as stale so it'll get regenerated (regardless of mPathSourceType, since
|
|
|
|
// <mpath> trumps all the other sources of path data)
|
2011-10-17 18:59:28 +04:00
|
|
|
void MpathChanged() { mIsPathStale = mHasChanged = true; }
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
protected:
|
|
|
|
enum PathSourceType {
|
|
|
|
// NOTE: Ordering matters here. Higher-priority path-descriptors should
|
|
|
|
// have higher enumerated values
|
|
|
|
ePathSourceType_None, // uninitialized or not applicable
|
|
|
|
ePathSourceType_ByAttr, // by or from-by animation
|
|
|
|
ePathSourceType_ToAttr, // to or from-to animation
|
|
|
|
ePathSourceType_ValuesAttr,
|
|
|
|
ePathSourceType_PathAttr,
|
|
|
|
ePathSourceType_Mpath
|
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsSMILCalcMode GetCalcMode() const override;
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual nsresult GetValues(const nsISMILAttr& aSMILAttr,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsSMILValueArray& aResult) override;
|
|
|
|
virtual void CheckValueListDependentAttrs(uint32_t aNumValues) override;
|
2011-09-07 03:50:49 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsToAnimation() const override;
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
void CheckKeyPoints();
|
|
|
|
nsresult SetKeyPoints(const nsAString& aKeyPoints, nsAttrValue& aResult);
|
|
|
|
void UnsetKeyPoints();
|
2010-04-29 03:00:54 +04:00
|
|
|
nsresult SetRotate(const nsAString& aRotate, nsAttrValue& aResult);
|
|
|
|
void UnsetRotate();
|
|
|
|
|
|
|
|
// Helpers for GetValues
|
|
|
|
void MarkStaleIfAttributeAffectsPath(nsIAtom* aAttribute);
|
|
|
|
void RebuildPathAndVertices(const nsIContent* aContextElem);
|
2013-01-05 05:50:22 +04:00
|
|
|
void RebuildPathAndVerticesFromMpathElem(dom::SVGMPathElement* aMpathElem);
|
2010-04-29 03:00:54 +04:00
|
|
|
void RebuildPathAndVerticesFromPathAttr();
|
2010-04-29 03:00:54 +04:00
|
|
|
void RebuildPathAndVerticesFromBasicAttrs(const nsIContent* aContextElem);
|
2013-11-18 05:29:06 +04:00
|
|
|
bool GenerateValuesForPathAndPoints(Path* aPath,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsKeyPoints,
|
2013-11-25 23:46:20 +04:00
|
|
|
FallibleTArray<double>& aPointDistances,
|
|
|
|
nsSMILValueArray& aResult);
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
// Members
|
|
|
|
// -------
|
2013-11-25 23:46:20 +04:00
|
|
|
FallibleTArray<double> mKeyPoints; // parsed from "keyPoints" attribute.
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
RotateType mRotateType; // auto, auto-reverse, or explicit.
|
|
|
|
float mRotateAngle; // the angle value, if explicit.
|
|
|
|
|
2013-11-18 05:29:06 +04:00
|
|
|
PathSourceType mPathSourceType; // source of our Path.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Path> mPath; // representation of motion path.
|
2013-11-25 23:46:20 +04:00
|
|
|
FallibleTArray<double> mPathVertices; // distances of vertices along path.
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsPathStale;
|
2010-04-29 03:00:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // MOZILLA_SVGMOTIONSMILANIMATIONFUNCTION_H_
|