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
18 : * Crocodile Clips Ltd..
19 : * Portions created by the Initial Developer are Copyright (C) 2001
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either of the GNU General Public License Version 2 or later (the "GPL"),
27 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #ifndef NSSVGFOREIGNOBJECTFRAME_H__
40 : #define NSSVGFOREIGNOBJECTFRAME_H__
41 :
42 : #include "nsContainerFrame.h"
43 : #include "nsISVGChildFrame.h"
44 : #include "nsSVGUtils.h"
45 : #include "nsRegion.h"
46 : #include "nsIPresShell.h"
47 : #include "mozilla/Attributes.h"
48 :
49 : class nsRenderingContext;
50 : class nsSVGOuterSVGFrame;
51 :
52 : typedef nsContainerFrame nsSVGForeignObjectFrameBase;
53 :
54 : class nsSVGForeignObjectFrame : public nsSVGForeignObjectFrameBase,
55 : public nsISVGChildFrame
56 0 : {
57 : friend nsIFrame*
58 : NS_NewSVGForeignObjectFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
59 : protected:
60 : nsSVGForeignObjectFrame(nsStyleContext* aContext);
61 :
62 : public:
63 : NS_DECL_QUERYFRAME
64 : NS_DECL_FRAMEARENA_HELPERS
65 :
66 : // nsIFrame:
67 : NS_IMETHOD Init(nsIContent* aContent,
68 : nsIFrame* aParent,
69 : nsIFrame* aPrevInFlow);
70 : virtual void DestroyFrom(nsIFrame* aDestructRoot);
71 : NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
72 : nsIAtom* aAttribute,
73 : PRInt32 aModType);
74 :
75 : virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
76 :
77 0 : virtual nsIFrame* GetContentInsertionFrame() {
78 0 : return GetFirstPrincipalChild()->GetContentInsertionFrame();
79 : }
80 :
81 : NS_IMETHOD Reflow(nsPresContext* aPresContext,
82 : nsHTMLReflowMetrics& aDesiredSize,
83 : const nsHTMLReflowState& aReflowState,
84 : nsReflowStatus& aStatus);
85 :
86 : /**
87 : * Foreign objects are always transformed.
88 : */
89 0 : virtual bool IsTransformed() const
90 : {
91 0 : return true;
92 : }
93 :
94 : /**
95 : * Foreign objects can return a transform matrix.
96 : */
97 : virtual gfx3DMatrix GetTransformMatrix(nsIFrame* aAncestor,
98 : nsIFrame **aOutAncestor);
99 :
100 : /**
101 : * Get the "type" of the frame
102 : *
103 : * @see nsGkAtoms::svgForeignObjectFrame
104 : */
105 : virtual nsIAtom* GetType() const;
106 :
107 0 : virtual bool IsFrameOfType(PRUint32 aFlags) const
108 : {
109 : return nsSVGForeignObjectFrameBase::IsFrameOfType(aFlags &
110 0 : ~(nsIFrame::eSVG | nsIFrame::eSVGForeignObject));
111 : }
112 :
113 : virtual void InvalidateInternal(const nsRect& aDamageRect,
114 : nscoord aX, nscoord aY, nsIFrame* aForChild,
115 : PRUint32 aFlags);
116 :
117 : #ifdef DEBUG
118 0 : NS_IMETHOD GetFrameName(nsAString& aResult) const
119 : {
120 0 : return MakeFrameName(NS_LITERAL_STRING("SVGForeignObject"), aResult);
121 : }
122 : #endif
123 :
124 : // nsISVGChildFrame interface:
125 : NS_IMETHOD PaintSVG(nsRenderingContext *aContext,
126 : const nsIntRect *aDirtyRect);
127 : NS_IMETHOD_(nsIFrame*) GetFrameForPoint(const nsPoint &aPoint);
128 : NS_IMETHOD_(nsRect) GetCoveredRegion();
129 : NS_IMETHOD UpdateCoveredRegion();
130 : NS_IMETHOD InitialUpdate();
131 : virtual void NotifySVGChanged(PRUint32 aFlags);
132 : virtual void NotifyRedrawSuspended();
133 : virtual void NotifyRedrawUnsuspended();
134 : virtual gfxRect GetBBoxContribution(const gfxMatrix &aToBBoxUserspace,
135 : PRUint32 aFlags);
136 0 : NS_IMETHOD_(bool) IsDisplayContainer() { return true; }
137 0 : NS_IMETHOD_(bool) HasValidCoveredRect() {
138 0 : return !(GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD);
139 : }
140 :
141 : gfxMatrix GetCanvasTM();
142 :
143 : // This method allows our nsSVGOuterSVGFrame to reflow us as necessary.
144 : void MaybeReflowFromOuterSVGFrame();
145 :
146 : protected:
147 : // implementation helpers:
148 : void DoReflow();
149 : void RequestReflow(nsIPresShell::IntrinsicDirty aType);
150 : void UpdateGraphic();
151 :
152 : // Returns GetCanvasTM followed by a scale from CSS px to Dev px. Used for
153 : // painting, because children expect to paint to device space, not userspace.
154 : gfxMatrix GetCanvasTMForChildren();
155 : void InvalidateDirtyRect(nsSVGOuterSVGFrame* aOuter,
156 : const nsRect& aRect, PRUint32 aFlags);
157 : void FlushDirtyRegion(PRUint32 aFlags);
158 :
159 : // If width or height is less than or equal to zero we must disable rendering
160 0 : bool IsDisabled() const { return mRect.width <= 0 || mRect.height <= 0; }
161 :
162 : nsAutoPtr<gfxMatrix> mCanvasTM;
163 :
164 : // Areas dirtied by changes to decendents that are in our document
165 : nsRegion mSameDocDirtyRegion;
166 :
167 : // Areas dirtied by changes to sub-documents embedded by our decendents
168 : nsRegion mSubDocDirtyRegion;
169 :
170 : nsRect mCoveredRegion;
171 :
172 : bool mInReflow;
173 : };
174 :
175 : #endif
|