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
18 : * Scooter Morris.
19 : * Portions created by the Initial Developer are Copyright (C) 2004
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Scooter Morris <scootermorris@comcast.net>
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either the GNU General Public License Version 2 or later (the "GPL"), or
27 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #include "mozilla/Util.h"
40 :
41 : #include "nsSVGStylableElement.h"
42 : #include "nsIDOMSVGStopElement.h"
43 : #include "nsSVGNumber2.h"
44 : #include "nsSVGUtils.h"
45 : #include "nsGenericHTMLElement.h"
46 :
47 : using namespace mozilla;
48 :
49 : typedef nsSVGStylableElement nsSVGStopElementBase;
50 :
51 : class nsSVGStopElement : public nsSVGStopElementBase,
52 : public nsIDOMSVGStopElement
53 0 : {
54 : protected:
55 : friend nsresult NS_NewSVGStopElement(nsIContent **aResult,
56 : already_AddRefed<nsINodeInfo> aNodeInfo);
57 : nsSVGStopElement(already_AddRefed<nsINodeInfo> aNodeInfo);
58 :
59 : public:
60 : // interfaces:
61 :
62 : NS_DECL_ISUPPORTS_INHERITED
63 : NS_DECL_NSIDOMSVGSTOPELEMENT
64 :
65 : // xxx If xpcom allowed virtual inheritance we wouldn't need to
66 : // forward here :-(
67 0 : NS_FORWARD_NSIDOMNODE(nsSVGStopElementBase::)
68 0 : NS_FORWARD_NSIDOMELEMENT(nsSVGStopElementBase::)
69 0 : NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStopElementBase::)
70 :
71 : // nsIContent interface
72 : NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
73 :
74 : virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
75 :
76 : virtual nsXPCClassInfo* GetClassInfo();
77 : protected:
78 :
79 : virtual NumberAttributesInfo GetNumberInfo();
80 : // nsIDOMSVGStopElement properties:
81 : nsSVGNumber2 mOffset;
82 : static NumberInfo sNumberInfo;
83 : };
84 :
85 : nsSVGElement::NumberInfo nsSVGStopElement::sNumberInfo =
86 : { &nsGkAtoms::offset, 0, true };
87 :
88 0 : NS_IMPL_NS_NEW_SVG_ELEMENT(Stop)
89 :
90 : //----------------------------------------------------------------------
91 : // nsISupports methods
92 :
93 0 : NS_IMPL_ADDREF_INHERITED(nsSVGStopElement,nsSVGStopElementBase)
94 0 : NS_IMPL_RELEASE_INHERITED(nsSVGStopElement,nsSVGStopElementBase)
95 :
96 0 : DOMCI_NODE_DATA(SVGStopElement, nsSVGStopElement)
97 :
98 0 : NS_INTERFACE_TABLE_HEAD(nsSVGStopElement)
99 0 : NS_NODE_INTERFACE_TABLE4(nsSVGStopElement, nsIDOMNode, nsIDOMElement,
100 : nsIDOMSVGElement, nsIDOMSVGStopElement)
101 0 : NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStopElement)
102 0 : NS_INTERFACE_MAP_END_INHERITING(nsSVGStopElementBase)
103 :
104 : //----------------------------------------------------------------------
105 : // Implementation
106 :
107 0 : nsSVGStopElement::nsSVGStopElement(already_AddRefed<nsINodeInfo> aNodeInfo)
108 0 : : nsSVGStopElementBase(aNodeInfo)
109 : {
110 :
111 0 : }
112 :
113 : //----------------------------------------------------------------------
114 : // nsIDOMNode methods
115 :
116 0 : NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStopElement)
117 :
118 : //----------------------------------------------------------------------
119 : // nsIDOMSVGStopElement methods
120 :
121 : /* readonly attribute nsIDOMSVGAnimatedNumber offset; */
122 0 : NS_IMETHODIMP nsSVGStopElement::GetOffset(nsIDOMSVGAnimatedNumber * *aOffset)
123 : {
124 0 : return mOffset.ToDOMAnimatedNumber(aOffset,this);
125 : }
126 :
127 : //----------------------------------------------------------------------
128 : // nsSVGElement methods
129 :
130 : nsSVGElement::NumberAttributesInfo
131 0 : nsSVGStopElement::GetNumberInfo()
132 : {
133 0 : return NumberAttributesInfo(&mOffset, &sNumberInfo, 1);
134 : }
135 :
136 : //----------------------------------------------------------------------
137 : // nsIContent methods
138 :
139 : NS_IMETHODIMP_(bool)
140 0 : nsSVGStopElement::IsAttributeMapped(const nsIAtom* name) const
141 : {
142 : static const MappedAttributeEntry* const map[] = {
143 : sGradientStopMap
144 : };
145 :
146 0 : return FindAttributeDependence(name, map) ||
147 0 : nsSVGStopElementBase::IsAttributeMapped(name);
148 : }
149 :
150 :
|