2008-06-14 09:09:44 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2008-06-14 09:09:44 +00:00
|
|
|
|
|
|
|
#ifndef __NS_SVGSTRING_H__
|
|
|
|
#define __NS_SVGSTRING_H__
|
|
|
|
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2008-06-14 09:09:44 +00:00
|
|
|
#include "nsSVGElement.h"
|
2012-06-19 02:30:09 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-06-14 22:37:27 +00:00
|
|
|
#include "mozilla/dom/SVGAnimatedString.h"
|
2008-06-14 09:09:44 +00:00
|
|
|
|
|
|
|
class nsSVGString
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2012-08-22 15:56:38 +00:00
|
|
|
void Init(uint8_t aAttrEnum) {
|
2012-07-30 14:20:58 +00:00
|
|
|
mAnimVal = nullptr;
|
2008-06-14 09:09:44 +00:00
|
|
|
mAttrEnum = aAttrEnum;
|
2011-10-17 14:59:28 +00:00
|
|
|
mIsBaseSet = false;
|
2008-06-14 09:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetBaseValue(const nsAString& aValue,
|
|
|
|
nsSVGElement *aSVGElement,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aDoSetAttr);
|
2011-10-18 12:43:57 +00:00
|
|
|
void GetBaseValue(nsAString& aValue, const nsSVGElement *aSVGElement) const
|
2009-01-22 00:56:51 +00:00
|
|
|
{ aSVGElement->GetStringBaseValue(mAttrEnum, aValue); }
|
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
void SetAnimValue(const nsAString& aValue, nsSVGElement *aSVGElement);
|
|
|
|
void GetAnimValue(nsAString& aValue, const nsSVGElement *aSVGElement) const;
|
2008-06-14 09:09:44 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
// Returns true if the animated value of this string has been explicitly
|
2011-07-01 07:19:52 +00:00
|
|
|
// set (either by animation, or by taking on the base value which has been
|
2011-10-17 14:59:28 +00: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 07:19:52 +00:00
|
|
|
// useable, and represents the default base value of the attribute.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsExplicitlySet() const
|
2011-07-01 07:19:52 +00:00
|
|
|
{ return !!mAnimVal || mIsBaseSet; }
|
|
|
|
|
2013-06-14 22:37:27 +00:00
|
|
|
already_AddRefed<mozilla::dom::SVGAnimatedString>
|
2013-02-07 08:08:56 +00:00
|
|
|
ToDOMAnimatedString(nsSVGElement* aSVGElement);
|
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
// Returns a new nsISMILAttr object that the caller must delete
|
|
|
|
nsISMILAttr* ToSMILAttr(nsSVGElement *aSVGElement);
|
2008-06-14 09:09:44 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2009-01-22 00:56:51 +00:00
|
|
|
nsAutoPtr<nsString> mAnimVal;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t mAttrEnum; // element specified tracking for attribute
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mIsBaseSet;
|
2008-06-14 09:09:44 +00:00
|
|
|
|
2010-01-12 13:08:43 +00:00
|
|
|
public:
|
2013-06-14 22:37:27 +00:00
|
|
|
struct DOMAnimatedString MOZ_FINAL : public mozilla::dom::SVGAnimatedString
|
2008-06-14 09:09:44 +00:00
|
|
|
{
|
2008-12-30 16:32:22 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2013-06-14 22:37:27 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMAnimatedString)
|
|
|
|
|
|
|
|
DOMAnimatedString(nsSVGString* aVal, nsSVGElement* aSVGElement)
|
|
|
|
: mozilla::dom::SVGAnimatedString(aSVGElement)
|
|
|
|
, mVal(aVal)
|
|
|
|
{}
|
2008-06-14 09:09:44 +00:00
|
|
|
|
|
|
|
nsSVGString* mVal; // kept alive because it belongs to content
|
|
|
|
|
2013-06-14 22:37:27 +00:00
|
|
|
void GetBaseVal(nsAString & aResult) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
mVal->GetBaseValue(aResult, mSVGElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBaseVal(const nsAString & aValue) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
mVal->SetBaseValue(aValue, mSVGElement, true);
|
|
|
|
}
|
2008-06-14 09:09:44 +00:00
|
|
|
|
2013-06-14 22:37:27 +00:00
|
|
|
void GetAnimVal(nsAString & aResult) MOZ_OVERRIDE
|
|
|
|
{
|
2010-10-07 19:19:32 +00:00
|
|
|
mSVGElement->FlushAnimations();
|
2013-06-14 22:37:27 +00:00
|
|
|
mVal->GetAnimValue(aResult, mSVGElement);
|
2010-10-07 19:19:32 +00:00
|
|
|
}
|
2008-06-14 09:09:44 +00:00
|
|
|
|
2014-06-24 16:36:45 +00:00
|
|
|
private:
|
|
|
|
virtual ~DOMAnimatedString();
|
2008-06-14 09:09:44 +00:00
|
|
|
};
|
2010-10-07 19:19:32 +00:00
|
|
|
struct SMILString : public nsISMILAttr
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SMILString(nsSVGString *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.
|
|
|
|
nsSVGString* mVal;
|
|
|
|
nsSVGElement* mSVGElement;
|
|
|
|
|
|
|
|
// nsISMILAttr methods
|
|
|
|
virtual nsresult ValueFromString(const nsAString& aStr,
|
2013-03-19 03:18:45 +00:00
|
|
|
const mozilla::dom::SVGAnimationElement *aSrcElement,
|
2010-10-07 19:19:32 +00:00
|
|
|
nsSMILValue& aValue,
|
2013-05-29 20:43:41 +00: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-10-07 19:19:32 +00:00
|
|
|
};
|
2008-06-14 09:09:44 +00:00
|
|
|
};
|
|
|
|
#endif //__NS_SVGSTRING_H__
|