Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / layout / svg / base / src / nsSVGPatternFrame.h
blob0177ca4fd51be933f5de0c331acb5e34d372b896
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
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/
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.
15 * The Original Code is the Mozilla SVG project.
17 * The Initial Developer of the Original Code is
18 * Scooter Morris.
19 * Portions created by the Initial Developer are Copyright (C) 2005
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Scooter Morris <scootermorris@comcast.net>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef __NS_SVGPATTERNFRAME_H__
40 #define __NS_SVGPATTERNFRAME_H__
42 #include "nsIDOMSVGMatrix.h"
43 #include "nsSVGPaintServerFrame.h"
44 #include "gfxMatrix.h"
46 class nsIDOMSVGAnimatedPreserveAspectRatio;
47 class nsIFrame;
48 class nsSVGLength2;
49 class nsSVGElement;
50 class gfxContext;
51 class gfxASurface;
53 typedef nsSVGPaintServerFrame nsSVGPatternFrameBase;
55 /**
56 * Patterns can refer to other patterns. We create an nsSVGPaintingProperty
57 * with property type nsGkAtoms::href to track the referenced pattern.
59 class nsSVGPatternFrame : public nsSVGPatternFrameBase
61 public:
62 friend nsIFrame* NS_NewSVGPatternFrame(nsIPresShell* aPresShell,
63 nsIContent* aContent,
64 nsStyleContext* aContext);
66 nsSVGPatternFrame(nsStyleContext* aContext);
68 nsresult PaintPattern(gfxASurface **surface,
69 gfxMatrix *patternMatrix,
70 nsSVGGeometryFrame *aSource,
71 float aGraphicOpacity);
73 // nsSVGPaintServerFrame methods:
74 virtual PRBool SetupPaintServer(gfxContext *aContext,
75 nsSVGGeometryFrame *aSource,
76 float aGraphicOpacity);
78 public:
79 // nsSVGContainerFrame methods:
80 virtual already_AddRefed<nsIDOMSVGMatrix> GetCanvasTM();
82 // nsIFrame interface:
83 virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
85 NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
86 nsIAtom* aAttribute,
87 PRInt32 aModType);
89 /**
90 * Get the "type" of the frame
92 * @see nsGkAtoms::svgPatternFrame
94 virtual nsIAtom* GetType() const;
96 #ifdef DEBUG
97 // nsIFrameDebug interface:
98 NS_IMETHOD GetFrameName(nsAString& aResult) const
100 return MakeFrameName(NS_LITERAL_STRING("SVGPattern"), aResult);
102 #endif // DEBUG
104 protected:
105 // Internal methods for handling referenced patterns
106 nsSVGPatternFrame* GetReferencedPattern();
107 // Helper to look at our pattern and then along its reference chain (if any)
108 // to find the first pattern with the specified attribute. Returns
109 // null if there isn't one.
110 nsSVGPatternElement* GetPatternWithAttr(nsIAtom *aAttrName, nsIContent *aDefault);
113 nsSVGLength2 *GetX();
114 nsSVGLength2 *GetY();
115 nsSVGLength2 *GetWidth();
116 nsSVGLength2 *GetHeight();
118 PRUint16 GetPatternUnits();
119 PRUint16 GetPatternContentUnits();
120 gfxMatrix GetPatternTransform();
122 NS_IMETHOD GetPreserveAspectRatio(nsIDOMSVGAnimatedPreserveAspectRatio
123 **aPreserveAspectRatio);
124 NS_IMETHOD GetPatternFirstChild(nsIFrame **kid);
125 NS_IMETHOD GetViewBox(nsIDOMSVGRect * *aMatrix);
126 nsresult GetPatternRect(nsIDOMSVGRect **patternRect,
127 nsIDOMSVGRect *bbox,
128 nsIDOMSVGMatrix *callerCTM,
129 nsSVGElement *content);
130 gfxMatrix GetPatternMatrix(nsIDOMSVGRect *bbox,
131 nsIDOMSVGRect *callerBBox,
132 nsIDOMSVGMatrix *callerCTM);
133 nsresult ConstructCTM(nsIDOMSVGMatrix **ctm,
134 nsIDOMSVGRect *callerBBox,
135 nsIDOMSVGMatrix *callerCTM);
136 nsresult GetCallerGeometry(nsIDOMSVGMatrix **aCTM,
137 nsIDOMSVGRect **aBBox,
138 nsSVGElement **aContent,
139 nsSVGGeometryFrame *aSource);
141 private:
142 // this is a *temporary* reference to the frame of the element currently
143 // referencing our pattern. This must be temporary because different
144 // referencing frames will all reference this one frame
145 nsSVGGeometryFrame *mSource;
146 nsCOMPtr<nsIDOMSVGMatrix> mCTM;
148 protected:
149 // This flag is used to detect loops in xlink:href processing
150 PRPackedBool mLoopFlag;
151 // This flag is used to detect loops when painting this pattern
152 // ends up recursively painting itself
153 PRPackedBool mPaintLoopFlag;
154 PRPackedBool mNoHRefURI;
157 #endif