2011-09-26 01:04:31 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
|
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/. */
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
#ifndef MOZILLA_SVGANIMATEDTRANSFORMLIST_H__
|
|
|
|
#define MOZILLA_SVGANIMATEDTRANSFORMLIST_H__
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-09-26 01:04:31 +04:00
|
|
|
#include "nsAutoPtr.h"
|
2013-03-20 07:20:38 +04:00
|
|
|
#include "nsISMILAttr.h"
|
|
|
|
#include "SVGTransformList.h"
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
class nsIAtom;
|
|
|
|
class nsSMILValue;
|
|
|
|
class nsSVGElement;
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
namespace mozilla {
|
2013-03-20 06:31:44 +04:00
|
|
|
|
|
|
|
namespace dom {
|
2013-03-20 07:20:38 +04:00
|
|
|
class SVGAnimationElement;
|
2013-04-02 23:17:41 +04:00
|
|
|
class SVGTransform;
|
2013-03-20 07:20:38 +04:00
|
|
|
}
|
2011-09-26 01:04:31 +04:00
|
|
|
|
|
|
|
/**
|
2013-04-15 02:56:34 +04:00
|
|
|
* Class nsSVGAnimatedTransformList
|
2011-09-26 01:04:31 +04:00
|
|
|
*
|
2013-03-20 07:20:38 +04:00
|
|
|
* This class is very different to the SVG DOM interface of the same name found
|
|
|
|
* in the SVG specification. This is a lightweight internal class - see
|
2013-04-15 02:56:34 +04:00
|
|
|
* SVGAnimatedTransformList for the heavier DOM class that wraps instances of
|
2013-03-20 07:20:38 +04:00
|
|
|
* this class and implements the SVG specification's SVGAnimatedTransformList
|
|
|
|
* DOM interface.
|
2011-09-26 01:04:31 +04:00
|
|
|
*
|
2013-03-20 07:20:38 +04:00
|
|
|
* Except where noted otherwise, this class' methods take care of keeping the
|
|
|
|
* appropriate DOM wrappers in sync (see the comment in
|
2013-04-15 02:56:34 +04:00
|
|
|
* SVGAnimatedTransformList::InternalBaseValListWillChangeTo) so that their
|
2013-03-20 07:20:38 +04:00
|
|
|
* consumers don't need to concern themselves with that.
|
2011-09-26 01:04:31 +04:00
|
|
|
*/
|
2013-04-15 02:56:34 +04:00
|
|
|
class nsSVGAnimatedTransformList
|
2011-09-26 01:04:31 +04:00
|
|
|
{
|
2013-03-20 07:20:38 +04:00
|
|
|
// friends so that they can get write access to mBaseVal
|
2013-04-02 23:17:41 +04:00
|
|
|
friend class dom::SVGTransform;
|
2011-09-26 01:04:31 +04:00
|
|
|
friend class DOMSVGTransformList;
|
|
|
|
|
|
|
|
public:
|
2013-04-15 02:56:34 +04:00
|
|
|
nsSVGAnimatedTransformList() : mIsAttrSet(false) { }
|
2011-09-26 01:04:31 +04:00
|
|
|
|
|
|
|
/**
|
2013-03-20 07:20:38 +04:00
|
|
|
* Because it's so important that mBaseVal and its DOMSVGTransformList wrapper
|
|
|
|
* (if any) be kept in sync (see the comment in
|
2013-04-15 02:56:34 +04:00
|
|
|
* SVGAnimatedTransformList::InternalBaseValListWillChangeTo), this method
|
2013-03-20 07:20:38 +04:00
|
|
|
* returns a const reference. Only our friend classes may get mutable
|
|
|
|
* references to mBaseVal.
|
2011-09-26 01:04:31 +04:00
|
|
|
*/
|
2013-03-20 07:20:38 +04:00
|
|
|
const SVGTransformList& GetBaseValue() const {
|
|
|
|
return mBaseVal;
|
|
|
|
}
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2013-05-05 11:20:25 +04:00
|
|
|
nsresult SetBaseValue(const SVGTransformList& aValue);
|
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
nsresult SetBaseValueString(const nsAString& aValue);
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
void ClearBaseValue();
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
const SVGTransformList& GetAnimValue() const {
|
|
|
|
return mAnimVal ? *mAnimVal : mBaseVal;
|
|
|
|
}
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
nsresult SetAnimValue(const SVGTransformList& aNewAnimValue,
|
|
|
|
nsSVGElement *aElement);
|
2012-12-23 08:54:20 +04:00
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
void ClearAnimValue(nsSVGElement *aElement);
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2013-04-14 11:17:36 +04:00
|
|
|
/**
|
|
|
|
* Returns true if the corresponding transform attribute is set (or animated)
|
|
|
|
* to a valid value. Unlike HasTransform it will return true for an empty
|
|
|
|
* transform.
|
|
|
|
*/
|
2013-03-20 07:20:38 +04:00
|
|
|
bool IsExplicitlySet() const;
|
|
|
|
|
2013-04-14 11:17:36 +04:00
|
|
|
/**
|
|
|
|
* Returns true if the corresponding transform attribute is set (or animated)
|
|
|
|
* to a valid value, such that we have at least one transform in our list.
|
|
|
|
* Returns false otherwise (e.g. if the transform attribute is missing or empty
|
|
|
|
* or invalid).
|
|
|
|
*/
|
|
|
|
bool HasTransform() const
|
|
|
|
{ return (mAnimVal && !mAnimVal->IsEmpty()) || !mBaseVal.IsEmpty(); }
|
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
bool IsAnimating() const {
|
|
|
|
return !!mAnimVal;
|
2012-12-23 08:54:20 +04:00
|
|
|
}
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
/// Callers own the returned nsISMILAttr
|
|
|
|
nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement);
|
|
|
|
|
|
|
|
private:
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
// mAnimVal is a pointer to allow us to determine if we're being animated or
|
|
|
|
// not. Making it a non-pointer member and using mAnimVal.IsEmpty() to check
|
|
|
|
// if we're animating is not an option, since that would break animation *to*
|
|
|
|
// the empty string (<set to="">).
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
SVGTransformList mBaseVal;
|
|
|
|
nsAutoPtr<SVGTransformList> mAnimVal;
|
|
|
|
bool mIsAttrSet;
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
struct SMILAnimatedTransformList : public nsISMILAttr
|
|
|
|
{
|
|
|
|
public:
|
2013-04-15 02:56:34 +04:00
|
|
|
SMILAnimatedTransformList(nsSVGAnimatedTransformList* aVal,
|
2013-03-20 07:20:38 +04:00
|
|
|
nsSVGElement* aSVGElement)
|
|
|
|
: mVal(aVal)
|
|
|
|
, mElement(aSVGElement)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// nsISMILAttr methods
|
|
|
|
virtual nsresult ValueFromString(const nsAString& aStr,
|
|
|
|
const dom::SVGAnimationElement* aSrcElement,
|
|
|
|
nsSMILValue& aValue,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool& aPreventCachingOfSandwich) const override;
|
|
|
|
virtual nsSMILValue GetBaseValue() const override;
|
|
|
|
virtual void ClearAnimValue() override;
|
|
|
|
virtual nsresult SetAnimValue(const nsSMILValue& aValue) override;
|
2013-03-20 07:20:38 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void ParseValue(const nsAString& aSpec,
|
|
|
|
const nsIAtom* aTransformType,
|
|
|
|
nsSMILValue& aResult);
|
|
|
|
static int32_t ParseParameterList(const nsAString& aSpec, float* aVars,
|
|
|
|
int32_t aNVars);
|
|
|
|
|
|
|
|
// These will stay alive because a nsISMILAttr only lives as long
|
|
|
|
// as the Compositing step, and DOM elements don't get a chance to
|
|
|
|
// die during that.
|
2013-04-15 02:56:34 +04:00
|
|
|
nsSVGAnimatedTransformList* mVal;
|
2013-03-20 07:20:38 +04:00
|
|
|
nsSVGElement* mElement;
|
|
|
|
};
|
2011-09-26 01:04:31 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
#endif // MOZILLA_SVGANIMATEDTRANSFORMLIST_H__
|