Back to index

lightning-sunbird  0.9+nobinonly
nsSVGAnimatedTransformList.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
00018  * Crocodile Clips Ltd..
00019  * Portions created by the Initial Developer are Copyright (C) 2001
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #include "nsSVGAnimatedTransformList.h"
00040 #include "nsSVGTransformList.h"
00041 #include "nsSVGValue.h"
00042 #include "nsWeakReference.h"
00043 #include "nsContentUtils.h"
00044 
00046 // nsSVGAnimatedTransformList
00047 
00048 class nsSVGAnimatedTransformList : public nsIDOMSVGAnimatedTransformList,
00049                                    public nsSVGValue,
00050                                    public nsISVGValueObserver,
00051                                    public nsSupportsWeakReference
00052 {  
00053 protected:
00054   friend nsresult
00055   NS_NewSVGAnimatedTransformList(nsIDOMSVGAnimatedTransformList** result,
00056                                  nsIDOMSVGTransformList* baseVal);
00057 
00058   nsSVGAnimatedTransformList();
00059   ~nsSVGAnimatedTransformList();
00060   void Init(nsIDOMSVGTransformList* baseVal);
00061   
00062 public:
00063   // nsISupports interface:
00064   NS_DECL_ISUPPORTS
00065 
00066   // nsIDOMSVGAnimatedTransformList interface:
00067   NS_DECL_NSIDOMSVGANIMATEDTRANSFORMLIST
00068 
00069   // remainder of nsISVGValue interface:
00070   NS_IMETHOD SetValueString(const nsAString& aValue);
00071   NS_IMETHOD GetValueString(nsAString& aValue);
00072 
00073   // nsISVGValueObserver
00074   NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
00075                                      modificationType aModType);
00076   NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable,
00077                                      modificationType aModType);
00078   
00079   // nsISupportsWeakReference
00080   // implementation inherited from nsSupportsWeakReference
00081   
00082 protected:
00083   nsCOMPtr<nsIDOMSVGTransformList> mBaseVal;
00084 };
00085 
00086 
00087 //----------------------------------------------------------------------
00088 // Implementation
00089 
00090 nsSVGAnimatedTransformList::nsSVGAnimatedTransformList()
00091 {
00092 }
00093 
00094 nsSVGAnimatedTransformList::~nsSVGAnimatedTransformList()
00095 {
00096   if (!mBaseVal) return;
00097     nsCOMPtr<nsISVGValue> val = do_QueryInterface(mBaseVal);
00098   if (!val) return;
00099   val->RemoveObserver(this);
00100 }
00101 
00102 void
00103 nsSVGAnimatedTransformList::Init(nsIDOMSVGTransformList* baseVal)
00104 {
00105   mBaseVal = baseVal;
00106   if (!mBaseVal) return;
00107   nsCOMPtr<nsISVGValue> val = do_QueryInterface(mBaseVal);
00108   if (!val) return;
00109   val->AddObserver(this);
00110 }
00111 
00112 //----------------------------------------------------------------------
00113 // nsISupports methods:
00114 
00115 NS_IMPL_ADDREF(nsSVGAnimatedTransformList)
00116 NS_IMPL_RELEASE(nsSVGAnimatedTransformList)
00117 
00118 NS_INTERFACE_MAP_BEGIN(nsSVGAnimatedTransformList)
00119   NS_INTERFACE_MAP_ENTRY(nsISVGValue)
00120   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedTransformList)
00121   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
00122   NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
00123   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGAnimatedTransformList)
00124   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
00125 NS_INTERFACE_MAP_END
00126 
00127 
00128 //----------------------------------------------------------------------
00129 // nsISVGValue methods:
00130 
00131 NS_IMETHODIMP
00132 nsSVGAnimatedTransformList::SetValueString(const nsAString& aValue)
00133 {
00134   nsCOMPtr<nsISVGValue> value = do_QueryInterface(mBaseVal);
00135   return value->SetValueString(aValue);
00136 }
00137 
00138 NS_IMETHODIMP
00139 nsSVGAnimatedTransformList::GetValueString(nsAString& aValue)
00140 {
00141   nsCOMPtr<nsISVGValue> value = do_QueryInterface(mBaseVal);
00142   return value->GetValueString(aValue);
00143 }
00144 
00145 //----------------------------------------------------------------------
00146 // nsIDOMSVGAnimatedTransformList methods:
00147 
00148 /* readonly attribute nsIDOMSVGTransformList baseVal; */
00149 NS_IMETHODIMP
00150 nsSVGAnimatedTransformList::GetBaseVal(nsIDOMSVGTransformList * *aBaseVal)
00151 {
00152   *aBaseVal = mBaseVal;
00153   NS_ADDREF(*aBaseVal);
00154   return NS_OK;
00155 }
00156 
00157 /* readonly attribute nsIDOMSVGTransformList animVal; */
00158 NS_IMETHODIMP
00159 nsSVGAnimatedTransformList::GetAnimVal(nsIDOMSVGTransformList * *aAnimVal)
00160 {
00161   *aAnimVal = mBaseVal;
00162   NS_ADDREF(*aAnimVal);
00163   return NS_OK;
00164 }
00165 
00166 //----------------------------------------------------------------------
00167 // nsISVGValueObserver methods
00168 
00169 NS_IMETHODIMP
00170 nsSVGAnimatedTransformList::WillModifySVGObservable(nsISVGValue* observable,
00171                                                     modificationType aModType)
00172 {
00173   WillModify(aModType);
00174   return NS_OK;
00175 }
00176 
00177 NS_IMETHODIMP
00178 nsSVGAnimatedTransformList::DidModifySVGObservable (nsISVGValue* observable,
00179                                                     modificationType aModType)
00180 {
00181   DidModify(aModType);
00182   return NS_OK;
00183 }
00184 
00185 
00187 // Exported creation functions:
00188 
00189 nsresult
00190 NS_NewSVGAnimatedTransformList(nsIDOMSVGAnimatedTransformList** result,
00191                       nsIDOMSVGTransformList* baseVal)
00192 {
00193   *result = nsnull;
00194   
00195   nsSVGAnimatedTransformList* animatedTransformList = new nsSVGAnimatedTransformList();
00196   if(!animatedTransformList) return NS_ERROR_OUT_OF_MEMORY;
00197   NS_ADDREF(animatedTransformList);
00198 
00199   animatedTransformList->Init(baseVal);
00200   
00201   *result = (nsIDOMSVGAnimatedTransformList*) animatedTransformList;
00202   
00203   return NS_OK;
00204 }
00205