Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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"
11 #include "gfxRect.h"
12 #include "nsFrame.h"
13 #include "nsISVGChildFrame.h"
14 #include "nsLiteralString.h"
15 #include "nsQueryFrame.h"
16 #include "nsSVGUtils.h"
18 class gfxContext;
19 class nsDisplaySVGPathGeometry;
20 class nsIAtom;
21 class nsIFrame;
22 class nsIPresShell;
23 class nsRenderingContext;
24 class nsStyleContext;
25 class nsSVGMarkerFrame;
26 class nsSVGMarkerProperty;
28 struct nsPoint;
29 struct nsRect;
30 struct nsIntRect;
32 typedef nsFrame nsSVGPathGeometryFrameBase;
34 class nsSVGPathGeometryFrame : public nsSVGPathGeometryFrameBase,
35 public nsISVGChildFrame
36 {
37 friend nsIFrame*
38 NS_NewSVGPathGeometryFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
40 friend class nsDisplaySVGPathGeometry;
42 protected:
43 nsSVGPathGeometryFrame(nsStyleContext* aContext)
44 : nsSVGPathGeometryFrameBase(aContext)
45 {
46 AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_MAY_BE_TRANSFORMED);
47 }
49 public:
50 NS_DECL_QUERYFRAME_TARGET(nsSVGPathGeometryFrame)
51 NS_DECL_QUERYFRAME
52 NS_DECL_FRAMEARENA_HELPERS
54 // nsIFrame interface:
55 virtual void Init(nsIContent* aContent,
56 nsIFrame* aParent,
57 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
59 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
60 {
61 return nsSVGPathGeometryFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGGeometry));
62 }
64 virtual nsresult AttributeChanged(int32_t aNameSpaceID,
65 nsIAtom* aAttribute,
66 int32_t aModType) MOZ_OVERRIDE;
68 virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
70 /**
71 * Get the "type" of the frame
72 *
73 * @see nsGkAtoms::svgPathGeometryFrame
74 */
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
82 {
83 return MakeFrameName(NS_LITERAL_STRING("SVGPathGeometry"), aResult);
84 }
85 #endif
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);
94 protected:
95 // nsISVGChildFrame interface:
96 virtual nsresult PaintSVG(nsRenderingContext *aContext,
97 const nsIntRect *aDirtyRect,
98 nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
99 virtual nsIFrame* GetFrameForPoint(const nsPoint &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);
108 /**
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.
113 */
114 virtual uint16_t GetHitTestFlags();
115 private:
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;
128 }
130 nsSVGMarkerFrame *GetMarkerStartFrame();
131 nsSVGMarkerFrame *GetMarkerMidFrame();
132 nsSVGMarkerFrame *GetMarkerEndFrame();
133 };
135 /**
136 * @param aFrame should be the first continuation
137 */
138 static MarkerProperties GetMarkerProperties(nsSVGPathGeometryFrame *aFrame);
139 };
141 #endif // __NS_SVGPATHGEOMETRYFRAME_H__