Merge m-c to fx-team.
[gecko.git] / layout / generic / nsBlockReflowContext.h
bloba7fb8ff8a8b0dd605d64d0bfd5ac81d6ef9a2b2d
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___
12 #include "nsIFrame.h"
13 #include "nsHTMLReflowMetrics.h"
15 class nsBlockFrame;
16 class nsBlockReflowState;
17 struct nsHTMLReflowState;
18 class nsLineBox;
19 class nsPresContext;
20 class nsLineLayout;
21 struct nsBlockHorizontalAlign;
23 /**
24 * An encapsulation of the state and algorithm for reflowing block frames.
26 class nsBlockReflowContext {
27 public:
28 nsBlockReflowContext(nsPresContext* aPresContext,
29 const nsHTMLReflowState& aParentRS);
30 ~nsBlockReflowContext() { }
32 nsresult ReflowBlock(const nsRect& aSpace,
33 bool aApplyTopMargin,
34 nsCollapsingMargin& aPrevMargin,
35 nscoord aClearance,
36 bool aIsAdjacentWithTop,
37 nsLineBox* aLine,
38 nsHTMLReflowState& aReflowState,
39 nsReflowStatus& aReflowStatus,
40 nsBlockReflowState& aState);
42 bool PlaceBlock(const nsHTMLReflowState& aReflowState,
43 bool aForceFit,
44 nsLineBox* aLine,
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 {
59 return mMetrics;
62 /**
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
73 * to true.
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);
80 protected:
81 nsPresContext* mPresContext;
82 const nsHTMLReflowState& mOuterReflowState;
84 nsIFrame* mFrame;
85 nsRect mSpace;
87 nscoord mX, mY;
88 nsHTMLReflowMetrics mMetrics;
89 nsCollapsingMargin mTopMargin;
92 #endif /* nsBlockReflowContext_h___ */