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 : *
23 : * Alternatively, the contents of this file may be used under the terms of
24 : * either the GNU General Public License Version 2 or later (the "GPL"), or
25 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 : * in which case the provisions of the GPL or the LGPL are applicable instead
27 : * of those above. If you wish to allow use of your version of this file only
28 : * under the terms of either the GPL or the LGPL, and not to allow others to
29 : * use your version of this file under the terms of the MPL, indicate your
30 : * decision by deleting the provisions above and replace them with the notice
31 : * and other provisions required by the GPL or the LGPL. If you do not delete
32 : * the provisions above, a recipient may use your version of this file under
33 : * the terms of any one of the MPL, the GPL or the LGPL.
34 : *
35 : * ***** END LICENSE BLOCK ***** */
36 :
37 : #include "mozilla/Util.h"
38 :
39 : #include "nsCOMPtr.h"
40 : #include "nsGkAtoms.h"
41 : #include "nsSVGMaskElement.h"
42 :
43 : using namespace mozilla;
44 :
45 : //--------------------- Masks ------------------------
46 :
47 : nsSVGElement::LengthInfo nsSVGMaskElement::sLengthInfo[4] =
48 : {
49 : { &nsGkAtoms::x, -10, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::X },
50 : { &nsGkAtoms::y, -10, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y },
51 : { &nsGkAtoms::width, 120, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::X },
52 : { &nsGkAtoms::height, 120, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y },
53 : };
54 :
55 : nsSVGElement::EnumInfo nsSVGMaskElement::sEnumInfo[2] =
56 : {
57 : { &nsGkAtoms::maskUnits,
58 : sSVGUnitTypesMap,
59 : nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
60 : },
61 : { &nsGkAtoms::maskContentUnits,
62 : sSVGUnitTypesMap,
63 : nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE
64 : }
65 : };
66 :
67 0 : NS_IMPL_NS_NEW_SVG_ELEMENT(Mask)
68 :
69 : //----------------------------------------------------------------------
70 : // nsISupports methods
71 :
72 0 : NS_IMPL_ADDREF_INHERITED(nsSVGMaskElement,nsSVGMaskElementBase)
73 0 : NS_IMPL_RELEASE_INHERITED(nsSVGMaskElement,nsSVGMaskElementBase)
74 :
75 0 : DOMCI_NODE_DATA(SVGMaskElement, nsSVGMaskElement)
76 :
77 0 : NS_INTERFACE_TABLE_HEAD(nsSVGMaskElement)
78 0 : NS_NODE_INTERFACE_TABLE6(nsSVGMaskElement, nsIDOMNode, nsIDOMElement,
79 : nsIDOMSVGElement, nsIDOMSVGTests,
80 : nsIDOMSVGMaskElement, nsIDOMSVGUnitTypes)
81 0 : NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMaskElement)
82 0 : NS_INTERFACE_MAP_END_INHERITING(nsSVGMaskElementBase)
83 :
84 : //----------------------------------------------------------------------
85 : // Implementation
86 :
87 0 : nsSVGMaskElement::nsSVGMaskElement(already_AddRefed<nsINodeInfo> aNodeInfo)
88 0 : : nsSVGMaskElementBase(aNodeInfo)
89 : {
90 0 : }
91 :
92 : //----------------------------------------------------------------------
93 : // nsIDOMNode method
94 :
95 0 : NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMaskElement)
96 :
97 : //----------------------------------------------------------------------
98 : // nsIDOMSVGMaskElement methods
99 :
100 : /* readonly attribute nsIDOMSVGAnimatedEnumeration maskUnits; */
101 0 : NS_IMETHODIMP nsSVGMaskElement::GetMaskUnits(nsIDOMSVGAnimatedEnumeration * *aMaskUnits)
102 : {
103 0 : return mEnumAttributes[MASKUNITS].ToDOMAnimatedEnum(aMaskUnits, this);
104 : }
105 :
106 : /* readonly attribute nsIDOMSVGAnimatedEnumeration maskContentUnits; */
107 0 : NS_IMETHODIMP nsSVGMaskElement::GetMaskContentUnits(nsIDOMSVGAnimatedEnumeration * *aMaskUnits)
108 : {
109 0 : return mEnumAttributes[MASKCONTENTUNITS].ToDOMAnimatedEnum(aMaskUnits, this);
110 : }
111 :
112 : /* readonly attribute nsIDOMSVGAnimatedLength x; */
113 0 : NS_IMETHODIMP nsSVGMaskElement::GetX(nsIDOMSVGAnimatedLength * *aX)
114 : {
115 0 : return mLengthAttributes[X].ToDOMAnimatedLength(aX, this);
116 : }
117 :
118 : /* readonly attribute nsIDOMSVGAnimatedLength y; */
119 0 : NS_IMETHODIMP nsSVGMaskElement::GetY(nsIDOMSVGAnimatedLength * *aY)
120 : {
121 0 : return mLengthAttributes[Y].ToDOMAnimatedLength(aY, this);
122 : }
123 :
124 : /* readonly attribute nsIDOMSVGAnimatedLength width; */
125 0 : NS_IMETHODIMP nsSVGMaskElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
126 : {
127 0 : return mLengthAttributes[WIDTH].ToDOMAnimatedLength(aWidth, this);
128 : }
129 :
130 : /* readonly attribute nsIDOMSVGAnimatedLength height; */
131 0 : NS_IMETHODIMP nsSVGMaskElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
132 : {
133 0 : return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this);
134 : }
135 :
136 : //----------------------------------------------------------------------
137 : // nsSVGElement methods
138 :
139 : /* virtual */ bool
140 0 : nsSVGMaskElement::HasValidDimensions() const
141 : {
142 0 : return (!mLengthAttributes[WIDTH].IsExplicitlySet() ||
143 0 : mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0) &&
144 0 : (!mLengthAttributes[HEIGHT].IsExplicitlySet() ||
145 0 : mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0);
146 : }
147 :
148 : nsSVGElement::LengthAttributesInfo
149 0 : nsSVGMaskElement::GetLengthInfo()
150 : {
151 : return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
152 0 : ArrayLength(sLengthInfo));
153 : }
154 :
155 : nsSVGElement::EnumAttributesInfo
156 0 : nsSVGMaskElement::GetEnumInfo()
157 : {
158 : return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
159 0 : ArrayLength(sEnumInfo));
160 : }
161 :
162 : //----------------------------------------------------------------------
163 : // nsIContent methods
164 :
165 : NS_IMETHODIMP_(bool)
166 0 : nsSVGMaskElement::IsAttributeMapped(const nsIAtom* name) const
167 : {
168 : static const MappedAttributeEntry* const map[] = {
169 : sFEFloodMap,
170 : sFiltersMap,
171 : sFontSpecificationMap,
172 : sGradientStopMap,
173 : sGraphicsMap,
174 : sMarkersMap,
175 : sTextContentElementsMap,
176 : sViewportsMap
177 : };
178 :
179 0 : return FindAttributeDependence(name, map) ||
180 0 : nsSVGMaskElementBase::IsAttributeMapped(name);
181 : }
|