Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / layout / tables / nsTableOuterFrame.h
blob66ac343c5eaee44f5fcf051e01c7e8419f22f53d
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.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
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.
36 * ***** END LICENSE BLOCK ***** */
37 #ifndef nsTableOuterFrame_h__
38 #define nsTableOuterFrame_h__
40 #include "nscore.h"
41 #include "nsHTMLContainerFrame.h"
42 #include "nsBlockFrame.h"
43 #include "nsITableLayout.h"
45 struct nsStyleTable;
46 class nsTableFrame;
48 class nsTableCaptionFrame : public nsBlockFrame
50 public:
51 // nsISupports
52 virtual nsIAtom* GetType() const;
53 friend nsIFrame* NS_NewTableCaptionFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
55 virtual nsSize ComputeAutoSize(nsIRenderingContext *aRenderingContext,
56 nsSize aCBSize, nscoord aAvailableWidth,
57 nsSize aMargin, nsSize aBorder,
58 nsSize aPadding, PRBool aShrinkWrap);
60 NS_IMETHOD GetParentStyleContextFrame(nsPresContext* aPresContext,
61 nsIFrame** aProviderFrame,
62 PRBool* aIsChild);
63 #ifdef ACCESSIBILITY
64 NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
65 #endif
67 #ifdef NS_DEBUG
68 NS_IMETHOD GetFrameName(nsAString& aResult) const;
69 #endif
71 protected:
72 nsTableCaptionFrame(nsStyleContext* aContext);
73 virtual ~nsTableCaptionFrame();
77 /* TODO
78 1. decide if we'll allow subclassing. If so, decide which methods really need to be virtual.
81 /**
82 * main frame for an nsTable content object,
83 * the nsTableOuterFrame contains 0 or one caption frame, and a nsTableFrame
84 * pseudo-frame (referred to as the "inner frame').
86 class nsTableOuterFrame : public nsHTMLContainerFrame, public nsITableLayout
88 public:
90 // nsISupports
91 NS_DECL_ISUPPORTS_INHERITED
93 /** instantiate a new instance of nsTableRowFrame.
94 * @param aPresShell the pres shell for this frame
96 * @return the frame that was created
98 friend nsIFrame* NS_NewTableOuterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
100 // nsIFrame overrides - see there for a description
102 virtual void Destroy();
104 virtual PRBool IsFrameOfType(PRUint32 aFlags) const
106 return nsHTMLContainerFrame::IsFrameOfType(aFlags &
107 ~nsIFrame::eExcludesIgnorableWhitespace);
110 virtual PRBool IsContainingBlock() const;
112 NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
113 nsIFrame* aChildList);
115 virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
117 virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
119 NS_IMETHOD AppendFrames(nsIAtom* aListName,
120 nsIFrame* aFrameList);
122 NS_IMETHOD InsertFrames(nsIAtom* aListName,
123 nsIFrame* aPrevFrame,
124 nsIFrame* aFrameList);
126 NS_IMETHOD RemoveFrame(nsIAtom* aListName,
127 nsIFrame* aOldFrame);
129 virtual nsIFrame* GetContentInsertionFrame() {
130 return GetFirstChild(nsnull)->GetContentInsertionFrame();
133 #ifdef ACCESSIBILITY
134 NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
135 #endif
137 NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
138 const nsRect& aDirtyRect,
139 const nsDisplayListSet& aLists);
141 nsresult BuildDisplayListForInnerTable(nsDisplayListBuilder* aBuilder,
142 const nsRect& aDirtyRect,
143 const nsDisplayListSet& aLists);
145 virtual nscoord GetBaseline() const;
147 virtual nscoord GetMinWidth(nsIRenderingContext *aRenderingContext);
148 virtual nscoord GetPrefWidth(nsIRenderingContext *aRenderingContext);
149 virtual nsSize ComputeAutoSize(nsIRenderingContext *aRenderingContext,
150 nsSize aCBSize, nscoord aAvailableWidth,
151 nsSize aMargin, nsSize aBorder,
152 nsSize aPadding, PRBool aShrinkWrap);
154 /** process a reflow command for the table.
155 * This involves reflowing the caption and the inner table.
156 * @see nsIFrame::Reflow */
157 NS_IMETHOD Reflow(nsPresContext* aPresContext,
158 nsHTMLReflowMetrics& aDesiredSize,
159 const nsHTMLReflowState& aReflowState,
160 nsReflowStatus& aStatus);
163 * Get the "type" of the frame
165 * @see nsGkAtoms::tableOuterFrame
167 virtual nsIAtom* GetType() const;
169 #ifdef DEBUG
170 NS_IMETHOD GetFrameName(nsAString& aResult) const;
171 #endif
173 /** SetSelected needs to be overridden to talk to inner tableframe
175 NS_IMETHOD SetSelected(nsPresContext* aPresContext,
176 nsIDOMRange *aRange,
177 PRBool aSelected,
178 nsSpread aSpread,
179 SelectionType aType);
181 NS_IMETHOD GetParentStyleContextFrame(nsPresContext* aPresContext,
182 nsIFrame** aProviderFrame,
183 PRBool* aIsChild);
185 /*---------------- nsITableLayout methods ------------------------*/
187 /** @see nsITableFrame::GetCellDataAt */
188 NS_IMETHOD GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
189 nsIDOMElement* &aCell, //out params
190 PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
191 PRInt32& aRowSpan, PRInt32& aColSpan,
192 PRInt32& aActualRowSpan, PRInt32& aActualColSpan,
193 PRBool& aIsSelected);
195 /** @see nsITableFrame::GetTableSize */
196 NS_IMETHOD GetTableSize(PRInt32& aRowCount, PRInt32& aColCount);
198 NS_IMETHOD GetIndexByRowAndColumn(PRInt32 aRow, PRInt32 aColumn, PRInt32 *aIndex);
199 NS_IMETHOD GetRowAndColumnByIndex(PRInt32 aIndex, PRInt32 *aRow, PRInt32 *aColumn);
201 protected:
204 nsTableOuterFrame(nsStyleContext* aContext);
205 virtual ~nsTableOuterFrame();
207 void InitChildReflowState(nsPresContext& aPresContext,
208 nsHTMLReflowState& aReflowState);
210 /** Always returns 0, since the outer table frame has no border of its own
211 * The inner table frame can answer this question in a meaningful way.
212 * @see nsHTMLContainerFrame::GetSkipSides */
213 virtual PRIntn GetSkipSides() const;
215 #ifdef NS_DEBUG
216 /** overridden here to handle special caption-table relationship
217 * @see nsContainerFrame::VerifyTree
219 NS_IMETHOD VerifyTree() const;
220 #endif
222 PRUint8 GetCaptionSide(); // NS_STYLE_CAPTION_SIDE_* or NO_SIDE
224 PRBool HasSideCaption() {
225 PRUint8 captionSide = GetCaptionSide();
226 return captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
227 captionSide == NS_STYLE_CAPTION_SIDE_RIGHT;
230 PRUint8 GetCaptionVerticalAlign();
232 void SetDesiredSize(PRUint8 aCaptionSide,
233 const nsMargin& aInnerMargin,
234 const nsMargin& aCaptionMargin,
235 nscoord& aWidth,
236 nscoord& aHeight);
238 void BalanceLeftRightCaption(PRUint8 aCaptionSide,
239 const nsMargin& aInnerMargin,
240 const nsMargin& aCaptionMargin,
241 nscoord& aInnerWidth,
242 nscoord& aCaptionWidth);
244 nsresult GetCaptionOrigin(PRUint32 aCaptionSide,
245 const nsSize& aContainBlockSize,
246 const nsSize& aInnerSize,
247 const nsMargin& aInnerMargin,
248 const nsSize& aCaptionSize,
249 nsMargin& aCaptionMargin,
250 nsPoint& aOrigin);
252 nsresult GetInnerOrigin(PRUint32 aCaptionSide,
253 const nsSize& aContainBlockSize,
254 const nsSize& aCaptionSize,
255 const nsMargin& aCaptionMargin,
256 const nsSize& aInnerSize,
257 nsMargin& aInnerMargin,
258 nsPoint& aOrigin);
260 // reflow the child (caption or innertable frame)
261 void OuterBeginReflowChild(nsPresContext* aPresContext,
262 nsIFrame* aChildFrame,
263 const nsHTMLReflowState& aOuterRS,
264 void* aChildRSSpace,
265 nscoord aAvailWidth);
267 nsresult OuterDoReflowChild(nsPresContext* aPresContext,
268 nsIFrame* aChildFrame,
269 const nsHTMLReflowState& aChildRS,
270 nsHTMLReflowMetrics& aMetrics,
271 nsReflowStatus& aStatus);
273 // Set the reflow metrics
274 void UpdateReflowMetrics(PRUint8 aCaptionSide,
275 nsHTMLReflowMetrics& aMet,
276 const nsMargin& aInnerMargin,
277 const nsMargin& aCaptionMargin);
279 // Get the margin. aMarginNoAuto is aMargin, but with auto
280 // margins set to 0
281 void GetMargin(nsPresContext* aPresContext,
282 const nsHTMLReflowState& aOuterRS,
283 nsIFrame* aChildFrame,
284 nscoord aAvailableWidth,
285 nsMargin& aMargin);
287 private:
288 // used to keep track of this frame's children. They are redundant with mFrames, but more convient
289 nsTableFrame* mInnerTableFrame;
290 nsFrameList mCaptionFrames;
291 nsIFrame* mCaptionFrame;
294 inline PRIntn nsTableOuterFrame::GetSkipSides() const
295 { return 0; }
297 #endif