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
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_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,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aCompileEventHandlers) MOZ_OVERRIDE;
|
|
|
|
virtual void UnbindFromTree(bool aDeep, bool aNullParent) MOZ_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,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aNotify) MOZ_OVERRIDE;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_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,
|
2013-05-29 13:43:41 -07:00
|
|
|
nsAttrValue& aResult) MOZ_OVERRIDE;
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
2013-05-29 13:43:41 -07:00
|
|
|
const nsAttrValue* aValue, bool aNotify) MOZ_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
|
|
|
|
2013-01-02 12:24:07 -08:00
|
|
|
virtual bool IsEventAttributeName(nsIAtom* aName) MOZ_OVERRIDE;
|
|
|
|
|
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.
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual void ElementChanged(Element* aFrom, Element* aTo) MOZ_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)
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual bool IsPersistent() MOZ_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
|