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_SVGPATHGEOMETRYFRAME_H__
7 #define __NS_SVGPATHGEOMETRYFRAME_H__
9 #include "mozilla/Attributes.h"
10 #include "gfxMatrix.h"
13 #include "nsISVGChildFrame.h"
14 #include "nsLiteralString.h"
15 #include "nsQueryFrame.h"
16 #include "nsSVGUtils.h"
19 class nsDisplaySVGPathGeometry
;
23 class nsRenderingContext
;
25 class nsSVGMarkerFrame
;
26 class nsSVGMarkerProperty
;
32 typedef nsFrame nsSVGPathGeometryFrameBase
;
34 class nsSVGPathGeometryFrame
: public nsSVGPathGeometryFrameBase
,
35 public nsISVGChildFrame
38 NS_NewSVGPathGeometryFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
);
40 friend class nsDisplaySVGPathGeometry
;
43 explicit nsSVGPathGeometryFrame(nsStyleContext
* aContext
)
44 : nsSVGPathGeometryFrameBase(aContext
)
46 AddStateBits(NS_FRAME_SVG_LAYOUT
| NS_FRAME_MAY_BE_TRANSFORMED
);
50 NS_DECL_QUERYFRAME_TARGET(nsSVGPathGeometryFrame
)
52 NS_DECL_FRAMEARENA_HELPERS
54 // nsIFrame interface:
55 virtual void Init(nsIContent
* aContent
,
56 nsContainerFrame
* aParent
,
57 nsIFrame
* aPrevInFlow
) MOZ_OVERRIDE
;
59 virtual bool IsFrameOfType(uint32_t aFlags
) const MOZ_OVERRIDE
61 return nsSVGPathGeometryFrameBase::IsFrameOfType(aFlags
& ~(nsIFrame::eSVG
| nsIFrame::eSVGGeometry
));
64 virtual nsresult
AttributeChanged(int32_t aNameSpaceID
,
66 int32_t aModType
) MOZ_OVERRIDE
;
68 virtual void DidSetStyleContext(nsStyleContext
* aOldStyleContext
) MOZ_OVERRIDE
;
71 * Get the "type" of the frame
73 * @see nsGkAtoms::svgPathGeometryFrame
75 virtual nsIAtom
* GetType() const MOZ_OVERRIDE
;
77 virtual bool IsSVGTransformed(Matrix
*aOwnTransforms
= nullptr,
78 Matrix
*aFromParentTransforms
= nullptr) const MOZ_OVERRIDE
;
80 #ifdef DEBUG_FRAME_DUMP
81 virtual nsresult
GetFrameName(nsAString
& aResult
) const MOZ_OVERRIDE
83 return MakeFrameName(NS_LITERAL_STRING("SVGPathGeometry"), aResult
);
87 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
88 const nsRect
& aDirtyRect
,
89 const nsDisplayListSet
& aLists
) MOZ_OVERRIDE
;
91 // nsSVGPathGeometryFrame methods
92 gfxMatrix
GetCanvasTM(uint32_t aFor
,
93 nsIFrame
* aTransformRoot
= nullptr);
95 // nsISVGChildFrame interface:
96 virtual nsresult
PaintSVG(nsRenderingContext
*aContext
,
97 const nsIntRect
*aDirtyRect
,
98 nsIFrame
* aTransformRoot
= nullptr) MOZ_OVERRIDE
;
99 virtual nsIFrame
* GetFrameForPoint(const gfxPoint
& aPoint
) MOZ_OVERRIDE
;
100 virtual nsRect
GetCoveredRegion() MOZ_OVERRIDE
;
101 virtual void ReflowSVG() MOZ_OVERRIDE
;
102 virtual void NotifySVGChanged(uint32_t aFlags
) MOZ_OVERRIDE
;
103 virtual SVGBBox
GetBBoxContribution(const Matrix
&aToBBoxUserspace
,
104 uint32_t aFlags
) MOZ_OVERRIDE
;
105 virtual bool IsDisplayContainer() MOZ_OVERRIDE
{ return false; }
107 void GeneratePath(gfxContext
*aContext
, const Matrix
&aTransform
);
109 * This function returns a set of bit flags indicating which parts of the
110 * element (fill, stroke, bounds) should intercept pointer events. It takes
111 * into account the type of element and the value of the 'pointer-events'
112 * property on the element.
114 virtual uint16_t GetHitTestFlags();
116 enum { eRenderFill
= 1, eRenderStroke
= 2 };
117 void Render(nsRenderingContext
*aContext
, uint32_t aRenderComponents
,
118 nsIFrame
* aTransformRoot
);
119 void PaintMarkers(nsRenderingContext
*aContext
);
121 struct MarkerProperties
{
122 nsSVGMarkerProperty
* mMarkerStart
;
123 nsSVGMarkerProperty
* mMarkerMid
;
124 nsSVGMarkerProperty
* mMarkerEnd
;
126 bool MarkersExist() const {
127 return mMarkerStart
|| mMarkerMid
|| mMarkerEnd
;
130 nsSVGMarkerFrame
*GetMarkerStartFrame();
131 nsSVGMarkerFrame
*GetMarkerMidFrame();
132 nsSVGMarkerFrame
*GetMarkerEndFrame();
136 * @param aFrame should be the first continuation
138 static MarkerProperties
GetMarkerProperties(nsSVGPathGeometryFrame
*aFrame
);
141 #endif // __NS_SVGPATHGEOMETRYFRAME_H__