1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is the Mozilla SVG project.
16 : *
17 : * The Initial Developer of the Original Code is IBM Corporation.
18 : * Portions created by the Initial Developer are Copyright (C) 2006
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Contributor(s):
22 : *
23 : * Alternatively, the contents of this file may be used under the terms of
24 : * either the GNU General Public License Version 2 or later (the "GPL"), or
25 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 : * in which case the provisions of the GPL or the LGPL are applicable instead
27 : * of those above. If you wish to allow use of your version of this file only
28 : * under the terms of either the GPL or the LGPL, and not to allow others to
29 : * use your version of this file under the terms of the MPL, indicate your
30 : * decision by deleting the provisions above and replace them with the notice
31 : * and other provisions required by the GPL or the LGPL. If you do not delete
32 : * the provisions above, a recipient may use your version of this file under
33 : * the terms of any one of the MPL, the GPL or the LGPL.
34 : *
35 : * ***** END LICENSE BLOCK ***** */
36 :
37 : #ifndef NS_SVGCONTAINERFRAME_H
38 : #define NS_SVGCONTAINERFRAME_H
39 :
40 : #include "nsContainerFrame.h"
41 : #include "nsISVGChildFrame.h"
42 : #include "nsSVGSVGElement.h"
43 : #include "gfxRect.h"
44 : #include "gfxMatrix.h"
45 :
46 : class nsRenderingContext;
47 :
48 : typedef nsContainerFrame nsSVGContainerFrameBase;
49 :
50 : /**
51 : * Base class for SVG container frames. Frame sub-classes that do not
52 : * display their contents directly (such as the frames for <marker> or
53 : * <pattern>) just inherit this class. Frame sub-classes that do or can
54 : * display their contents directly (such as the frames for inner-<svg> or
55 : * <g>) inherit our nsDisplayContainerFrame sub-class.
56 : */
57 : class nsSVGContainerFrame : public nsSVGContainerFrameBase
58 0 : {
59 : friend nsIFrame* NS_NewSVGContainerFrame(nsIPresShell* aPresShell,
60 : nsStyleContext* aContext);
61 : protected:
62 0 : nsSVGContainerFrame(nsStyleContext* aContext) :
63 0 : nsSVGContainerFrameBase(aContext) {}
64 :
65 : public:
66 : NS_DECL_QUERYFRAME_TARGET(nsSVGContainerFrame)
67 : NS_DECL_QUERYFRAME
68 : NS_DECL_FRAMEARENA_HELPERS
69 :
70 : // Returns the transform to our gfxContext (to device pixels, not CSS px)
71 0 : virtual gfxMatrix GetCanvasTM() { return gfxMatrix(); }
72 :
73 : // nsIFrame:
74 : NS_IMETHOD AppendFrames(ChildListID aListID,
75 : nsFrameList& aFrameList);
76 : NS_IMETHOD InsertFrames(ChildListID aListID,
77 : nsIFrame* aPrevFrame,
78 : nsFrameList& aFrameList);
79 : NS_IMETHOD RemoveFrame(ChildListID aListID,
80 : nsIFrame* aOldFrame);
81 :
82 0 : virtual bool IsFrameOfType(PRUint32 aFlags) const
83 : {
84 : return nsSVGContainerFrameBase::IsFrameOfType(
85 0 : aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGContainer));
86 : }
87 : };
88 :
89 : /**
90 : * Frame class or base-class for SVG containers that can or do display their
91 : * contents directly.
92 : */
93 : class nsSVGDisplayContainerFrame : public nsSVGContainerFrame,
94 : public nsISVGChildFrame
95 0 : {
96 : protected:
97 0 : nsSVGDisplayContainerFrame(nsStyleContext* aContext) :
98 0 : nsSVGContainerFrame(aContext) {}
99 :
100 : public:
101 : NS_DECL_QUERYFRAME_TARGET(nsSVGDisplayContainerFrame)
102 : NS_DECL_QUERYFRAME
103 : NS_DECL_FRAMEARENA_HELPERS
104 :
105 : // nsIFrame:
106 : NS_IMETHOD InsertFrames(ChildListID aListID,
107 : nsIFrame* aPrevFrame,
108 : nsFrameList& aFrameList);
109 : NS_IMETHOD RemoveFrame(ChildListID aListID,
110 : nsIFrame* aOldFrame);
111 : NS_IMETHOD Init(nsIContent* aContent,
112 : nsIFrame* aParent,
113 : nsIFrame* aPrevInFlow);
114 :
115 : // nsISVGChildFrame interface:
116 : NS_IMETHOD PaintSVG(nsRenderingContext* aContext,
117 : const nsIntRect *aDirtyRect);
118 : NS_IMETHOD_(nsIFrame*) GetFrameForPoint(const nsPoint &aPoint);
119 : NS_IMETHOD_(nsRect) GetCoveredRegion();
120 : NS_IMETHOD UpdateCoveredRegion();
121 : NS_IMETHOD InitialUpdate();
122 : virtual void NotifySVGChanged(PRUint32 aFlags);
123 : virtual void NotifyRedrawSuspended();
124 : virtual void NotifyRedrawUnsuspended();
125 : virtual gfxRect GetBBoxContribution(const gfxMatrix &aToBBoxUserspace,
126 : PRUint32 aFlags);
127 0 : NS_IMETHOD_(bool) IsDisplayContainer() { return true; }
128 0 : NS_IMETHOD_(bool) HasValidCoveredRect() { return false; }
129 : };
130 :
131 : #endif
|