1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 // vim:cindent:ts=2:et:sw=2:
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* class that a parent frame uses to reflow a block frame */
9 #ifndef nsBlockReflowContext_h___
10 #define nsBlockReflowContext_h___
13 #include "nsHTMLReflowMetrics.h"
15 class nsBlockReflowState
;
16 struct nsHTMLReflowState
;
20 struct nsBlockHorizontalAlign
;
23 * An encapsulation of the state and algorithm for reflowing block frames.
25 class nsBlockReflowContext
{
27 nsBlockReflowContext(nsPresContext
* aPresContext
,
28 const nsHTMLReflowState
& aParentRS
);
29 ~nsBlockReflowContext() { }
31 void ReflowBlock(const nsRect
& aSpace
,
32 bool aApplyBStartMargin
,
33 nsCollapsingMargin
& aPrevMargin
,
35 bool aIsAdjacentWithBStart
,
37 nsHTMLReflowState
& aReflowState
,
38 nsReflowStatus
& aReflowStatus
,
39 nsBlockReflowState
& aState
);
41 bool PlaceBlock(const nsHTMLReflowState
& aReflowState
,
44 nsCollapsingMargin
& aBEndMarginResult
/* out */,
45 nsOverflowAreas
& aOverflowAreas
,
46 nsReflowStatus aReflowStatus
);
48 nsCollapsingMargin
& GetCarriedOutBEndMargin() {
49 return mMetrics
.mCarriedOutBottomMargin
;
52 const nsHTMLReflowMetrics
& GetMetrics() const {
57 * Computes the collapsed block-start margin for a block whose reflow state
59 * The computed margin is added into aMargin.
60 * If aClearanceFrame is null then this is the first optimistic pass which
61 * shall assume that no frames have clearance, and we clear the HasClearance
62 * on all frames encountered.
63 * If non-null, this is the second pass and the caller has decided
64 * aClearanceFrame needs clearance (and we will therefore stop collapsing
65 * there); also, this function is responsible for marking it with
67 * If in the optimistic pass any frame is encountered that might possibly
68 * need clearance (i.e., if we really needed the optimism assumption) then
69 * we set aMayNeedRetry to true.
70 * We return true if we changed the clearance state of any line and marked it
73 static bool ComputeCollapsedBStartMargin(const nsHTMLReflowState
& aRS
,
74 nsCollapsingMargin
* aMargin
,
75 nsIFrame
* aClearanceFrame
,
77 bool* aIsEmpty
= nullptr);
80 nsPresContext
* mPresContext
;
81 const nsHTMLReflowState
& mOuterReflowState
;
84 mozilla::LogicalRect mSpace
;
86 nscoord mICoord
, mBCoord
, mContainerWidth
;
87 mozilla::WritingMode mWritingMode
;
88 nsHTMLReflowMetrics mMetrics
;
89 nsCollapsingMargin mBStartMargin
;
92 #endif /* nsBlockReflowContext_h___ */