Back to index

lightning-sunbird  0.9+nobinonly
nsBoxLayoutState.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00045 #ifndef nsBoxLayoutState_h___
00046 #define nsBoxLayoutState_h___
00047 
00048 #include "nsIFrame.h"
00049 #include "nsCOMPtr.h"
00050 #include "nsPresContext.h"
00051 #include "nsIPresShell.h"
00052 #include "nsHTMLReflowState.h"
00053 
00054 class nsReflowState;
00055 class nsCalculatedBoxInfo;
00056 struct nsHTMLReflowMetrics;
00057 class nsString;
00058 class nsHTMLReflowCommand;
00059 
00060 class nsBoxLayoutState
00061 {
00062 public:
00063   enum eBoxLayoutReason {
00064     Dirty,
00065     Resize,
00066     Initial
00067   };
00068 
00069   nsBoxLayoutState(nsPresContext* aPresContext,
00070                    const nsHTMLReflowState& aReflowState,
00071                    nsHTMLReflowMetrics& aDesiredSize) NS_HIDDEN;
00072   nsBoxLayoutState(nsPresContext* aPresContext) NS_HIDDEN;
00073   nsBoxLayoutState(nsIPresShell* aShell) NS_HIDDEN;
00074   nsBoxLayoutState(const nsBoxLayoutState& aState) NS_HIDDEN;
00075 
00076   NS_HIDDEN_(void) HandleReflow(nsIBox* aRootBox);
00077 
00078   nsPresContext* PresContext() { return mPresContext; }
00079   nsIPresShell*   PresShell() { return mPresContext->PresShell(); }
00080   nscoord* GetMaxElementWidth() { return mReflowState ? mMaxElementWidth : nsnull; }
00081 
00082   PRUint32 LayoutFlags() const { return mLayoutFlags; }
00083   void SetLayoutFlags(PRUint32 aFlags) { mLayoutFlags = aFlags; }
00084 
00085   // if true no one under us will paint during reflow.
00086   void SetPaintingDisabled(PRBool aDisable) { mPaintingDisabled = aDisable; }
00087   PRBool PaintingDisabled() const { return mPaintingDisabled; }
00088 
00089   eBoxLayoutReason LayoutReason() { return mType; }
00090   void SetLayoutReason(eBoxLayoutReason aReason) { mType = aReason; }
00091   const nsHTMLReflowState* GetReflowState() { return mReflowState; }
00092 
00093   static NS_HIDDEN_(void*) Allocate(size_t sz, nsIPresShell* aPresShell);
00094   static NS_HIDDEN_(void) Free(void* aPtr, size_t sz);
00095   static NS_HIDDEN_(void) RecycleFreedMemory(nsIPresShell* aPresShell,
00096                                              void* mem);
00097 
00098   nsresult PushStackMemory() { return PresShell()->PushStackMemory(); }
00099   nsresult PopStackMemory()  { return PresShell()->PopStackMemory(); }
00100   nsresult AllocateStackMemory(size_t aSize, void** aResult)
00101   { return PresShell()->AllocateStackMemory(aSize, aResult); }
00102 
00103 private:
00104   //void DirtyAllChildren(nsBoxLayoutState& aState, nsIBox* aBox);
00105   NS_HIDDEN_(void) Unwind(nsReflowPath* aReflowPath, nsIBox* aRootBox);
00106   NS_HIDDEN_(nsIBox*) GetBoxForFrame(nsIFrame* aFrame, PRBool& aIsAdaptor);
00107 
00108   nsCOMPtr<nsPresContext> mPresContext;
00109   const nsHTMLReflowState* mReflowState;
00110   nscoord* mMaxElementWidth;
00111   eBoxLayoutReason mType;
00112   PRUint32 mLayoutFlags;
00113   PRBool mPaintingDisabled;
00114 };
00115 
00116 #endif
00117