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 IsSVGTransformed(Matrix
* aOwnTransform
,
54 Matrix
* aFromParentTransform
) const override
;
56 #ifdef DEBUG_FRAME_DUMP
57 nsresult
GetFrameName(nsAString
& aResult
) const override
{
58 return MakeFrameName(u
"SVGForeignObject"_ns
, aResult
);
62 // ISVGDisplayableFrame interface:
63 void PaintSVG(gfxContext
& aContext
, const gfxMatrix
& aTransform
,
64 imgDrawingParams
& aImgParams
) override
;
65 nsIFrame
* GetFrameForPoint(const gfxPoint
& aPoint
) override
;
66 void ReflowSVG() override
;
67 void NotifySVGChanged(uint32_t aFlags
) override
;
68 SVGBBox
GetBBoxContribution(const Matrix
& aToBBoxUserspace
,
69 uint32_t aFlags
) override
;
70 bool IsDisplayContainer() override
{ return true; }
72 gfxMatrix
GetCanvasTM();
74 // Return our ::-moz-svg-foreign-content anonymous box.
75 void AppendDirectlyOwnedAnonBoxes(nsTArray
<OwnedAnonBox
>& aResult
) override
;
77 void DidSetComputedStyle(ComputedStyle
* aOldComputedStyle
) override
;
80 // implementation helpers:
82 void RequestReflow(IntrinsicDirty aType
);
84 // If width or height is less than or equal to zero we must disable rendering
85 bool IsDisabled() const { return mRect
.width
<= 0 || mRect
.height
<= 0; }
87 UniquePtr
<gfxMatrix
> mCanvasTM
;
90 } // namespace mozilla
92 #endif // LAYOUT_SVG_SVGFOREIGNOBJECTFRAME_H_