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