SVGForeignObjectFrame.h (3204B)
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/. */ 6 7 #ifndef LAYOUT_SVG_SVGFOREIGNOBJECTFRAME_H_ 8 #define LAYOUT_SVG_SVGFOREIGNOBJECTFRAME_H_ 9 10 #include "mozilla/ISVGDisplayableFrame.h" 11 #include "mozilla/PresShellForwards.h" 12 #include "mozilla/UniquePtr.h" 13 #include "nsContainerFrame.h" 14 15 class gfxContext; 16 17 nsContainerFrame* NS_NewSVGForeignObjectFrame(mozilla::PresShell* aPresShell, 18 mozilla::ComputedStyle* aStyle); 19 20 namespace mozilla { 21 22 class SVGForeignObjectFrame final : public nsContainerFrame, 23 public ISVGDisplayableFrame { 24 friend nsContainerFrame* ::NS_NewSVGForeignObjectFrame( 25 mozilla::PresShell* aPresShell, ComputedStyle* aStyle); 26 27 protected: 28 explicit SVGForeignObjectFrame(ComputedStyle* aStyle, 29 nsPresContext* aPresContext); 30 31 public: 32 NS_DECL_QUERYFRAME 33 NS_DECL_FRAMEARENA_HELPERS(SVGForeignObjectFrame) 34 35 // nsIFrame: 36 void Init(nsIContent* aContent, nsContainerFrame* aParent, 37 nsIFrame* aPrevInFlow) override; 38 nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute, 39 AttrModType aModType) override; 40 41 nsContainerFrame* GetContentInsertionFrame() override { 42 return PrincipalChildList().FirstChild()->GetContentInsertionFrame(); 43 } 44 45 void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize, 46 const ReflowInput& aReflowInput, 47 nsReflowStatus& aStatus) override; 48 49 void BuildDisplayList(nsDisplayListBuilder* aBuilder, 50 const nsDisplayListSet& aLists) override; 51 52 bool DoGetParentSVGTransforms(Matrix*) const override; 53 54 #ifdef DEBUG_FRAME_DUMP 55 nsresult GetFrameName(nsAString& aResult) const override { 56 return MakeFrameName(u"SVGForeignObject"_ns, aResult); 57 } 58 #endif 59 60 // ISVGDisplayableFrame interface: 61 void PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform, 62 imgDrawingParams& aImgParams) override; 63 nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) override; 64 void ReflowSVG() override; 65 void NotifySVGChanged(ChangeFlags aFlags) override; 66 SVGBBox GetBBoxContribution(const Matrix& aToBBoxUserspace, 67 uint32_t aFlags) override; 68 bool IsDisplayContainer() override { return true; } 69 70 gfxMatrix GetCanvasTM(); 71 72 // Return our ::-moz-svg-foreign-content anonymous box. 73 void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override; 74 75 void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override; 76 77 protected: 78 // implementation helpers: 79 void DoReflow(); 80 void RequestReflow(IntrinsicDirty aType); 81 82 // If width or height is less than or equal to zero we must disable rendering 83 bool IsDisabled() const { return mRect.width <= 0 || mRect.height <= 0; } 84 85 UniquePtr<gfxMatrix> mCanvasTM; 86 }; 87 88 } // namespace mozilla 89 90 #endif // LAYOUT_SVG_SVGFOREIGNOBJECTFRAME_H_