1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/dom/SVGTextPathElement.h"
7 #include "mozilla/dom/SVGTextPathElementBinding.h"
8 #include "nsSVGElement.h"
12 NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(TextPath
)
17 class SVGAnimatedLength
;
20 SVGTextPathElement::WrapNode(JSContext
*aCx
)
22 return SVGTextPathElementBinding::Wrap(aCx
, this);
25 nsSVGElement::LengthInfo
SVGTextPathElement::sLengthInfo
[2] =
27 // from SVGTextContentElement:
28 { &nsGkAtoms::textLength
, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER
, SVGContentUtils::XY
},
29 // from SVGTextPathElement:
30 { &nsGkAtoms::startOffset
, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER
, SVGContentUtils::X
}
33 nsSVGEnumMapping
SVGTextPathElement::sMethodMap
[] = {
34 {&nsGkAtoms::align
, TEXTPATH_METHODTYPE_ALIGN
},
35 {&nsGkAtoms::stretch
, TEXTPATH_METHODTYPE_STRETCH
},
39 nsSVGEnumMapping
SVGTextPathElement::sSpacingMap
[] = {
40 {&nsGkAtoms::_auto
, TEXTPATH_SPACINGTYPE_AUTO
},
41 {&nsGkAtoms::exact
, TEXTPATH_SPACINGTYPE_EXACT
},
45 nsSVGElement::EnumInfo
SVGTextPathElement::sEnumInfo
[3] =
47 // from SVGTextContentElement:
48 { &nsGkAtoms::lengthAdjust
,
50 SVG_LENGTHADJUST_SPACING
52 // from SVGTextPathElement:
55 TEXTPATH_METHODTYPE_ALIGN
57 { &nsGkAtoms::spacing
,
59 TEXTPATH_SPACINGTYPE_EXACT
63 nsSVGElement::StringInfo
SVGTextPathElement::sStringInfo
[1] =
65 { &nsGkAtoms::href
, kNameSpaceID_XLink
, true }
68 //----------------------------------------------------------------------
71 SVGTextPathElement::SVGTextPathElement(already_AddRefed
<mozilla::dom::NodeInfo
>& aNodeInfo
)
72 : SVGTextPathElementBase(aNodeInfo
)
76 //----------------------------------------------------------------------
79 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTextPathElement
)
81 already_AddRefed
<SVGAnimatedString
>
82 SVGTextPathElement::Href()
84 return mStringAttributes
[HREF
].ToDOMAnimatedString(this);
87 //----------------------------------------------------------------------
89 already_AddRefed
<SVGAnimatedLength
>
90 SVGTextPathElement::StartOffset()
92 return mLengthAttributes
[STARTOFFSET
].ToDOMAnimatedLength(this);
95 already_AddRefed
<SVGAnimatedEnumeration
>
96 SVGTextPathElement::Method()
98 return mEnumAttributes
[METHOD
].ToDOMAnimatedEnum(this);
101 already_AddRefed
<SVGAnimatedEnumeration
>
102 SVGTextPathElement::Spacing()
104 return mEnumAttributes
[SPACING
].ToDOMAnimatedEnum(this);
107 //----------------------------------------------------------------------
108 // nsIContent methods
111 SVGTextPathElement::IsAttributeMapped(const nsIAtom
* name
) const
113 static const MappedAttributeEntry
* const map
[] = {
116 sFontSpecificationMap
,
118 sTextContentElementsMap
121 return FindAttributeDependence(name
, map
) ||
122 SVGTextPathElementBase::IsAttributeMapped(name
);
125 //----------------------------------------------------------------------
126 // nsSVGElement overrides
128 nsSVGElement::LengthAttributesInfo
129 SVGTextPathElement::GetLengthInfo()
131 return LengthAttributesInfo(mLengthAttributes
, sLengthInfo
,
132 ArrayLength(sLengthInfo
));
135 nsSVGElement::EnumAttributesInfo
136 SVGTextPathElement::GetEnumInfo()
138 return EnumAttributesInfo(mEnumAttributes
, sEnumInfo
,
139 ArrayLength(sEnumInfo
));
142 nsSVGElement::StringAttributesInfo
143 SVGTextPathElement::GetStringInfo()
145 return StringAttributesInfo(mStringAttributes
, sStringInfo
,
146 ArrayLength(sStringInfo
));
150 } // namespace mozilla