1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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___
12 #include "mozilla/ReflowOutput.h"
19 class BlockReflowState
;
20 } // namespace mozilla
23 * An encapsulation of the state and algorithm for reflowing block frames.
25 class nsBlockReflowContext
{
26 using BlockReflowState
= mozilla::BlockReflowState
;
27 using ReflowInput
= mozilla::ReflowInput
;
28 using ReflowOutput
= mozilla::ReflowOutput
;
31 nsBlockReflowContext(nsPresContext
* aPresContext
,
32 const ReflowInput
& aParentRI
);
33 ~nsBlockReflowContext() = default;
35 void ReflowBlock(const mozilla::LogicalRect
& aSpace
, bool aApplyBStartMargin
,
36 nsCollapsingMargin
& aPrevMargin
, nscoord aClearance
,
37 nsLineBox
* aLine
, ReflowInput
& aReflowInput
,
38 nsReflowStatus
& aReflowStatus
, BlockReflowState
& aState
);
40 bool PlaceBlock(const ReflowInput
& aReflowInput
, bool aForceFit
,
42 nsCollapsingMargin
& aBEndMarginResult
/* out */,
43 mozilla::OverflowAreas
& aOverflowAreas
,
44 const nsReflowStatus
& aReflowStatus
);
46 nsCollapsingMargin
& GetCarriedOutBEndMargin() {
47 return mMetrics
.mCarriedOutBEndMargin
;
50 const ReflowOutput
& GetMetrics() const { return mMetrics
; }
53 * Computes the collapsed block-start margin (in the context's parent's
54 * writing mode) for a block whose reflow input is in aRI.
55 * The computed margin is added into aMargin, whose writing mode is the
56 * parent's mode as found in mMetrics.GetWritingMode(); note this may not be
57 * the block's own writing mode as found in aRI.
58 * If aClearanceFrame is null then this is the first optimistic pass which
59 * shall assume that no frames have clearance, and we clear the HasClearance
60 * on all frames encountered.
61 * If non-null, this is the second pass and the caller has decided
62 * aClearanceFrame needs clearance (and we will therefore stop collapsing
63 * there); also, this function is responsible for marking it with
65 * If in the optimistic pass any frame is encountered that might possibly
66 * need clearance (i.e., if we really needed the optimism assumption) then
67 * we set aMayNeedRetry to true.
68 * We return true if we changed the clearance state of any line and marked it
71 bool ComputeCollapsedBStartMargin(const ReflowInput
& aRI
,
72 nsCollapsingMargin
* aMargin
,
73 nsIFrame
* aClearanceFrame
,
75 bool* aIsEmpty
= nullptr);
78 nsPresContext
* mPresContext
;
79 const ReflowInput
& mOuterReflowInput
;
82 mozilla::LogicalRect mSpace
;
84 nscoord mICoord
, mBCoord
;
85 nsSize mContainerSize
;
86 mozilla::WritingMode mWritingMode
;
87 ReflowOutput mMetrics
;
88 nsCollapsingMargin mBStartMargin
;
91 #endif /* nsBlockReflowContext_h___ */