layout/generic/nsAbsoluteContainingBlock.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:4e22492f7a9f
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 /*
7 * code for managing absolutely positioned children of a rendering
8 * object that is a containing block for them
9 */
10
11 #ifndef nsAbsoluteContainingBlock_h___
12 #define nsAbsoluteContainingBlock_h___
13
14 #include "nsFrameList.h"
15 #include "nsIFrame.h"
16
17 class nsContainerFrame;
18 class nsHTMLReflowState;
19 class nsPresContext;
20
21 /**
22 * This class contains the logic for being an absolute containing block. This
23 * class is used within viewport frames (for frames representing content with
24 * fixed position) and blocks (for frames representing absolutely positioned
25 * content), since each set of frames is absolutely positioned with respect to
26 * its parent.
27 *
28 * There is no principal child list, just a named child list which contains
29 * the absolutely positioned frames (kAbsoluteList or kFixedList).
30 *
31 * All functions include as the first argument the frame that is delegating
32 * the request.
33 */
34 class nsAbsoluteContainingBlock
35 {
36 public:
37 typedef nsIFrame::ChildListID ChildListID;
38
39 nsAbsoluteContainingBlock(ChildListID aChildListID)
40 #ifdef DEBUG
41 : mChildListID(aChildListID)
42 #endif
43 {
44 MOZ_ASSERT(mChildListID == nsIFrame::kAbsoluteList ||
45 mChildListID == nsIFrame::kFixedList,
46 "should either represent position:fixed or absolute content");
47 }
48
49 const nsFrameList& GetChildList() const { return mAbsoluteFrames; }
50 void AppendChildList(nsTArray<nsIFrame::ChildList>* aLists,
51 ChildListID aListID) const
52 {
53 NS_ASSERTION(aListID == mChildListID, "wrong list ID");
54 GetChildList().AppendIfNonempty(aLists, aListID);
55 }
56
57 nsresult SetInitialChildList(nsIFrame* aDelegatingFrame,
58 ChildListID aListID,
59 nsFrameList& aChildList);
60 nsresult AppendFrames(nsIFrame* aDelegatingFrame,
61 ChildListID aListID,
62 nsFrameList& aFrameList);
63 nsresult InsertFrames(nsIFrame* aDelegatingFrame,
64 ChildListID aListID,
65 nsIFrame* aPrevFrame,
66 nsFrameList& aFrameList);
67 void RemoveFrame(nsIFrame* aDelegatingFrame,
68 ChildListID aListID,
69 nsIFrame* aOldFrame);
70
71 /**
72 * Called by the delegating frame after it has done its reflow first. This
73 * function will reflow any absolutely positioned child frames that need to
74 * be reflowed, e.g., because the absolutely positioned child frame has
75 * 'auto' for an offset, or a percentage based width or height.
76 *
77 * @param aOverflowAreas, if non-null, is unioned with (in the local
78 * coordinate space) the overflow areas of the absolutely positioned
79 * children.
80 *
81 * @param aReflowStatus is assumed to be already-initialized, e.g. with the
82 * status of the delegating frame's main reflow. This function merges in the
83 * statuses of the absolutely positioned children's reflows.
84 */
85 nsresult Reflow(nsContainerFrame* aDelegatingFrame,
86 nsPresContext* aPresContext,
87 const nsHTMLReflowState& aReflowState,
88 nsReflowStatus& aReflowStatus,
89 const nsRect& aContainingBlock,
90 bool aConstrainHeight,
91 bool aCBWidthChanged,
92 bool aCBHeightChanged,
93 nsOverflowAreas* aOverflowAreas);
94
95 void DestroyFrames(nsIFrame* aDelegatingFrame,
96 nsIFrame* aDestructRoot);
97
98 bool HasAbsoluteFrames() const { return mAbsoluteFrames.NotEmpty(); }
99
100 /**
101 * Mark our size-dependent absolute frames with NS_FRAME_HAS_DIRTY_CHILDREN
102 * so that we'll make sure to reflow them.
103 */
104 void MarkSizeDependentFramesDirty();
105
106 /**
107 * Mark all our absolute frames with NS_FRAME_IS_DIRTY.
108 */
109 void MarkAllFramesDirty();
110
111 protected:
112 /**
113 * Returns true if the position of aFrame depends on the position of
114 * its placeholder or if the position or size of aFrame depends on a
115 * containing block dimension that changed.
116 */
117 bool FrameDependsOnContainer(nsIFrame* aFrame, bool aCBWidthChanged,
118 bool aCBHeightChanged);
119
120 nsresult ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
121 nsPresContext* aPresContext,
122 const nsHTMLReflowState& aReflowState,
123 const nsRect& aContainingBlockRect,
124 bool aConstrainHeight,
125 nsIFrame* aKidFrame,
126 nsReflowStatus& aStatus,
127 nsOverflowAreas* aOverflowAreas);
128
129 /**
130 * Mark our absolute frames dirty.
131 * @param aMarkAllDirty if true, all will be marked with NS_FRAME_IS_DIRTY.
132 * Otherwise, the size-dependant ones will be marked with
133 * NS_FRAME_HAS_DIRTY_CHILDREN.
134 */
135 void DoMarkFramesDirty(bool aMarkAllDirty);
136
137 protected:
138 nsFrameList mAbsoluteFrames; // additional named child list
139
140 #ifdef DEBUG
141 ChildListID const mChildListID; // kFixedList or kAbsoluteList
142 #endif
143 };
144
145 #endif /* nsnsAbsoluteContainingBlock_h___ */

mercurial