Back to index

lightning-sunbird  0.9+nobinonly
nsSVGMarkerFrame.h
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 #ifndef __NS_SVGMARKERFRAME_H__
00038 #define __NS_SVGMARKERFRAME_H__
00039 
00040 #include "nsSVGDefsFrame.h"
00041 #include "nsIDOMSVGLength.h"
00042 #include "nsIDOMSVGAngle.h"
00043 #include "nsIDOMSVGRect.h"
00044 #include "nsIDOMSVGAnimatedEnum.h"
00045 #include "nsISVGMarkable.h"
00046 #include "nsLayoutAtoms.h"
00047 
00048 #ifndef M_PI
00049 #define M_PI 3.14159265358979323846
00050 #endif
00051 
00052 class nsSVGPathGeometryFrame;
00053 
00054 #define NS_SVGMARKERFRAME_CID \
00055 {0x899a645c, 0xf817, 0x4a1a, {0xaa, 0x3d, 0xa9, 0x1a, 0xbf, 0xa2, 0xb2, 0x0a}}
00056 
00057 class nsSVGMarkerFrame : public nsSVGDefsFrame
00058 {
00059 protected:
00060   friend nsresult
00061   NS_NewSVGMarkerFrame(nsIPresShell* aPresShell,
00062                        nsIContent* aContent,
00063                        nsIFrame** aNewFrame);
00064 
00065   virtual ~nsSVGMarkerFrame();
00066   NS_IMETHOD InitSVG();
00067 
00068 public:
00069   NS_DECL_ISUPPORTS
00070 
00071   NS_DEFINE_STATIC_CID_ACCESSOR(NS_SVGMARKERFRAME_CID)
00072   NS_DEFINE_STATIC_IID_ACCESSOR(NS_SVGMARKERFRAME_CID)
00073 
00074   // nsISVGValueObserver interface:
00075   NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable,
00076                                     nsISVGValue::modificationType aModType);
00077 
00083   virtual nsIAtom* GetType() const;
00084 
00085 #ifdef DEBUG
00086   NS_IMETHOD GetFrameName(nsAString& aResult) const
00087   {
00088     return MakeFrameName(NS_LITERAL_STRING("SVGMarker"), aResult);
00089   }
00090 #endif
00091 
00092   void PaintMark(nsISVGRendererCanvas *aCanvas,
00093                  nsSVGPathGeometryFrame *aParent,
00094                  nsSVGMark *aMark,
00095                  float aStrokeWidth);
00096 
00097   NS_IMETHOD_(already_AddRefed<nsISVGRendererRegion>)
00098     RegionMark(nsSVGPathGeometryFrame *aParent,
00099                nsSVGMark *aMark, float aStrokeWidth);
00100 
00101   static float bisect(float a1, float a2);
00102 
00103 private:
00104   nsCOMPtr<nsIDOMSVGLength>              mRefX;
00105   nsCOMPtr<nsIDOMSVGLength>              mRefY;
00106   nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mMarkerUnits;
00107   nsCOMPtr<nsIDOMSVGLength>              mMarkerWidth;
00108   nsCOMPtr<nsIDOMSVGLength>              mMarkerHeight;
00109   nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mOrientType;
00110   nsCOMPtr<nsIDOMSVGAngle>               mOrientAngle;
00111   nsCOMPtr<nsIDOMSVGRect>                mViewBox;
00112 
00113   // stuff needed for callback
00114   float mStrokeWidth, mX, mY, mAngle;
00115   nsSVGPathGeometryFrame *mMarkerParent;
00116 
00117   // nsISVGContainerFrame interface:
00118   already_AddRefed<nsIDOMSVGMatrix> GetCanvasTM();
00119 
00120   // recursion prevention flag
00121   PRPackedBool mInUse;
00122 
00123   // second recursion prevention flag, for GetCanvasTM()
00124   PRPackedBool mInUse2;
00125 };
00126 
00127 nsresult
00128 NS_GetSVGMarkerFrame(nsSVGMarkerFrame **aResult,
00129                      nsIURI *aURI,
00130                      nsIContent *aContent);
00131 
00132 #endif