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 LAYOUT_SVG_SVGFOREIGNOBJECTFRAME_H_
8 #define LAYOUT_SVG_SVGFOREIGNOBJECTFRAME_H_
10 #include "mozilla/Attributes.h"
11 #include "mozilla/ISVGDisplayableFrame.h"
12 #include "mozilla/PresShellForwards.h"
13 #include "mozilla/UniquePtr.h"
14 #include "nsContainerFrame.h"
18 nsContainerFrame
* NS_NewSVGForeignObjectFrame(mozilla::PresShell
* aPresShell
,
19 mozilla::ComputedStyle
* aStyle
);
23 class SVGForeignObjectFrame final
: public nsContainerFrame
,
24 public ISVGDisplayableFrame
{
25 friend nsContainerFrame
* ::NS_NewSVGForeignObjectFrame(
26 mozilla::PresShell
* aPresShell
, ComputedStyle
* aStyle
);
29 explicit SVGForeignObjectFrame(ComputedStyle
* aStyle
,
30 nsPresContext
* aPresContext
);
34 NS_DECL_FRAMEARENA_HELPERS(SVGForeignObjectFrame
)
37 void Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
38 nsIFrame
* aPrevInFlow
) override
;
39 nsresult
AttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
40 int32_t aModType
) override
;
42 nsContainerFrame
* GetContentInsertionFrame() override
{
43 return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
46 void Reflow(nsPresContext
* aPresContext
, ReflowOutput
& aDesiredSize
,
47 const ReflowInput
& aReflowInput
,
48 nsReflowStatus
& aStatus
) override
;
50 void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
51 const nsDisplayListSet
& aLists
) override
;
53 bool IsFrameOfType(uint32_t aFlags
) const override
{
54 if (aFlags
& eSupportsContainLayoutAndPaint
) {
58 return nsContainerFrame::IsFrameOfType(aFlags
& ~nsIFrame::eSVG
);
61 bool IsSVGTransformed(Matrix
* aOwnTransform
,
62 Matrix
* aFromParentTransform
) const override
;
64 #ifdef DEBUG_FRAME_DUMP
65 nsresult
GetFrameName(nsAString
& aResult
) const override
{
66 return MakeFrameName(u
"SVGForeignObject"_ns
, aResult
);
70 // ISVGDisplayableFrame interface:
71 void PaintSVG(gfxContext
& aContext
, const gfxMatrix
& aTransform
,
72 imgDrawingParams
& aImgParams
) override
;
73 nsIFrame
* GetFrameForPoint(const gfxPoint
& aPoint
) override
;
74 void ReflowSVG() override
;
75 void NotifySVGChanged(uint32_t aFlags
) override
;
76 SVGBBox
GetBBoxContribution(const Matrix
& aToBBoxUserspace
,
77 uint32_t aFlags
) override
;
78 bool IsDisplayContainer() override
{ return true; }
80 gfxMatrix
GetCanvasTM();
82 // Return our ::-moz-svg-foreign-content anonymous box.
83 void AppendDirectlyOwnedAnonBoxes(nsTArray
<OwnedAnonBox
>& aResult
) override
;
85 void DidSetComputedStyle(ComputedStyle
* aOldComputedStyle
) override
;
88 // implementation helpers:
90 void RequestReflow(IntrinsicDirty aType
);
92 // If width or height is less than or equal to zero we must disable rendering
93 bool IsDisabled() const { return mRect
.width
<= 0 || mRect
.height
<= 0; }
95 UniquePtr
<gfxMatrix
> mCanvasTM
;
100 } // namespace mozilla
102 #endif // LAYOUT_SVG_SVGFOREIGNOBJECTFRAME_H_