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-12-09 06:16:15 +03:00
|
|
|
|
|
|
|
#ifndef __NS_SVGANGLE_H__
|
|
|
|
#define __NS_SVGANGLE_H__
|
|
|
|
|
2013-03-12 02:05:58 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsISMILAttr.h"
|
2012-06-19 06:30:09 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2004-12-09 06:16:15 +03:00
|
|
|
|
2013-03-12 02:05:58 +04:00
|
|
|
class nsISupports;
|
2012-01-26 13:57:21 +04:00
|
|
|
class nsSMILValue;
|
2013-03-12 02:05:58 +04:00
|
|
|
class nsSVGElement;
|
2010-02-19 00:50:59 +03:00
|
|
|
|
2012-12-23 08:54:23 +04:00
|
|
|
namespace mozilla {
|
2012-12-23 08:54:23 +04:00
|
|
|
|
|
|
|
// Angle Unit Types
|
|
|
|
static const unsigned short SVG_ANGLETYPE_UNKNOWN = 0;
|
|
|
|
static const unsigned short SVG_ANGLETYPE_UNSPECIFIED = 1;
|
|
|
|
static const unsigned short SVG_ANGLETYPE_DEG = 2;
|
|
|
|
static const unsigned short SVG_ANGLETYPE_RAD = 3;
|
|
|
|
static const unsigned short SVG_ANGLETYPE_GRAD = 4;
|
|
|
|
|
2012-12-23 08:54:23 +04:00
|
|
|
namespace dom {
|
2013-01-30 02:11:44 +04:00
|
|
|
class nsSVGOrientType;
|
2012-12-23 08:54:23 +04:00
|
|
|
class SVGAngle;
|
2012-12-23 08:54:23 +04:00
|
|
|
class SVGAnimatedAngle;
|
2013-03-19 07:18:45 +04:00
|
|
|
class SVGAnimationElement;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2012-12-23 08:54:23 +04:00
|
|
|
|
2007-10-10 14:07:59 +04:00
|
|
|
class nsSVGAngle
|
|
|
|
{
|
2012-12-23 08:54:23 +04:00
|
|
|
friend class mozilla::dom::SVGAngle;
|
2012-12-23 08:54:23 +04:00
|
|
|
friend class mozilla::dom::SVGAnimatedAngle;
|
2007-10-10 14:07:59 +04:00
|
|
|
|
|
|
|
public:
|
2012-08-22 19:56:38 +04:00
|
|
|
void Init(uint8_t aAttrEnum = 0xff,
|
2007-10-10 14:07:59 +04:00
|
|
|
float aValue = 0,
|
2012-12-23 08:54:23 +04:00
|
|
|
uint8_t aUnitType = mozilla::SVG_ANGLETYPE_UNSPECIFIED) {
|
2007-10-10 14:07:59 +04:00
|
|
|
mAnimVal = mBaseVal = aValue;
|
2010-02-19 00:50:59 +03:00
|
|
|
mAnimValUnit = mBaseValUnit = aUnitType;
|
2007-10-10 14:07:59 +04:00
|
|
|
mAttrEnum = aAttrEnum;
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsAnimated = false;
|
2007-10-10 14:07:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult SetBaseValueString(const nsAString& aValue,
|
|
|
|
nsSVGElement *aSVGElement,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aDoSetAttr);
|
2012-02-16 03:40:45 +04:00
|
|
|
void GetBaseValueString(nsAString& aValue) const;
|
|
|
|
void GetAnimValueString(nsAString& aValue) const;
|
2007-10-10 14:07:59 +04:00
|
|
|
|
|
|
|
float GetBaseValue() const
|
2010-02-19 00:50:59 +03:00
|
|
|
{ return mBaseVal * GetDegreesPerUnit(mBaseValUnit); }
|
2007-10-10 14:07:59 +04:00
|
|
|
float GetAnimValue() const
|
2010-02-19 00:50:59 +03:00
|
|
|
{ return mAnimVal * GetDegreesPerUnit(mAnimValUnit); }
|
2007-10-10 14:07:59 +04:00
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
void SetBaseValue(float aValue, nsSVGElement *aSVGElement, bool aDoSetAttr);
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetAnimValue(float aValue, uint8_t aUnit, nsSVGElement *aSVGElement);
|
2007-10-10 14:07:59 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t GetBaseValueUnit() const { return mBaseValUnit; }
|
|
|
|
uint8_t GetAnimValueUnit() const { return mAnimValUnit; }
|
2007-10-10 14:07:59 +04:00
|
|
|
float GetBaseValInSpecifiedUnits() const { return mBaseVal; }
|
2010-02-19 00:50:59 +03:00
|
|
|
float GetAnimValInSpecifiedUnits() const { return mAnimVal; }
|
2007-10-10 14:07:59 +04:00
|
|
|
|
2012-12-23 08:54:23 +04:00
|
|
|
static nsresult ToDOMSVGAngle(nsISupports **aResult);
|
2013-01-30 02:11:44 +04:00
|
|
|
already_AddRefed<mozilla::dom::SVGAnimatedAngle>
|
|
|
|
ToDOMAnimatedAngle(nsSVGElement* aSVGElement);
|
2010-02-19 00:50:59 +03:00
|
|
|
// Returns a new nsISMILAttr object that the caller must delete
|
|
|
|
nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement);
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static float GetDegreesPerUnit(uint8_t aUnit);
|
2007-10-10 14:07:59 +04:00
|
|
|
|
|
|
|
private:
|
2012-12-23 08:54:23 +04:00
|
|
|
|
2007-10-10 14:07:59 +04:00
|
|
|
float mAnimVal;
|
|
|
|
float mBaseVal;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t mAnimValUnit;
|
|
|
|
uint8_t mBaseValUnit;
|
|
|
|
uint8_t mAttrEnum; // element specified tracking for attribute
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsAnimated;
|
2012-12-23 08:54:23 +04:00
|
|
|
|
2007-10-10 14:07:59 +04:00
|
|
|
void SetBaseValueInSpecifiedUnits(float aValue, nsSVGElement *aSVGElement);
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult NewValueSpecifiedUnits(uint16_t aUnitType, float aValue,
|
2010-01-20 23:22:40 +03:00
|
|
|
nsSVGElement *aSVGElement);
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult ConvertToSpecifiedUnits(uint16_t aUnitType, nsSVGElement *aSVGElement);
|
2013-01-30 10:31:11 +04:00
|
|
|
already_AddRefed<mozilla::dom::SVGAngle> ToDOMBaseVal(nsSVGElement* aSVGElement);
|
|
|
|
already_AddRefed<mozilla::dom::SVGAngle> ToDOMAnimVal(nsSVGElement* aSVGElement);
|
2007-10-10 14:07:59 +04:00
|
|
|
|
2010-01-12 16:08:43 +03:00
|
|
|
public:
|
2010-02-19 00:50:59 +03:00
|
|
|
// We do not currently implemente a SMILAngle struct because in SVG 1.1 the
|
|
|
|
// only *animatable* attribute that takes an <angle> is 'orient', on the
|
|
|
|
// 'marker' element, and 'orient' must be special cased since it can also
|
|
|
|
// take the value 'auto', making it a more complex type.
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
struct SMILOrient final : public nsISMILAttr
|
2010-02-19 00:50:59 +03:00
|
|
|
{
|
|
|
|
public:
|
2013-01-30 02:11:44 +04:00
|
|
|
SMILOrient(mozilla::dom::nsSVGOrientType* aOrientType,
|
2010-02-19 00:50:59 +03:00
|
|
|
nsSVGAngle* aAngle,
|
|
|
|
nsSVGElement* aSVGElement)
|
|
|
|
: mOrientType(aOrientType)
|
|
|
|
, mAngle(aAngle)
|
|
|
|
, 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.
|
2013-01-30 02:11:44 +04:00
|
|
|
mozilla::dom::nsSVGOrientType* mOrientType;
|
2010-02-19 00:50:59 +03:00
|
|
|
nsSVGAngle* mAngle;
|
|
|
|
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-02-19 00:50:59 +03:00
|
|
|
};
|
2007-10-10 14:07:59 +04:00
|
|
|
};
|
2004-12-09 06:16:15 +03:00
|
|
|
|
2006-02-21 20:00:02 +03:00
|
|
|
#endif //__NS_SVGANGLE_H__
|