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"
16 class nsBlockReflowState
;
17 struct nsHTMLReflowState
;
21 struct nsBlockHorizontalAlign
;
24 * An encapsulation of the state and algorithm for reflowing block frames.
26 class nsBlockReflowContext
{
28 nsBlockReflowContext(nsPresContext
* aPresContext
,
29 const nsHTMLReflowState
& aParentRS
);
30 ~nsBlockReflowContext() { }
32 nsresult
ReflowBlock(const nsRect
& aSpace
,
34 nsCollapsingMargin
& aPrevMargin
,
36 bool aIsAdjacentWithTop
,
38 nsHTMLReflowState
& aReflowState
,
39 nsReflowStatus
& aReflowStatus
,
40 nsBlockReflowState
& aState
);
42 bool PlaceBlock(const nsHTMLReflowState
& aReflowState
,
45 nsCollapsingMargin
& aBottomMarginResult
/* out */,
46 nsRect
& aInFlowBounds
,
47 nsOverflowAreas
& aOverflowAreas
,
48 nsReflowStatus aReflowStatus
);
50 nsCollapsingMargin
& GetCarriedOutBottomMargin() {
51 return mMetrics
.mCarriedOutBottomMargin
;
54 nscoord
GetTopMargin() const {
55 return mTopMargin
.get();
58 const nsHTMLReflowMetrics
& GetMetrics() const {
63 * Computes the collapsed top margin for a block whose reflow state is in aRS.
64 * The computed margin is added into aMargin.
65 * If aClearanceFrame is null then this is the first optimistic pass which shall assume
66 * that no frames have clearance, and we clear the HasClearance on all frames encountered.
67 * If non-null, this is the second pass and
68 * the caller has decided aClearanceFrame needs clearance (and we will
69 * therefore stop collapsing there); also, this function is responsible for marking
70 * it with SetHasClearance.
71 * If in the optimistic pass any frame is encountered that might possibly need
72 * clearance (i.e., if we really needed the optimism assumption) then we set aMayNeedRetry
74 * We return true if we changed the clearance state of any line and marked it dirty.
76 static bool ComputeCollapsedTopMargin(const nsHTMLReflowState
& aRS
,
77 nsCollapsingMargin
* aMargin
, nsIFrame
* aClearanceFrame
,
78 bool* aMayNeedRetry
, bool* aIsEmpty
= nullptr);
81 nsPresContext
* mPresContext
;
82 const nsHTMLReflowState
& mOuterReflowState
;
88 nsHTMLReflowMetrics mMetrics
;
89 nsCollapsingMargin mTopMargin
;
92 #endif /* nsBlockReflowContext_h___ */