Merge mozilla-central and tracemonkey. (a=blockers)
[mozilla-central.git] / layout / mathml / nsMathMLmtableFrame.h
blob06b0ba39d108164f53a5f3db934e3e1083677d8e
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
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/
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.
15 * The Original Code is Mozilla MathML Project.
17 * The Initial Developer of the Original Code is
18 * The University Of Queensland.
19 * Portions created by the Initial Developer are Copyright (C) 1999
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Roger B. Sidje <rbs@maths.uq.edu.au>
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.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef nsMathMLmtableFrame_h___
40 #define nsMathMLmtableFrame_h___
42 #include "nsCOMPtr.h"
43 #include "nsMathMLContainerFrame.h"
46 // <mtable> -- table or matrix
49 class nsMathMLmtableOuterFrame : public nsTableOuterFrame,
50 public nsMathMLFrame
52 public:
53 friend nsIFrame* NS_NewMathMLmtableOuterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
55 NS_DECL_QUERYFRAME
56 NS_DECL_FRAMEARENA_HELPERS
58 // Overloaded nsIMathMLFrame methods
60 NS_IMETHOD
61 InheritAutomaticData(nsIFrame* aParent);
63 NS_IMETHOD
64 UpdatePresentationData(PRUint32 aFlagsValues,
65 PRUint32 aWhichFlags);
67 NS_IMETHOD
68 UpdatePresentationDataFromChildAt(PRInt32 aFirstIndex,
69 PRInt32 aLastIndex,
70 PRUint32 aFlagsValues,
71 PRUint32 aWhichFlags);
73 // overloaded nsTableOuterFrame methods
75 NS_IMETHOD
76 Reflow(nsPresContext* aPresContext,
77 nsHTMLReflowMetrics& aDesiredSize,
78 const nsHTMLReflowState& aReflowState,
79 nsReflowStatus& aStatus);
81 NS_IMETHOD
82 AttributeChanged(PRInt32 aNameSpaceID,
83 nsIAtom* aAttribute,
84 PRInt32 aModType);
86 virtual PRBool IsFrameOfType(PRUint32 aFlags) const
88 return nsTableOuterFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
91 protected:
92 nsMathMLmtableOuterFrame(nsStyleContext* aContext) : nsTableOuterFrame(aContext) {}
93 virtual ~nsMathMLmtableOuterFrame();
95 // helper to find the row frame at a given index, positive or negative, e.g.,
96 // 1..n means the first row down to the last row, -1..-n means the last row
97 // up to the first row. Used for alignments that are relative to a given row
98 nsIFrame*
99 GetRowFrameAt(nsPresContext* aPresContext,
100 PRInt32 aRowIndex);
101 }; // class nsMathMLmtableOuterFrame
103 // --------------
105 class nsMathMLmtableFrame : public nsTableFrame
107 public:
108 NS_DECL_FRAMEARENA_HELPERS
110 friend nsIFrame* NS_NewMathMLmtableFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
112 // Overloaded nsTableFrame methods
114 NS_IMETHOD
115 SetInitialChildList(nsIAtom* aListName,
116 nsFrameList& aChildList);
118 NS_IMETHOD
119 AppendFrames(nsIAtom* aListName,
120 nsFrameList& aFrameList)
122 nsresult rv = nsTableFrame::AppendFrames(aListName, aFrameList);
123 RestyleTable();
124 return rv;
127 NS_IMETHOD
128 InsertFrames(nsIAtom* aListName,
129 nsIFrame* aPrevFrame,
130 nsFrameList& aFrameList)
132 nsresult rv = nsTableFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
133 RestyleTable();
134 return rv;
137 NS_IMETHOD
138 RemoveFrame(nsIAtom* aListName,
139 nsIFrame* aOldFrame)
141 nsresult rv = nsTableFrame::RemoveFrame(aListName, aOldFrame);
142 RestyleTable();
143 return rv;
146 virtual PRBool IsFrameOfType(PRUint32 aFlags) const
148 return nsTableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
151 // helper to restyle and reflow the table when a row is changed -- since MathML
152 // attributes are inter-dependent and row/colspan can affect the table, it is
153 // safer (albeit grossly suboptimal) to just relayout the whole thing.
154 void RestyleTable();
156 protected:
157 nsMathMLmtableFrame(nsStyleContext* aContext) : nsTableFrame(aContext) {}
158 virtual ~nsMathMLmtableFrame();
159 }; // class nsMathMLmtableFrame
161 // --------------
163 class nsMathMLmtrFrame : public nsTableRowFrame
165 public:
166 NS_DECL_FRAMEARENA_HELPERS
168 friend nsIFrame* NS_NewMathMLmtrFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
170 // overloaded nsTableRowFrame methods
172 NS_IMETHOD
173 AttributeChanged(PRInt32 aNameSpaceID,
174 nsIAtom* aAttribute,
175 PRInt32 aModType);
177 NS_IMETHOD
178 AppendFrames(nsIAtom* aListName,
179 nsFrameList& aFrameList)
181 nsresult rv = nsTableRowFrame::AppendFrames(aListName, aFrameList);
182 RestyleTable();
183 return rv;
186 NS_IMETHOD
187 InsertFrames(nsIAtom* aListName,
188 nsIFrame* aPrevFrame,
189 nsFrameList& aFrameList)
191 nsresult rv = nsTableRowFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
192 RestyleTable();
193 return rv;
196 NS_IMETHOD
197 RemoveFrame(nsIAtom* aListName,
198 nsIFrame* aOldFrame)
200 nsresult rv = nsTableRowFrame::RemoveFrame(aListName, aOldFrame);
201 RestyleTable();
202 return rv;
205 virtual PRBool IsFrameOfType(PRUint32 aFlags) const
207 return nsTableRowFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
210 // helper to restyle and reflow the table -- @see nsMathMLmtableFrame.
211 void RestyleTable()
213 nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
214 if (tableFrame && tableFrame->IsFrameOfType(nsIFrame::eMathML)) {
215 // relayout the table
216 ((nsMathMLmtableFrame*)tableFrame)->RestyleTable();
220 protected:
221 nsMathMLmtrFrame(nsStyleContext* aContext) : nsTableRowFrame(aContext) {}
222 virtual ~nsMathMLmtrFrame();
223 }; // class nsMathMLmtrFrame
225 // --------------
227 class nsMathMLmtdFrame : public nsTableCellFrame
229 public:
230 NS_DECL_FRAMEARENA_HELPERS
232 friend nsIFrame* NS_NewMathMLmtdFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
234 // overloaded nsTableCellFrame methods
236 NS_IMETHOD
237 AttributeChanged(PRInt32 aNameSpaceID,
238 nsIAtom* aAttribute,
239 PRInt32 aModType);
241 virtual PRInt32 GetRowSpan();
242 virtual PRInt32 GetColSpan();
243 virtual PRBool IsFrameOfType(PRUint32 aFlags) const
245 return nsTableCellFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
248 protected:
249 nsMathMLmtdFrame(nsStyleContext* aContext) : nsTableCellFrame(aContext) {}
250 virtual ~nsMathMLmtdFrame();
251 }; // class nsMathMLmtdFrame
253 // --------------
255 class nsMathMLmtdInnerFrame : public nsBlockFrame,
256 public nsMathMLFrame {
257 public:
258 friend nsIFrame* NS_NewMathMLmtdInnerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
260 NS_DECL_QUERYFRAME
261 NS_DECL_FRAMEARENA_HELPERS
263 // Overloaded nsIMathMLFrame methods
265 NS_IMETHOD
266 UpdatePresentationDataFromChildAt(PRInt32 aFirstIndex,
267 PRInt32 aLastIndex,
268 PRUint32 aFlagsValues,
269 PRUint32 aFlagsToUpdate)
271 nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(this,
272 aFirstIndex, aLastIndex, aFlagsValues, aFlagsToUpdate);
273 return NS_OK;
276 NS_IMETHOD
277 Reflow(nsPresContext* aPresContext,
278 nsHTMLReflowMetrics& aDesiredSize,
279 const nsHTMLReflowState& aReflowState,
280 nsReflowStatus& aStatus);
282 virtual PRBool IsFrameOfType(PRUint32 aFlags) const
284 return nsBlockFrame::IsFrameOfType(aFlags &
285 ~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
288 protected:
289 nsMathMLmtdInnerFrame(nsStyleContext* aContext) : nsBlockFrame(aContext) {}
290 virtual ~nsMathMLmtdInnerFrame();
292 virtual PRIntn GetSkipSides() const { return 0; }
293 }; // class nsMathMLmtdInnerFrame
295 #endif /* nsMathMLmtableFrame_h___ */