Back to index

lightning-sunbird  0.9+nobinonly
nsBlockReflowContext.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 /* ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is Mozilla Communicator client code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 #ifndef nsBlockReflowContext_h___
00039 #define nsBlockReflowContext_h___
00040 
00041 #include "nsIFrame.h"
00042 #include "nsHTMLReflowMetrics.h"
00043 
00044 class nsBlockFrame;
00045 class nsBlockReflowState;
00046 struct nsHTMLReflowState;
00047 class nsLineBox;
00048 class nsIFrame;
00049 class nsPresContext;
00050 class nsLineLayout;
00051 struct nsStylePosition;
00052 struct nsBlockHorizontalAlign;
00053 
00057 class nsBlockReflowContext {
00058 public:
00059   nsBlockReflowContext(nsPresContext* aPresContext,
00060                        const nsHTMLReflowState& aParentRS,
00061                        PRBool aComputeMaxElementWidth,
00062                        PRBool aComputeMaximumWidth);
00063   ~nsBlockReflowContext() { }
00064 
00065   nsresult ReflowBlock(const nsRect&       aSpace,
00066                        PRBool              aApplyTopMargin,
00067                        nsCollapsingMargin& aPrevMargin,
00068                        nscoord             aClearance,
00069                        PRBool              aIsAdjacentWithTop,
00070                        nsMargin&           aComputedOffsets,
00071                        nsHTMLReflowState&  aReflowState,
00072                        nsReflowStatus&     aReflowStatus);
00073 
00074   PRBool PlaceBlock(const nsHTMLReflowState& aReflowState,
00075                     PRBool                   aForceFit,
00076                     nsLineBox*               aLine,
00077                     const nsMargin&          aComputedOffsets,
00078                     nsCollapsingMargin&      aBottomMarginResult /* out */,
00079                     nsRect&                  aInFlowBounds,
00080                     nsRect&                  aCombinedRect,
00081                     nsReflowStatus           aReflowStatus);
00082 
00083   void AlignBlockHorizontally(nscoord aWidth, nsBlockHorizontalAlign&);
00084 
00085   nsCollapsingMargin& GetCarriedOutBottomMargin() {
00086     return mMetrics.mCarriedOutBottomMargin;
00087   }
00088 
00089   nscoord GetTopMargin() const {
00090     return mTopMargin.get();
00091   }
00092 
00093   const nsMargin& GetMargin() const {
00094     return mMargin;
00095   }
00096 
00097   const nsHTMLReflowMetrics& GetMetrics() const {
00098     return mMetrics;
00099   }
00100 
00101   nscoord GetMaxElementWidth() const {
00102     return mMetrics.mMaxElementWidth;
00103   }
00104   
00105   nscoord GetMaximumWidth() const {
00106     return mMetrics.mMaximumWidth;
00107   }
00108 
00123   static PRBool ComputeCollapsedTopMargin(const nsHTMLReflowState& aRS,
00124                                           nsCollapsingMargin* aMargin, nsIFrame* aClearanceFrame,
00125                                           PRBool* aMayNeedRetry);
00126 
00127 protected:
00128   nsPresContext* mPresContext;
00129   const nsHTMLReflowState& mOuterReflowState;
00130 
00131   nsIFrame* mFrame;
00132   nsRect mSpace;
00133 
00134   // Spacing style for the frame we are reflowing; only valid after reflow
00135   const nsStyleBorder* mStyleBorder;
00136   const nsStyleMargin* mStyleMargin;
00137   const nsStylePadding* mStylePadding;
00138 
00139   nscoord mComputedWidth;               // copy of reflowstate's computedWidth
00140   nsMargin mMargin;
00141   nscoord mX, mY;
00142   nsHTMLReflowMetrics mMetrics;
00143   nsCollapsingMargin mTopMargin;
00144   PRPackedBool mComputeMaximumWidth;
00145 };
00146 
00147 #endif /* nsBlockReflowContext_h___ */