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
.mCarriedOutBEndMargin
;
52 const nsHTMLReflowMetrics
& GetMetrics() const {
57 * Computes the collapsed block-start margin (in the context's parent's
58 * writing mode) for a block whose reflow state is in aRS.
59 * The computed margin is added into aMargin, whose writing mode is the
60 * parent's mode as found in mMetrics.GetWritingMode(); note this may not be
61 * the block's own writing mode as found in aRS.
62 * If aClearanceFrame is null then this is the first optimistic pass which
63 * shall assume that no frames have clearance, and we clear the HasClearance
64 * on all frames encountered.
65 * If non-null, this is the second pass and the caller has decided
66 * aClearanceFrame needs clearance (and we will therefore stop collapsing
67 * there); also, this function is responsible for marking it with
69 * If in the optimistic pass any frame is encountered that might possibly
70 * need clearance (i.e., if we really needed the optimism assumption) then
71 * we set aMayNeedRetry to true.
72 * We return true if we changed the clearance state of any line and marked it
75 bool ComputeCollapsedBStartMargin(const nsHTMLReflowState
& aRS
,
76 nsCollapsingMargin
* aMargin
,
77 nsIFrame
* aClearanceFrame
,
79 bool* aIsEmpty
= nullptr);
82 nsPresContext
* mPresContext
;
83 const nsHTMLReflowState
& mOuterReflowState
;
86 mozilla::LogicalRect mSpace
;
88 nscoord mICoord
, mBCoord
, mContainerWidth
;
89 mozilla::WritingMode mWritingMode
;
90 nsHTMLReflowMetrics mMetrics
;
91 nsCollapsingMargin mBStartMargin
;
94 #endif /* nsBlockReflowContext_h___ */