michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: // vim:cindent:ts=2:et:sw=2: michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* class that a parent frame uses to reflow a block frame */ michael@0: michael@0: #ifndef nsBlockReflowContext_h___ michael@0: #define nsBlockReflowContext_h___ michael@0: michael@0: #include "nsIFrame.h" michael@0: #include "nsHTMLReflowMetrics.h" michael@0: michael@0: class nsBlockReflowState; michael@0: struct nsHTMLReflowState; michael@0: class nsLineBox; michael@0: class nsPresContext; michael@0: class nsLineLayout; michael@0: struct nsBlockHorizontalAlign; michael@0: michael@0: /** michael@0: * An encapsulation of the state and algorithm for reflowing block frames. michael@0: */ michael@0: class nsBlockReflowContext { michael@0: public: michael@0: nsBlockReflowContext(nsPresContext* aPresContext, michael@0: const nsHTMLReflowState& aParentRS); michael@0: ~nsBlockReflowContext() { } michael@0: michael@0: nsresult ReflowBlock(const nsRect& aSpace, michael@0: bool aApplyTopMargin, michael@0: nsCollapsingMargin& aPrevMargin, michael@0: nscoord aClearance, michael@0: bool aIsAdjacentWithTop, michael@0: nsLineBox* aLine, michael@0: nsHTMLReflowState& aReflowState, michael@0: nsReflowStatus& aReflowStatus, michael@0: nsBlockReflowState& aState); michael@0: michael@0: bool PlaceBlock(const nsHTMLReflowState& aReflowState, michael@0: bool aForceFit, michael@0: nsLineBox* aLine, michael@0: nsCollapsingMargin& aBottomMarginResult /* out */, michael@0: nsOverflowAreas& aOverflowAreas, michael@0: nsReflowStatus aReflowStatus, michael@0: nscoord aContainerWidth); michael@0: michael@0: nsCollapsingMargin& GetCarriedOutBottomMargin() { michael@0: return mMetrics.mCarriedOutBottomMargin; michael@0: } michael@0: michael@0: nscoord GetTopMargin() const { michael@0: return mTopMargin.get(); michael@0: } michael@0: michael@0: const nsHTMLReflowMetrics& GetMetrics() const { michael@0: return mMetrics; michael@0: } michael@0: michael@0: /** michael@0: * Computes the collapsed top margin for a block whose reflow state is in aRS. michael@0: * The computed margin is added into aMargin. michael@0: * If aClearanceFrame is null then this is the first optimistic pass which shall assume michael@0: * that no frames have clearance, and we clear the HasClearance on all frames encountered. michael@0: * If non-null, this is the second pass and michael@0: * the caller has decided aClearanceFrame needs clearance (and we will michael@0: * therefore stop collapsing there); also, this function is responsible for marking michael@0: * it with SetHasClearance. michael@0: * If in the optimistic pass any frame is encountered that might possibly need michael@0: * clearance (i.e., if we really needed the optimism assumption) then we set aMayNeedRetry michael@0: * to true. michael@0: * We return true if we changed the clearance state of any line and marked it dirty. michael@0: */ michael@0: static bool ComputeCollapsedTopMargin(const nsHTMLReflowState& aRS, michael@0: nsCollapsingMargin* aMargin, nsIFrame* aClearanceFrame, michael@0: bool* aMayNeedRetry, bool* aIsEmpty = nullptr); michael@0: michael@0: protected: michael@0: nsPresContext* mPresContext; michael@0: const nsHTMLReflowState& mOuterReflowState; michael@0: michael@0: nsIFrame* mFrame; michael@0: nsRect mSpace; michael@0: michael@0: nscoord mX, mY; michael@0: nsHTMLReflowMetrics mMetrics; michael@0: nsCollapsingMargin mTopMargin; michael@0: }; michael@0: michael@0: #endif /* nsBlockReflowContext_h___ */