Bumping manifests a=b2g-bump
[gecko.git] / dom / svg / SVGTextPathElement.cpp
blobff836be7d1a6c335023d7c998b0edacd44855298
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"
9 #include "nsGkAtoms.h"
10 #include "nsError.h"
12 NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(TextPath)
14 namespace mozilla {
15 namespace dom {
17 class SVGAnimatedLength;
19 JSObject*
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},
36 {nullptr, 0}
39 nsSVGEnumMapping SVGTextPathElement::sSpacingMap[] = {
40 {&nsGkAtoms::_auto, TEXTPATH_SPACINGTYPE_AUTO},
41 {&nsGkAtoms::exact, TEXTPATH_SPACINGTYPE_EXACT},
42 {nullptr, 0}
45 nsSVGElement::EnumInfo SVGTextPathElement::sEnumInfo[3] =
47 // from SVGTextContentElement:
48 { &nsGkAtoms::lengthAdjust,
49 sLengthAdjustMap,
50 SVG_LENGTHADJUST_SPACING
52 // from SVGTextPathElement:
53 { &nsGkAtoms::method,
54 sMethodMap,
55 TEXTPATH_METHODTYPE_ALIGN
57 { &nsGkAtoms::spacing,
58 sSpacingMap,
59 TEXTPATH_SPACINGTYPE_EXACT
63 nsSVGElement::StringInfo SVGTextPathElement::sStringInfo[1] =
65 { &nsGkAtoms::href, kNameSpaceID_XLink, true }
68 //----------------------------------------------------------------------
69 // Implementation
71 SVGTextPathElement::SVGTextPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
72 : SVGTextPathElementBase(aNodeInfo)
76 //----------------------------------------------------------------------
77 // nsIDOMNode methods
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
110 NS_IMETHODIMP_(bool)
111 SVGTextPathElement::IsAttributeMapped(const nsIAtom* name) const
113 static const MappedAttributeEntry* const map[] = {
114 sColorMap,
115 sFillStrokeMap,
116 sFontSpecificationMap,
117 sGraphicsMap,
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));
149 } // namespace dom
150 } // namespace mozilla