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
18 * Crocodile Clips Ltd..
19 * Portions created by the Initial Developer are Copyright (C) 2001
20 * the Initial Developer. All Rights Reserved.
23 * Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or 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 NSSVGFOREIGNOBJECTFRAME_H__
40 #define NSSVGFOREIGNOBJECTFRAME_H__
42 #include "nsContainerFrame.h"
43 #include "nsISVGChildFrame.h"
44 #include "nsIDOMSVGMatrix.h"
46 #include "nsIPresShell.h"
48 #include "gfxMatrix.h"
50 class nsSVGOuterSVGFrame
;
52 typedef nsContainerFrame nsSVGForeignObjectFrameBase
;
54 class nsSVGForeignObjectFrame
: public nsSVGForeignObjectFrameBase
,
55 public nsISVGChildFrame
58 NS_NewSVGForeignObjectFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
);
60 nsSVGForeignObjectFrame(nsStyleContext
* aContext
);
64 NS_DECL_FRAMEARENA_HELPERS
67 NS_IMETHOD
Init(nsIContent
* aContent
,
69 nsIFrame
* aPrevInFlow
);
70 virtual void DestroyFrom(nsIFrame
* aDestructRoot
);
71 NS_IMETHOD
AttributeChanged(PRInt32 aNameSpaceID
,
75 virtual nsIFrame
* GetContentInsertionFrame() {
76 return GetFirstChild(nsnull
)->GetContentInsertionFrame();
79 NS_IMETHOD
Reflow(nsPresContext
* aPresContext
,
80 nsHTMLReflowMetrics
& aDesiredSize
,
81 const nsHTMLReflowState
& aReflowState
,
82 nsReflowStatus
& aStatus
);
85 * Foreign objects are always transformed.
87 virtual PRBool
IsTransformed() const
93 * Foreign objects can return a transform matrix.
95 virtual gfxMatrix
GetTransformMatrix(nsIFrame
**aOutAncestor
);
98 * Get the "type" of the frame
100 * @see nsGkAtoms::svgForeignObjectFrame
102 virtual nsIAtom
* GetType() const;
104 virtual PRBool
IsFrameOfType(PRUint32 aFlags
) const
106 return nsSVGForeignObjectFrameBase::IsFrameOfType(aFlags
&
107 ~(nsIFrame::eSVG
| nsIFrame::eSVGForeignObject
));
110 virtual void InvalidateInternal(const nsRect
& aDamageRect
,
111 nscoord aX
, nscoord aY
, nsIFrame
* aForChild
,
115 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const
117 return MakeFrameName(NS_LITERAL_STRING("SVGForeignObject"), aResult
);
121 // nsISVGChildFrame interface:
122 NS_IMETHOD
PaintSVG(nsSVGRenderState
*aContext
,
123 const nsIntRect
*aDirtyRect
);
124 NS_IMETHOD_(nsIFrame
*) GetFrameForPoint(const nsPoint
&aPoint
);
125 NS_IMETHOD_(nsRect
) GetCoveredRegion();
126 NS_IMETHOD
UpdateCoveredRegion();
127 NS_IMETHOD
InitialUpdate();
128 virtual void NotifySVGChanged(PRUint32 aFlags
);
129 NS_IMETHOD
NotifyRedrawSuspended();
130 NS_IMETHOD
NotifyRedrawUnsuspended();
131 NS_IMETHOD
SetMatrixPropagation(PRBool aPropagate
);
132 virtual PRBool
GetMatrixPropagation();
133 virtual gfxRect
GetBBoxContribution(const gfxMatrix
&aToBBoxUserspace
);
134 NS_IMETHOD_(PRBool
) IsDisplayContainer() { return PR_TRUE
; }
135 NS_IMETHOD_(PRBool
) HasValidCoveredRect() { return PR_TRUE
; }
137 gfxMatrix
GetCanvasTM();
139 // This method allows our nsSVGOuterSVGFrame to reflow us as necessary.
140 void MaybeReflowFromOuterSVGFrame();
143 // implementation helpers:
145 void RequestReflow(nsIPresShell::IntrinsicDirty aType
);
146 void UpdateGraphic();
148 // Returns GetCanvasTM followed by a scale from CSS px to Dev px. Used for
149 // painting, because children expect to paint to device space, not userspace.
150 gfxMatrix
GetCanvasTMForChildren();
151 void InvalidateDirtyRect(nsSVGOuterSVGFrame
* aOuter
,
152 const nsRect
& aRect
, PRUint32 aFlags
);
153 void FlushDirtyRegion();
155 // If width or height is less than or equal to zero we must disable rendering
156 PRBool
IsDisabled() const { return mRect
.width
<= 0 || mRect
.height
<= 0; }
158 nsCOMPtr
<nsIDOMSVGMatrix
> mCanvasTM
;
160 // Areas dirtied by changes to decendents that are in our document
161 nsRegion mSameDocDirtyRegion
;
163 // Areas dirtied by changes to sub-documents embedded by our decendents
164 nsRegion mSubDocDirtyRegion
;
166 PRPackedBool mInReflow
;