1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is the Mozilla SVG project.
16 : *
17 : * The Initial Developer of the Original Code is Brian Birtles.
18 : * Portions created by the Initial Developer are Copyright (C) 2005
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Contributor(s):
22 : * Brian Birtles <birtles@gmail.com>
23 : * Chris Double <chris.double@double.co.nz>
24 : * Daniel Holbert <dholbert@mozilla.com>
25 : *
26 : * Alternatively, the contents of this file may be used under the terms of
27 : * either of the GNU General Public License Version 2 or later (the "GPL"),
28 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 : * in which case the provisions of the GPL or the LGPL are applicable instead
30 : * of those above. If you wish to allow use of your version of this file only
31 : * under the terms of either the GPL or the LGPL, and not to allow others to
32 : * use your version of this file under the terms of the MPL, indicate your
33 : * decision by deleting the provisions above and replace them with the notice
34 : * and other provisions required by the GPL or the LGPL. If you do not delete
35 : * the provisions above, a recipient may use your version of this file under
36 : * the terms of any one of the MPL, the GPL or the LGPL.
37 : *
38 : * ***** END LICENSE BLOCK ***** */
39 :
40 : #include "nsSVGAnimationElement.h"
41 : #include "nsIDOMSVGAnimateTransformElement.h"
42 : #include "nsSVGEnum.h"
43 : #include "nsIDOMSVGTransform.h"
44 : #include "nsIDOMSVGTransformable.h"
45 : #include "nsSMILAnimationFunction.h"
46 :
47 : typedef nsSVGAnimationElement nsSVGAnimateTransformElementBase;
48 :
49 : class nsSVGAnimateTransformElement : public nsSVGAnimateTransformElementBase,
50 : public nsIDOMSVGAnimateTransformElement
51 0 : {
52 : protected:
53 : friend nsresult NS_NewSVGAnimateTransformElement(nsIContent **aResult,
54 : already_AddRefed<nsINodeInfo> aNodeInfo);
55 : nsSVGAnimateTransformElement(already_AddRefed<nsINodeInfo> aNodeInfo);
56 :
57 : nsSMILAnimationFunction mAnimationFunction;
58 :
59 : public:
60 : // interfaces:
61 : NS_DECL_ISUPPORTS_INHERITED
62 : NS_DECL_NSIDOMSVGANIMATETRANSFORMELEMENT
63 :
64 0 : NS_FORWARD_NSIDOMNODE(nsSVGAnimateTransformElementBase::)
65 0 : NS_FORWARD_NSIDOMELEMENT(nsSVGAnimateTransformElementBase::)
66 0 : NS_FORWARD_NSIDOMSVGELEMENT(nsSVGAnimateTransformElementBase::)
67 0 : NS_FORWARD_NSIDOMSVGANIMATIONELEMENT(nsSVGAnimateTransformElementBase::)
68 :
69 : // nsIDOMNode specializations
70 : virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
71 :
72 : // nsGenericElement specializations
73 : bool ParseAttribute(PRInt32 aNamespaceID,
74 : nsIAtom* aAttribute,
75 : const nsAString& aValue,
76 : nsAttrValue& aResult);
77 :
78 : // nsISMILAnimationElement
79 : virtual nsSMILAnimationFunction& AnimationFunction();
80 :
81 : virtual nsXPCClassInfo* GetClassInfo();
82 : };
83 :
84 0 : NS_IMPL_NS_NEW_SVG_ELEMENT(AnimateTransform)
85 :
86 : //----------------------------------------------------------------------
87 : // nsISupports methods
88 :
89 0 : NS_IMPL_ADDREF_INHERITED(nsSVGAnimateTransformElement,nsSVGAnimateTransformElementBase)
90 0 : NS_IMPL_RELEASE_INHERITED(nsSVGAnimateTransformElement,nsSVGAnimateTransformElementBase)
91 :
92 0 : DOMCI_NODE_DATA(SVGAnimateTransformElement, nsSVGAnimateTransformElement)
93 :
94 0 : NS_INTERFACE_TABLE_HEAD(nsSVGAnimateTransformElement)
95 0 : NS_NODE_INTERFACE_TABLE6(nsSVGAnimateTransformElement, nsIDOMNode,
96 : nsIDOMElement, nsIDOMSVGElement,
97 : nsIDOMSVGAnimationElement,
98 : nsIDOMSVGTests,
99 : nsIDOMSVGAnimateTransformElement)
100 0 : NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimateTransformElement)
101 0 : NS_INTERFACE_MAP_END_INHERITING(nsSVGAnimateTransformElementBase)
102 :
103 : //----------------------------------------------------------------------
104 : // Implementation
105 :
106 0 : nsSVGAnimateTransformElement::nsSVGAnimateTransformElement(already_AddRefed<nsINodeInfo> aNodeInfo)
107 0 : : nsSVGAnimateTransformElementBase(aNodeInfo)
108 : {
109 0 : }
110 :
111 : bool
112 0 : nsSVGAnimateTransformElement::ParseAttribute(PRInt32 aNamespaceID,
113 : nsIAtom* aAttribute,
114 : const nsAString& aValue,
115 : nsAttrValue& aResult)
116 : {
117 : // 'type' is an <animateTransform>-specific attribute, and we'll handle it
118 : // specially.
119 0 : if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::type) {
120 0 : aResult.ParseAtom(aValue);
121 0 : nsIAtom* atom = aResult.GetAtomValue();
122 0 : if (atom != nsGkAtoms::translate &&
123 : atom != nsGkAtoms::scale &&
124 : atom != nsGkAtoms::rotate &&
125 : atom != nsGkAtoms::skewX &&
126 : atom != nsGkAtoms::skewY) {
127 0 : ReportAttributeParseFailure(OwnerDoc(), aAttribute, aValue);
128 : }
129 0 : return true;
130 : }
131 :
132 : return nsSVGAnimateTransformElementBase::ParseAttribute(aNamespaceID,
133 : aAttribute, aValue,
134 0 : aResult);
135 : }
136 :
137 : //----------------------------------------------------------------------
138 : // nsIDOMNode methods
139 :
140 0 : NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGAnimateTransformElement)
141 :
142 : //----------------------------------------------------------------------
143 : // nsISMILAnimationElement methods
144 :
145 : nsSMILAnimationFunction&
146 0 : nsSVGAnimateTransformElement::AnimationFunction()
147 : {
148 0 : return mAnimationFunction;
149 : }
|