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/. */
|
2011-07-01 11:19:52 +04:00
|
|
|
|
|
|
|
#ifndef __NS_SVGINTEGERPAIR_H__
|
|
|
|
#define __NS_SVGINTEGERPAIR_H__
|
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
#include "DOMSVGAnimatedInteger.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsError.h"
|
2012-06-19 06:30:09 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2019-01-25 06:24:01 +03:00
|
|
|
#include "mozilla/SMILAttr.h"
|
2017-03-30 07:10:07 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2011-07-01 11:19:52 +04:00
|
|
|
|
2013-03-19 07:18:45 +04:00
|
|
|
namespace mozilla {
|
2019-01-23 16:48:08 +03:00
|
|
|
|
|
|
|
class SMILValue;
|
|
|
|
|
2013-03-19 07:18:45 +04:00
|
|
|
namespace dom {
|
|
|
|
class SVGAnimationElement;
|
2019-01-06 11:22:55 +03:00
|
|
|
class SVGElement;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2013-03-19 07:18:45 +04:00
|
|
|
|
2019-04-04 20:40:56 +03:00
|
|
|
class SVGAnimatedIntegerPair {
|
2018-11-30 13:46:48 +03:00
|
|
|
public:
|
2018-12-21 11:58:14 +03:00
|
|
|
typedef mozilla::dom::SVGElement SVGElement;
|
|
|
|
|
2011-07-01 11:19:52 +04:00
|
|
|
enum PairIndex { eFirst, eSecond };
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void Init(uint8_t aAttrEnum = 0xff, int32_t aValue1 = 0,
|
|
|
|
int32_t aValue2 = 0) {
|
2011-07-01 11:19:52 +04:00
|
|
|
mAnimVal[0] = mBaseVal[0] = aValue1;
|
|
|
|
mAnimVal[1] = mBaseVal[1] = aValue2;
|
|
|
|
mAttrEnum = aAttrEnum;
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsAnimated = false;
|
|
|
|
mIsBaseSet = false;
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
nsresult SetBaseValueString(const nsAString& aValue, SVGElement* aSVGElement);
|
2012-02-16 03:40:45 +04:00
|
|
|
void GetBaseValueString(nsAString& aValue) const;
|
2011-07-01 11:19:52 +04:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
void SetBaseValue(int32_t aValue, PairIndex aIndex, SVGElement* aSVGElement);
|
|
|
|
void SetBaseValues(int32_t aValue1, int32_t aValue2, SVGElement* aSVGElement);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetBaseValue(PairIndex aIndex) const {
|
2011-07-01 11:19:52 +04:00
|
|
|
return mBaseVal[aIndex == eFirst ? 0 : 1];
|
|
|
|
}
|
2018-12-21 11:58:14 +03:00
|
|
|
void SetAnimValue(const int32_t aValue[2], SVGElement* aSVGElement);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetAnimValue(PairIndex aIndex) const {
|
2011-07-01 11:19:52 +04:00
|
|
|
return mAnimVal[aIndex == eFirst ? 0 : 1];
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
// Returns true if the animated value of this integer has been explicitly
|
2011-07-01 11:19:52 +04:00
|
|
|
// set (either by animation, or by taking on the base value which has been
|
2011-10-17 18:59:28 +04:00
|
|
|
// explicitly set by markup or a DOM call), false otherwise.
|
|
|
|
// If this returns false, the animated value is still valid, that is,
|
2018-03-18 21:09:51 +03:00
|
|
|
// usable, and represents the default base value of the attribute.
|
2011-07-01 11:19:52 +04:00
|
|
|
bool IsExplicitlySet() const { return mIsAnimated || mIsBaseSet; }
|
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<mozilla::dom::DOMSVGAnimatedInteger> ToDOMAnimatedInteger(
|
2018-12-21 11:58:14 +03:00
|
|
|
PairIndex aIndex, SVGElement* aSVGElement);
|
2019-01-25 06:24:01 +03:00
|
|
|
mozilla::UniquePtr<SMILAttr> ToSMILAttr(SVGElement* aSVGElement);
|
2011-07-01 11:19:52 +04:00
|
|
|
|
|
|
|
private:
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mAnimVal[2];
|
|
|
|
int32_t mBaseVal[2];
|
|
|
|
uint8_t mAttrEnum; // element specified tracking for attribute
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsAnimated;
|
|
|
|
bool mIsBaseSet;
|
2011-07-01 11:19:52 +04:00
|
|
|
|
|
|
|
public:
|
2019-03-19 03:01:03 +03:00
|
|
|
struct DOMAnimatedInteger final : public mozilla::dom::DOMSVGAnimatedInteger {
|
2019-04-04 20:40:56 +03:00
|
|
|
DOMAnimatedInteger(SVGAnimatedIntegerPair* aVal, PairIndex aIndex,
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* aSVGElement)
|
2019-03-19 03:01:03 +03:00
|
|
|
: mozilla::dom::DOMSVGAnimatedInteger(aSVGElement),
|
2013-07-01 11:02:56 +04:00
|
|
|
mVal(aVal),
|
|
|
|
mIndex(aIndex) {}
|
2012-12-21 13:18:58 +04:00
|
|
|
virtual ~DOMAnimatedInteger();
|
2011-07-01 11:19:52 +04:00
|
|
|
|
2019-04-04 20:40:56 +03:00
|
|
|
SVGAnimatedIntegerPair* mVal; // kept alive because it belongs to content
|
2019-04-12 16:14:25 +03:00
|
|
|
PairIndex mIndex; // are we the first or second integer
|
2011-07-01 11:19:52 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual int32_t BaseVal() override { return mVal->GetBaseValue(mIndex); }
|
|
|
|
virtual void SetBaseVal(int32_t aValue) override {
|
2013-07-01 11:02:56 +04:00
|
|
|
mVal->SetBaseValue(aValue, mIndex, mSVGElement);
|
|
|
|
}
|
2011-07-01 11:19:52 +04:00
|
|
|
|
|
|
|
// Script may have modified animation parameters or timeline -- DOM getters
|
|
|
|
// need to flush any resample requests to reflect these modifications.
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual int32_t AnimVal() override {
|
2011-07-01 11:19:52 +04:00
|
|
|
mSVGElement->FlushAnimations();
|
2013-07-01 11:02:56 +04:00
|
|
|
return mVal->GetAnimValue(mIndex);
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-25 06:24:01 +03:00
|
|
|
struct SMILIntegerPair : public SMILAttr {
|
2011-07-01 11:19:52 +04:00
|
|
|
public:
|
2019-04-04 20:40:56 +03:00
|
|
|
SMILIntegerPair(SVGAnimatedIntegerPair* aVal, SVGElement* aSVGElement)
|
2011-07-01 11:19:52 +04:00
|
|
|
: mVal(aVal), mSVGElement(aSVGElement) {}
|
|
|
|
|
2019-01-25 06:24:01 +03:00
|
|
|
// These will stay alive because a SMILAttr only lives as long
|
2011-07-01 11:19:52 +04: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
|
|
|
SVGAnimatedIntegerPair* mVal;
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* mSVGElement;
|
2011-07-01 11:19:52 +04:00
|
|
|
|
2019-01-25 06:24:01 +03:00
|
|
|
// SMILAttr methods
|
2011-07-01 11:19:52 +04:00
|
|
|
virtual nsresult ValueFromString(
|
|
|
|
const nsAString& aStr,
|
2019-01-23 16:48:08 +03:00
|
|
|
const mozilla::dom::SVGAnimationElement* aSrcElement, SMILValue& aValue,
|
|
|
|
bool& aPreventCachingOfSandwich) const override;
|
|
|
|
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;
|
2011-07-01 11:19:52 +04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-01-06 11:22:55 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2011-07-01 11:19:52 +04:00
|
|
|
#endif //__NS_SVGINTEGERPAIR_H__
|