1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef NSSVGFOREIGNOBJECTFRAME_H__
8 #define NSSVGFOREIGNOBJECTFRAME_H__
10 #include "mozilla/Attributes.h"
11 #include "mozilla/PresShellForwards.h"
12 #include "nsAutoPtr.h"
13 #include "nsContainerFrame.h"
14 #include "nsSVGDisplayableFrame.h"
16 #include "nsSVGUtils.h"
20 class nsSVGForeignObjectFrame final
: public nsContainerFrame
,
21 public nsSVGDisplayableFrame
{
22 friend nsContainerFrame
* NS_NewSVGForeignObjectFrame(
23 mozilla::PresShell
* aPresShell
, ComputedStyle
* aStyle
);
26 explicit nsSVGForeignObjectFrame(ComputedStyle
* aStyle
,
27 nsPresContext
* aPresContext
);
31 NS_DECL_FRAMEARENA_HELPERS(nsSVGForeignObjectFrame
)
34 virtual void Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
35 nsIFrame
* aPrevInFlow
) override
;
36 virtual void DestroyFrom(nsIFrame
* aDestructRoot
,
37 PostDestroyData
& aPostDestroyData
) override
;
38 virtual nsresult
AttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
39 int32_t aModType
) override
;
41 virtual nsContainerFrame
* GetContentInsertionFrame() override
{
42 return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
45 virtual void Reflow(nsPresContext
* aPresContext
, ReflowOutput
& aDesiredSize
,
46 const ReflowInput
& aReflowInput
,
47 nsReflowStatus
& aStatus
) override
;
49 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
50 const nsDisplayListSet
& aLists
) override
;
52 virtual bool IsFrameOfType(uint32_t aFlags
) const override
{
53 if (aFlags
& eSupportsContainLayoutAndPaint
) {
57 return nsContainerFrame::IsFrameOfType(
58 aFlags
& ~(nsIFrame::eSVG
| nsIFrame::eSVGForeignObject
));
61 virtual bool IsSVGTransformed(Matrix
* aOwnTransform
,
62 Matrix
* aFromParentTransform
) const override
;
64 #ifdef DEBUG_FRAME_DUMP
65 virtual nsresult
GetFrameName(nsAString
& aResult
) const override
{
66 return MakeFrameName(NS_LITERAL_STRING("SVGForeignObject"), aResult
);
70 // nsSVGDisplayableFrame interface:
71 virtual void PaintSVG(gfxContext
& aContext
, const gfxMatrix
& aTransform
,
72 imgDrawingParams
& aImgParams
,
73 const nsIntRect
* aDirtyRect
= nullptr) override
;
74 virtual nsIFrame
* GetFrameForPoint(const gfxPoint
& aPoint
) override
;
75 virtual void ReflowSVG() override
;
76 virtual void NotifySVGChanged(uint32_t aFlags
) override
;
77 virtual SVGBBox
GetBBoxContribution(const Matrix
& aToBBoxUserspace
,
78 uint32_t aFlags
) override
;
79 virtual bool IsDisplayContainer() override
{ return true; }
81 gfxMatrix
GetCanvasTM();
83 nsRect
GetInvalidRegion();
85 // Return our ::-moz-svg-foreign-content anonymous box.
86 void AppendDirectlyOwnedAnonBoxes(nsTArray
<OwnedAnonBox
>& aResult
) override
;
88 virtual void DidSetComputedStyle(ComputedStyle
* aOldComputedStyle
) override
;
91 // implementation helpers:
93 void RequestReflow(mozilla::IntrinsicDirty aType
);
95 // If width or height is less than or equal to zero we must disable rendering
96 bool IsDisabled() const { return mRect
.width
<= 0 || mRect
.height
<= 0; }
98 nsAutoPtr
<gfxMatrix
> mCanvasTM
;