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
15 * The Original Code is the Mozilla SVG project.
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2005
20 * the Initial Developer. All Rights Reserved.
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
;
53 typedef nsSVGPaintServerFrame nsSVGPatternFrameBase
;
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
62 friend nsIFrame
* NS_NewSVGPatternFrame(nsIPresShell
* aPresShell
,
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
);
79 // nsSVGContainerFrame methods:
80 virtual already_AddRefed
<nsIDOMSVGMatrix
> GetCanvasTM();
82 // nsIFrame interface:
83 virtual void DidSetStyleContext(nsStyleContext
* aOldStyleContext
);
85 NS_IMETHOD
AttributeChanged(PRInt32 aNameSpaceID
,
90 * Get the "type" of the frame
92 * @see nsGkAtoms::svgPatternFrame
94 virtual nsIAtom
* GetType() const;
97 // nsIFrameDebug interface:
98 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const
100 return MakeFrameName(NS_LITERAL_STRING("SVGPattern"), aResult
);
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
,
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
);
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
;
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
;