2011-01-23 09:08:17 -08: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-01-23 09:08:17 -08:00
|
|
|
|
|
|
|
#ifndef __NS_SVGCLASS_H__
|
|
|
|
#define __NS_SVGCLASS_H__
|
|
|
|
|
2011-10-18 05:43:57 -07:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2012-07-27 07:03:27 -07:00
|
|
|
#include "nsError.h"
|
2011-11-01 12:22:30 -07:00
|
|
|
#include "nsISMILAttr.h"
|
2012-01-26 01:57:21 -08:00
|
|
|
#include "nsString.h"
|
2012-06-18 19:30:09 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-11-01 12:22:30 -07:00
|
|
|
|
2012-12-23 00:22:22 -08:00
|
|
|
class nsSVGElement;
|
2011-10-18 05:43:57 -07:00
|
|
|
|
2013-06-14 15:37:27 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class SVGAnimatedString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 09:08:17 -08:00
|
|
|
class nsSVGClass
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
void Init() {
|
2012-07-30 07:20:58 -07:00
|
|
|
mAnimVal = nullptr;
|
2011-01-23 09:08:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetBaseValue(const nsAString& aValue,
|
2012-12-23 00:22:22 -08:00
|
|
|
nsSVGElement *aSVGElement,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aDoSetAttr);
|
2012-12-23 00:22:22 -08:00
|
|
|
void GetBaseValue(nsAString& aValue, const nsSVGElement *aSVGElement) const;
|
2011-01-23 09:08:17 -08:00
|
|
|
|
2012-12-23 00:22:22 -08:00
|
|
|
void SetAnimValue(const nsAString& aValue, nsSVGElement *aSVGElement);
|
|
|
|
void GetAnimValue(nsAString& aValue, const nsSVGElement *aSVGElement) const;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsAnimated() const
|
2011-01-23 09:08:17 -08:00
|
|
|
{ return !!mAnimVal; }
|
|
|
|
|
2013-06-14 15:37:27 -07:00
|
|
|
already_AddRefed<mozilla::dom::SVGAnimatedString>
|
|
|
|
ToDOMAnimatedString(nsSVGElement* aSVGElement);
|
2013-02-07 00:08:56 -08:00
|
|
|
|
2011-01-23 09:08:17 -08:00
|
|
|
// Returns a new nsISMILAttr object that the caller must delete
|
2012-12-23 00:22:22 -08:00
|
|
|
nsISMILAttr* ToSMILAttr(nsSVGElement *aSVGElement);
|
2011-01-23 09:08:17 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
nsAutoPtr<nsString> mAnimVal;
|
|
|
|
|
|
|
|
public:
|
|
|
|
struct SMILString : public nsISMILAttr
|
|
|
|
{
|
|
|
|
public:
|
2012-12-23 00:22:22 -08:00
|
|
|
SMILString(nsSVGClass *aVal, nsSVGElement *aSVGElement)
|
2011-01-23 09:08:17 -08:00
|
|
|
: 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.
|
|
|
|
nsSVGClass* mVal;
|
2012-12-23 00:22:22 -08:00
|
|
|
nsSVGElement* mSVGElement;
|
2011-01-23 09:08:17 -08:00
|
|
|
|
|
|
|
// nsISMILAttr methods
|
|
|
|
virtual nsresult ValueFromString(const nsAString& aStr,
|
2013-03-18 20:18:45 -07:00
|
|
|
const mozilla::dom::SVGAnimationElement *aSrcElement,
|
2011-01-23 09:08:17 -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;
|
2011-01-23 09:08:17 -08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
#endif //__NS_SVGCLASS_H__
|