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) 2004
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 of the GNU General Public License Version 2 or later (the "GPL"),
25 : * or 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 : #ifndef __NS_SVGMARKERFRAME_H__
38 : #define __NS_SVGMARKERFRAME_H__
39 :
40 : #include "nsSVGContainerFrame.h"
41 : #include "gfxMatrix.h"
42 :
43 : class gfxContext;
44 : class nsRenderingContext;
45 : class nsSVGPathGeometryFrame;
46 : class nsIURI;
47 : class nsIContent;
48 : struct nsSVGMark;
49 :
50 : typedef nsSVGContainerFrame nsSVGMarkerFrameBase;
51 :
52 : class nsSVGMarkerFrame : public nsSVGMarkerFrameBase
53 0 : {
54 : friend nsIFrame*
55 : NS_NewSVGMarkerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
56 : protected:
57 0 : nsSVGMarkerFrame(nsStyleContext* aContext)
58 : : nsSVGMarkerFrameBase(aContext)
59 : , mMarkedFrame(nsnull)
60 : , mInUse(false)
61 0 : , mInUse2(false)
62 : {
63 0 : AddStateBits(NS_STATE_SVG_NONDISPLAY_CHILD);
64 0 : }
65 :
66 : public:
67 : NS_DECL_FRAMEARENA_HELPERS
68 :
69 : // nsIFrame interface:
70 : #ifdef DEBUG
71 : NS_IMETHOD Init(nsIContent* aContent,
72 : nsIFrame* aParent,
73 : nsIFrame* aPrevInFlow);
74 : #endif
75 :
76 : NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
77 : nsIAtom* aAttribute,
78 : PRInt32 aModType);
79 : /**
80 : * Get the "type" of the frame
81 : *
82 : * @see nsGkAtoms::svgMarkerFrame
83 : */
84 : virtual nsIAtom* GetType() const;
85 :
86 : #ifdef DEBUG
87 0 : NS_IMETHOD GetFrameName(nsAString& aResult) const
88 : {
89 0 : return MakeFrameName(NS_LITERAL_STRING("SVGMarker"), aResult);
90 : }
91 : #endif
92 :
93 : // nsSVGMarkerFrame methods:
94 : nsresult PaintMark(nsRenderingContext *aContext,
95 : nsSVGPathGeometryFrame *aMarkedFrame,
96 : nsSVGMark *aMark,
97 : float aStrokeWidth);
98 :
99 : gfxRect GetMarkBBoxContribution(const gfxMatrix &aToBBoxUserspace,
100 : PRUint32 aFlags,
101 : nsSVGPathGeometryFrame *aMarkedFrame,
102 : const nsSVGMark *aMark,
103 : float aStrokeWidth);
104 :
105 : private:
106 : // stuff needed for callback
107 : nsSVGPathGeometryFrame *mMarkedFrame;
108 : float mStrokeWidth, mX, mY, mAutoAngle;
109 :
110 : // nsSVGContainerFrame methods:
111 : virtual gfxMatrix GetCanvasTM();
112 :
113 : // A helper class to allow us to paint markers safely. The helper
114 : // automatically sets and clears the mInUse flag on the marker frame (to
115 : // prevent nasty reference loops) as well as the reference to the marked
116 : // frame and its coordinate context. It's easy to mess this up
117 : // and break things, so this helper makes the code far more robust.
118 : class AutoMarkerReferencer
119 : {
120 : public:
121 : AutoMarkerReferencer(nsSVGMarkerFrame *aFrame,
122 : nsSVGPathGeometryFrame *aMarkedFrame);
123 : ~AutoMarkerReferencer();
124 : private:
125 : nsSVGMarkerFrame *mFrame;
126 : };
127 :
128 : // nsSVGMarkerFrame methods:
129 : void SetParentCoordCtxProvider(nsSVGSVGElement *aContext);
130 :
131 : // recursion prevention flag
132 : bool mInUse;
133 :
134 : // second recursion prevention flag, for GetCanvasTM()
135 : bool mInUse2;
136 : };
137 :
138 : #endif
|