1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * vim:cindent:ts=2:et:sw=2:
3 : *
4 : * ***** BEGIN LICENSE BLOCK *****
5 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 : *
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/
11 : *
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
15 : * License.
16 : *
17 : * The Original Code is mozilla.org code.
18 : *
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.
23 : *
24 : * Contributor(s):
25 : * Pierre Phaneuf <pp@ludusdesign.com>
26 : *
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.
38 : *
39 : * ***** END LICENSE BLOCK *****
40 : *
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
44 : * per MPL Section 3.3
45 : *
46 : * Date Modified by Description of modification
47 : * 04/20/2000 IBM Corp. OS/2 VisualAge build.
48 : */
49 :
50 : /* storage of the frame tree and information about it */
51 :
52 : #ifndef _nsFrameManager_h_
53 : #define _nsFrameManager_h_
54 :
55 : #include "nsIFrame.h"
56 : #include "nsIStatefulFrame.h"
57 : #include "nsChangeHint.h"
58 : #include "nsFrameManagerBase.h"
59 :
60 : namespace mozilla {
61 : namespace css {
62 : class RestyleTracker;
63 : } // namespace css
64 : } // namespace mozilla
65 :
66 : struct TreeMatchContext;
67 :
68 : /**
69 : * Frame manager interface. The frame manager serves two purposes:
70 : * <li>provides a service for mapping from content to frame and from
71 : * out-of-flow frame to placeholder frame.
72 : * <li>handles structural modifications to the frame model. If the frame model
73 : * lock can be acquired, then the changes are processed immediately; otherwise,
74 : * they're queued and processed later.
75 : *
76 : * Do not add virtual methods to this class, or bryner will punish you.
77 : */
78 :
79 : class nsFrameManager : public nsFrameManagerBase
80 : {
81 : typedef mozilla::css::RestyleTracker RestyleTracker;
82 : typedef nsIFrame::ChildListID ChildListID;
83 :
84 : public:
85 0 : nsFrameManager(nsIPresShell *aPresShell) NS_HIDDEN {
86 0 : mPresShell = aPresShell;
87 0 : }
88 : ~nsFrameManager() NS_HIDDEN;
89 :
90 : // Initialization
91 : NS_HIDDEN_(nsresult) Init(nsStyleSet* aStyleSet);
92 :
93 : /*
94 : * After Destroy is called, it is an error to call any FrameManager methods.
95 : * Destroy should be called when the frame tree managed by the frame
96 : * manager is no longer being displayed.
97 : */
98 : NS_HIDDEN_(void) Destroy();
99 :
100 : // Placeholder frame functions
101 : NS_HIDDEN_(nsPlaceholderFrame*) GetPlaceholderFrameFor(const nsIFrame* aFrame);
102 : NS_HIDDEN_(nsresult)
103 : RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
104 :
105 : NS_HIDDEN_(void)
106 : UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
107 :
108 : NS_HIDDEN_(void) ClearPlaceholderFrameMap();
109 :
110 : // Mapping undisplayed content
111 : NS_HIDDEN_(nsStyleContext*) GetUndisplayedContent(nsIContent* aContent);
112 : NS_HIDDEN_(void) SetUndisplayedContent(nsIContent* aContent,
113 : nsStyleContext* aStyleContext);
114 : NS_HIDDEN_(void) ChangeUndisplayedContent(nsIContent* aContent,
115 : nsStyleContext* aStyleContext);
116 : NS_HIDDEN_(void) ClearUndisplayedContentIn(nsIContent* aContent,
117 : nsIContent* aParentContent);
118 : NS_HIDDEN_(void) ClearAllUndisplayedContentIn(nsIContent* aParentContent);
119 :
120 : // Functions for manipulating the frame model
121 : NS_HIDDEN_(nsresult) AppendFrames(nsIFrame* aParentFrame,
122 : ChildListID aListID,
123 : nsFrameList& aFrameList);
124 :
125 : NS_HIDDEN_(nsresult) InsertFrames(nsIFrame* aParentFrame,
126 : ChildListID aListID,
127 : nsIFrame* aPrevFrame,
128 : nsFrameList& aFrameList);
129 :
130 : NS_HIDDEN_(nsresult) RemoveFrame(ChildListID aListID,
131 : nsIFrame* aOldFrame);
132 :
133 : /*
134 : * Notification that a frame is about to be destroyed. This allows any
135 : * outstanding references to the frame to be cleaned up.
136 : */
137 : NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame);
138 :
139 : /*
140 : * Reparent the style contexts of this frame subtree. The parent frame of
141 : * aFrame must be changed to the new parent before this function is called;
142 : * the new parent style context will be automatically computed based on the
143 : * new position in the frame tree.
144 : *
145 : * @param aFrame the root of the subtree to reparent. Must not be null.
146 : */
147 : NS_HIDDEN_(nsresult) ReparentStyleContext(nsIFrame* aFrame);
148 :
149 : /*
150 : * Re-resolve the style contexts for a frame tree, building
151 : * aChangeList based on the resulting style changes, plus aMinChange
152 : * applied to aFrame.
153 : */
154 : NS_HIDDEN_(void)
155 : ComputeStyleChangeFor(nsIFrame* aFrame,
156 : nsStyleChangeList* aChangeList,
157 : nsChangeHint aMinChange,
158 : RestyleTracker& aRestyleTracker,
159 : bool aRestyleDescendants);
160 :
161 : /*
162 : * Capture/restore frame state for the frame subtree rooted at aFrame.
163 : * aState is the document state storage object onto which each frame
164 : * stores its state.
165 : */
166 :
167 : NS_HIDDEN_(void) CaptureFrameState(nsIFrame* aFrame,
168 : nsILayoutHistoryState* aState);
169 :
170 : NS_HIDDEN_(void) RestoreFrameState(nsIFrame* aFrame,
171 : nsILayoutHistoryState* aState);
172 :
173 : /*
174 : * Add/restore state for one frame
175 : * (special, global type, like scroll position)
176 : */
177 : NS_HIDDEN_(void) CaptureFrameStateFor(nsIFrame* aFrame,
178 : nsILayoutHistoryState* aState,
179 : nsIStatefulFrame::SpecialStateID aID =
180 : nsIStatefulFrame::eNoID);
181 :
182 : NS_HIDDEN_(void) RestoreFrameStateFor(nsIFrame* aFrame,
183 : nsILayoutHistoryState* aState,
184 : nsIStatefulFrame::SpecialStateID aID =
185 : nsIStatefulFrame::eNoID);
186 :
187 : #ifdef NS_DEBUG
188 : /**
189 : * DEBUG ONLY method to verify integrity of style tree versus frame tree
190 : */
191 : NS_HIDDEN_(void) DebugVerifyStyleTree(nsIFrame* aFrame);
192 : #endif
193 :
194 : NS_HIDDEN_(nsIPresShell*) GetPresShell() const { return mPresShell; }
195 0 : NS_HIDDEN_(nsPresContext*) GetPresContext() const {
196 0 : return mPresShell->GetPresContext();
197 : }
198 :
199 : private:
200 : enum DesiredA11yNotifications {
201 : eSkipNotifications,
202 : eSendAllNotifications,
203 : eNotifyIfShown
204 : };
205 :
206 : enum A11yNotificationType {
207 : eDontNotify,
208 : eNotifyShown,
209 : eNotifyHidden
210 : };
211 :
212 : // Use eRestyle_Self for the aRestyleHint argument to mean
213 : // "reresolve our style context but not kids", use eRestyle_Subtree
214 : // to mean "reresolve our style context and kids", and use
215 : // nsRestyleHint(0) to mean recompute a new style context for our
216 : // current parent and existing rulenode, and the same for kids.
217 : NS_HIDDEN_(nsChangeHint)
218 : ReResolveStyleContext(nsPresContext *aPresContext,
219 : nsIFrame *aFrame,
220 : nsIContent *aParentContent,
221 : nsStyleChangeList *aChangeList,
222 : nsChangeHint aMinChange,
223 : nsRestyleHint aRestyleHint,
224 : RestyleTracker& aRestyleTracker,
225 : DesiredA11yNotifications aDesiredA11yNotifications,
226 : nsTArray<nsIContent*>& aVisibleKidsOfHiddenElement,
227 : TreeMatchContext &aTreeMatchContext);
228 : };
229 :
230 : #endif
|