Bumping manifests a=b2g-bump
[gecko.git] / layout / generic / nsBlockReflowContext.h
blob29237cb26f3b2a296f90508b472abfafae29fca7
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.mCarriedOutBEndMargin;
52 const nsHTMLReflowMetrics& GetMetrics() const {
53 return mMetrics;
56 /**
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
68 * SetHasClearance.
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
73 * dirty.
75 bool ComputeCollapsedBStartMargin(const nsHTMLReflowState& aRS,
76 nsCollapsingMargin* aMargin,
77 nsIFrame* aClearanceFrame,
78 bool* aMayNeedRetry,
79 bool* aIsEmpty = nullptr);
81 protected:
82 nsPresContext* mPresContext;
83 const nsHTMLReflowState& mOuterReflowState;
85 nsIFrame* mFrame;
86 mozilla::LogicalRect mSpace;
88 nscoord mICoord, mBCoord, mContainerWidth;
89 mozilla::WritingMode mWritingMode;
90 nsHTMLReflowMetrics mMetrics;
91 nsCollapsingMargin mBStartMargin;
94 #endif /* nsBlockReflowContext_h___ */