1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 // vim:cindent:ts=2:et:sw=2:
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is Mozilla Communicator client code.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 /* class that a parent frame uses to reflow a block frame */
41 #ifndef nsBlockReflowContext_h___
42 #define nsBlockReflowContext_h___
45 #include "nsHTMLReflowMetrics.h"
48 class nsBlockReflowState
;
49 struct nsHTMLReflowState
;
54 struct nsStylePosition
;
55 struct nsBlockHorizontalAlign
;
58 * An encapsulation of the state and algorithm for reflowing block frames.
60 class nsBlockReflowContext
{
62 nsBlockReflowContext(nsPresContext
* aPresContext
,
63 const nsHTMLReflowState
& aParentRS
);
64 ~nsBlockReflowContext() { }
66 nsresult
ReflowBlock(const nsRect
& aSpace
,
67 PRBool aApplyTopMargin
,
68 nsCollapsingMargin
& aPrevMargin
,
70 PRBool aIsAdjacentWithTop
,
71 nsMargin
& aComputedOffsets
,
73 nsHTMLReflowState
& aReflowState
,
74 nsReflowStatus
& aReflowStatus
,
75 nsBlockReflowState
& aState
);
77 PRBool
PlaceBlock(const nsHTMLReflowState
& aReflowState
,
80 const nsMargin
& aComputedOffsets
,
81 nsCollapsingMargin
& aBottomMarginResult
/* out */,
82 nsRect
& aInFlowBounds
,
83 nsRect
& aCombinedRect
,
84 nsReflowStatus aReflowStatus
);
86 nsCollapsingMargin
& GetCarriedOutBottomMargin() {
87 return mMetrics
.mCarriedOutBottomMargin
;
90 nscoord
GetTopMargin() const {
91 return mTopMargin
.get();
94 const nsHTMLReflowMetrics
& GetMetrics() const {
99 * Computes the collapsed top margin for a block whose reflow state is in aRS.
100 * The computed margin is added into aMargin.
101 * If aClearanceFrame is null then this is the first optimistic pass which shall assume
102 * that no frames have clearance, and we clear the HasClearance on all frames encountered.
103 * If non-null, this is the second pass and
104 * the caller has decided aClearanceFrame needs clearance (and we will
105 * therefore stop collapsing there); also, this function is responsible for marking
106 * it with SetHasClearance.
107 * If in the optimistic pass any frame is encountered that might possibly need
108 * clearance (i.e., if we really needed the optimism assumption) then we set aMayNeedRetry
110 * We return PR_TRUE if we changed the clearance state of any line and marked it dirty.
112 static PRBool
ComputeCollapsedTopMargin(const nsHTMLReflowState
& aRS
,
113 nsCollapsingMargin
* aMargin
, nsIFrame
* aClearanceFrame
,
114 PRBool
* aMayNeedRetry
, PRBool
* aIsEmpty
= nsnull
);
117 nsPresContext
* mPresContext
;
118 const nsHTMLReflowState
& mOuterReflowState
;
124 nsHTMLReflowMetrics mMetrics
;
125 nsCollapsingMargin mTopMargin
;
128 #endif /* nsBlockReflowContext_h___ */