/src/mozilla-central/layout/svg/SVGGeometryFrame.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef __SVGGEOMETRYFRAME_H__ |
8 | | #define __SVGGEOMETRYFRAME_H__ |
9 | | |
10 | | #include "mozilla/Attributes.h" |
11 | | #include "gfxMatrix.h" |
12 | | #include "gfxRect.h" |
13 | | #include "nsFrame.h" |
14 | | #include "nsSVGDisplayableFrame.h" |
15 | | #include "nsLiteralString.h" |
16 | | #include "nsQueryFrame.h" |
17 | | #include "nsSVGUtils.h" |
18 | | |
19 | | namespace mozilla { |
20 | | class SVGGeometryFrame; |
21 | | class SVGMarkerObserver; |
22 | | namespace gfx { |
23 | | class DrawTarget; |
24 | | } // namespace gfx |
25 | | } // namespace mozilla |
26 | | |
27 | | class gfxContext; |
28 | | class nsDisplaySVGGeometry; |
29 | | class nsAtom; |
30 | | class nsIFrame; |
31 | | class nsIPresShell; |
32 | | class nsSVGMarkerFrame; |
33 | | |
34 | | struct nsRect; |
35 | | |
36 | | nsIFrame* |
37 | | NS_NewSVGGeometryFrame(nsIPresShell* aPresShell, mozilla::ComputedStyle* aStyle); |
38 | | |
39 | | namespace mozilla { |
40 | | |
41 | | class SVGGeometryFrame : public nsFrame |
42 | | , public nsSVGDisplayableFrame |
43 | | { |
44 | | typedef mozilla::gfx::DrawTarget DrawTarget; |
45 | | |
46 | | friend nsIFrame* |
47 | | ::NS_NewSVGGeometryFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle); |
48 | | |
49 | | friend class ::nsDisplaySVGGeometry; |
50 | | |
51 | | protected: |
52 | | SVGGeometryFrame(ComputedStyle* aStyle, nsIFrame::ClassID aID) |
53 | | : nsFrame(aStyle, aID) |
54 | 0 | { |
55 | 0 | AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_MAY_BE_TRANSFORMED); |
56 | 0 | } |
57 | | |
58 | | explicit SVGGeometryFrame(ComputedStyle* aStyle) |
59 | | : SVGGeometryFrame(aStyle, kClassID) |
60 | 0 | {} |
61 | | |
62 | | public: |
63 | | NS_DECL_QUERYFRAME |
64 | | NS_DECL_FRAMEARENA_HELPERS(SVGGeometryFrame) |
65 | | |
66 | | // nsIFrame interface: |
67 | | virtual void Init(nsIContent* aContent, |
68 | | nsContainerFrame* aParent, |
69 | | nsIFrame* aPrevInFlow) override; |
70 | | |
71 | | virtual bool IsFrameOfType(uint32_t aFlags) const override |
72 | 0 | { |
73 | 0 | if (aFlags & eSupportsContainLayoutAndPaint) { |
74 | 0 | return false; |
75 | 0 | } |
76 | 0 | |
77 | 0 | return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGGeometry)); |
78 | 0 | } |
79 | | |
80 | | virtual nsresult AttributeChanged(int32_t aNameSpaceID, |
81 | | nsAtom* aAttribute, |
82 | | int32_t aModType) override; |
83 | | |
84 | | virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override; |
85 | | |
86 | | virtual bool IsSVGTransformed(Matrix *aOwnTransforms = nullptr, |
87 | | Matrix *aFromParentTransforms = nullptr) const override; |
88 | | |
89 | | #ifdef DEBUG_FRAME_DUMP |
90 | | virtual nsresult GetFrameName(nsAString& aResult) const override |
91 | | { |
92 | | return MakeFrameName(NS_LITERAL_STRING("SVGGeometry"), aResult); |
93 | | } |
94 | | #endif |
95 | | |
96 | | virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
97 | | const nsDisplayListSet& aLists) override; |
98 | | |
99 | | // SVGGeometryFrame methods |
100 | | gfxMatrix GetCanvasTM(); |
101 | | protected: |
102 | | // nsSVGDisplayableFrame interface: |
103 | | virtual void PaintSVG(gfxContext& aContext, |
104 | | const gfxMatrix& aTransform, |
105 | | imgDrawingParams& aImgParams, |
106 | | const nsIntRect* aDirtyRect = nullptr) override; |
107 | | virtual nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) override; |
108 | | virtual void ReflowSVG() override; |
109 | | virtual void NotifySVGChanged(uint32_t aFlags) override; |
110 | | virtual SVGBBox GetBBoxContribution(const Matrix &aToBBoxUserspace, |
111 | | uint32_t aFlags) override; |
112 | 0 | virtual bool IsDisplayContainer() override { return false; } |
113 | | |
114 | | /** |
115 | | * This function returns a set of bit flags indicating which parts of the |
116 | | * element (fill, stroke, bounds) should intercept pointer events. It takes |
117 | | * into account the type of element and the value of the 'pointer-events' |
118 | | * property on the element. |
119 | | */ |
120 | | virtual uint16_t GetHitTestFlags(); |
121 | | private: |
122 | | enum { eRenderFill = 1, eRenderStroke = 2 }; |
123 | | void Render(gfxContext* aContext, uint32_t aRenderComponents, |
124 | | const gfxMatrix& aTransform, imgDrawingParams& aImgParams); |
125 | | |
126 | | /** |
127 | | * @param aMatrix The transform that must be multiplied onto aContext to |
128 | | * establish this frame's SVG user space. |
129 | | */ |
130 | | void PaintMarkers(gfxContext& aContext, const gfxMatrix& aMatrix, |
131 | | imgDrawingParams& aImgParams); |
132 | | }; |
133 | | } // namespace mozilla |
134 | | |
135 | | #endif // __SVGGEOMETRYFRAME_H__ |