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
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.
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__
41 #include "nsHTMLContainerFrame.h"
42 #include "nsBlockFrame.h"
43 #include "nsITableLayout.h"
48 class nsTableCaptionFrame
: public nsBlockFrame
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
,
64 NS_IMETHOD
GetAccessible(nsIAccessible
** aAccessible
);
68 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const;
72 nsTableCaptionFrame(nsStyleContext
* aContext
);
73 virtual ~nsTableCaptionFrame();
78 1. decide if we'll allow subclassing. If so, decide which methods really need to be virtual.
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
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();
134 NS_IMETHOD
GetAccessible(nsIAccessible
** aAccessible
);
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;
170 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const;
173 /** SetSelected needs to be overridden to talk to inner tableframe
175 NS_IMETHOD
SetSelected(nsPresContext
* aPresContext
,
179 SelectionType aType
);
181 NS_IMETHOD
GetParentStyleContextFrame(nsPresContext
* aPresContext
,
182 nsIFrame
** aProviderFrame
,
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
);
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;
216 /** overridden here to handle special caption-table relationship
217 * @see nsContainerFrame::VerifyTree
219 NS_IMETHOD
VerifyTree() const;
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
,
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
,
252 nsresult
GetInnerOrigin(PRUint32 aCaptionSide
,
253 const nsSize
& aContainBlockSize
,
254 const nsSize
& aCaptionSize
,
255 const nsMargin
& aCaptionMargin
,
256 const nsSize
& aInnerSize
,
257 nsMargin
& aInnerMargin
,
260 // reflow the child (caption or innertable frame)
261 void OuterBeginReflowChild(nsPresContext
* aPresContext
,
262 nsIFrame
* aChildFrame
,
263 const nsHTMLReflowState
& aOuterRS
,
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
281 void GetMargin(nsPresContext
* aPresContext
,
282 const nsHTMLReflowState
& aOuterRS
,
283 nsIFrame
* aChildFrame
,
284 nscoord aAvailableWidth
,
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