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 IBM Corporation.
18 : * Portions created by the Initial Developer are Copyright (C) 2005
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Contributor(s):
22 : * Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #include "mozilla/Util.h"
39 :
40 : #include "nsSVGStylableElement.h"
41 : #include "nsGkAtoms.h"
42 : #include "nsIDOMSVGTextPathElement.h"
43 : #include "nsIDOMSVGURIReference.h"
44 : #include "nsIFrame.h"
45 : #include "nsSVGTextPathElement.h"
46 : #include "nsDOMError.h"
47 : #include "nsContentUtils.h"
48 :
49 : using namespace mozilla;
50 :
51 : nsSVGElement::LengthInfo nsSVGTextPathElement::sLengthInfo[1] =
52 : {
53 : { &nsGkAtoms::startOffset, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, nsSVGUtils::X },
54 : };
55 :
56 : nsSVGEnumMapping nsSVGTextPathElement::sMethodMap[] = {
57 : {&nsGkAtoms::align, nsIDOMSVGTextPathElement::TEXTPATH_METHODTYPE_ALIGN},
58 : {&nsGkAtoms::stretch, nsIDOMSVGTextPathElement::TEXTPATH_METHODTYPE_STRETCH},
59 : {nsnull, 0}
60 : };
61 :
62 : nsSVGEnumMapping nsSVGTextPathElement::sSpacingMap[] = {
63 : {&nsGkAtoms::_auto, nsIDOMSVGTextPathElement::TEXTPATH_SPACINGTYPE_AUTO},
64 : {&nsGkAtoms::exact, nsIDOMSVGTextPathElement::TEXTPATH_SPACINGTYPE_EXACT},
65 : {nsnull, 0}
66 : };
67 :
68 : nsSVGElement::EnumInfo nsSVGTextPathElement::sEnumInfo[2] =
69 : {
70 : { &nsGkAtoms::method,
71 : sMethodMap,
72 : nsIDOMSVGTextPathElement::TEXTPATH_METHODTYPE_ALIGN
73 : },
74 : { &nsGkAtoms::spacing,
75 : sSpacingMap,
76 : nsIDOMSVGTextPathElement::TEXTPATH_SPACINGTYPE_EXACT
77 : }
78 : };
79 :
80 : nsSVGElement::StringInfo nsSVGTextPathElement::sStringInfo[1] =
81 : {
82 : { &nsGkAtoms::href, kNameSpaceID_XLink, true }
83 : };
84 :
85 0 : NS_IMPL_NS_NEW_SVG_ELEMENT(TextPath)
86 :
87 : //----------------------------------------------------------------------
88 : // nsISupports methods
89 :
90 0 : NS_IMPL_ADDREF_INHERITED(nsSVGTextPathElement,nsSVGTextPathElementBase)
91 0 : NS_IMPL_RELEASE_INHERITED(nsSVGTextPathElement,nsSVGTextPathElementBase)
92 :
93 0 : DOMCI_NODE_DATA(SVGTextPathElement, nsSVGTextPathElement)
94 :
95 0 : NS_INTERFACE_TABLE_HEAD(nsSVGTextPathElement)
96 0 : NS_NODE_INTERFACE_TABLE7(nsSVGTextPathElement, nsIDOMNode, nsIDOMElement,
97 : nsIDOMSVGElement, nsIDOMSVGTextPathElement,
98 : nsIDOMSVGTextContentElement, nsIDOMSVGTests,
99 : nsIDOMSVGURIReference)
100 0 : NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTextPathElement)
101 0 : NS_INTERFACE_MAP_END_INHERITING(nsSVGTextPathElementBase)
102 :
103 : //----------------------------------------------------------------------
104 : // Implementation
105 :
106 0 : nsSVGTextPathElement::nsSVGTextPathElement(already_AddRefed<nsINodeInfo> aNodeInfo)
107 0 : : nsSVGTextPathElementBase(aNodeInfo)
108 : {
109 0 : }
110 :
111 : //----------------------------------------------------------------------
112 : // nsIDOMNode methods
113 :
114 0 : NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGTextPathElement)
115 :
116 : //----------------------------------------------------------------------
117 : // nsIDOMSVGURIReference methods
118 :
119 : /* readonly attribute nsIDOMSVGAnimatedString href; */
120 0 : NS_IMETHODIMP nsSVGTextPathElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
121 : {
122 0 : return mStringAttributes[HREF].ToDOMAnimatedString(aHref, this);
123 : }
124 :
125 : //----------------------------------------------------------------------
126 : // nsIDOMSVGTextPathElement methods
127 :
128 0 : NS_IMETHODIMP nsSVGTextPathElement::GetStartOffset(nsIDOMSVGAnimatedLength * *aStartOffset)
129 : {
130 0 : return mLengthAttributes[STARTOFFSET].ToDOMAnimatedLength(aStartOffset, this);
131 : }
132 :
133 : /* readonly attribute nsIDOMSVGAnimatedEnumeration method; */
134 0 : NS_IMETHODIMP nsSVGTextPathElement::GetMethod(nsIDOMSVGAnimatedEnumeration * *aMethod)
135 : {
136 0 : return mEnumAttributes[METHOD].ToDOMAnimatedEnum(aMethod, this);
137 : }
138 :
139 : /* readonly attribute nsIDOMSVGAnimatedEnumeration spacing; */
140 0 : NS_IMETHODIMP nsSVGTextPathElement::GetSpacing(nsIDOMSVGAnimatedEnumeration * *aSpacing)
141 : {
142 0 : return mEnumAttributes[SPACING].ToDOMAnimatedEnum(aSpacing, this);
143 : }
144 :
145 : //----------------------------------------------------------------------
146 : // nsIContent methods
147 :
148 : NS_IMETHODIMP_(bool)
149 0 : nsSVGTextPathElement::IsAttributeMapped(const nsIAtom* name) const
150 : {
151 : static const MappedAttributeEntry* const map[] = {
152 : sColorMap,
153 : sFillStrokeMap,
154 : sFontSpecificationMap,
155 : sGraphicsMap,
156 : sTextContentElementsMap
157 : };
158 :
159 0 : return FindAttributeDependence(name, map) ||
160 0 : nsSVGTextPathElementBase::IsAttributeMapped(name);
161 : }
162 :
163 : //----------------------------------------------------------------------
164 : // nsSVGElement overrides
165 :
166 : bool
167 0 : nsSVGTextPathElement::IsEventName(nsIAtom* aName)
168 : {
169 0 : return nsContentUtils::IsEventAttributeName(aName, EventNameType_SVGGraphic);
170 : }
171 :
172 : nsSVGElement::LengthAttributesInfo
173 0 : nsSVGTextPathElement::GetLengthInfo()
174 : {
175 : return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
176 0 : ArrayLength(sLengthInfo));
177 : }
178 :
179 : nsSVGElement::EnumAttributesInfo
180 0 : nsSVGTextPathElement::GetEnumInfo()
181 : {
182 : return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
183 0 : ArrayLength(sEnumInfo));
184 : }
185 :
186 : nsSVGElement::StringAttributesInfo
187 0 : nsSVGTextPathElement::GetStringInfo()
188 : {
189 : return StringAttributesInfo(mStringAttributes, sStringInfo,
190 0 : ArrayLength(sStringInfo));
191 : }
|