Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / generic / nsBlockReflowContext.h
bloba573e644eec19bb11a85bc3286822b7be3e89c32
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 "mozilla/ReflowOutput.h"
14 class nsIFrame;
15 class nsLineBox;
16 class nsPresContext;
17 class nsReflowStatus;
18 namespace mozilla {
19 class BlockReflowState;
20 } // namespace mozilla
22 /**
23 * An encapsulation of the state and algorithm for reflowing block frames.
25 class nsBlockReflowContext {
26 using BlockReflowState = mozilla::BlockReflowState;
27 using ReflowInput = mozilla::ReflowInput;
28 using ReflowOutput = mozilla::ReflowOutput;
30 public:
31 nsBlockReflowContext(nsPresContext* aPresContext,
32 const ReflowInput& aParentRI);
33 ~nsBlockReflowContext() = default;
35 void ReflowBlock(const mozilla::LogicalRect& aSpace, bool aApplyBStartMargin,
36 nsCollapsingMargin& aPrevMargin, nscoord aClearance,
37 nsLineBox* aLine, ReflowInput& aReflowInput,
38 nsReflowStatus& aReflowStatus, BlockReflowState& aState);
40 bool PlaceBlock(const ReflowInput& aReflowInput, bool aForceFit,
41 nsLineBox* aLine,
42 nsCollapsingMargin& aBEndMarginResult /* out */,
43 mozilla::OverflowAreas& aOverflowAreas,
44 const nsReflowStatus& aReflowStatus);
46 nsCollapsingMargin& GetCarriedOutBEndMargin() {
47 return mMetrics.mCarriedOutBEndMargin;
50 const ReflowOutput& GetMetrics() const { return mMetrics; }
52 /**
53 * Computes the collapsed block-start margin (in the context's parent's
54 * writing mode) for a block whose reflow input is in aRI.
55 * The computed margin is added into aMargin, whose writing mode is the
56 * parent's mode as found in mMetrics.GetWritingMode(); note this may not be
57 * the block's own writing mode as found in aRI.
58 * If aClearanceFrame is null then this is the first optimistic pass which
59 * shall assume that no frames have clearance, and we clear the HasClearance
60 * on all frames encountered.
61 * If non-null, this is the second pass and the caller has decided
62 * aClearanceFrame needs clearance (and we will therefore stop collapsing
63 * there); also, this function is responsible for marking it with
64 * SetHasClearance.
65 * If in the optimistic pass any frame is encountered that might possibly
66 * need clearance (i.e., if we really needed the optimism assumption) then
67 * we set aMayNeedRetry to true.
68 * We return true if we changed the clearance state of any line and marked it
69 * dirty.
71 bool ComputeCollapsedBStartMargin(const ReflowInput& aRI,
72 nsCollapsingMargin* aMargin,
73 nsIFrame* aClearanceFrame,
74 bool* aMayNeedRetry,
75 bool* aIsEmpty = nullptr);
77 protected:
78 nsPresContext* mPresContext;
79 const ReflowInput& mOuterReflowInput;
81 nsIFrame* mFrame;
82 mozilla::LogicalRect mSpace;
84 nscoord mICoord, mBCoord;
85 nsSize mContainerSize;
86 mozilla::WritingMode mWritingMode;
87 ReflowOutput mMetrics;
88 nsCollapsingMargin mBStartMargin;
91 #endif /* nsBlockReflowContext_h___ */