michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef NSSVGFOREIGNOBJECTFRAME_H__ michael@0: #define NSSVGFOREIGNOBJECTFRAME_H__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsContainerFrame.h" michael@0: #include "nsIPresShell.h" michael@0: #include "nsISVGChildFrame.h" michael@0: #include "nsRegion.h" michael@0: #include "nsSVGUtils.h" michael@0: michael@0: class nsRenderingContext; michael@0: class nsSVGOuterSVGFrame; michael@0: michael@0: typedef nsContainerFrame nsSVGForeignObjectFrameBase; michael@0: michael@0: class nsSVGForeignObjectFrame : public nsSVGForeignObjectFrameBase, michael@0: public nsISVGChildFrame michael@0: { michael@0: friend nsIFrame* michael@0: NS_NewSVGForeignObjectFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); michael@0: protected: michael@0: nsSVGForeignObjectFrame(nsStyleContext* aContext); michael@0: michael@0: public: michael@0: NS_DECL_QUERYFRAME michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: // nsIFrame: michael@0: virtual void Init(nsIContent* aContent, michael@0: nsIFrame* aParent, michael@0: nsIFrame* aPrevInFlow) MOZ_OVERRIDE; michael@0: virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; michael@0: virtual nsresult AttributeChanged(int32_t aNameSpaceID, michael@0: nsIAtom* aAttribute, michael@0: int32_t aModType) MOZ_OVERRIDE; michael@0: michael@0: virtual nsIFrame* GetContentInsertionFrame() MOZ_OVERRIDE { michael@0: return GetFirstPrincipalChild()->GetContentInsertionFrame(); michael@0: } michael@0: michael@0: virtual nsresult Reflow(nsPresContext* aPresContext, michael@0: nsHTMLReflowMetrics& aDesiredSize, michael@0: const nsHTMLReflowState& aReflowState, michael@0: nsReflowStatus& aStatus) MOZ_OVERRIDE; michael@0: michael@0: virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, michael@0: const nsRect& aDirtyRect, michael@0: const nsDisplayListSet& aLists) MOZ_OVERRIDE; michael@0: michael@0: /** michael@0: * Get the "type" of the frame michael@0: * michael@0: * @see nsGkAtoms::svgForeignObjectFrame michael@0: */ michael@0: virtual nsIAtom* GetType() const MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE michael@0: { michael@0: return nsSVGForeignObjectFrameBase::IsFrameOfType(aFlags & michael@0: ~(nsIFrame::eSVG | nsIFrame::eSVGForeignObject)); michael@0: } michael@0: michael@0: virtual bool IsSVGTransformed(Matrix *aOwnTransform, michael@0: Matrix *aFromParentTransform) const MOZ_OVERRIDE; michael@0: michael@0: #ifdef DEBUG_FRAME_DUMP michael@0: virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE michael@0: { michael@0: return MakeFrameName(NS_LITERAL_STRING("SVGForeignObject"), aResult); michael@0: } michael@0: #endif michael@0: michael@0: // nsISVGChildFrame interface: michael@0: virtual nsresult PaintSVG(nsRenderingContext *aContext, michael@0: const nsIntRect *aDirtyRect, michael@0: nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE; michael@0: virtual nsIFrame* GetFrameForPoint(const nsPoint &aPoint) MOZ_OVERRIDE; michael@0: virtual nsRect GetCoveredRegion() MOZ_OVERRIDE; michael@0: virtual void ReflowSVG() MOZ_OVERRIDE; michael@0: virtual void NotifySVGChanged(uint32_t aFlags) MOZ_OVERRIDE; michael@0: virtual SVGBBox GetBBoxContribution(const Matrix &aToBBoxUserspace, michael@0: uint32_t aFlags) MOZ_OVERRIDE; michael@0: virtual bool IsDisplayContainer() MOZ_OVERRIDE { return true; } michael@0: michael@0: gfxMatrix GetCanvasTM(uint32_t aFor, nsIFrame* aTransformRoot = nullptr); michael@0: michael@0: nsRect GetInvalidRegion(); michael@0: michael@0: protected: michael@0: // implementation helpers: michael@0: void DoReflow(); michael@0: void RequestReflow(nsIPresShell::IntrinsicDirty aType); michael@0: michael@0: // If width or height is less than or equal to zero we must disable rendering michael@0: bool IsDisabled() const { return mRect.width <= 0 || mRect.height <= 0; } michael@0: michael@0: nsAutoPtr mCanvasTM; michael@0: michael@0: bool mInReflow; michael@0: }; michael@0: michael@0: #endif