2015-05-03 19:32:37 +00: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 11:12:37 +00: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-01-23 17:08:17 +00:00
|
|
|
|
2020-07-14 23:40:05 +00:00
|
|
|
#ifndef DOM_SVG_SVGANIMATEDCLASS_H_
|
|
|
|
#define DOM_SVG_SVGANIMATEDCLASS_H_
|
2011-01-23 17:08:17 +00:00
|
|
|
|
2011-10-18 12:43:57 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2020-08-10 07:55:15 +00:00
|
|
|
#include "mozilla/SVGAnimatedClassOrString.h"
|
2012-06-19 02:30:09 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2019-01-25 03:24:01 +00:00
|
|
|
#include "mozilla/SMILAttr.h"
|
2017-03-30 04:10:07 +00:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2011-11-01 19:22:30 +00:00
|
|
|
|
2013-06-14 22:37:27 +00:00
|
|
|
namespace mozilla {
|
2019-01-23 13:48:08 +00:00
|
|
|
|
|
|
|
class SMILValue;
|
|
|
|
|
2013-06-14 22:37:27 +00:00
|
|
|
namespace dom {
|
2019-03-19 00:01:03 +00:00
|
|
|
class DOMSVGAnimatedString;
|
2018-12-21 08:58:14 +00:00
|
|
|
class SVGElement;
|
2020-08-10 07:55:15 +00:00
|
|
|
} // namespace dom
|
2013-06-14 22:37:27 +00:00
|
|
|
|
2020-08-10 07:55:15 +00:00
|
|
|
class SVGAnimatedClass final : public SVGAnimatedClassOrString {
|
2018-11-30 10:46:48 +00:00
|
|
|
public:
|
2020-07-15 10:37:55 +00:00
|
|
|
using SVGElement = dom::SVGElement;
|
2018-12-21 08:58:14 +00:00
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
void Init() { mAnimVal = nullptr; }
|
|
|
|
|
2018-12-21 08:58:14 +00:00
|
|
|
void SetBaseValue(const nsAString& aValue, SVGElement* aSVGElement,
|
2020-08-10 07:55:15 +00:00
|
|
|
bool aDoSetAttr) override;
|
|
|
|
void GetBaseValue(nsAString& aValue,
|
|
|
|
const SVGElement* aSVGElement) const override;
|
2011-01-23 17:08:17 +00:00
|
|
|
|
2018-12-21 08:58:14 +00:00
|
|
|
void SetAnimValue(const nsAString& aValue, SVGElement* aSVGElement);
|
2020-08-10 07:55:15 +00:00
|
|
|
void GetAnimValue(nsAString& aResult,
|
|
|
|
const SVGElement* aSVGElement) const override;
|
2013-06-14 22:37:27 +00:00
|
|
|
bool IsAnimated() const { return !!mAnimVal; }
|
2013-02-07 08:08:56 +00:00
|
|
|
|
2020-07-15 10:37:55 +00:00
|
|
|
UniquePtr<SMILAttr> ToSMILAttr(SVGElement* aSVGElement);
|
2011-01-23 17:08:17 +00:00
|
|
|
|
2018-11-30 10:46:48 +00:00
|
|
|
private:
|
2020-02-25 20:03:26 +00:00
|
|
|
UniquePtr<nsString> mAnimVal;
|
2011-01-23 17:08:17 +00:00
|
|
|
|
|
|
|
public:
|
2019-01-25 03:24:01 +00:00
|
|
|
struct SMILString : public SMILAttr {
|
2011-01-23 17:08:17 +00:00
|
|
|
public:
|
2019-04-04 17:40:56 +00:00
|
|
|
SMILString(SVGAnimatedClass* aVal, SVGElement* aSVGElement)
|
2011-01-23 17:08:17 +00:00
|
|
|
: mVal(aVal), mSVGElement(aSVGElement) {}
|
|
|
|
|
2019-01-25 03:24:01 +00:00
|
|
|
// These will stay alive because a SMILAttr only lives as long
|
2011-01-23 17:08:17 +00:00
|
|
|
// as the Compositing step, and DOM elements don't get a chance to
|
|
|
|
// die during that.
|
2019-04-04 17:40:56 +00:00
|
|
|
SVGAnimatedClass* mVal;
|
2018-12-21 08:58:14 +00:00
|
|
|
SVGElement* mSVGElement;
|
2011-01-23 17:08:17 +00:00
|
|
|
|
2019-01-25 03:24:01 +00:00
|
|
|
// SMILAttr methods
|
2022-12-03 19:18:26 +00:00
|
|
|
nsresult ValueFromString(const nsAString& aStr,
|
|
|
|
const dom::SVGAnimationElement* aSrcElement,
|
|
|
|
SMILValue& aValue,
|
|
|
|
bool& aPreventCachingOfSandwich) const override;
|
|
|
|
SMILValue GetBaseValue() const override;
|
|
|
|
void ClearAnimValue() override;
|
|
|
|
nsresult SetAnimValue(const SMILValue& aValue) override;
|
2011-01-23 17:08:17 +00:00
|
|
|
};
|
|
|
|
};
|
2019-01-01 16:26:26 +00:00
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-07-14 23:40:05 +00:00
|
|
|
#endif // DOM_SVG_SVGANIMATEDCLASS_H_
|