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
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#ifndef DOM_SVG_SVGANIMATEDORIENT_H_
|
|
|
|
#define DOM_SVG_SVGANIMATEDORIENT_H_
|
2004-12-09 06:16:15 +03:00
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
#include "DOMSVGAnimatedEnumeration.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsError.h"
|
2019-04-04 20:40:56 +03:00
|
|
|
#include "SVGAnimatedEnumeration.h"
|
2019-01-25 02:40:25 +03:00
|
|
|
#include "mozilla/AlreadyAddRefed.h"
|
2012-06-19 06:30:09 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2019-01-25 07:41:23 +03:00
|
|
|
#include "mozilla/SMILAttr.h"
|
2018-02-18 18:53:13 +03:00
|
|
|
#include "mozilla/dom/SVGAngleBinding.h"
|
2019-02-15 11:41:37 +03:00
|
|
|
#include "mozilla/dom/SVGMarkerElementBinding.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;
|
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
|
|
|
|
2019-01-23 16:48:08 +03:00
|
|
|
class SMILValue;
|
|
|
|
|
2012-12-23 08:54:23 +04:00
|
|
|
namespace dom {
|
2018-12-30 21:18:30 +03:00
|
|
|
class DOMSVGAngle;
|
2019-03-19 03:01:03 +03:00
|
|
|
class DOMSVGAnimatedAngle;
|
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
|
2012-12-23 08:54:23 +04:00
|
|
|
|
2019-04-04 20:40:56 +03:00
|
|
|
class SVGAnimatedOrient {
|
2019-02-15 11:41:37 +03:00
|
|
|
friend class AutoChangeOrientNotifier;
|
2020-07-15 13:37:55 +03:00
|
|
|
friend class dom::DOMSVGAngle;
|
|
|
|
friend class dom::DOMSVGAnimatedAngle;
|
|
|
|
using SVGElement = dom::SVGElement;
|
2007-10-10 14:07:59 +04:00
|
|
|
|
|
|
|
public:
|
2019-02-15 11:41:37 +03:00
|
|
|
void Init() {
|
|
|
|
mAnimVal = mBaseVal = .0f;
|
|
|
|
mAnimType = mBaseType =
|
|
|
|
dom::SVGMarkerElement_Binding::SVG_MARKER_ORIENT_ANGLE;
|
|
|
|
mAnimValUnit = mBaseValUnit =
|
|
|
|
dom::SVGAngle_Binding::SVG_ANGLETYPE_UNSPECIFIED;
|
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;
|
2019-02-15 11:41:37 +03:00
|
|
|
void GetBaseAngleValueString(nsAString& aValue) const;
|
|
|
|
void GetAnimAngleValueString(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);
|
|
|
|
}
|
2019-02-15 11:41:37 +03:00
|
|
|
SVGEnumValue GetAnimType() const { return mAnimType; }
|
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);
|
2020-02-20 01:06:09 +03:00
|
|
|
void SetBaseType(SVGEnumValue aValue, SVGElement* aSVGElement,
|
|
|
|
ErrorResult& aRv);
|
2018-12-21 11:58:14 +03:00
|
|
|
void SetAnimValue(float aValue, uint8_t aUnit, SVGElement* aSVGElement);
|
2019-04-27 10:57:50 +03:00
|
|
|
void SetAnimType(SVGEnumValue aValue, 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);
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<dom::DOMSVGAnimatedAngle> ToDOMAnimatedAngle(
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* aSVGElement);
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<dom::DOMSVGAnimatedEnumeration> ToDOMAnimatedEnum(
|
2019-02-15 11:41:37 +03:00
|
|
|
SVGElement* aSVGElement);
|
|
|
|
UniquePtr<SMILAttr> 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;
|
2019-02-15 11:41:37 +03:00
|
|
|
uint8_t mAnimType;
|
|
|
|
uint8_t mBaseType;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t mAnimValUnit;
|
|
|
|
uint8_t mBaseValUnit;
|
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);
|
2019-04-27 10:57:50 +03:00
|
|
|
nsresult NewValueSpecifiedUnits(uint16_t aUnitType,
|
|
|
|
float aValueInSpecifiedUnits,
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* aSVGElement);
|
|
|
|
nsresult ConvertToSpecifiedUnits(uint16_t aUnitType, SVGElement* aSVGElement);
|
2019-02-15 11:41:37 +03:00
|
|
|
already_AddRefed<dom::DOMSVGAngle> ToDOMBaseVal(SVGElement* aSVGElement);
|
|
|
|
already_AddRefed<dom::DOMSVGAngle> ToDOMAnimVal(SVGElement* aSVGElement);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2010-01-12 16:08:43 +03:00
|
|
|
public:
|
2019-03-19 03:01:03 +03:00
|
|
|
// DOM wrapper class for the (DOM)SVGAnimatedEnumeration interface where the
|
2019-04-04 20:40:56 +03:00
|
|
|
// wrapped class is SVGAnimatedOrient.
|
2019-03-19 03:01:03 +03:00
|
|
|
struct DOMAnimatedEnum final : public dom::DOMSVGAnimatedEnumeration {
|
2019-04-04 20:40:56 +03:00
|
|
|
DOMAnimatedEnum(SVGAnimatedOrient* aVal, SVGElement* aSVGElement)
|
2019-03-19 03:01:03 +03:00
|
|
|
: DOMSVGAnimatedEnumeration(aSVGElement), mVal(aVal) {}
|
2019-02-15 11:41:37 +03:00
|
|
|
~DOMAnimatedEnum();
|
|
|
|
|
2019-04-04 20:40:56 +03:00
|
|
|
SVGAnimatedOrient* mVal; // kept alive because it belongs to content
|
2019-02-15 11:41:37 +03:00
|
|
|
|
2020-07-15 13:37:55 +03:00
|
|
|
using dom::DOMSVGAnimatedEnumeration::SetBaseVal;
|
2019-02-15 11:41:37 +03:00
|
|
|
uint16_t BaseVal() override { return Sanitize(mVal->mBaseType); }
|
|
|
|
void SetBaseVal(uint16_t aBaseVal, ErrorResult& aRv) override {
|
2020-02-20 01:06:09 +03:00
|
|
|
mVal->SetBaseType(aBaseVal, mSVGElement, aRv);
|
2019-02-15 11:41:37 +03:00
|
|
|
}
|
|
|
|
uint16_t AnimVal() override {
|
|
|
|
// Script may have modified animation parameters or timeline -- DOM
|
|
|
|
// getters need to flush any resample requests to reflect these
|
|
|
|
// modifications.
|
|
|
|
mSVGElement->FlushAnimations();
|
|
|
|
return Sanitize(mVal->mAnimType);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint16_t Sanitize(uint16_t aValue);
|
|
|
|
};
|
2010-02-19 00:50:59 +03:00
|
|
|
|
2019-01-25 06:24:01 +03:00
|
|
|
struct SMILOrient final : public SMILAttr {
|
2010-02-19 00:50:59 +03:00
|
|
|
public:
|
2019-04-04 20:40:56 +03:00
|
|
|
SMILOrient(SVGAnimatedOrient* aOrient, SVGElement* aSVGElement)
|
2019-02-15 11:41:37 +03:00
|
|
|
: mOrient(aOrient), mSVGElement(aSVGElement) {}
|
2010-02-19 00:50:59 +03:00
|
|
|
|
2019-01-25 06:24:01 +03:00
|
|
|
// These will stay alive because a SMILAttr only lives as long
|
2010-02-19 00:50:59 +03:00
|
|
|
// as the Compositing step, and DOM elements don't get a chance to
|
|
|
|
// die during that.
|
2019-04-04 20:40:56 +03:00
|
|
|
SVGAnimatedOrient* mOrient;
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* mSVGElement;
|
2010-02-19 00:50:59 +03:00
|
|
|
|
2019-01-25 06:24:01 +03:00
|
|
|
// SMILAttr methods
|
2010-02-19 00:50:59 +03:00
|
|
|
virtual nsresult ValueFromString(
|
2019-02-15 11:41:37 +03:00
|
|
|
const nsAString& aStr, const dom::SVGAnimationElement* aSrcElement,
|
|
|
|
SMILValue& aValue, bool& aPreventCachingOfSandwich) const override;
|
2019-01-23 16:48:08 +03:00
|
|
|
virtual SMILValue GetBaseValue() const override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ClearAnimValue() override;
|
2019-01-23 16:48:08 +03:00
|
|
|
virtual nsresult SetAnimValue(const SMILValue& 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
|
|
|
|
2019-01-02 00:01:19 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#endif // DOM_SVG_SVGANIMATEDORIENT_H_
|