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 __NS_SVGOUTERSVGFRAME_H__
40 #define __NS_SVGOUTERSVGFRAME_H__
42 #include "nsSVGContainerFrame.h"
43 #include "nsISVGSVGFrame.h"
44 #include "nsIDOMSVGPoint.h"
45 #include "nsIDOMSVGNumber.h"
47 class nsSVGForeignObjectFrame
;
49 ////////////////////////////////////////////////////////////////////////
50 // nsSVGOuterSVGFrame class
52 typedef nsSVGDisplayContainerFrame nsSVGOuterSVGFrameBase
;
54 class nsSVGOuterSVGFrame
: public nsSVGOuterSVGFrameBase
,
58 NS_NewSVGOuterSVGFrame(nsIPresShell
* aPresShell
, nsIContent
* aContent
, nsStyleContext
* aContext
);
60 nsSVGOuterSVGFrame(nsStyleContext
* aContext
);
62 // nsISupports interface:
63 NS_IMETHOD
QueryInterface(const nsIID
& aIID
, void** aInstancePtr
);
65 NS_IMETHOD_(nsrefcnt
) AddRef() { return 1; }
66 NS_IMETHOD_(nsrefcnt
) Release() { return 1; }
71 ~nsSVGOuterSVGFrame() {
72 NS_ASSERTION(mForeignObjectHash
.Count() == 0,
73 "foreignObject(s) still registered!");
78 virtual nscoord
GetMinWidth(nsIRenderingContext
*aRenderingContext
);
79 virtual nscoord
GetPrefWidth(nsIRenderingContext
*aRenderingContext
);
81 virtual IntrinsicSize
GetIntrinsicSize();
82 virtual nsSize
GetIntrinsicRatio();
84 virtual nsSize
ComputeSize(nsIRenderingContext
*aRenderingContext
,
85 nsSize aCBSize
, nscoord aAvailableWidth
,
86 nsSize aMargin
, nsSize aBorder
, nsSize aPadding
,
89 NS_IMETHOD
Reflow(nsPresContext
* aPresContext
,
90 nsHTMLReflowMetrics
& aDesiredSize
,
91 const nsHTMLReflowState
& aReflowState
,
92 nsReflowStatus
& aStatus
);
94 NS_IMETHOD
DidReflow(nsPresContext
* aPresContext
,
95 const nsHTMLReflowState
* aReflowState
,
96 nsDidReflowStatus aStatus
);
98 NS_IMETHOD_(nsIFrame
*) GetFrameForPoint(const nsPoint
& aPoint
);
100 NS_IMETHOD
BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
101 const nsRect
& aDirtyRect
,
102 const nsDisplayListSet
& aLists
);
104 NS_IMETHOD
Init(nsIContent
* aContent
,
106 nsIFrame
* aPrevInFlow
);
108 virtual nsSplittableType
GetSplittableType() const;
111 * Get the "type" of the frame
113 * @see nsGkAtoms::svgOuterSVGFrame
115 virtual nsIAtom
* GetType() const;
117 void Paint(nsIRenderingContext
& aRenderingContext
,
118 const nsRect
& aDirtyRect
, nsPoint aPt
);
121 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const
123 return MakeFrameName(NS_LITERAL_STRING("SVGOuterSVG"), aResult
);
127 NS_IMETHOD
AttributeChanged(PRInt32 aNameSpaceID
,
131 // nsSVGOuterSVGFrame methods:
133 void InvalidateCoveredRegion(nsIFrame
*aFrame
);
134 // Calls aSVG->UpdateCoveredRegion and returns true if the covered
135 // region actually changed. If it changed, invalidates the old and new
136 // covered regions, taking filters into account, like
137 // InvalidateCoveredRegion.
138 PRBool
UpdateAndInvalidateCoveredRegion(nsIFrame
*aFrame
);
140 PRBool
IsRedrawSuspended();
142 // nsISVGSVGFrame interface:
143 NS_IMETHOD
SuspendRedraw();
144 NS_IMETHOD
UnsuspendRedraw();
145 NS_IMETHOD
NotifyViewportChange();
147 // nsSVGContainerFrame methods:
148 virtual already_AddRefed
<nsIDOMSVGMatrix
> GetCanvasTM();
150 /* Methods to allow descendant nsSVGForeignObjectFrame frames to register and
151 * unregister themselves with their nearest nsSVGOuterSVGFrame ancestor so
152 * they can be reflowed. The methods return PR_TRUE on success or PR_FALSE on
155 void RegisterForeignObject(nsSVGForeignObjectFrame
* aFrame
);
156 void UnregisterForeignObject(nsSVGForeignObjectFrame
* aFrame
);
160 /* Returns true if our content is the document element and our document is
161 * embedded in an HTML 'object', 'embed' or 'applet' element. Set
162 * aEmbeddingFrame to obtain the nsIFrame for the embedding HTML element.
164 PRBool
EmbeddedByReference(nsIFrame
**aEmbeddingFrame
= nsnull
);
166 // A hash-set containing our nsSVGForeignObjectFrame descendants. Note we use
167 // a hash-set to avoid the O(N^2) behavior we'd get tearing down an SVG frame
168 // subtree if we were to use a list (see bug 381285 comment 20).
169 nsTHashtable
<nsVoidPtrHashKey
> mForeignObjectHash
;
171 PRUint32 mRedrawSuspendCount
;
172 nsCOMPtr
<nsIDOMSVGMatrix
> mCanvasTM
;
175 nsCOMPtr
<nsIDOMSVGPoint
> mCurrentTranslate
;
176 nsCOMPtr
<nsIDOMSVGNumber
> mCurrentScale
;
180 PRPackedBool mViewportInitialized
;
182 PRPackedBool mEnableBitmapFallback
;