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/. */
|
2008-06-14 13:09:44 +04:00
|
|
|
|
|
|
|
#ifndef __NS_SVGSTRING_H__
|
|
|
|
#define __NS_SVGSTRING_H__
|
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
#include "DOMSVGAnimatedString.h"
|
2016-06-07 23:10:18 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2019-01-06 20:52:55 +03:00
|
|
|
#include "mozilla/Attributes.h"
|
2017-03-30 07:10:07 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2008-06-14 13:09:44 +04:00
|
|
|
|
2019-01-06 20:52:55 +03:00
|
|
|
namespace mozilla {
|
2019-01-23 16:48:08 +03:00
|
|
|
|
|
|
|
class SMILValue;
|
|
|
|
|
2019-01-06 20:52:55 +03:00
|
|
|
namespace dom {
|
|
|
|
class SVGElement;
|
|
|
|
}
|
|
|
|
|
2019-04-04 20:40:56 +03:00
|
|
|
class SVGAnimatedString {
|
2008-06-14 13:09:44 +04:00
|
|
|
public:
|
2018-12-21 11:58:14 +03:00
|
|
|
typedef mozilla::dom::SVGElement SVGElement;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void Init(uint8_t aAttrEnum) {
|
2012-07-30 18:20:58 +04:00
|
|
|
mAnimVal = nullptr;
|
2008-06-14 13:09:44 +04:00
|
|
|
mAttrEnum = aAttrEnum;
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsBaseSet = false;
|
2008-06-14 13:09:44 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
void SetBaseValue(const nsAString& aValue, SVGElement* aSVGElement,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aDoSetAttr);
|
2018-12-21 11:58:14 +03:00
|
|
|
void GetBaseValue(nsAString& aValue, const SVGElement* aSVGElement) const {
|
2009-01-22 03:56:51 +03:00
|
|
|
aSVGElement->GetStringBaseValue(mAttrEnum, aValue);
|
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
void SetAnimValue(const nsAString& aValue, SVGElement* aSVGElement);
|
|
|
|
void GetAnimValue(nsAString& aValue, const SVGElement* aSVGElement) const;
|
2008-06-14 13:09:44 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
// Returns true if the animated value of this string 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 !!mAnimVal || mIsBaseSet; }
|
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<mozilla::dom::DOMSVGAnimatedString> ToDOMAnimatedString(
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* aSVGElement);
|
2013-02-07 12:08:56 +04:00
|
|
|
|
2019-01-25 06:24:01 +03:00
|
|
|
mozilla::UniquePtr<SMILAttr> ToSMILAttr(SVGElement* aSVGElement);
|
2008-06-14 13:09:44 +04:00
|
|
|
|
|
|
|
private:
|
2009-01-22 03:56:51 +03:00
|
|
|
nsAutoPtr<nsString> mAnimVal;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t mAttrEnum; // element specified tracking for attribute
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsBaseSet;
|
2008-06-14 13:09:44 +04:00
|
|
|
|
2010-01-12 16:08:43 +03:00
|
|
|
public:
|
2019-03-19 03:01:03 +03:00
|
|
|
// DOM wrapper class for the (DOM)SVGAnimatedString interface where the
|
2019-04-04 20:40:56 +03:00
|
|
|
// wrapped class is SVGAnimatedString.
|
2019-03-19 03:01:03 +03:00
|
|
|
struct DOMAnimatedString final : public mozilla::dom::DOMSVGAnimatedString {
|
2008-12-30 19:32:22 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2013-06-15 02:37:27 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMAnimatedString)
|
|
|
|
|
2019-04-04 20:40:56 +03:00
|
|
|
DOMAnimatedString(SVGAnimatedString* aVal, SVGElement* aSVGElement)
|
2019-03-19 03:01:03 +03:00
|
|
|
: mozilla::dom::DOMSVGAnimatedString(aSVGElement), mVal(aVal) {}
|
2008-06-14 13:09:44 +04:00
|
|
|
|
2019-04-04 20:40:56 +03:00
|
|
|
SVGAnimatedString* mVal; // kept alive because it belongs to content
|
2008-06-14 13:09:44 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void GetBaseVal(nsAString& aResult) override {
|
2013-06-15 02:37:27 +04:00
|
|
|
mVal->GetBaseValue(aResult, mSVGElement);
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void SetBaseVal(const nsAString& aValue) override {
|
2013-06-15 02:37:27 +04:00
|
|
|
mVal->SetBaseValue(aValue, mSVGElement, true);
|
|
|
|
}
|
2008-06-14 13:09:44 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void GetAnimVal(nsAString& aResult) override {
|
2010-10-07 23:19:32 +04:00
|
|
|
mSVGElement->FlushAnimations();
|
2013-06-15 02:37:27 +04:00
|
|
|
mVal->GetAnimValue(aResult, mSVGElement);
|
2010-10-07 23:19:32 +04:00
|
|
|
}
|
2008-06-14 13:09:44 +04:00
|
|
|
|
2014-06-24 20:36:45 +04:00
|
|
|
private:
|
|
|
|
virtual ~DOMAnimatedString();
|
2008-06-14 13:09:44 +04:00
|
|
|
};
|
2019-01-25 06:24:01 +03:00
|
|
|
struct SMILString : public SMILAttr {
|
2010-10-07 23:19:32 +04:00
|
|
|
public:
|
2019-04-04 20:40:56 +03:00
|
|
|
SMILString(SVGAnimatedString* aVal, SVGElement* aSVGElement)
|
2010-10-07 23:19:32 +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
|
2010-10-07 23:19:32 +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
|
|
|
SVGAnimatedString* mVal;
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* mSVGElement;
|
2010-10-07 23:19:32 +04:00
|
|
|
|
2019-01-25 06:24:01 +03:00
|
|
|
// SMILAttr methods
|
2010-10-07 23:19:32 +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;
|
2010-10-07 23:19:32 +04:00
|
|
|
};
|
2008-06-14 13:09:44 +04:00
|
|
|
};
|
2019-01-06 20:52:55 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2008-06-14 13:09:44 +04:00
|
|
|
#endif //__NS_SVGSTRING_H__
|