1 :
2 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 : /* ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is the Mozilla SVG project.
17 : *
18 : * The Initial Developer of the Original Code is IBM Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 2006
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef __NS_SVGGEOMETRYFRAME_H__
39 : #define __NS_SVGGEOMETRYFRAME_H__
40 :
41 : #include "nsFrame.h"
42 : #include "gfxMatrix.h"
43 :
44 : class nsSVGPaintServerFrame;
45 : class gfxContext;
46 :
47 : typedef nsFrame nsSVGGeometryFrameBase;
48 :
49 : #define SVG_HIT_TEST_FILL 0x01
50 : #define SVG_HIT_TEST_STROKE 0x02
51 : #define SVG_HIT_TEST_CHECK_MRECT 0x04
52 :
53 : /* nsSVGGeometryFrame is a base class for SVG objects that directly
54 : * have geometry (circle, ellipse, line, polyline, polygon, path, and
55 : * glyph frames). It knows how to convert the style information into
56 : * cairo context information and stores the fill/stroke paint
57 : * servers. */
58 :
59 : class nsSVGGeometryFrame : public nsSVGGeometryFrameBase
60 0 : {
61 : protected:
62 : NS_DECL_FRAMEARENA_HELPERS
63 :
64 0 : nsSVGGeometryFrame(nsStyleContext *aContext) : nsSVGGeometryFrameBase(aContext) {}
65 :
66 : public:
67 : // nsIFrame interface:
68 : NS_IMETHOD Init(nsIContent* aContent,
69 : nsIFrame* aParent,
70 : nsIFrame* aPrevInFlow);
71 :
72 0 : virtual bool IsFrameOfType(PRUint32 aFlags) const
73 : {
74 0 : return nsSVGGeometryFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGGeometry));
75 : }
76 :
77 : // nsSVGGeometryFrame methods:
78 : virtual gfxMatrix GetCanvasTM() = 0;
79 : PRUint16 GetClipRule();
80 :
81 : float GetStrokeWidth();
82 :
83 : /*
84 : * Set up a cairo context for filling a path
85 : * @return false to skip rendering
86 : */
87 : bool SetupCairoFill(gfxContext *aContext);
88 : /*
89 : * @return false if there is no stroke
90 : */
91 : bool HasStroke();
92 : /*
93 : * Set up a cairo context for measuring a stroked path
94 : */
95 : void SetupCairoStrokeGeometry(gfxContext *aContext);
96 : /*
97 : * Set up a cairo context for hit testing a stroked path
98 : */
99 : void SetupCairoStrokeHitGeometry(gfxContext *aContext);
100 : /*
101 : * Set up a cairo context for stroking a path
102 : * @return false to skip rendering
103 : */
104 : bool SetupCairoStroke(gfxContext *aContext);
105 :
106 : protected:
107 : nsSVGPaintServerFrame *GetPaintServer(const nsStyleSVGPaint *aPaint,
108 : const FramePropertyDescriptor *aProperty);
109 :
110 : /**
111 : * This function returns a set of bit flags indicating which parts of the
112 : * element (fill, stroke, bounds) should intercept pointer events. It takes
113 : * into account the type of element and the value of the 'pointer-events'
114 : * property on the element.
115 : */
116 : virtual PRUint16 GetHitTestFlags();
117 :
118 : /**
119 : * Returns the given 'fill-opacity' or 'stroke-opacity' value multiplied by
120 : * the value of the 'opacity' property if it's possible to avoid the expense
121 : * of creating and compositing an offscreen surface for 'opacity' by
122 : * combining 'opacity' with the 'fill-opacity'/'stroke-opacity'. If not, the
123 : * given 'fill-opacity'/'stroke-opacity' is returned unmodified.
124 : */
125 : float MaybeOptimizeOpacity(float aFillOrStrokeOpacity);
126 :
127 : nsRect mCoveredRegion;
128 :
129 : private:
130 : bool GetStrokeDashData(FallibleTArray<gfxFloat>& dashes, gfxFloat *dashOffset);
131 : };
132 :
133 : #endif // __NS_SVGGEOMETRYFRAME_H__
|