2011-07-01 00:19:52 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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-07-01 00:19:52 -07:00
|
|
|
|
|
|
|
#ifndef __NS_SVGINTEGERPAIR_H__
|
|
|
|
#define __NS_SVGINTEGERPAIR_H__
|
|
|
|
|
2012-01-26 01:57:21 -08:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsISMILAttr.h"
|
2011-07-01 00:19:52 -07:00
|
|
|
#include "nsSVGElement.h"
|
2012-06-18 19:30:09 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-07-01 00:02:56 -07:00
|
|
|
#include "mozilla/dom/SVGAnimatedInteger.h"
|
2011-07-01 00:19:52 -07:00
|
|
|
|
|
|
|
class nsSMILValue;
|
|
|
|
|
2013-03-18 20:18:45 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class SVGAnimationElement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-01 00:19:52 -07:00
|
|
|
class nsSVGIntegerPair
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum PairIndex {
|
|
|
|
eFirst,
|
|
|
|
eSecond
|
|
|
|
};
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void Init(uint8_t aAttrEnum = 0xff, int32_t aValue1 = 0, int32_t aValue2 = 0) {
|
2011-07-01 00:19:52 -07:00
|
|
|
mAnimVal[0] = mBaseVal[0] = aValue1;
|
|
|
|
mAnimVal[1] = mBaseVal[1] = aValue2;
|
|
|
|
mAttrEnum = aAttrEnum;
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsAnimated = false;
|
|
|
|
mIsBaseSet = false;
|
2011-07-01 00:19:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult SetBaseValueString(const nsAString& aValue,
|
2011-10-09 08:25:07 -07:00
|
|
|
nsSVGElement *aSVGElement);
|
2012-02-15 15:40:45 -08:00
|
|
|
void GetBaseValueString(nsAString& aValue) const;
|
2011-07-01 00:19:52 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetBaseValue(int32_t aValue, PairIndex aIndex, nsSVGElement *aSVGElement);
|
|
|
|
void SetBaseValues(int32_t aValue1, int32_t aValue2, nsSVGElement *aSVGElement);
|
|
|
|
int32_t GetBaseValue(PairIndex aIndex) const
|
2011-07-01 00:19:52 -07:00
|
|
|
{ return mBaseVal[aIndex == eFirst ? 0 : 1]; }
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetAnimValue(const int32_t aValue[2], nsSVGElement *aSVGElement);
|
|
|
|
int32_t GetAnimValue(PairIndex aIndex) const
|
2011-07-01 00:19:52 -07:00
|
|
|
{ return mAnimVal[aIndex == eFirst ? 0 : 1]; }
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
// Returns true if the animated value of this integer has been explicitly
|
2011-07-01 00:19:52 -07:00
|
|
|
// set (either by animation, or by taking on the base value which has been
|
2011-10-17 07:59:28 -07:00
|
|
|
// explicitly set by markup or a DOM call), false otherwise.
|
|
|
|
// If this returns false, the animated value is still valid, that is,
|
2011-07-01 00:19:52 -07:00
|
|
|
// useable, and represents the default base value of the attribute.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsExplicitlySet() const
|
2011-07-01 00:19:52 -07:00
|
|
|
{ return mIsAnimated || mIsBaseSet; }
|
|
|
|
|
2013-07-01 00:02:56 -07:00
|
|
|
already_AddRefed<mozilla::dom::SVGAnimatedInteger>
|
2013-02-17 18:14:02 -08:00
|
|
|
ToDOMAnimatedInteger(PairIndex aIndex,
|
|
|
|
nsSVGElement* aSVGElement);
|
|
|
|
// Returns a new nsISMILAttr object that the caller must delete
|
2011-07-01 00:19:52 -07:00
|
|
|
nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mAnimVal[2];
|
|
|
|
int32_t mBaseVal[2];
|
|
|
|
uint8_t mAttrEnum; // element specified tracking for attribute
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsAnimated;
|
|
|
|
bool mIsBaseSet;
|
2011-07-01 00:19:52 -07:00
|
|
|
|
|
|
|
public:
|
2013-07-01 00:02:56 -07:00
|
|
|
struct DOMAnimatedInteger MOZ_FINAL : public mozilla::dom::SVGAnimatedInteger
|
2011-07-01 00:19:52 -07:00
|
|
|
{
|
2013-07-01 00:02:56 -07:00
|
|
|
DOMAnimatedInteger(nsSVGIntegerPair* aVal, PairIndex aIndex,
|
|
|
|
nsSVGElement* aSVGElement)
|
|
|
|
: mozilla::dom::SVGAnimatedInteger(aSVGElement)
|
|
|
|
, mVal(aVal)
|
|
|
|
, mIndex(aIndex)
|
|
|
|
{}
|
2012-12-21 01:18:58 -08:00
|
|
|
virtual ~DOMAnimatedInteger();
|
2011-07-01 00:19:52 -07:00
|
|
|
|
|
|
|
nsSVGIntegerPair* mVal; // kept alive because it belongs to content
|
|
|
|
PairIndex mIndex; // are we the first or second integer
|
|
|
|
|
2013-07-01 00:02:56 -07:00
|
|
|
virtual int32_t BaseVal() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return mVal->GetBaseValue(mIndex);
|
|
|
|
}
|
|
|
|
virtual void SetBaseVal(int32_t aValue) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
mVal->SetBaseValue(aValue, mIndex, mSVGElement);
|
|
|
|
}
|
2011-07-01 00:19:52 -07:00
|
|
|
|
|
|
|
// Script may have modified animation parameters or timeline -- DOM getters
|
|
|
|
// need to flush any resample requests to reflect these modifications.
|
2013-07-01 00:02:56 -07:00
|
|
|
virtual int32_t AnimVal() MOZ_OVERRIDE
|
2011-07-01 00:19:52 -07:00
|
|
|
{
|
|
|
|
mSVGElement->FlushAnimations();
|
2013-07-01 00:02:56 -07:00
|
|
|
return mVal->GetAnimValue(mIndex);
|
2011-07-01 00:19:52 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SMILIntegerPair : public nsISMILAttr
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SMILIntegerPair(nsSVGIntegerPair* aVal, nsSVGElement* aSVGElement)
|
|
|
|
: mVal(aVal), mSVGElement(aSVGElement) {}
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
nsSVGIntegerPair* mVal;
|
|
|
|
nsSVGElement* mSVGElement;
|
|
|
|
|
|
|
|
// nsISMILAttr methods
|
|
|
|
virtual nsresult ValueFromString(const nsAString& aStr,
|
2013-03-18 20:18:45 -07:00
|
|
|
const mozilla::dom::SVGAnimationElement* aSrcElement,
|
2011-07-01 00:19:52 -07:00
|
|
|
nsSMILValue& aValue,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool& aPreventCachingOfSandwich) const MOZ_OVERRIDE;
|
|
|
|
virtual nsSMILValue GetBaseValue() const MOZ_OVERRIDE;
|
|
|
|
virtual void ClearAnimValue() MOZ_OVERRIDE;
|
|
|
|
virtual nsresult SetAnimValue(const nsSMILValue& aValue) MOZ_OVERRIDE;
|
2011-07-01 00:19:52 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //__NS_SVGINTEGERPAIR_H__
|