Bug 574454 - Cleanup nsNativeThemeWin's GetMinimumWidgetSize a bit. r=roc.
[mozilla-central.git] / layout / generic / nsAbsoluteContainingBlock.h
blob04886f1f56adf6dad4c6d3bc48419a28c7141978
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 ***** */
39 * code for managing absolutely positioned children of a rendering
40 * object that is a containing block for them
43 #ifndef nsAbsoluteContainingBlock_h___
44 #define nsAbsoluteContainingBlock_h___
46 #include "nsFrameList.h"
47 #include "nsHTMLReflowState.h"
48 #include "nsGkAtoms.h"
49 #include "nsContainerFrame.h"
51 class nsIAtom;
52 class nsIFrame;
53 class nsPresContext;
55 /**
56 * This class contains the logic for being an absolute containing block. This
57 * class is used within viewport frames (for frames representing content with
58 * fixed position) and blocks (for frames representing absolutely positioned
59 * content), since each set of frames is absolutely positioned with respect to
60 * its parent.
62 * There is no principal child list, just a named child list which contains
63 * the absolutely positioned frames.
65 * All functions include as the first argument the frame that is delegating
66 * the request.
68 * @see nsGkAtoms::absoluteList and nsGkAtoms::fixedList
70 class nsAbsoluteContainingBlock
72 public:
73 nsAbsoluteContainingBlock(nsIAtom* aChildListName)
74 #ifdef DEBUG
75 : mChildListName(aChildListName)
76 #endif
78 NS_ASSERTION(mChildListName == nsGkAtoms::absoluteList ||
79 mChildListName == nsGkAtoms::fixedList,
80 "should either represent position:fixed or absolute content");
83 #ifdef DEBUG
84 nsIAtom* GetChildListName() const { return mChildListName; }
85 #endif
87 const nsFrameList& GetChildList() const { return mAbsoluteFrames; }
89 nsresult SetInitialChildList(nsIFrame* aDelegatingFrame,
90 nsIAtom* aListName,
91 nsFrameList& aChildList);
92 nsresult AppendFrames(nsIFrame* aDelegatingFrame,
93 nsIAtom* aListName,
94 nsFrameList& aFrameList);
95 nsresult InsertFrames(nsIFrame* aDelegatingFrame,
96 nsIAtom* aListName,
97 nsIFrame* aPrevFrame,
98 nsFrameList& aFrameList);
99 void RemoveFrame(nsIFrame* aDelegatingFrame,
100 nsIAtom* aListName,
101 nsIFrame* aOldFrame);
103 // Called by the delegating frame after it has done its reflow first. This
104 // function will reflow any absolutely positioned child frames that need to
105 // be reflowed, e.g., because the absolutely positioned child frame has
106 // 'auto' for an offset, or a percentage based width or height.
107 // If aChildBounds is set, it returns (in the local coordinate space) the
108 // bounding rect of the absolutely positioned child elements taking into
109 // account their overflow area (if it is visible).
110 // @param aForceReflow if this is false, reflow for some absolutely
111 // positioned frames may be skipped based on whether they use
112 // placeholders for positioning and on whether the containing block
113 // width or height changed.
114 nsresult Reflow(nsContainerFrame* aDelegatingFrame,
115 nsPresContext* aPresContext,
116 const nsHTMLReflowState& aReflowState,
117 nsReflowStatus& aReflowStatus,
118 nscoord aContainingBlockWidth,
119 nscoord aContainingBlockHeight,
120 PRBool aConstrainHeight,
121 PRBool aCBWidthChanged,
122 PRBool aCBHeightChanged,
123 nsRect* aChildBounds = nsnull);
126 void DestroyFrames(nsIFrame* aDelegatingFrame,
127 nsIFrame* aDestructRoot);
129 PRBool HasAbsoluteFrames() {return mAbsoluteFrames.NotEmpty();}
131 // Mark our size-dependent absolute frames with NS_FRAME_HAS_DIRTY_CHILDREN
132 // so that we'll make sure to reflow them.
133 void MarkSizeDependentFramesDirty();
135 // Mark all our absolute frames with NS_FRAME_IS_DIRTY
136 void MarkAllFramesDirty();
138 protected:
139 // Returns PR_TRUE if the position of f depends on the position of
140 // its placeholder or if the position or size of f depends on a
141 // containing block dimension that changed.
142 PRBool FrameDependsOnContainer(nsIFrame* f, PRBool aCBWidthChanged,
143 PRBool aCBHeightChanged);
145 nsresult ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
146 nsPresContext* aPresContext,
147 const nsHTMLReflowState& aReflowState,
148 nscoord aContainingBlockWidth,
149 nscoord aContainingBlockHeight,
150 PRBool aConstrainHeight,
151 nsIFrame* aKidFrame,
152 nsReflowStatus& aStatus,
153 nsRect* aChildBounds);
155 // Mark our absolute frames dirty. If aMarkAllDirty is true, all will be
156 // marked with NS_FRAME_IS_DIRTY. Otherwise, the size-dependant ones will be
157 // marked with NS_FRAME_HAS_DIRTY_CHILDREN.
158 void DoMarkFramesDirty(PRBool aMarkAllDirty);
160 protected:
161 nsFrameList mAbsoluteFrames; // additional named child list
163 #ifdef DEBUG
164 nsIAtom* const mChildListName; // nsGkAtoms::fixedList or nsGkAtoms::absoluteList
166 // helper routine for debug printout
167 void PrettyUC(nscoord aSize,
168 char* aBuf);
169 #endif
172 #endif /* nsnsAbsoluteContainingBlock_h___ */