Bumping manifests a=b2g-bump
[gecko.git] / layout / generic / nsBlockReflowContext.h
blobaa7cb703fd83f0bd9a4c04e544d073649e4f425c
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 nsBlockReflowState;
16 struct nsHTMLReflowState;
17 class nsLineBox;
18 class nsPresContext;
19 class nsLineLayout;
20 struct nsBlockHorizontalAlign;
22 /**
23 * An encapsulation of the state and algorithm for reflowing block frames.
25 class nsBlockReflowContext {
26 public:
27 nsBlockReflowContext(nsPresContext* aPresContext,
28 const nsHTMLReflowState& aParentRS);
29 ~nsBlockReflowContext() { }
31 void ReflowBlock(const nsRect& aSpace,
32 bool aApplyBStartMargin,
33 nsCollapsingMargin& aPrevMargin,
34 nscoord aClearance,
35 bool aIsAdjacentWithBStart,
36 nsLineBox* aLine,
37 nsHTMLReflowState& aReflowState,
38 nsReflowStatus& aReflowStatus,
39 nsBlockReflowState& aState);
41 bool PlaceBlock(const nsHTMLReflowState& aReflowState,
42 bool aForceFit,
43 nsLineBox* aLine,
44 nsCollapsingMargin& aBEndMarginResult /* out */,
45 nsOverflowAreas& aOverflowAreas,
46 nsReflowStatus aReflowStatus);
48 nsCollapsingMargin& GetCarriedOutBEndMargin() {
49 return mMetrics.mCarriedOutBottomMargin;
52 const nsHTMLReflowMetrics& GetMetrics() const {
53 return mMetrics;
56 /**
57 * Computes the collapsed block-start margin for a block whose reflow state
58 * is in aRS.
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
66 * SetHasClearance.
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
71 * dirty.
73 static bool ComputeCollapsedBStartMargin(const nsHTMLReflowState& aRS,
74 nsCollapsingMargin* aMargin,
75 nsIFrame* aClearanceFrame,
76 bool* aMayNeedRetry,
77 bool* aIsEmpty = nullptr);
79 protected:
80 nsPresContext* mPresContext;
81 const nsHTMLReflowState& mOuterReflowState;
83 nsIFrame* mFrame;
84 mozilla::LogicalRect mSpace;
86 nscoord mICoord, mBCoord, mContainerWidth;
87 mozilla::WritingMode mWritingMode;
88 nsHTMLReflowMetrics mMetrics;
89 nsCollapsingMargin mBStartMargin;
92 #endif /* nsBlockReflowContext_h___ */