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"
|
2013-03-02 10:08:42 +04:00
|
|
|
#include "mozilla/dom/SVGTests.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsReferencedElement.h"
|
2009-01-15 07:38:07 +03:00
|
|
|
#include "nsSMILTimedElement.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsSVGElement.h"
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2013-01-06 13:32:02 +04:00
|
|
|
typedef nsSVGElement SVGAnimationElementBase;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2013-01-06 13:32:02 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2013-03-19 07:18:45 +04:00
|
|
|
enum nsSMILTargetAttrType {
|
|
|
|
eSMILTargetAttrType_auto,
|
|
|
|
eSMILTargetAttrType_CSS,
|
|
|
|
eSMILTargetAttrType_XML
|
|
|
|
};
|
|
|
|
|
2013-01-06 13:32:02 +04:00
|
|
|
class SVGAnimationElement : public SVGAnimationElementBase,
|
2013-03-19 07:18:45 +04:00
|
|
|
public SVGTests
|
2009-01-15 07:38:07 +03:00
|
|
|
{
|
|
|
|
protected:
|
2014-08-08 17:49:39 +04:00
|
|
|
explicit SVGAnimationElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2009-01-15 07:38:07 +03:00
|
|
|
nsresult Init();
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~SVGAnimationElement();
|
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
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override = 0;
|
2013-03-31 06:27:27 +04:00
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
// nsIContent specializations
|
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aCompileEventHandlers) override;
|
|
|
|
virtual void UnbindFromTree(bool aDeep, bool aNullParent) override;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual nsresult UnsetAttr(int32_t aNamespaceID, nsIAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aNotify) 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,
|
2009-01-15 07:38:07 +03:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAttrValue& aResult) override;
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsAttrValue* aValue, bool aNotify) override;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2013-03-19 07:18:45 +04:00
|
|
|
const nsAttrValue* GetAnimAttr(nsIAtom* aName) const;
|
|
|
|
bool GetAnimAttr(nsIAtom* aAttName, nsAString& aResult) const;
|
|
|
|
bool HasAnimAttr(nsIAtom* aAttName) const;
|
|
|
|
Element* GetTargetElementContent();
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual bool GetTargetAttributeName(int32_t* aNamespaceID,
|
2013-03-19 07:18:45 +04:00
|
|
|
nsIAtom** aLocalName) const;
|
2009-01-15 07:38:07 +03:00
|
|
|
virtual nsSMILTargetAttrType GetTargetAttributeType() const;
|
2013-03-19 07:18:45 +04:00
|
|
|
nsSMILTimedElement& TimedElement();
|
|
|
|
nsSMILTimeContainer* GetTimeContainer();
|
|
|
|
virtual nsSMILAnimationFunction& AnimationFunction() = 0;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsEventAttributeName(nsIAtom* 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
|
|
|
|
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);
|
|
|
|
|
2016-06-28 17:24:48 +03:00
|
|
|
// SVGTests
|
|
|
|
virtual bool IsInChromeDoc() const override;
|
|
|
|
|
|
|
|
|
2013-01-06 13:32:03 +04:00
|
|
|
protected:
|
2010-07-31 11:02:52 +04:00
|
|
|
// nsSVGElement overrides
|
|
|
|
|
2009-07-16 08:20:16 +04:00
|
|
|
void UpdateHrefTarget(nsIContent* aNodeForContext,
|
|
|
|
const nsAString& aHrefStr);
|
2010-08-18 14:20:24 +04:00
|
|
|
void AnimationTargetChanged();
|
2009-07-16 08:20:16 +04:00
|
|
|
|
|
|
|
class TargetReference : public nsReferencedElement {
|
|
|
|
public:
|
2014-08-08 17:49:39 +04:00
|
|
|
explicit TargetReference(SVGAnimationElement* aAnimationElement) :
|
2009-07-16 08:20:16 +04: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 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 {
|
2010-05-14 21:04:51 +04:00
|
|
|
nsReferencedElement::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; }
|
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
|
|
|
};
|
|
|
|
|
|
|
|
TargetReference mHrefTarget;
|
2009-01-15 07:38:07 +03:00
|
|
|
nsSMILTimedElement mTimedElement;
|
|
|
|
};
|
|
|
|
|
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
|