Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef NSSVGFOREIGNOBJECTFRAME_H__
7 : #define NSSVGFOREIGNOBJECTFRAME_H__
8 :
9 : #include "mozilla/Attributes.h"
10 : #include "nsAutoPtr.h"
11 : #include "nsContainerFrame.h"
12 : #include "nsIPresShell.h"
13 : #include "nsSVGDisplayableFrame.h"
14 : #include "nsRegion.h"
15 : #include "nsSVGUtils.h"
16 :
17 : class gfxContext;
18 :
19 0 : class nsSVGForeignObjectFrame : public nsContainerFrame
20 : , public nsSVGDisplayableFrame
21 : {
22 : friend nsContainerFrame*
23 : NS_NewSVGForeignObjectFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
24 : protected:
25 : explicit nsSVGForeignObjectFrame(nsStyleContext* aContext);
26 :
27 : public:
28 : NS_DECL_QUERYFRAME
29 4 : NS_DECL_FRAMEARENA_HELPERS(nsSVGForeignObjectFrame)
30 :
31 : // nsIFrame:
32 : virtual void Init(nsIContent* aContent,
33 : nsContainerFrame* aParent,
34 : nsIFrame* aPrevInFlow) override;
35 : virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
36 : virtual nsresult AttributeChanged(int32_t aNameSpaceID,
37 : nsIAtom* aAttribute,
38 : int32_t aModType) override;
39 :
40 4 : virtual nsContainerFrame* GetContentInsertionFrame() override {
41 4 : return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
42 : }
43 :
44 : virtual void Reflow(nsPresContext* aPresContext,
45 : ReflowOutput& aDesiredSize,
46 : const ReflowInput& aReflowInput,
47 : nsReflowStatus& aStatus) override;
48 :
49 : virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
50 : const nsRect& aDirtyRect,
51 : const nsDisplayListSet& aLists) override;
52 :
53 62 : virtual bool IsFrameOfType(uint32_t aFlags) const override
54 : {
55 62 : return nsContainerFrame::IsFrameOfType(aFlags &
56 62 : ~(nsIFrame::eSVG | nsIFrame::eSVGForeignObject));
57 : }
58 :
59 : virtual bool IsSVGTransformed(Matrix *aOwnTransform,
60 : Matrix *aFromParentTransform) const override;
61 :
62 : #ifdef DEBUG_FRAME_DUMP
63 0 : virtual nsresult GetFrameName(nsAString& aResult) const override
64 : {
65 0 : return MakeFrameName(NS_LITERAL_STRING("SVGForeignObject"), aResult);
66 : }
67 : #endif
68 :
69 : // nsSVGDisplayableFrame interface:
70 : virtual void PaintSVG(gfxContext& aContext,
71 : 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 0 : virtual bool IsDisplayContainer() override { return true; }
80 :
81 : gfxMatrix GetCanvasTM();
82 :
83 : nsRect GetInvalidRegion();
84 :
85 : // Return our ::-moz-svg-foreign-content anonymous box.
86 : void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
87 :
88 : protected:
89 : // implementation helpers:
90 : void DoReflow();
91 : void RequestReflow(nsIPresShell::IntrinsicDirty aType);
92 :
93 : // If width or height is less than or equal to zero we must disable rendering
94 4 : bool IsDisabled() const { return mRect.width <= 0 || mRect.height <= 0; }
95 :
96 : nsAutoPtr<gfxMatrix> mCanvasTM;
97 :
98 : bool mInReflow;
99 : };
100 :
101 : #endif
|