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 NS_SVGCONTAINERFRAME_H michael@0: #define NS_SVGCONTAINERFRAME_H michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsContainerFrame.h" michael@0: #include "nsFrame.h" michael@0: #include "nsIFrame.h" michael@0: #include "nsISVGChildFrame.h" michael@0: #include "nsQueryFrame.h" michael@0: #include "nsRect.h" michael@0: #include "nsSVGUtils.h" michael@0: michael@0: class nsFrameList; michael@0: class nsIContent; michael@0: class nsIPresShell; michael@0: class nsRenderingContext; michael@0: class nsStyleContext; michael@0: michael@0: struct nsPoint; michael@0: struct nsRect; michael@0: struct nsIntRect; michael@0: michael@0: typedef nsContainerFrame nsSVGContainerFrameBase; michael@0: michael@0: /** michael@0: * Base class for SVG container frames. Frame sub-classes that do not michael@0: * display their contents directly (such as the frames for or michael@0: * ) just inherit this class. Frame sub-classes that do or can michael@0: * display their contents directly (such as the frames for inner- or michael@0: * ) inherit our nsDisplayContainerFrame sub-class. michael@0: * michael@0: * *** WARNING *** michael@0: * michael@0: * Do *not* blindly cast to SVG element types in this class's methods (see the michael@0: * warning comment for nsSVGDisplayContainerFrame below). michael@0: */ michael@0: class nsSVGContainerFrame : public nsSVGContainerFrameBase michael@0: { michael@0: friend nsIFrame* NS_NewSVGContainerFrame(nsIPresShell* aPresShell, michael@0: nsStyleContext* aContext); michael@0: protected: michael@0: nsSVGContainerFrame(nsStyleContext* aContext) michael@0: : nsSVGContainerFrameBase(aContext) michael@0: { michael@0: AddStateBits(NS_FRAME_SVG_LAYOUT); michael@0: } michael@0: michael@0: public: michael@0: NS_DECL_QUERYFRAME_TARGET(nsSVGContainerFrame) michael@0: NS_DECL_QUERYFRAME michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: // Returns the transform to our gfxContext (to device pixels, not CSS px) michael@0: virtual gfxMatrix GetCanvasTM(uint32_t aFor, michael@0: nsIFrame* aTransformRoot = nullptr) { michael@0: return gfxMatrix(); michael@0: } michael@0: michael@0: /** michael@0: * Returns true if the frame's content has a transform that applies only to michael@0: * its children, and not to the frame itself. For example, an implicit michael@0: * transform introduced by a 'viewBox' attribute, or an explicit transform michael@0: * due to a root- having its currentScale/currentTransform properties michael@0: * set. If aTransform is non-null, then it will be set to the transform. michael@0: */ michael@0: virtual bool HasChildrenOnlyTransform(Matrix *aTransform) const { michael@0: return false; michael@0: } michael@0: michael@0: // nsIFrame: michael@0: virtual nsresult AppendFrames(ChildListID aListID, michael@0: nsFrameList& aFrameList) MOZ_OVERRIDE; michael@0: virtual nsresult InsertFrames(ChildListID aListID, michael@0: nsIFrame* aPrevFrame, michael@0: nsFrameList& aFrameList) MOZ_OVERRIDE; michael@0: virtual nsresult RemoveFrame(ChildListID aListID, michael@0: nsIFrame* aOldFrame) MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE michael@0: { michael@0: return nsSVGContainerFrameBase::IsFrameOfType( michael@0: aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGContainer)); michael@0: } 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: virtual bool UpdateOverflow() MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: /** michael@0: * Traverses a frame tree, marking any SVGTextFrame frames as dirty michael@0: * and calling InvalidateRenderingObservers() on it. michael@0: */ michael@0: static void ReflowSVGNonDisplayText(nsIFrame* aContainer); michael@0: }; michael@0: michael@0: /** michael@0: * Frame class or base-class for SVG containers that can or do display their michael@0: * contents directly. michael@0: * michael@0: * *** WARNING *** michael@0: * michael@0: * This class's methods can *not* assume that mContent points to an instance of michael@0: * an SVG element class since this class is inherited by michael@0: * nsSVGGenericContainerFrame which is used for unrecognized elements in the michael@0: * SVG namespace. Do *not* blindly cast to SVG element types. michael@0: */ michael@0: class nsSVGDisplayContainerFrame : public nsSVGContainerFrame, michael@0: public nsISVGChildFrame michael@0: { michael@0: protected: michael@0: nsSVGDisplayContainerFrame(nsStyleContext* aContext) michael@0: : nsSVGContainerFrame(aContext) michael@0: { michael@0: AddStateBits(NS_FRAME_MAY_BE_TRANSFORMED); michael@0: } michael@0: michael@0: public: michael@0: NS_DECL_QUERYFRAME_TARGET(nsSVGDisplayContainerFrame) michael@0: NS_DECL_QUERYFRAME michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: // nsIFrame: michael@0: virtual nsresult InsertFrames(ChildListID aListID, michael@0: nsIFrame* aPrevFrame, michael@0: nsFrameList& aFrameList) MOZ_OVERRIDE; michael@0: virtual nsresult RemoveFrame(ChildListID aListID, michael@0: nsIFrame* aOldFrame) MOZ_OVERRIDE; michael@0: virtual void Init(nsIContent* aContent, michael@0: nsIFrame* aParent, michael@0: nsIFrame* aPrevInFlow) 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: virtual bool IsSVGTransformed(Matrix *aOwnTransform = nullptr, michael@0: Matrix *aFromParentTransform = nullptr) const MOZ_OVERRIDE; 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: michael@0: #endif