Back to index

lightning-sunbird  0.9+nobinonly
nsFrameManager.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  * vim:cindent:ts=2:et:sw=2:
00003  *
00004  * ***** BEGIN LICENSE BLOCK *****
00005  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00006  *
00007  * The contents of this file are subject to the Mozilla Public License Version
00008  * 1.1 (the "License"); you may not use this file except in compliance with
00009  * the License. You may obtain a copy of the License at
00010  * http://www.mozilla.org/MPL/
00011  *
00012  * Software distributed under the License is distributed on an "AS IS" basis,
00013  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00014  * for the specific language governing rights and limitations under the
00015  * License.
00016  *
00017  * The Original Code is mozilla.org code.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 1998
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *   Pierre Phaneuf <pp@ludusdesign.com>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either of the GNU General Public License Version 2 or later (the "GPL"),
00029  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK *****
00040  *
00041  * This Original Code has been modified by IBM Corporation. Modifications made
00042  * by IBM described herein are Copyright (c) International Business Machines
00043  * Corporation, 2000. Modifications to Mozilla code or documentation identified
00044  * per MPL Section 3.3
00045  *
00046  * Date             Modified by     Description of modification
00047  * 04/20/2000       IBM Corp.      OS/2 VisualAge build.
00048  */
00049 
00050 #ifndef _nsFrameManager_h_
00051 #define _nsFrameManager_h_
00052 
00053 #include "nsIFrame.h"
00054 #include "nsIStatefulFrame.h"
00055 #include "nsChangeHint.h"
00056 #include "nsFrameManagerBase.h"
00057 
00069 class nsFrameManager : public nsFrameManagerBase
00070 {
00071 public:
00072   nsFrameManager() NS_HIDDEN;
00073   ~nsFrameManager() NS_HIDDEN;
00074 
00075   void* operator new(size_t aSize, nsIPresShell* aHost) {
00076     NS_ASSERTION(aSize == sizeof(nsFrameManager), "Unexpected subclass");
00077     NS_ASSERTION(aSize == sizeof(nsFrameManagerBase),
00078                  "Superclass/subclass mismatch");
00079     return aHost->FrameManager();
00080   }
00081 
00082   // Initialization
00083   NS_HIDDEN_(nsresult) Init(nsIPresShell* aPresShell, nsStyleSet* aStyleSet);
00084 
00085   /*
00086    * After Destroy is called, it is an error to call any FrameManager methods.
00087    * Destroy should be called when the frame tree managed by the frame
00088    * manager is no longer being displayed.
00089    */
00090   NS_HIDDEN_(void) Destroy();
00091 
00092   /*
00093    * Gets and sets the root frame (typically the viewport). The lifetime of the
00094    * root frame is controlled by the frame manager. When the frame manager is
00095    * destroyed, it destroys the entire frame hierarchy.
00096    */
00097   NS_HIDDEN_(nsIFrame*) GetRootFrame() { return mRootFrame; }
00098   NS_HIDDEN_(void)      SetRootFrame(nsIFrame* aRootFrame)
00099   {
00100     NS_ASSERTION(!mRootFrame, "already have a root frame");
00101     mRootFrame = aRootFrame;
00102   }
00103 
00104   /*
00105    * Get the canvas frame, searching from the root frame down.
00106    * The canvas frame may or may not exist, so this may return null.
00107    */
00108   NS_HIDDEN_(nsIFrame*) GetCanvasFrame();
00109 
00110   // Primary frame functions
00111   NS_HIDDEN_(nsIFrame*) GetPrimaryFrameFor(nsIContent* aContent);
00112   // aPrimaryFrame must not be null.  If you're trying to remove a primary frame
00113   // mapping, use RemoveAsPrimaryFrame.
00114   NS_HIDDEN_(nsresult)  SetPrimaryFrameFor(nsIContent* aContent,
00115                                            nsIFrame* aPrimaryFrame);
00116   // If aPrimaryFrame is the current primary frame for aContent, remove the
00117   // relevant hashtable entry.  If the current primary frame for aContent is
00118   // null, this does nothing.  aPrimaryFrame must not be null, and this method
00119   // handles calling RemovedAsPrimaryFrame on aPrimaryFrame.
00120   NS_HIDDEN_(void)      RemoveAsPrimaryFrame(nsIContent* aContent,
00121                                              nsIFrame* aPrimaryFrame);
00122   NS_HIDDEN_(void)      ClearPrimaryFrameMap();
00123 
00124   // Placeholder frame functions
00125   NS_HIDDEN_(nsPlaceholderFrame*) GetPlaceholderFrameFor(nsIFrame* aFrame);
00126   NS_HIDDEN_(nsresult)
00127     RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
00128 
00129   NS_HIDDEN_(void)
00130     UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
00131 
00132   NS_HIDDEN_(void)      ClearPlaceholderFrameMap();
00133 
00134   // Mapping undisplayed content
00135   NS_HIDDEN_(nsStyleContext*) GetUndisplayedContent(nsIContent* aContent);
00136   NS_HIDDEN_(void) SetUndisplayedContent(nsIContent* aContent,
00137                                          nsStyleContext* aStyleContext);
00138   NS_HIDDEN_(void) ChangeUndisplayedContent(nsIContent* aContent,
00139                                             nsStyleContext* aStyleContext);
00140   NS_HIDDEN_(void) ClearUndisplayedContentIn(nsIContent* aContent,
00141                                              nsIContent* aParentContent);
00142   NS_HIDDEN_(void) ClearAllUndisplayedContentIn(nsIContent* aParentContent);
00143   NS_HIDDEN_(void) ClearUndisplayedContentMap();
00144 
00145   // Functions for manipulating the frame model
00146   NS_HIDDEN_(nsresult) AppendFrames(nsIFrame*       aParentFrame,
00147                                     nsIAtom*        aListName,
00148                                     nsIFrame*       aFrameList)
00149   {
00150     return aParentFrame->AppendFrames(aListName, aFrameList);
00151   }
00152 
00153   NS_HIDDEN_(nsresult) InsertFrames(nsIFrame*       aParentFrame,
00154                                     nsIAtom*        aListName,
00155                                     nsIFrame*       aPrevFrame,
00156                                     nsIFrame*       aFrameList);
00157 
00158   NS_HIDDEN_(nsresult) RemoveFrame(nsIFrame*       aParentFrame,
00159                                    nsIAtom*        aListName,
00160                                    nsIFrame*       aOldFrame);
00161 
00162   NS_HIDDEN_(nsresult) ReplaceFrame(nsIFrame*       aParentFrame,
00163                                     nsIAtom*        aListName,
00164                                     nsIFrame*       aOldFrame,
00165                                     nsIFrame*       aNewFrame)
00166   {
00167     return aParentFrame->ReplaceFrame(aListName, aOldFrame, aNewFrame);
00168   }
00169 
00170   /*
00171    * Notification that a frame is about to be destroyed. This allows any
00172    * outstanding references to the frame to be cleaned up.
00173    */
00174   NS_HIDDEN_(void)     NotifyDestroyingFrame(nsIFrame* aFrame);
00175 
00176   /*
00177    * Reparent the style contexts of this frame subtree.  The parent frame of
00178    * aFrame must be changed to the new parent before this function is called;
00179    * the new parent style context will be automatically computed based on the
00180    * new position in the frame tree.
00181    *
00182    * @param aFrame the root of the subtree to reparent.  Must not be null.
00183    */
00184   NS_HIDDEN_(nsresult) ReParentStyleContext(nsIFrame* aFrame);
00185 
00186   /*
00187    * Re-resolve the style contexts for a frame tree.  Returns the top-level
00188    * change hint resulting from the style re-resolution.
00189    */
00190   NS_HIDDEN_(nsChangeHint)
00191     ComputeStyleChangeFor(nsIFrame* aFrame,
00192                           nsStyleChangeList* aChangeList,
00193                           nsChangeHint aMinChange);
00194 
00195   // Determine whether an attribute affects style
00196   NS_HIDDEN_(nsReStyleHint) HasAttributeDependentStyle(nsIContent *aContent,
00197                                                        nsIAtom *aAttribute,
00198                                                        PRInt32 aModType);
00199 
00200   /*
00201    * Capture/restore frame state for the frame subtree rooted at aFrame.
00202    * aState is the document state storage object onto which each frame
00203    * stores its state.
00204    */
00205 
00206   NS_HIDDEN_(void) CaptureFrameState(nsIFrame*              aFrame,
00207                                      nsILayoutHistoryState* aState);
00208 
00209   NS_HIDDEN_(void) RestoreFrameState(nsIFrame*              aFrame,
00210                                      nsILayoutHistoryState* aState);
00211 
00212   /*
00213    * Add/restore state for one frame
00214    * (special, global type, like scroll position)
00215    */
00216   NS_HIDDEN_(void) CaptureFrameStateFor(nsIFrame*              aFrame,
00217                                         nsILayoutHistoryState* aState,
00218                                         nsIStatefulFrame::SpecialStateID aID =
00219                                                       nsIStatefulFrame::eNoID);
00220 
00221   NS_HIDDEN_(void) RestoreFrameStateFor(nsIFrame*              aFrame,
00222                                         nsILayoutHistoryState* aState,
00223                                         nsIStatefulFrame::SpecialStateID aID =
00224                                                       nsIStatefulFrame::eNoID);
00225 
00226 #ifdef NS_DEBUG
00227 
00230   NS_HIDDEN_(void) DebugVerifyStyleTree(nsIFrame* aFrame);
00231 #endif
00232 
00233 private:
00234 
00235   NS_HIDDEN_(nsIPresShell*) GetPresShell() const { return mPresShell; }
00236   NS_HIDDEN_(nsPresContext*) GetPresContext() const {
00237     return mPresShell->GetPresContext();
00238   }
00239 
00240   NS_HIDDEN_(nsChangeHint)
00241     ReResolveStyleContext(nsPresContext    *aPresContext,
00242                           nsIFrame          *aFrame,
00243                           nsIContent        *aParentContent,
00244                           nsStyleChangeList *aChangeList, 
00245                           nsChangeHint       aMinChange);
00246 };
00247 
00248 #endif