2009-01-14 20:38:07 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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-14 20:38:07 -08:00
|
|
|
|
2013-01-06 01:32:02 -08:00
|
|
|
#ifndef mozilla_dom_SVGAnimationElement_h
|
|
|
|
#define mozilla_dom_SVGAnimationElement_h
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-03-01 22:08:42 -08:00
|
|
|
#include "mozilla/dom/SVGTests.h"
|
2012-01-26 01:57:21 -08:00
|
|
|
#include "nsReferencedElement.h"
|
2009-01-14 20:38:07 -08:00
|
|
|
#include "nsSMILTimedElement.h"
|
2012-01-26 01:57:21 -08:00
|
|
|
#include "nsSVGElement.h"
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2013-01-06 01:32:02 -08:00
|
|
|
typedef nsSVGElement SVGAnimationElementBase;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2013-01-06 01:32:02 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2013-03-18 20:18:45 -07:00
|
|
|
enum nsSMILTargetAttrType {
|
|
|
|
eSMILTargetAttrType_auto,
|
|
|
|
eSMILTargetAttrType_CSS,
|
|
|
|
eSMILTargetAttrType_XML
|
|
|
|
};
|
|
|
|
|
2013-01-06 01:32:02 -08:00
|
|
|
class SVGAnimationElement : public SVGAnimationElementBase,
|
2013-03-18 20:18:45 -07:00
|
|
|
public SVGTests
|
2009-01-14 20:38:07 -08:00
|
|
|
{
|
|
|
|
protected:
|
2014-08-08 06:49:39 -07:00
|
|
|
explicit SVGAnimationElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2009-01-14 20:38:07 -08:00
|
|
|
nsresult Init();
|
2014-07-08 14:23:16 -07:00
|
|
|
virtual ~SVGAnimationElement();
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
public:
|
2009-07-15 11:33:31 -07:00
|
|
|
// interfaces:
|
2009-01-14 20:38:07 -08:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2009-07-15 21:20:16 -07:00
|
|
|
|
2013-01-06 01:32:02 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGAnimationElement,
|
|
|
|
SVGAnimationElementBase)
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override = 0;
|
2013-03-30 19:27:27 -07:00
|
|
|
|
2009-01-14 20:38:07 -08:00
|
|
|
// nsIContent specializations
|
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2015-03-21 09:28:04 -07:00
|
|
|
bool aCompileEventHandlers) override;
|
|
|
|
virtual void UnbindFromTree(bool aDeep, bool aNullParent) override;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult UnsetAttr(int32_t aNamespaceID, nsIAtom* aAttribute,
|
2015-03-21 09:28:04 -07:00
|
|
|
bool aNotify) override;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
2010-03-19 04:17:49 -07:00
|
|
|
|
2012-11-14 14:10:08 -08:00
|
|
|
// Element specializations
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
2009-01-14 20:38:07 -08:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2015-03-21 09:28:04 -07:00
|
|
|
nsAttrValue& aResult) override;
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
2015-03-21 09:28:04 -07:00
|
|
|
const nsAttrValue* aValue, bool aNotify) override;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2013-03-18 20:18:45 -07:00
|
|
|
const nsAttrValue* GetAnimAttr(nsIAtom* aName) const;
|
|
|
|
bool GetAnimAttr(nsIAtom* aAttName, nsAString& aResult) const;
|
|
|
|
bool HasAnimAttr(nsIAtom* aAttName) const;
|
|
|
|
Element* GetTargetElementContent();
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool GetTargetAttributeName(int32_t* aNamespaceID,
|
2013-03-18 20:18:45 -07:00
|
|
|
nsIAtom** aLocalName) const;
|
2009-01-14 20:38:07 -08:00
|
|
|
virtual nsSMILTargetAttrType GetTargetAttributeType() const;
|
2013-03-18 20:18:45 -07:00
|
|
|
nsSMILTimedElement& TimedElement();
|
|
|
|
nsSMILTimeContainer* GetTimeContainer();
|
|
|
|
virtual nsSMILAnimationFunction& AnimationFunction() = 0;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual bool IsEventAttributeName(nsIAtom* aName) override;
|
2013-01-02 12:24:07 -08:00
|
|
|
|
2012-05-17 02:56:57 -07:00
|
|
|
// Utility methods for within SVG
|
|
|
|
void ActivateByHyperlink();
|
|
|
|
|
2013-01-06 01:32:03 -08:00
|
|
|
// WebIDL
|
|
|
|
nsSVGElement* GetTargetElement();
|
|
|
|
float GetStartTime(ErrorResult& rv);
|
|
|
|
float GetCurrentTime();
|
|
|
|
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);
|
|
|
|
|
|
|
|
protected:
|
2010-07-31 00:02:52 -07:00
|
|
|
// nsSVGElement overrides
|
|
|
|
|
2009-07-15 21:20:16 -07:00
|
|
|
void UpdateHrefTarget(nsIContent* aNodeForContext,
|
|
|
|
const nsAString& aHrefStr);
|
2010-08-18 03:20:24 -07:00
|
|
|
void AnimationTargetChanged();
|
2009-07-15 21:20:16 -07:00
|
|
|
|
|
|
|
class TargetReference : public nsReferencedElement {
|
|
|
|
public:
|
2014-08-08 06:49:39 -07:00
|
|
|
explicit TargetReference(SVGAnimationElement* aAnimationElement) :
|
2009-07-15 21:20:16 -07:00
|
|
|
mAnimationElement(aAnimationElement) {}
|
|
|
|
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 03:20:24 -07:00
|
|
|
// them to the new target) and update any event registrations.
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void ElementChanged(Element* aFrom, Element* aTo) override {
|
2010-05-14 10:04:51 -07:00
|
|
|
nsReferencedElement::ElementChanged(aFrom, aTo);
|
2010-08-18 03:20:24 -07:00
|
|
|
mAnimationElement->AnimationTargetChanged();
|
2009-07-15 21:20:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// We need to override IsPersistent to get persistent tracking (beyond the
|
|
|
|
// first time the target changes)
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual bool IsPersistent() override { return true; }
|
2009-07-15 21:20:16 -07:00
|
|
|
private:
|
2013-01-06 01:32:02 -08:00
|
|
|
SVGAnimationElement* const mAnimationElement;
|
2009-07-15 21:20:16 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
TargetReference mHrefTarget;
|
2009-01-14 20:38:07 -08:00
|
|
|
nsSMILTimedElement mTimedElement;
|
|
|
|
};
|
|
|
|
|
2013-01-06 01:32:02 -08:00
|
|
|
} // namespace mozilla
|
|
|
|
} // namespace dom
|
|
|
|
|
|
|
|
#endif // mozilla_dom_SVGAnimationElement_h
|