2007-09-18 05:09:26 -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/. */
|
2007-09-18 05:09:26 -07:00
|
|
|
|
|
|
|
#ifndef __NS_SVGINTEGER_H__
|
|
|
|
#define __NS_SVGINTEGER_H__
|
|
|
|
|
2012-01-26 01:57:21 -08:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsError.h"
|
2013-07-01 00:02:56 -07:00
|
|
|
#include "SVGAnimatedInteger.h"
|
2012-01-26 01:57:21 -08:00
|
|
|
#include "nsISMILAttr.h"
|
2007-09-18 05:09:26 -07:00
|
|
|
#include "nsSVGElement.h"
|
2012-06-18 19:30:09 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-01-26 01:57:21 -08:00
|
|
|
|
|
|
|
class nsSMILValue;
|
2007-09-18 05:09:26 -07:00
|
|
|
|
2013-03-18 20:18:45 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class SVGAnimationElement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-18 05:09:26 -07:00
|
|
|
class nsSVGInteger
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
void Init(uint8_t aAttrEnum = 0xff, int32_t aValue = 0) {
|
2007-09-18 05:09:26 -07:00
|
|
|
mAnimVal = mBaseVal = aValue;
|
|
|
|
mAttrEnum = aAttrEnum;
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsAnimated = false;
|
|
|
|
mIsBaseSet = false;
|
2007-09-18 05:09:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult SetBaseValueString(const nsAString& aValue,
|
2011-10-09 08:25:07 -07:00
|
|
|
nsSVGElement *aSVGElement);
|
2007-09-18 05:09:26 -07:00
|
|
|
void GetBaseValueString(nsAString& aValue);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetBaseValue(int32_t aValue, nsSVGElement *aSVGElement);
|
|
|
|
int32_t GetBaseValue() const
|
2007-09-18 05:09:26 -07:00
|
|
|
{ return mBaseVal; }
|
|
|
|
|
2010-02-18 13:51:00 -08:00
|
|
|
void SetAnimValue(int aValue, nsSVGElement *aSVGElement);
|
2010-02-25 10:20:43 -08:00
|
|
|
int GetAnimValue() const
|
|
|
|
{ return mAnimVal; }
|
2011-07-01 00:19:52 -07:00
|
|
|
|
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-03-24 23:26:06 -07:00
|
|
|
|
2013-07-01 00:02:56 -07:00
|
|
|
already_AddRefed<mozilla::dom::SVGAnimatedInteger>
|
2013-03-24 23:26:06 -07:00
|
|
|
ToDOMAnimatedInteger(nsSVGElement* aSVGElement);
|
2010-02-18 13:51:00 -08:00
|
|
|
// Returns a new nsISMILAttr object that the caller must delete
|
|
|
|
nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement);
|
|
|
|
|
2007-09-18 05:09:26 -07:00
|
|
|
private:
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mAnimVal;
|
|
|
|
int32_t mBaseVal;
|
|
|
|
uint8_t mAttrEnum; // element specified tracking for attribute
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsAnimated;
|
|
|
|
bool mIsBaseSet;
|
2007-09-18 05:09:26 -07:00
|
|
|
|
2010-01-12 05:08:43 -08:00
|
|
|
public:
|
2013-07-01 00:02:56 -07:00
|
|
|
struct DOMAnimatedInteger MOZ_FINAL : public mozilla::dom::SVGAnimatedInteger
|
2007-09-18 05:09:26 -07:00
|
|
|
{
|
2013-07-01 00:02:56 -07:00
|
|
|
DOMAnimatedInteger(nsSVGInteger* aVal, nsSVGElement* aSVGElement)
|
|
|
|
: mozilla::dom::SVGAnimatedInteger(aSVGElement)
|
|
|
|
, mVal(aVal)
|
|
|
|
{}
|
2012-12-21 01:18:58 -08:00
|
|
|
virtual ~DOMAnimatedInteger();
|
2007-09-18 05:09:26 -07:00
|
|
|
|
|
|
|
nsSVGInteger* mVal; // kept alive because it belongs to content
|
|
|
|
|
2013-07-01 00:02:56 -07:00
|
|
|
virtual int32_t BaseVal() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return mVal->GetBaseValue();
|
|
|
|
}
|
|
|
|
virtual void SetBaseVal(int32_t aValue) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
mVal->SetBaseValue(aValue, mSVGElement);
|
|
|
|
}
|
2007-09-18 05:09:26 -07:00
|
|
|
|
2010-02-25 10:20:43 -08: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
|
2010-02-25 10:20:43 -08:00
|
|
|
{
|
|
|
|
mSVGElement->FlushAnimations();
|
2013-07-01 00:02:56 -07:00
|
|
|
return mVal->GetAnimValue();
|
2010-02-25 10:20:43 -08:00
|
|
|
}
|
2007-09-18 05:09:26 -07:00
|
|
|
};
|
|
|
|
|
2010-02-18 13:51:00 -08:00
|
|
|
struct SMILInteger : public nsISMILAttr
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SMILInteger(nsSVGInteger* 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.
|
|
|
|
nsSVGInteger* mVal;
|
|
|
|
nsSVGElement* mSVGElement;
|
|
|
|
|
|
|
|
// nsISMILAttr methods
|
|
|
|
virtual nsresult ValueFromString(const nsAString& aStr,
|
2013-03-18 20:18:45 -07:00
|
|
|
const mozilla::dom::SVGAnimationElement* aSrcElement,
|
2010-02-20 13:13:11 -08: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;
|
2010-02-18 13:51:00 -08:00
|
|
|
};
|
2007-09-18 05:09:26 -07:00
|
|
|
};
|
2010-02-18 13:51:00 -08:00
|
|
|
|
2007-09-18 05:09:26 -07:00
|
|
|
#endif //__NS_SVGINTEGER_H__
|