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
51 NS_DECL_FRAMEARENA_HELPERS
54 virtual nsIAtom
* GetType() const;
55 friend nsIFrame
* NS_NewTableCaptionFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
);
57 virtual nsSize
ComputeAutoSize(nsIRenderingContext
*aRenderingContext
,
58 nsSize aCBSize
, nscoord aAvailableWidth
,
59 nsSize aMargin
, nsSize aBorder
,
60 nsSize aPadding
, PRBool aShrinkWrap
);
62 NS_IMETHOD
GetParentStyleContextFrame(nsPresContext
* aPresContext
,
63 nsIFrame
** aProviderFrame
,
66 virtual already_AddRefed
<nsAccessible
> CreateAccessible();
70 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const;
74 nsTableCaptionFrame(nsStyleContext
* aContext
);
75 virtual ~nsTableCaptionFrame();
80 1. decide if we'll allow subclassing. If so, decide which methods really need to be virtual.
84 * main frame for an nsTable content object,
85 * the nsTableOuterFrame contains 0 or one caption frame, and a nsTableFrame
86 * pseudo-frame (referred to as the "inner frame').
88 class nsTableOuterFrame
: public nsHTMLContainerFrame
, public nsITableLayout
92 NS_DECL_FRAMEARENA_HELPERS
94 /** instantiate a new instance of nsTableRowFrame.
95 * @param aPresShell the pres shell for this frame
97 * @return the frame that was created
99 friend nsIFrame
* NS_NewTableOuterFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
);
101 // nsIFrame overrides - see there for a description
103 virtual void DestroyFrom(nsIFrame
* aDestructRoot
);
105 virtual PRBool
IsContainingBlock() const;
107 NS_IMETHOD
SetInitialChildList(nsIAtom
* aListName
,
108 nsFrameList
& aChildList
);
110 virtual nsFrameList
GetChildList(nsIAtom
* aListName
) const;
112 virtual nsIAtom
* GetAdditionalChildListName(PRInt32 aIndex
) const;
114 NS_IMETHOD
AppendFrames(nsIAtom
* aListName
,
115 nsFrameList
& aFrameList
);
117 NS_IMETHOD
InsertFrames(nsIAtom
* aListName
,
118 nsIFrame
* aPrevFrame
,
119 nsFrameList
& aFrameList
);
121 NS_IMETHOD
RemoveFrame(nsIAtom
* aListName
,
122 nsIFrame
* aOldFrame
);
124 virtual nsIFrame
* GetContentInsertionFrame() {
125 return GetFirstChild(nsnull
)->GetContentInsertionFrame();
129 virtual already_AddRefed
<nsAccessible
> CreateAccessible();
132 NS_IMETHOD
BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
133 const nsRect
& aDirtyRect
,
134 const nsDisplayListSet
& aLists
);
136 nsresult
BuildDisplayListForInnerTable(nsDisplayListBuilder
* aBuilder
,
137 const nsRect
& aDirtyRect
,
138 const nsDisplayListSet
& aLists
);
140 virtual nscoord
GetBaseline() const;
142 virtual nscoord
GetMinWidth(nsIRenderingContext
*aRenderingContext
);
143 virtual nscoord
GetPrefWidth(nsIRenderingContext
*aRenderingContext
);
144 virtual nsSize
ComputeAutoSize(nsIRenderingContext
*aRenderingContext
,
145 nsSize aCBSize
, nscoord aAvailableWidth
,
146 nsSize aMargin
, nsSize aBorder
,
147 nsSize aPadding
, PRBool aShrinkWrap
);
149 /** process a reflow command for the table.
150 * This involves reflowing the caption and the inner table.
151 * @see nsIFrame::Reflow */
152 NS_IMETHOD
Reflow(nsPresContext
* aPresContext
,
153 nsHTMLReflowMetrics
& aDesiredSize
,
154 const nsHTMLReflowState
& aReflowState
,
155 nsReflowStatus
& aStatus
);
158 * Get the "type" of the frame
160 * @see nsGkAtoms::tableOuterFrame
162 virtual nsIAtom
* GetType() const;
165 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const;
168 /** SetSelected needs to be overridden to talk to inner tableframe
170 void SetSelected(PRBool aSelected
,
171 SelectionType aType
);
173 NS_IMETHOD
GetParentStyleContextFrame(nsPresContext
* aPresContext
,
174 nsIFrame
** aProviderFrame
,
177 /*---------------- nsITableLayout methods ------------------------*/
179 /** @see nsITableFrame::GetCellDataAt */
180 NS_IMETHOD
GetCellDataAt(PRInt32 aRowIndex
, PRInt32 aColIndex
,
181 nsIDOMElement
* &aCell
, //out params
182 PRInt32
& aStartRowIndex
, PRInt32
& aStartColIndex
,
183 PRInt32
& aRowSpan
, PRInt32
& aColSpan
,
184 PRInt32
& aActualRowSpan
, PRInt32
& aActualColSpan
,
185 PRBool
& aIsSelected
);
187 /** @see nsITableFrame::GetTableSize */
188 NS_IMETHOD
GetTableSize(PRInt32
& aRowCount
, PRInt32
& aColCount
);
190 NS_IMETHOD
GetIndexByRowAndColumn(PRInt32 aRow
, PRInt32 aColumn
, PRInt32
*aIndex
);
191 NS_IMETHOD
GetRowAndColumnByIndex(PRInt32 aIndex
, PRInt32
*aRow
, PRInt32
*aColumn
);
196 nsTableOuterFrame(nsStyleContext
* aContext
);
197 virtual ~nsTableOuterFrame();
199 void InitChildReflowState(nsPresContext
& aPresContext
,
200 nsHTMLReflowState
& aReflowState
);
202 /** Always returns 0, since the outer table frame has no border of its own
203 * The inner table frame can answer this question in a meaningful way.
204 * @see nsHTMLContainerFrame::GetSkipSides */
205 virtual PRIntn
GetSkipSides() const;
207 PRUint8
GetCaptionSide(); // NS_STYLE_CAPTION_SIDE_* or NO_SIDE
209 PRBool
HasSideCaption() {
210 PRUint8 captionSide
= GetCaptionSide();
211 return captionSide
== NS_STYLE_CAPTION_SIDE_LEFT
||
212 captionSide
== NS_STYLE_CAPTION_SIDE_RIGHT
;
215 PRUint8
GetCaptionVerticalAlign();
217 void SetDesiredSize(PRUint8 aCaptionSide
,
218 const nsMargin
& aInnerMargin
,
219 const nsMargin
& aCaptionMargin
,
223 nsresult
GetCaptionOrigin(PRUint32 aCaptionSide
,
224 const nsSize
& aContainBlockSize
,
225 const nsSize
& aInnerSize
,
226 const nsMargin
& aInnerMargin
,
227 const nsSize
& aCaptionSize
,
228 nsMargin
& aCaptionMargin
,
231 nsresult
GetInnerOrigin(PRUint32 aCaptionSide
,
232 const nsSize
& aContainBlockSize
,
233 const nsSize
& aCaptionSize
,
234 const nsMargin
& aCaptionMargin
,
235 const nsSize
& aInnerSize
,
236 nsMargin
& aInnerMargin
,
239 // reflow the child (caption or innertable frame)
240 void OuterBeginReflowChild(nsPresContext
* aPresContext
,
241 nsIFrame
* aChildFrame
,
242 const nsHTMLReflowState
& aOuterRS
,
244 nscoord aAvailWidth
);
246 nsresult
OuterDoReflowChild(nsPresContext
* aPresContext
,
247 nsIFrame
* aChildFrame
,
248 const nsHTMLReflowState
& aChildRS
,
249 nsHTMLReflowMetrics
& aMetrics
,
250 nsReflowStatus
& aStatus
);
252 // Set the reflow metrics
253 void UpdateReflowMetrics(PRUint8 aCaptionSide
,
254 nsHTMLReflowMetrics
& aMet
,
255 const nsMargin
& aInnerMargin
,
256 const nsMargin
& aCaptionMargin
);
258 // Get the margin. aMarginNoAuto is aMargin, but with auto
260 void GetChildMargin(nsPresContext
* aPresContext
,
261 const nsHTMLReflowState
& aOuterRS
,
262 nsIFrame
* aChildFrame
,
263 nscoord aAvailableWidth
,
267 // used to keep track of this frame's children. They are redundant with mFrames, but more convient
268 nsTableFrame
* mInnerTableFrame
;
269 nsFrameList mCaptionFrames
;
270 nsIFrame
* mCaptionFrame
;
273 inline PRIntn
nsTableOuterFrame::GetSkipSides() const