/src/mozilla-central/dom/svg/SVGMaskElement.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "mozilla/ArrayUtils.h" |
8 | | |
9 | | #include "nsCOMPtr.h" |
10 | | #include "nsGkAtoms.h" |
11 | | #include "mozilla/dom/SVGLengthBinding.h" |
12 | | #include "mozilla/dom/SVGMaskElement.h" |
13 | | #include "mozilla/dom/SVGMaskElementBinding.h" |
14 | | #include "mozilla/dom/SVGUnitTypesBinding.h" |
15 | | |
16 | | NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Mask) |
17 | | |
18 | | namespace mozilla { |
19 | | namespace dom { |
20 | | |
21 | | using namespace SVGUnitTypes_Binding; |
22 | | |
23 | | JSObject* |
24 | | SVGMaskElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) |
25 | 0 | { |
26 | 0 | return SVGMaskElement_Binding::Wrap(aCx, this, aGivenProto); |
27 | 0 | } |
28 | | |
29 | | //--------------------- Masks ------------------------ |
30 | | |
31 | | nsSVGElement::LengthInfo SVGMaskElement::sLengthInfo[4] = |
32 | | { |
33 | | { &nsGkAtoms::x, -10, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, |
34 | | { &nsGkAtoms::y, -10, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, |
35 | | { &nsGkAtoms::width, 120, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, |
36 | | { &nsGkAtoms::height, 120, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, |
37 | | }; |
38 | | |
39 | | nsSVGElement::EnumInfo SVGMaskElement::sEnumInfo[2] = |
40 | | { |
41 | | { &nsGkAtoms::maskUnits, |
42 | | sSVGUnitTypesMap, |
43 | | SVG_UNIT_TYPE_OBJECTBOUNDINGBOX |
44 | | }, |
45 | | { &nsGkAtoms::maskContentUnits, |
46 | | sSVGUnitTypesMap, |
47 | | SVG_UNIT_TYPE_USERSPACEONUSE |
48 | | } |
49 | | }; |
50 | | |
51 | | //---------------------------------------------------------------------- |
52 | | // Implementation |
53 | | |
54 | | SVGMaskElement::SVGMaskElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo) |
55 | | : SVGMaskElementBase(std::move(aNodeInfo)) |
56 | 0 | { |
57 | 0 | } |
58 | | |
59 | | //---------------------------------------------------------------------- |
60 | | // nsINode method |
61 | | |
62 | | NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMaskElement) |
63 | | |
64 | | //---------------------------------------------------------------------- |
65 | | |
66 | | already_AddRefed<SVGAnimatedEnumeration> |
67 | | SVGMaskElement::MaskUnits() |
68 | 0 | { |
69 | 0 | return mEnumAttributes[MASKUNITS].ToDOMAnimatedEnum(this); |
70 | 0 | } |
71 | | |
72 | | already_AddRefed<SVGAnimatedEnumeration> |
73 | | SVGMaskElement::MaskContentUnits() |
74 | 0 | { |
75 | 0 | return mEnumAttributes[MASKCONTENTUNITS].ToDOMAnimatedEnum(this); |
76 | 0 | } |
77 | | |
78 | | already_AddRefed<SVGAnimatedLength> |
79 | | SVGMaskElement::X() |
80 | 0 | { |
81 | 0 | return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this); |
82 | 0 | } |
83 | | |
84 | | already_AddRefed<SVGAnimatedLength> |
85 | | SVGMaskElement::Y() |
86 | 0 | { |
87 | 0 | return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this); |
88 | 0 | } |
89 | | |
90 | | already_AddRefed<SVGAnimatedLength> |
91 | | SVGMaskElement::Width() |
92 | 0 | { |
93 | 0 | return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this); |
94 | 0 | } |
95 | | |
96 | | already_AddRefed<SVGAnimatedLength> |
97 | | SVGMaskElement::Height() |
98 | 0 | { |
99 | 0 | return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this); |
100 | 0 | } |
101 | | |
102 | | //---------------------------------------------------------------------- |
103 | | // nsSVGElement methods |
104 | | |
105 | | /* virtual */ bool |
106 | | SVGMaskElement::HasValidDimensions() const |
107 | 0 | { |
108 | 0 | return (!mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() || |
109 | 0 | mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0) && |
110 | 0 | (!mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() || |
111 | 0 | mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0); |
112 | 0 | } |
113 | | |
114 | | nsSVGElement::LengthAttributesInfo |
115 | | SVGMaskElement::GetLengthInfo() |
116 | 0 | { |
117 | 0 | return LengthAttributesInfo(mLengthAttributes, sLengthInfo, |
118 | 0 | ArrayLength(sLengthInfo)); |
119 | 0 | } |
120 | | |
121 | | nsSVGElement::EnumAttributesInfo |
122 | | SVGMaskElement::GetEnumInfo() |
123 | 0 | { |
124 | 0 | return EnumAttributesInfo(mEnumAttributes, sEnumInfo, |
125 | 0 | ArrayLength(sEnumInfo)); |
126 | 0 | } |
127 | | |
128 | | //---------------------------------------------------------------------- |
129 | | // nsIContent methods |
130 | | |
131 | | NS_IMETHODIMP_(bool) |
132 | | SVGMaskElement::IsAttributeMapped(const nsAtom* name) const |
133 | 0 | { |
134 | 0 | static const MappedAttributeEntry* const map[] = { |
135 | 0 | sColorMap, |
136 | 0 | sFEFloodMap, |
137 | 0 | sFillStrokeMap, |
138 | 0 | sFiltersMap, |
139 | 0 | sFontSpecificationMap, |
140 | 0 | sGradientStopMap, |
141 | 0 | sGraphicsMap, |
142 | 0 | sMarkersMap, |
143 | 0 | sMaskMap, |
144 | 0 | sTextContentElementsMap, |
145 | 0 | sViewportsMap |
146 | 0 | }; |
147 | 0 |
|
148 | 0 | return FindAttributeDependence(name, map) || |
149 | 0 | SVGMaskElementBase::IsAttributeMapped(name); |
150 | 0 | } |
151 | | |
152 | | } // namespace dom |
153 | | } // namespace mozilla |