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/. */
6 #ifndef __NS_SVGMARKERFRAME_H__
7 #define __NS_SVGMARKERFRAME_H__
9 #include "mozilla/Attributes.h"
10 #include "gfxMatrix.h"
13 #include "nsLiteralString.h"
14 #include "nsQueryFrame.h"
15 #include "nsSVGContainerFrame.h"
16 #include "nsSVGUtils.h"
22 class nsRenderingContext
;
24 class nsSVGPathGeometryFrame
;
34 typedef nsSVGContainerFrame nsSVGMarkerFrameBase
;
36 class nsSVGMarkerFrame
: public nsSVGMarkerFrameBase
39 NS_NewSVGMarkerFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
);
41 nsSVGMarkerFrame(nsStyleContext
* aContext
)
42 : nsSVGMarkerFrameBase(aContext
)
43 , mMarkedFrame(nullptr)
47 AddStateBits(NS_STATE_SVG_NONDISPLAY_CHILD
);
51 NS_DECL_FRAMEARENA_HELPERS
53 // nsIFrame interface:
55 virtual void Init(nsIContent
* aContent
,
57 nsIFrame
* aPrevInFlow
) MOZ_OVERRIDE
;
60 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
61 const nsRect
& aDirtyRect
,
62 const nsDisplayListSet
& aLists
) MOZ_OVERRIDE
{}
64 NS_IMETHOD
AttributeChanged(int32_t aNameSpaceID
,
66 int32_t aModType
) MOZ_OVERRIDE
;
68 * Get the "type" of the frame
70 * @see nsGkAtoms::svgMarkerFrame
72 virtual nsIAtom
* GetType() const MOZ_OVERRIDE
;
75 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const MOZ_OVERRIDE
77 return MakeFrameName(NS_LITERAL_STRING("SVGMarker"), aResult
);
81 // nsSVGMarkerFrame methods:
82 nsresult
PaintMark(nsRenderingContext
*aContext
,
83 nsSVGPathGeometryFrame
*aMarkedFrame
,
87 SVGBBox
GetMarkBBoxContribution(const gfxMatrix
&aToBBoxUserspace
,
89 nsSVGPathGeometryFrame
*aMarkedFrame
,
90 const nsSVGMark
*aMark
,
94 // stuff needed for callback
95 nsSVGPathGeometryFrame
*mMarkedFrame
;
96 float mStrokeWidth
, mX
, mY
, mAutoAngle
;
98 // nsSVGContainerFrame methods:
99 virtual gfxMatrix
GetCanvasTM(uint32_t aFor
) MOZ_OVERRIDE
;
101 // A helper class to allow us to paint markers safely. The helper
102 // automatically sets and clears the mInUse flag on the marker frame (to
103 // prevent nasty reference loops) as well as the reference to the marked
104 // frame and its coordinate context. It's easy to mess this up
105 // and break things, so this helper makes the code far more robust.
106 class AutoMarkerReferencer
109 AutoMarkerReferencer(nsSVGMarkerFrame
*aFrame
,
110 nsSVGPathGeometryFrame
*aMarkedFrame
);
111 ~AutoMarkerReferencer();
113 nsSVGMarkerFrame
*mFrame
;
116 // nsSVGMarkerFrame methods:
117 void SetParentCoordCtxProvider(mozilla::dom::SVGSVGElement
*aContext
);
119 // recursion prevention flag
122 // second recursion prevention flag, for GetCanvasTM()