Back to index

lightning-sunbird  0.9+nobinonly
nsSVGClipPathElement.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Mozilla SVG project.
00016  *
00017  * The Initial Developer of the Original Code is IBM Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 2004
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either of the GNU General Public License Version 2 or later (the "GPL"),
00025  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 #include "nsSVGGraphicElement.h"
00038 #include "nsIDOMSVGClipPathElement.h"
00039 #include "nsSVGAtoms.h"
00040 #include "nsSVGAnimatedEnumeration.h"
00041 #include "nsSVGEnum.h"
00042 
00043 typedef nsSVGGraphicElement nsSVGClipPathElementBase;
00044 
00045 class nsSVGClipPathElement : public nsSVGClipPathElementBase,
00046                              public nsIDOMSVGClipPathElement
00047 {
00048 protected:
00049   friend nsresult NS_NewSVGClipPathElement(nsIContent **aResult,
00050                                            nsINodeInfo *aNodeInfo);
00051   nsSVGClipPathElement(nsINodeInfo *aNodeInfo);
00052   virtual ~nsSVGClipPathElement();
00053   nsresult Init();
00054 
00055 public:
00056   // interfaces:
00057   
00058   NS_DECL_ISUPPORTS_INHERITED
00059   NS_DECL_NSIDOMSVGCLIPPATHELEMENT
00060 
00061   // xxx I wish we could use virtual inheritance
00062   NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGClipPathElementBase::)
00063   NS_FORWARD_NSIDOMELEMENT(nsSVGClipPathElementBase::)
00064   NS_FORWARD_NSIDOMSVGELEMENT(nsSVGClipPathElementBase::)
00065 
00066 protected:
00067 
00068   // nsIDOMSVGClipPathElement values
00069   nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mClipPathUnits;
00070 
00071 };
00072 
00074 // implementation
00075 
00076 
00077 NS_IMPL_NS_NEW_SVG_ELEMENT(ClipPath)
00078 
00079 
00080 //----------------------------------------------------------------------
00081 // nsISupports methods
00082 
00083 NS_IMPL_ADDREF_INHERITED(nsSVGClipPathElement,nsSVGClipPathElementBase)
00084 NS_IMPL_RELEASE_INHERITED(nsSVGClipPathElement,nsSVGClipPathElementBase)
00085 
00086 NS_INTERFACE_MAP_BEGIN(nsSVGClipPathElement)
00087   NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
00088   NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
00089   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
00090   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGClipPathElement)
00091   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGClipPathElement)
00092 NS_INTERFACE_MAP_END_INHERITING(nsSVGClipPathElementBase)
00093 
00094 //----------------------------------------------------------------------
00095 // Implementation
00096 
00097 nsSVGClipPathElement::nsSVGClipPathElement(nsINodeInfo *aNodeInfo)
00098   : nsSVGClipPathElementBase(aNodeInfo)
00099 {
00100 }
00101 
00102 nsSVGClipPathElement::~nsSVGClipPathElement()
00103 {
00104 }
00105 
00106 nsresult
00107 nsSVGClipPathElement::Init()
00108 {
00109   nsresult rv = nsSVGClipPathElementBase::Init();
00110   NS_ENSURE_SUCCESS(rv,rv);
00111 
00112   // Define enumeration mappings
00113   static struct nsSVGEnumMapping gUnitMap[] = {
00114     {&nsSVGAtoms::objectBoundingBox, nsIDOMSVGClipPathElement::SVG_CPUNITS_OBJECTBOUNDINGBOX},
00115     {&nsSVGAtoms::userSpaceOnUse, nsIDOMSVGClipPathElement::SVG_CPUNITS_USERSPACEONUSE},
00116     {nsnull, 0}
00117   };
00118 
00119   // DOM property: clipPathUnits ,  #IMPLIED attrib: clipPathUnits
00120   {
00121     nsCOMPtr<nsISVGEnum> units;
00122     rv = NS_NewSVGEnum(getter_AddRefs(units),
00123                        nsIDOMSVGClipPathElement::SVG_CPUNITS_USERSPACEONUSE,
00124                        gUnitMap);
00125     NS_ENSURE_SUCCESS(rv,rv);
00126     rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mClipPathUnits), units);
00127     NS_ENSURE_SUCCESS(rv,rv);
00128     rv = AddMappedSVGValue(nsSVGAtoms::clipPathUnits, mClipPathUnits);
00129     NS_ENSURE_SUCCESS(rv,rv);
00130   }
00131 
00132   return NS_OK;
00133 }
00134 
00135 /* readonly attribute nsIDOMSVGAnimatedEnumeration clipPathUnits; */
00136 NS_IMETHODIMP nsSVGClipPathElement::GetClipPathUnits(nsIDOMSVGAnimatedEnumeration * *aClipPathUnits)
00137 {
00138   *aClipPathUnits = mClipPathUnits;
00139   NS_IF_ADDREF(*aClipPathUnits);
00140   return NS_OK;
00141 }
00142 
00143 
00144 //----------------------------------------------------------------------
00145 // nsIDOMNode methods
00146 
00147 NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGClipPathElement)
00148