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/. */
|
2004-10-15 03:02:53 +04:00
|
|
|
|
|
|
|
#ifndef __NS_SVGENUM_H__
|
|
|
|
#define __NS_SVGENUM_H__
|
|
|
|
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsISMILAttr.h"
|
2007-08-28 03:11:14 +04:00
|
|
|
#include "nsSVGElement.h"
|
2012-06-19 06:30:09 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-07-01 11:02:46 +04:00
|
|
|
#include "mozilla/dom/SVGAnimatedEnumeration.h"
|
2017-03-30 07:10:07 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
|
|
|
|
class nsIAtom;
|
|
|
|
class nsSMILValue;
|
2007-08-28 03:11:14 +04:00
|
|
|
|
2013-03-19 07:18:45 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class SVGAnimationElement;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2013-03-19 07:18:45 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
typedef uint8_t nsSVGEnumValue;
|
2004-10-15 03:02:53 +04:00
|
|
|
|
|
|
|
struct nsSVGEnumMapping {
|
2007-08-28 03:11:14 +04:00
|
|
|
nsIAtom **mKey;
|
|
|
|
nsSVGEnumValue mVal;
|
2004-10-15 03:02:53 +04:00
|
|
|
};
|
|
|
|
|
2007-08-28 03:11:14 +04:00
|
|
|
class nsSVGEnum
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 19:56:38 +04:00
|
|
|
void Init(uint8_t aAttrEnum, uint16_t aValue) {
|
|
|
|
mAnimVal = mBaseVal = uint8_t(aValue);
|
2007-08-28 03:11:14 +04:00
|
|
|
mAttrEnum = aAttrEnum;
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsAnimated = false;
|
|
|
|
mIsBaseSet = false;
|
2007-08-28 03:11:14 +04:00
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:44 +04:00
|
|
|
nsresult SetBaseValueAtom(const nsIAtom* aValue, nsSVGElement *aSVGElement);
|
|
|
|
nsIAtom* GetBaseValueAtom(nsSVGElement *aSVGElement);
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult SetBaseValue(uint16_t aValue,
|
2011-10-09 19:25:07 +04:00
|
|
|
nsSVGElement *aSVGElement);
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t GetBaseValue() const
|
2007-08-28 03:11:14 +04:00
|
|
|
{ return mBaseVal; }
|
2010-01-23 21:59:03 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetAnimValue(uint16_t aValue, nsSVGElement *aSVGElement);
|
|
|
|
uint16_t GetAnimValue() const
|
2010-02-25 21:20:43 +03:00
|
|
|
{ return mAnimVal; }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsExplicitlySet() const
|
2011-01-16 10:36:34 +03:00
|
|
|
{ return mIsAnimated || mIsBaseSet; }
|
2007-08-28 03:11:14 +04:00
|
|
|
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<mozilla::dom::SVGAnimatedEnumeration>
|
2013-01-06 18:14:43 +04:00
|
|
|
ToDOMAnimatedEnum(nsSVGElement* aSVGElement);
|
|
|
|
|
2017-03-30 07:10:07 +03:00
|
|
|
mozilla::UniquePtr<nsISMILAttr> ToSMILAttr(nsSVGElement* aSVGElement);
|
2004-10-15 03:02:53 +04:00
|
|
|
|
2007-08-28 03:11:14 +04:00
|
|
|
private:
|
|
|
|
nsSVGEnumValue mAnimVal;
|
|
|
|
nsSVGEnumValue mBaseVal;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t mAttrEnum; // element specified tracking for attribute
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsAnimated;
|
|
|
|
bool mIsBaseSet;
|
2004-10-15 03:02:53 +04:00
|
|
|
|
2007-08-28 03:11:14 +04:00
|
|
|
nsSVGEnumMapping *GetMapping(nsSVGElement *aSVGElement);
|
2004-10-15 03:02:53 +04:00
|
|
|
|
2010-01-12 16:08:43 +03:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
struct DOMAnimatedEnum final : public mozilla::dom::SVGAnimatedEnumeration
|
2007-08-28 03:11:14 +04:00
|
|
|
{
|
|
|
|
DOMAnimatedEnum(nsSVGEnum* aVal, nsSVGElement *aSVGElement)
|
2013-07-01 11:02:46 +04:00
|
|
|
: mozilla::dom::SVGAnimatedEnumeration(aSVGElement)
|
|
|
|
, mVal(aVal)
|
|
|
|
{}
|
2012-12-21 13:18:58 +04:00
|
|
|
virtual ~DOMAnimatedEnum();
|
2007-08-28 03:11:14 +04:00
|
|
|
|
|
|
|
nsSVGEnum *mVal; // kept alive because it belongs to content
|
2010-02-25 21:20:43 +03:00
|
|
|
|
2013-07-01 11:02:46 +04:00
|
|
|
using mozilla::dom::SVGAnimatedEnumeration::SetBaseVal;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual uint16_t BaseVal() override
|
2013-07-01 11:02:46 +04:00
|
|
|
{
|
|
|
|
return mVal->GetBaseValue();
|
|
|
|
}
|
|
|
|
virtual void SetBaseVal(uint16_t aBaseVal,
|
2015-03-21 19:28:04 +03:00
|
|
|
mozilla::ErrorResult& aRv) override
|
2013-07-01 11:02:46 +04:00
|
|
|
{
|
|
|
|
aRv = mVal->SetBaseValue(aBaseVal, mSVGElement);
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual uint16_t AnimVal() override
|
2010-02-25 21:20:43 +03:00
|
|
|
{
|
2013-07-01 11:02:46 +04:00
|
|
|
// Script may have modified animation parameters or timeline -- DOM
|
|
|
|
// getters need to flush any resample requests to reflect these
|
|
|
|
// modifications.
|
2010-02-25 21:20:43 +03:00
|
|
|
mSVGElement->FlushAnimations();
|
2013-07-01 11:02:46 +04:00
|
|
|
return mVal->GetAnimValue();
|
2010-02-25 21:20:43 +03:00
|
|
|
}
|
2007-08-28 03:11:14 +04:00
|
|
|
};
|
2010-01-23 21:59:03 +03:00
|
|
|
|
|
|
|
struct SMILEnum : public nsISMILAttr
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SMILEnum(nsSVGEnum* 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.
|
|
|
|
nsSVGEnum* mVal;
|
|
|
|
nsSVGElement* mSVGElement;
|
|
|
|
|
|
|
|
// nsISMILAttr methods
|
|
|
|
virtual nsresult ValueFromString(const nsAString& aStr,
|
2013-03-19 07:18:45 +04:00
|
|
|
const mozilla::dom::SVGAnimationElement* aSrcElement,
|
2010-02-21 00:13:11 +03:00
|
|
|
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;
|
2010-01-23 21:59:03 +03:00
|
|
|
};
|
2007-08-28 03:11:14 +04:00
|
|
|
};
|
2004-10-15 03:02:53 +04:00
|
|
|
|
2008-01-09 12:52:14 +03:00
|
|
|
#endif //__NS_SVGENUM_H__
|