1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef NSSVGFOREIGNOBJECTFRAME_H__
7 #define NSSVGFOREIGNOBJECTFRAME_H__
9 #include "mozilla/Attributes.h"
10 #include "nsContainerFrame.h"
11 #include "nsIPresShell.h"
12 #include "nsISVGChildFrame.h"
14 #include "nsSVGUtils.h"
16 class nsRenderingContext
;
17 class nsSVGOuterSVGFrame
;
19 typedef nsContainerFrame nsSVGForeignObjectFrameBase
;
21 class nsSVGForeignObjectFrame
: public nsSVGForeignObjectFrameBase
,
22 public nsISVGChildFrame
25 NS_NewSVGForeignObjectFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
);
27 nsSVGForeignObjectFrame(nsStyleContext
* aContext
);
31 NS_DECL_FRAMEARENA_HELPERS
34 virtual void Init(nsIContent
* aContent
,
36 nsIFrame
* aPrevInFlow
) MOZ_OVERRIDE
;
37 virtual void DestroyFrom(nsIFrame
* aDestructRoot
) MOZ_OVERRIDE
;
38 NS_IMETHOD
AttributeChanged(int32_t aNameSpaceID
,
40 int32_t aModType
) MOZ_OVERRIDE
;
42 virtual nsIFrame
* GetContentInsertionFrame() MOZ_OVERRIDE
{
43 return GetFirstPrincipalChild()->GetContentInsertionFrame();
46 NS_IMETHOD
Reflow(nsPresContext
* aPresContext
,
47 nsHTMLReflowMetrics
& aDesiredSize
,
48 const nsHTMLReflowState
& aReflowState
,
49 nsReflowStatus
& aStatus
) MOZ_OVERRIDE
;
51 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
52 const nsRect
& aDirtyRect
,
53 const nsDisplayListSet
& aLists
) MOZ_OVERRIDE
;
56 * Get the "type" of the frame
58 * @see nsGkAtoms::svgForeignObjectFrame
60 virtual nsIAtom
* GetType() const MOZ_OVERRIDE
;
62 virtual bool IsFrameOfType(uint32_t aFlags
) const MOZ_OVERRIDE
64 return nsSVGForeignObjectFrameBase::IsFrameOfType(aFlags
&
65 ~(nsIFrame::eSVG
| nsIFrame::eSVGForeignObject
));
68 virtual bool IsSVGTransformed(gfxMatrix
*aOwnTransform
,
69 gfxMatrix
*aFromParentTransform
) const MOZ_OVERRIDE
;
72 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const MOZ_OVERRIDE
74 return MakeFrameName(NS_LITERAL_STRING("SVGForeignObject"), aResult
);
78 // nsISVGChildFrame interface:
79 NS_IMETHOD
PaintSVG(nsRenderingContext
*aContext
,
80 const nsIntRect
*aDirtyRect
) MOZ_OVERRIDE
;
81 NS_IMETHOD_(nsIFrame
*) GetFrameForPoint(const nsPoint
&aPoint
) MOZ_OVERRIDE
;
82 NS_IMETHOD_(nsRect
) GetCoveredRegion() MOZ_OVERRIDE
;
83 virtual void ReflowSVG() MOZ_OVERRIDE
;
84 virtual void NotifySVGChanged(uint32_t aFlags
) MOZ_OVERRIDE
;
85 virtual SVGBBox
GetBBoxContribution(const gfxMatrix
&aToBBoxUserspace
,
86 uint32_t aFlags
) MOZ_OVERRIDE
;
87 NS_IMETHOD_(bool) IsDisplayContainer() MOZ_OVERRIDE
{ return true; }
89 gfxMatrix
GetCanvasTM(uint32_t aFor
);
91 nsRect
GetInvalidRegion();
94 // implementation helpers:
96 void RequestReflow(nsIPresShell::IntrinsicDirty aType
);
98 // If width or height is less than or equal to zero we must disable rendering
99 bool IsDisabled() const { return mRect
.width
<= 0 || mRect
.height
<= 0; }
101 nsAutoPtr
<gfxMatrix
> mCanvasTM
;