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/. */
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2013-01-06 13:32:02 +04:00
|
|
|
#ifndef mozilla_dom_SVGAnimationElement_h
|
|
|
|
#define mozilla_dom_SVGAnimationElement_h
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2019-01-02 10:21:13 +03:00
|
|
|
#include "mozilla/SMILTimedElement.h"
|
2017-09-08 12:02:05 +03:00
|
|
|
#include "mozilla/dom/IDTracker.h"
|
2019-01-01 12:16:21 +03:00
|
|
|
#include "mozilla/dom/SVGElement.h"
|
2013-03-02 10:08:42 +04:00
|
|
|
#include "mozilla/dom/SVGTests.h"
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2013-01-06 13:32:02 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
typedef SVGElement SVGAnimationElementBase;
|
|
|
|
|
2013-01-06 13:32:02 +04:00
|
|
|
class SVGAnimationElement : public SVGAnimationElementBase, public SVGTests {
|
2009-01-15 07:38:07 +03:00
|
|
|
protected:
|
2018-09-21 23:45:49 +03:00
|
|
|
explicit SVGAnimationElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2009-01-15 07:38:07 +03:00
|
|
|
nsresult Init();
|
2019-04-18 01:38:02 +03:00
|
|
|
virtual ~SVGAnimationElement() = default;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
|
|
|
public:
|
2009-07-15 22:33:31 +04:00
|
|
|
// interfaces:
|
2009-01-15 07:38:07 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2009-07-16 08:20:16 +04:00
|
|
|
|
2013-01-06 13:32:02 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGAnimationElement,
|
|
|
|
SVGAnimationElementBase)
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override = 0;
|
2013-03-31 06:27:27 +04:00
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
// nsIContent specializations
|
2019-01-02 16:05:23 +03:00
|
|
|
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
|
2018-07-31 21:18:38 +03:00
|
|
|
nsIContent* aBindingParent) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void UnbindFromTree(bool aDeep, bool aNullParent) override;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
2010-03-19 14:17:49 +03:00
|
|
|
|
2012-11-15 02:10:08 +04:00
|
|
|
// Element specializations
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
2009-01-15 07:38:07 +03:00
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAttrValue& aResult) override;
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
|
2017-05-19 00:09:01 +03:00
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
2017-05-19 00:09:01 +03:00
|
|
|
bool aNotify) override;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2013-03-19 07:18:45 +04:00
|
|
|
Element* GetTargetElementContent();
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual bool GetTargetAttributeName(int32_t* aNamespaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom** aLocalName) const;
|
2019-01-01 12:16:21 +03:00
|
|
|
mozilla::SMILTimedElement& TimedElement();
|
2019-01-02 10:21:13 +03:00
|
|
|
mozilla::SMILTimeContainer* GetTimeContainer();
|
2018-12-31 14:54:22 +03:00
|
|
|
virtual SMILAnimationFunction& AnimationFunction() = 0;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual bool IsEventAttributeNameInternal(nsAtom* aName) override;
|
2013-01-03 00:24:07 +04:00
|
|
|
|
2012-05-17 13:56:57 +04:00
|
|
|
// Utility methods for within SVG
|
|
|
|
void ActivateByHyperlink();
|
|
|
|
|
2013-01-06 13:32:03 +04:00
|
|
|
// WebIDL
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* GetTargetElement();
|
2013-01-06 13:32:03 +04:00
|
|
|
float GetStartTime(ErrorResult& rv);
|
2018-12-21 08:37:58 +03:00
|
|
|
float GetCurrentTimeAsFloat();
|
2013-01-06 13:32:03 +04:00
|
|
|
float GetSimpleDuration(ErrorResult& rv);
|
|
|
|
void BeginElement(ErrorResult& rv) { BeginElementAt(0.f, rv); }
|
|
|
|
void BeginElementAt(float offset, ErrorResult& rv);
|
|
|
|
void EndElement(ErrorResult& rv) { EndElementAt(0.f, rv); }
|
|
|
|
void EndElementAt(float offset, ErrorResult& rv);
|
|
|
|
|
2016-06-28 17:24:48 +03:00
|
|
|
// SVGTests
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement* AsSVGElement() final { return this; }
|
2016-06-28 17:24:48 +03:00
|
|
|
|
2013-01-06 13:32:03 +04:00
|
|
|
protected:
|
2018-12-21 11:58:14 +03:00
|
|
|
// SVGElement overrides
|
2010-07-31 11:02:52 +04:00
|
|
|
|
2018-07-24 03:03:49 +03:00
|
|
|
void UpdateHrefTarget(const nsAString& aHrefStr);
|
2010-08-18 14:20:24 +04:00
|
|
|
void AnimationTargetChanged();
|
2009-07-16 08:20:16 +04:00
|
|
|
|
2017-09-12 22:14:17 +03:00
|
|
|
/**
|
|
|
|
* Helper that provides a reference to the element with the ID that is
|
|
|
|
* referenced by the animation element's 'href' attribute, if any, and that
|
|
|
|
* will notify the animation element if the element that that ID identifies
|
|
|
|
* changes to a different element (or none). (If the 'href' attribute is not
|
|
|
|
* specified, then the animation target is the parent element and this helper
|
|
|
|
* is not used.)
|
|
|
|
*/
|
|
|
|
class HrefTargetTracker final : public IDTracker {
|
2009-07-16 08:20:16 +04:00
|
|
|
public:
|
2017-09-12 22:14:17 +03:00
|
|
|
explicit HrefTargetTracker(SVGAnimationElement* aAnimationElement)
|
|
|
|
: mAnimationElement(aAnimationElement) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2009-07-16 08:20:16 +04:00
|
|
|
protected:
|
|
|
|
// We need to be notified when target changes, in order to request a
|
|
|
|
// sample (which will clear animation effects from old target and apply
|
2010-08-18 14:20:24 +04:00
|
|
|
// them to the new target) and update any event registrations.
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ElementChanged(Element* aFrom, Element* aTo) override {
|
2017-09-08 12:02:05 +03:00
|
|
|
IDTracker::ElementChanged(aFrom, aTo);
|
2010-08-18 14:20:24 +04:00
|
|
|
mAnimationElement->AnimationTargetChanged();
|
2009-07-16 08:20:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// We need to override IsPersistent to get persistent tracking (beyond the
|
|
|
|
// first time the target changes)
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsPersistent() override { return true; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2009-07-16 08:20:16 +04:00
|
|
|
private:
|
2013-01-06 13:32:02 +04:00
|
|
|
SVGAnimationElement* const mAnimationElement;
|
2009-07-16 08:20:16 +04:00
|
|
|
};
|
|
|
|
|
2017-09-12 22:14:17 +03:00
|
|
|
HrefTargetTracker mHrefTarget;
|
2019-01-01 12:16:21 +03:00
|
|
|
mozilla::SMILTimedElement mTimedElement;
|
2009-01-15 07:38:07 +03:00
|
|
|
};
|
|
|
|
|
2013-01-06 13:32:02 +04:00
|
|
|
} // namespace dom
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|
2013-01-06 13:32:02 +04:00
|
|
|
|
|
|
|
#endif // mozilla_dom_SVGAnimationElement_h
|