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 class nsSVGOuterSVGFrame
;
50 typedef nsContainerFrame nsSVGForeignObjectFrameBase
;
52 class nsSVGForeignObjectFrame
: public nsSVGForeignObjectFrameBase
,
53 public nsISVGChildFrame
56 NS_NewSVGForeignObjectFrame(nsIPresShell
* aPresShell
, nsIContent
* aContent
, nsStyleContext
* aContext
);
58 nsSVGForeignObjectFrame(nsStyleContext
* aContext
);
60 // nsISupports interface:
61 NS_IMETHOD
QueryInterface(const nsIID
& aIID
, void** aInstancePtr
);
63 NS_IMETHOD_(nsrefcnt
) AddRef() { return 1; }
64 NS_IMETHOD_(nsrefcnt
) Release() { return 1; }
68 NS_IMETHOD
Init(nsIContent
* aContent
,
70 nsIFrame
* aPrevInFlow
);
71 virtual void Destroy();
72 NS_IMETHOD
AttributeChanged(PRInt32 aNameSpaceID
,
76 virtual nsIFrame
* GetContentInsertionFrame() {
77 return GetFirstChild(nsnull
)->GetContentInsertionFrame();
80 NS_IMETHOD
Reflow(nsPresContext
* aPresContext
,
81 nsHTMLReflowMetrics
& aDesiredSize
,
82 const nsHTMLReflowState
& aReflowState
,
83 nsReflowStatus
& aStatus
);
86 * Foreign objects are always transformed.
88 virtual PRBool
IsTransformed() const
94 * Foreign objects can return a transform matrix.
96 virtual gfxMatrix
GetTransformMatrix(nsIFrame
**aOutAncestor
);
99 * Get the "type" of the frame
101 * @see nsGkAtoms::svgForeignObjectFrame
103 virtual nsIAtom
* GetType() const;
105 virtual PRBool
IsFrameOfType(PRUint32 aFlags
) const
107 return nsSVGForeignObjectFrameBase::IsFrameOfType(aFlags
&
108 ~(nsIFrame::eSVG
| nsIFrame::eSVGForeignObject
));
111 virtual void InvalidateInternal(const nsRect
& aDamageRect
,
112 nscoord aX
, nscoord aY
, nsIFrame
* aForChild
,
116 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const
118 return MakeFrameName(NS_LITERAL_STRING("SVGForeignObject"), aResult
);
122 // nsISVGChildFrame interface:
123 NS_IMETHOD
PaintSVG(nsSVGRenderState
*aContext
,
124 const nsIntRect
*aDirtyRect
);
125 NS_IMETHOD_(nsIFrame
*) GetFrameForPoint(const nsPoint
&aPoint
);
126 NS_IMETHOD_(nsRect
) GetCoveredRegion();
127 NS_IMETHOD
UpdateCoveredRegion();
128 NS_IMETHOD
InitialUpdate();
129 virtual void NotifySVGChanged(PRUint32 aFlags
);
130 NS_IMETHOD
NotifyRedrawSuspended();
131 NS_IMETHOD
NotifyRedrawUnsuspended();
132 NS_IMETHOD
SetMatrixPropagation(PRBool aPropagate
);
133 virtual PRBool
GetMatrixPropagation();
134 NS_IMETHOD
GetBBox(nsIDOMSVGRect
**_retval
);
135 NS_IMETHOD_(PRBool
) IsDisplayContainer() { return PR_TRUE
; }
136 NS_IMETHOD_(PRBool
) HasValidCoveredRect() { return PR_FALSE
; }
138 // foreignobject public methods
140 * @param aPt a point in the app unit coordinate system of the SVG outer frame
141 * Transforms the point to a point in this frame's app unit coordinate system
143 nsPoint
TransformPointFromOuter(nsPoint aPt
);
145 already_AddRefed
<nsIDOMSVGMatrix
> GetCanvasTM();
147 // This method allows our nsSVGOuterSVGFrame to reflow us as necessary.
148 void MaybeReflowFromOuterSVGFrame();
151 // implementation helpers:
153 void RequestReflow(nsIPresShell::IntrinsicDirty aType
);
154 void UpdateGraphic();
155 already_AddRefed
<nsIDOMSVGMatrix
> GetTMIncludingOffset();
156 nsresult
TransformPointFromOuterPx(const nsPoint
&aIn
, nsPoint
* aOut
);
157 void InvalidateDirtyRect(nsSVGOuterSVGFrame
* aOuter
,
158 const nsRect
& aRect
, PRUint32 aFlags
);
159 void FlushDirtyRegion();
161 // If width or height is less than or equal to zero we must disable rendering
162 PRBool
IsDisabled() const { return mRect
.width
<= 0 || mRect
.height
<= 0; }
164 nsCOMPtr
<nsIDOMSVGMatrix
> mCanvasTM
;
165 // Damage area due to in-this-doc invalidation
166 nsRegion mSameDocDirtyRegion
;
167 // Damage area due to cross-doc invalidation
168 nsRegion mCrossDocDirtyRegion
;
170 PRPackedBool mInReflow
;