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_SVGPATHGEOMETRYFRAME_H__ michael@0: #define __NS_SVGPATHGEOMETRYFRAME_H__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "gfxMatrix.h" michael@0: #include "gfxRect.h" michael@0: #include "nsFrame.h" michael@0: #include "nsISVGChildFrame.h" michael@0: #include "nsLiteralString.h" michael@0: #include "nsQueryFrame.h" michael@0: #include "nsSVGUtils.h" michael@0: michael@0: class gfxContext; michael@0: class nsDisplaySVGPathGeometry; michael@0: class nsIAtom; michael@0: class nsIFrame; michael@0: class nsIPresShell; michael@0: class nsRenderingContext; michael@0: class nsStyleContext; michael@0: class nsSVGMarkerFrame; michael@0: class nsSVGMarkerProperty; michael@0: michael@0: struct nsPoint; michael@0: struct nsRect; michael@0: struct nsIntRect; michael@0: michael@0: typedef nsFrame nsSVGPathGeometryFrameBase; michael@0: michael@0: class nsSVGPathGeometryFrame : public nsSVGPathGeometryFrameBase, michael@0: public nsISVGChildFrame michael@0: { michael@0: friend nsIFrame* michael@0: NS_NewSVGPathGeometryFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); michael@0: michael@0: friend class nsDisplaySVGPathGeometry; michael@0: michael@0: protected: michael@0: nsSVGPathGeometryFrame(nsStyleContext* aContext) michael@0: : nsSVGPathGeometryFrameBase(aContext) michael@0: { michael@0: AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_MAY_BE_TRANSFORMED); michael@0: } michael@0: michael@0: public: michael@0: NS_DECL_QUERYFRAME_TARGET(nsSVGPathGeometryFrame) michael@0: NS_DECL_QUERYFRAME michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: // nsIFrame interface: michael@0: virtual void Init(nsIContent* aContent, michael@0: nsIFrame* aParent, michael@0: nsIFrame* aPrevInFlow) MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE michael@0: { michael@0: return nsSVGPathGeometryFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGGeometry)); michael@0: } michael@0: michael@0: virtual nsresult AttributeChanged(int32_t aNameSpaceID, michael@0: nsIAtom* aAttribute, michael@0: int32_t aModType) MOZ_OVERRIDE; michael@0: michael@0: virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE; michael@0: michael@0: /** michael@0: * Get the "type" of the frame michael@0: * michael@0: * @see nsGkAtoms::svgPathGeometryFrame michael@0: */ michael@0: virtual nsIAtom* GetType() const MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsSVGTransformed(Matrix *aOwnTransforms = nullptr, michael@0: Matrix *aFromParentTransforms = nullptr) 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("SVGPathGeometry"), aResult); michael@0: } michael@0: #endif 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: // nsSVGPathGeometryFrame methods michael@0: gfxMatrix GetCanvasTM(uint32_t aFor, michael@0: nsIFrame* aTransformRoot = nullptr); michael@0: protected: 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 false; } michael@0: michael@0: void GeneratePath(gfxContext *aContext, const Matrix &aTransform); michael@0: /** michael@0: * This function returns a set of bit flags indicating which parts of the michael@0: * element (fill, stroke, bounds) should intercept pointer events. It takes michael@0: * into account the type of element and the value of the 'pointer-events' michael@0: * property on the element. michael@0: */ michael@0: virtual uint16_t GetHitTestFlags(); michael@0: private: michael@0: enum { eRenderFill = 1, eRenderStroke = 2 }; michael@0: void Render(nsRenderingContext *aContext, uint32_t aRenderComponents, michael@0: nsIFrame* aTransformRoot); michael@0: void PaintMarkers(nsRenderingContext *aContext); michael@0: michael@0: struct MarkerProperties { michael@0: nsSVGMarkerProperty* mMarkerStart; michael@0: nsSVGMarkerProperty* mMarkerMid; michael@0: nsSVGMarkerProperty* mMarkerEnd; michael@0: michael@0: bool MarkersExist() const { michael@0: return mMarkerStart || mMarkerMid || mMarkerEnd; michael@0: } michael@0: michael@0: nsSVGMarkerFrame *GetMarkerStartFrame(); michael@0: nsSVGMarkerFrame *GetMarkerMidFrame(); michael@0: nsSVGMarkerFrame *GetMarkerEndFrame(); michael@0: }; michael@0: michael@0: /** michael@0: * @param aFrame should be the first continuation michael@0: */ michael@0: static MarkerProperties GetMarkerProperties(nsSVGPathGeometryFrame *aFrame); michael@0: }; michael@0: michael@0: #endif // __NS_SVGPATHGEOMETRYFRAME_H__