Bug 1776056 - Switch to the tab an animation is running and make sure the animation...
[gecko.git] / layout / svg / SVGForeignObjectFrame.h
blob4fcd6fe96337a37699ae6e359e2ef103e0949bcb
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"
15 #include "nsRegion.h"
17 class gfxContext;
19 nsContainerFrame* NS_NewSVGForeignObjectFrame(mozilla::PresShell* aPresShell,
20 mozilla::ComputedStyle* aStyle);
22 namespace mozilla {
24 class SVGForeignObjectFrame final : public nsContainerFrame,
25 public ISVGDisplayableFrame {
26 friend nsContainerFrame* ::NS_NewSVGForeignObjectFrame(
27 mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
29 protected:
30 explicit SVGForeignObjectFrame(ComputedStyle* aStyle,
31 nsPresContext* aPresContext);
33 public:
34 NS_DECL_QUERYFRAME
35 NS_DECL_FRAMEARENA_HELPERS(SVGForeignObjectFrame)
37 // nsIFrame:
38 void Init(nsIContent* aContent, nsContainerFrame* aParent,
39 nsIFrame* aPrevInFlow) override;
40 void DestroyFrom(nsIFrame* aDestructRoot,
41 PostDestroyData& aPostDestroyData) override;
42 nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
43 int32_t aModType) override;
45 nsContainerFrame* GetContentInsertionFrame() override {
46 return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
49 void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
50 const ReflowInput& aReflowInput,
51 nsReflowStatus& aStatus) override;
53 void BuildDisplayList(nsDisplayListBuilder* aBuilder,
54 const nsDisplayListSet& aLists) override;
56 bool IsFrameOfType(uint32_t aFlags) const override {
57 if (aFlags & eSupportsContainLayoutAndPaint) {
58 return false;
61 return nsContainerFrame::IsFrameOfType(aFlags & ~nsIFrame::eSVG);
64 bool IsSVGTransformed(Matrix* aOwnTransform,
65 Matrix* aFromParentTransform) const override;
67 #ifdef DEBUG_FRAME_DUMP
68 nsresult GetFrameName(nsAString& aResult) const override {
69 return MakeFrameName(u"SVGForeignObject"_ns, aResult);
71 #endif
73 // ISVGDisplayableFrame interface:
74 void PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform,
75 imgDrawingParams& aImgParams,
76 const nsIntRect* aDirtyRect = nullptr) override;
77 nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) override;
78 void ReflowSVG() override;
79 void NotifySVGChanged(uint32_t aFlags) override;
80 SVGBBox GetBBoxContribution(const Matrix& aToBBoxUserspace,
81 uint32_t aFlags) override;
82 bool IsDisplayContainer() override { return true; }
84 gfxMatrix GetCanvasTM();
86 nsRect GetInvalidRegion();
88 // Return our ::-moz-svg-foreign-content anonymous box.
89 void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
91 void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
93 protected:
94 // implementation helpers:
95 void DoReflow();
96 void RequestReflow(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 UniquePtr<gfxMatrix> mCanvasTM;
103 bool mInReflow;
106 } // namespace mozilla
108 #endif // LAYOUT_SVG_SVGFOREIGNOBJECTFRAME_H_