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"
|
2018-02-18 18:53:13 +03:00
|
|
|
#include "mozilla/dom/SVGAngleBinding.h"
|
2017-03-30 07:10:07 +03:00
|
|
|
#include "mozilla/UniquePtr.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;
|
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
|
|
|
|
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;
|
2018-12-21 11:58:14 +03:00
|
|
|
class SVGElement;
|
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;
|
2018-12-21 11:58:14 +03:00
|
|
|
typedef mozilla::dom::SVGElement SVGElement;
|
2007-10-10 14:07:59 +04:00
|
|
|
|
|
|
|
public:
|
2012-08-22 19:56:38 +04:00
|
|
|
void Init(uint8_t aAttrEnum = 0xff, float aValue = 0,
|
2018-02-18 18:53:13 +03:00
|
|
|
uint8_t aUnitType =
|
2018-06-26 00:20:54 +03:00
|
|
|
mozilla::dom::SVGAngle_Binding::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
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
nsresult SetBaseValueString(const nsAString& aValue, SVGElement* aSVGElement,
|
|
|
|
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
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
void SetBaseValue(float aValue, uint8_t aUnit, SVGElement* aSVGElement,
|
2018-07-01 18:12:14 +03:00
|
|
|
bool aDoSetAttr);
|
2018-12-21 11:58:14 +03:00
|
|
|
void SetAnimValue(float aValue, uint8_t aUnit, SVGElement* 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(
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* aSVGElement);
|
|
|
|
mozilla::UniquePtr<nsISMILAttr> ToSMILAttr(SVGElement* aSVGElement);
|
2010-02-19 00:50:59 +03:00
|
|
|
|
2017-09-30 13:47:00 +03:00
|
|
|
static bool GetValueFromString(const nsAString& aString, float& aValue,
|
|
|
|
uint16_t* aUnitType);
|
2012-08-22 19:56:38 +04:00
|
|
|
static float GetDegreesPerUnit(uint8_t aUnit);
|
2007-10-10 14:07:59 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
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
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
void SetBaseValueInSpecifiedUnits(float aValue, SVGElement* aSVGElement);
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult NewValueSpecifiedUnits(uint16_t aUnitType, float aValue,
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* aSVGElement);
|
|
|
|
nsresult ConvertToSpecifiedUnits(uint16_t aUnitType, SVGElement* aSVGElement);
|
2013-01-30 10:31:11 +04:00
|
|
|
already_AddRefed<mozilla::dom::SVGAngle> ToDOMBaseVal(
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* aSVGElement);
|
2013-01-30 10:31:11 +04:00
|
|
|
already_AddRefed<mozilla::dom::SVGAngle> ToDOMAnimVal(
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* aSVGElement);
|
2018-11-30 13:46:48 +03: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, nsSVGAngle* aAngle,
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* aSVGElement)
|
2010-02-19 00:50:59 +03:00
|
|
|
: 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;
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* mSVGElement;
|
2010-02-19 00:50:59 +03:00
|
|
|
|
|
|
|
// nsISMILAttr methods
|
|
|
|
virtual nsresult ValueFromString(
|
|
|
|
const nsAString& aStr,
|
2013-03-19 07:18:45 +04:00
|
|
|
const mozilla::dom::SVGAnimationElement* aSrcElement,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsSMILValue& aValue, 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__
|