Back to index

lightning-sunbird  0.9+nobinonly
nsSVGLibartGlyphGeometryDefault.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) 2002
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 
00040 #include "nsCOMPtr.h"
00041 #include "nsISVGRendererGlyphGeometry.h"
00042 #include "nsIDOMSVGMatrix.h"
00043 #include "nsISVGGlyphGeometrySource.h"
00044 #include "nsPromiseFlatString.h"
00045 #include "nsPresContext.h"
00046 #include "nsMemory.h"
00047 
00048 #include "nsSVGTypeCIDs.h"
00049 #include "nsIComponentManager.h"
00050 #include "nsIDOMSVGRect.h"
00051 
00056 
00057 
00060 class nsSVGLibartGlyphGeometry : public nsISVGRendererGlyphGeometry
00061 {
00062 protected:
00063   friend nsresult NS_NewSVGLibartGlyphGeometryDefault(nsISVGRendererGlyphGeometry **result,
00064                                                       nsISVGGlyphGeometrySource *src);
00065 
00066   nsSVGLibartGlyphGeometry();
00067   ~nsSVGLibartGlyphGeometry();
00068   nsresult Init(nsISVGGlyphGeometrySource* src);
00069 
00070 public:
00071   // nsISupports interface:
00072   NS_DECL_ISUPPORTS
00073 
00074   // nsISVGRendererGlyphGeometry interface:
00075   NS_DECL_NSISVGRENDERERGLYPHGEOMETRY
00076   
00077 };
00078 
00081 //----------------------------------------------------------------------
00082 // implementation:
00083 
00084 nsSVGLibartGlyphGeometry::nsSVGLibartGlyphGeometry()
00085 {
00086 }
00087 
00088 nsSVGLibartGlyphGeometry::~nsSVGLibartGlyphGeometry()
00089 {
00090 }
00091 
00092 nsresult
00093 nsSVGLibartGlyphGeometry::Init(nsISVGGlyphGeometrySource* src)
00094 {
00095   return NS_OK;
00096 }
00097 
00098 
00099 nsresult
00100 NS_NewSVGLibartGlyphGeometryDefault(nsISVGRendererGlyphGeometry **result,
00101                                     nsISVGGlyphGeometrySource *src)
00102 {
00103   *result = nsnull;
00104   
00105   nsSVGLibartGlyphGeometry* gg = new nsSVGLibartGlyphGeometry();
00106   if (!gg) return NS_ERROR_OUT_OF_MEMORY;
00107 
00108   NS_ADDREF(gg);
00109 
00110   nsresult rv = gg->Init(src);
00111 
00112   if (NS_FAILED(rv)) {
00113     NS_RELEASE(gg);
00114     return rv;
00115   }
00116   
00117   *result = gg;
00118   return rv;
00119 }
00120 
00121 //----------------------------------------------------------------------
00122 // nsISupports methods:
00123 
00124 NS_IMPL_ADDREF(nsSVGLibartGlyphGeometry)
00125 NS_IMPL_RELEASE(nsSVGLibartGlyphGeometry)
00126 
00127 NS_INTERFACE_MAP_BEGIN(nsSVGLibartGlyphGeometry)
00128   NS_INTERFACE_MAP_ENTRY(nsISVGRendererGlyphGeometry)
00129   NS_INTERFACE_MAP_ENTRY(nsISupports)
00130 NS_INTERFACE_MAP_END
00131 
00132 
00133 //----------------------------------------------------------------------
00134 // nsISVGRendererGlyphGeometry methods:
00135 
00137 NS_IMETHODIMP
00138 nsSVGLibartGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
00139 {
00140   return NS_OK;
00141 }
00142 
00144 NS_IMETHODIMP
00145 nsSVGLibartGlyphGeometry::Update(PRUint32 updatemask, nsISVGRendererRegion **_retval)
00146 {
00147   *_retval = nsnull;      
00148   return NS_OK;
00149 }
00150 
00152 NS_IMETHODIMP
00153 nsSVGLibartGlyphGeometry::GetCoveredRegion(nsISVGRendererRegion **_retval)
00154 {
00155   *_retval = nsnull;
00156   return NS_OK;
00157 }
00158 
00160 NS_IMETHODIMP
00161 nsSVGLibartGlyphGeometry::ContainsPoint(float x, float y, PRBool *_retval)
00162 {
00163   *_retval = PR_FALSE;
00164   return NS_OK;
00165 }
00166 
00168 NS_IMETHODIMP
00169 nsSVGLibartGlyphGeometry::GetBoundingBox(nsIDOMSVGRect * *aBoundingBox)
00170 {
00171   *aBoundingBox = nsnull;
00172 
00173   nsCOMPtr<nsIDOMSVGRect> rect = do_CreateInstance(NS_SVGRECT_CONTRACTID);
00174 
00175   NS_ASSERTION(rect, "could not create rect");
00176   if (!rect) return NS_ERROR_FAILURE;
00177   
00178   rect->SetX(0);
00179   rect->SetY(0);
00180   rect->SetWidth(0);
00181   rect->SetHeight(0);
00182 
00183   *aBoundingBox = rect;
00184   NS_ADDREF(*aBoundingBox);
00185   
00186   return NS_OK;
00187 }