Bug 886842 - Add clang trunk builds for ASan. r=froydnj
[gecko.git] / layout / svg / nsSVGMarkerFrame.h
blob4f10e30cc14c3c52f85afc4d02e079da0f398545
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"
11 #include "gfxRect.h"
12 #include "nsFrame.h"
13 #include "nsLiteralString.h"
14 #include "nsQueryFrame.h"
15 #include "nsSVGContainerFrame.h"
16 #include "nsSVGUtils.h"
18 class nsIAtom;
19 class nsIContent;
20 class nsIFrame;
21 class nsIPresShell;
22 class nsRenderingContext;
23 class nsStyleContext;
24 class nsSVGPathGeometryFrame;
26 namespace mozilla {
27 namespace dom {
28 class SVGSVGElement;
32 struct nsSVGMark;
34 typedef nsSVGContainerFrame nsSVGMarkerFrameBase;
36 class nsSVGMarkerFrame : public nsSVGMarkerFrameBase
38 friend nsIFrame*
39 NS_NewSVGMarkerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
40 protected:
41 nsSVGMarkerFrame(nsStyleContext* aContext)
42 : nsSVGMarkerFrameBase(aContext)
43 , mMarkedFrame(nullptr)
44 , mInUse(false)
45 , mInUse2(false)
47 AddStateBits(NS_STATE_SVG_NONDISPLAY_CHILD);
50 public:
51 NS_DECL_FRAMEARENA_HELPERS
53 // nsIFrame interface:
54 #ifdef DEBUG
55 virtual void Init(nsIContent* aContent,
56 nsIFrame* aParent,
57 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
58 #endif
60 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
61 const nsRect& aDirtyRect,
62 const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
64 NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
65 nsIAtom* aAttribute,
66 int32_t aModType) MOZ_OVERRIDE;
67 /**
68 * Get the "type" of the frame
70 * @see nsGkAtoms::svgMarkerFrame
72 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
74 #ifdef DEBUG
75 NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
77 return MakeFrameName(NS_LITERAL_STRING("SVGMarker"), aResult);
79 #endif
81 // nsSVGMarkerFrame methods:
82 nsresult PaintMark(nsRenderingContext *aContext,
83 nsSVGPathGeometryFrame *aMarkedFrame,
84 nsSVGMark *aMark,
85 float aStrokeWidth);
87 SVGBBox GetMarkBBoxContribution(const gfxMatrix &aToBBoxUserspace,
88 uint32_t aFlags,
89 nsSVGPathGeometryFrame *aMarkedFrame,
90 const nsSVGMark *aMark,
91 float aStrokeWidth);
93 private:
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
108 public:
109 AutoMarkerReferencer(nsSVGMarkerFrame *aFrame,
110 nsSVGPathGeometryFrame *aMarkedFrame);
111 ~AutoMarkerReferencer();
112 private:
113 nsSVGMarkerFrame *mFrame;
116 // nsSVGMarkerFrame methods:
117 void SetParentCoordCtxProvider(mozilla::dom::SVGSVGElement *aContext);
119 // recursion prevention flag
120 bool mInUse;
122 // second recursion prevention flag, for GetCanvasTM()
123 bool mInUse2;
126 #endif