1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim:cindent:ts=2:et:sw=2:
4 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
17 * The Original Code is mozilla.org code.
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 1998
22 * the Initial Developer. All Rights Reserved.
25 * Pierre Phaneuf <pp@ludusdesign.com>
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK *****
41 * This Original Code has been modified by IBM Corporation. Modifications made
42 * by IBM described herein are Copyright (c) International Business Machines
43 * Corporation, 2000. Modifications to Mozilla code or documentation identified
46 * Date Modified by Description of modification
47 * 04/20/2000 IBM Corp. OS/2 VisualAge build.
50 /* storage of the frame tree and information about it */
52 #ifndef _nsFrameManager_h_
53 #define _nsFrameManager_h_
56 #include "nsIStatefulFrame.h"
57 #include "nsChangeHint.h"
58 #include "nsFrameManagerBase.h"
61 * Frame manager interface. The frame manager serves two purposes:
62 * <li>provides a service for mapping from content to frame and from
63 * out-of-flow frame to placeholder frame.
64 * <li>handles structural modifications to the frame model. If the frame model
65 * lock can be acquired, then the changes are processed immediately; otherwise,
66 * they're queued and processed later.
68 * Do not add virtual methods to this class, or bryner will punish you.
71 class nsFrameManager
: public nsFrameManagerBase
74 nsFrameManager() NS_HIDDEN
;
75 ~nsFrameManager() NS_HIDDEN
;
77 void* operator new(size_t aSize
, nsIPresShell
* aHost
) {
78 NS_ASSERTION(aSize
== sizeof(nsFrameManager
), "Unexpected subclass");
79 NS_ASSERTION(aSize
== sizeof(nsFrameManagerBase
),
80 "Superclass/subclass mismatch");
81 return aHost
->FrameManager();
85 NS_HIDDEN_(nsresult
) Init(nsIPresShell
* aPresShell
, nsStyleSet
* aStyleSet
);
88 * After Destroy is called, it is an error to call any FrameManager methods.
89 * Destroy should be called when the frame tree managed by the frame
90 * manager is no longer being displayed.
92 NS_HIDDEN_(void) Destroy();
95 * Gets and sets the root frame (typically the viewport). The lifetime of the
96 * root frame is controlled by the frame manager. When the frame manager is
97 * destroyed, it destroys the entire frame hierarchy.
99 NS_HIDDEN_(nsIFrame
*) GetRootFrame() { return mRootFrame
; }
100 NS_HIDDEN_(void) SetRootFrame(nsIFrame
* aRootFrame
)
102 NS_ASSERTION(!mRootFrame
, "already have a root frame");
103 mRootFrame
= aRootFrame
;
107 * Get the canvas frame, searching from the root frame down.
108 * The canvas frame may or may not exist, so this may return null.
110 NS_HIDDEN_(nsIFrame
*) GetCanvasFrame();
112 // Primary frame functions
113 // If aIndexHint it not -1, it will be used as when determining a frame hint
114 // instead of calling IndexOf(aContent).
115 NS_HIDDEN_(nsIFrame
*) GetPrimaryFrameFor(nsIContent
* aContent
,
117 // aPrimaryFrame must not be null. If you're trying to remove a primary frame
118 // mapping, use RemoveAsPrimaryFrame.
119 NS_HIDDEN_(nsresult
) SetPrimaryFrameFor(nsIContent
* aContent
,
120 nsIFrame
* aPrimaryFrame
);
121 // If aPrimaryFrame is the current primary frame for aContent, remove the
122 // relevant hashtable entry. If the current primary frame for aContent is
123 // null, this does nothing. aPrimaryFrame must not be null, and this method
124 // handles calling RemovedAsPrimaryFrame on aPrimaryFrame.
125 NS_HIDDEN_(void) RemoveAsPrimaryFrame(nsIContent
* aContent
,
126 nsIFrame
* aPrimaryFrame
);
127 NS_HIDDEN_(void) ClearPrimaryFrameMap();
129 // Placeholder frame functions
130 NS_HIDDEN_(nsPlaceholderFrame
*) GetPlaceholderFrameFor(nsIFrame
* aFrame
);
132 RegisterPlaceholderFrame(nsPlaceholderFrame
* aPlaceholderFrame
);
135 UnregisterPlaceholderFrame(nsPlaceholderFrame
* aPlaceholderFrame
);
137 NS_HIDDEN_(void) ClearPlaceholderFrameMap();
139 // Mapping undisplayed content
140 NS_HIDDEN_(nsStyleContext
*) GetUndisplayedContent(nsIContent
* aContent
);
141 NS_HIDDEN_(void) SetUndisplayedContent(nsIContent
* aContent
,
142 nsStyleContext
* aStyleContext
);
143 NS_HIDDEN_(void) ChangeUndisplayedContent(nsIContent
* aContent
,
144 nsStyleContext
* aStyleContext
);
145 NS_HIDDEN_(void) ClearUndisplayedContentIn(nsIContent
* aContent
,
146 nsIContent
* aParentContent
);
147 NS_HIDDEN_(void) ClearAllUndisplayedContentIn(nsIContent
* aParentContent
);
148 NS_HIDDEN_(void) ClearUndisplayedContentMap();
150 // Functions for manipulating the frame model
151 NS_HIDDEN_(nsresult
) AppendFrames(nsIFrame
* aParentFrame
,
153 nsIFrame
* aFrameList
)
155 return aParentFrame
->AppendFrames(aListName
, aFrameList
);
158 NS_HIDDEN_(nsresult
) InsertFrames(nsIFrame
* aParentFrame
,
160 nsIFrame
* aPrevFrame
,
161 nsIFrame
* aFrameList
);
163 NS_HIDDEN_(nsresult
) RemoveFrame(nsIFrame
* aParentFrame
,
165 nsIFrame
* aOldFrame
);
168 * Notification that a frame is about to be destroyed. This allows any
169 * outstanding references to the frame to be cleaned up.
171 NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame
* aFrame
);
174 * Reparent the style contexts of this frame subtree. The parent frame of
175 * aFrame must be changed to the new parent before this function is called;
176 * the new parent style context will be automatically computed based on the
177 * new position in the frame tree.
179 * @param aFrame the root of the subtree to reparent. Must not be null.
181 NS_HIDDEN_(nsresult
) ReParentStyleContext(nsIFrame
* aFrame
);
184 * Re-resolve the style contexts for a frame tree, building
185 * aChangeList based on the resulting style changes, plus aMinChange
189 ComputeStyleChangeFor(nsIFrame
* aFrame
,
190 nsStyleChangeList
* aChangeList
,
191 nsChangeHint aMinChange
);
193 // Determine whether an attribute affects style
194 NS_HIDDEN_(nsReStyleHint
) HasAttributeDependentStyle(nsIContent
*aContent
,
197 PRUint32 aStateMask
);
200 * Capture/restore frame state for the frame subtree rooted at aFrame.
201 * aState is the document state storage object onto which each frame
205 NS_HIDDEN_(void) CaptureFrameState(nsIFrame
* aFrame
,
206 nsILayoutHistoryState
* aState
);
208 NS_HIDDEN_(void) RestoreFrameState(nsIFrame
* aFrame
,
209 nsILayoutHistoryState
* aState
);
212 * Add/restore state for one frame
213 * (special, global type, like scroll position)
215 NS_HIDDEN_(void) CaptureFrameStateFor(nsIFrame
* aFrame
,
216 nsILayoutHistoryState
* aState
,
217 nsIStatefulFrame::SpecialStateID aID
=
218 nsIStatefulFrame::eNoID
);
220 NS_HIDDEN_(void) RestoreFrameStateFor(nsIFrame
* aFrame
,
221 nsILayoutHistoryState
* aState
,
222 nsIStatefulFrame::SpecialStateID aID
=
223 nsIStatefulFrame::eNoID
);
227 * DEBUG ONLY method to verify integrity of style tree versus frame tree
229 NS_HIDDEN_(void) DebugVerifyStyleTree(nsIFrame
* aFrame
);
232 NS_HIDDEN_(nsIPresShell
*) GetPresShell() const { return mPresShell
; }
233 NS_HIDDEN_(nsPresContext
*) GetPresContext() const {
234 return mPresShell
->GetPresContext();
238 NS_HIDDEN_(nsChangeHint
)
239 ReResolveStyleContext(nsPresContext
*aPresContext
,
241 nsIContent
*aParentContent
,
242 nsStyleChangeList
*aChangeList
,
243 nsChangeHint aMinChange
);