1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/generic/nsBlockReflowContext.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,91 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +// vim:cindent:ts=2:et:sw=2: 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +/* class that a parent frame uses to reflow a block frame */ 1.11 + 1.12 +#ifndef nsBlockReflowContext_h___ 1.13 +#define nsBlockReflowContext_h___ 1.14 + 1.15 +#include "nsIFrame.h" 1.16 +#include "nsHTMLReflowMetrics.h" 1.17 + 1.18 +class nsBlockReflowState; 1.19 +struct nsHTMLReflowState; 1.20 +class nsLineBox; 1.21 +class nsPresContext; 1.22 +class nsLineLayout; 1.23 +struct nsBlockHorizontalAlign; 1.24 + 1.25 +/** 1.26 + * An encapsulation of the state and algorithm for reflowing block frames. 1.27 + */ 1.28 +class nsBlockReflowContext { 1.29 +public: 1.30 + nsBlockReflowContext(nsPresContext* aPresContext, 1.31 + const nsHTMLReflowState& aParentRS); 1.32 + ~nsBlockReflowContext() { } 1.33 + 1.34 + nsresult ReflowBlock(const nsRect& aSpace, 1.35 + bool aApplyTopMargin, 1.36 + nsCollapsingMargin& aPrevMargin, 1.37 + nscoord aClearance, 1.38 + bool aIsAdjacentWithTop, 1.39 + nsLineBox* aLine, 1.40 + nsHTMLReflowState& aReflowState, 1.41 + nsReflowStatus& aReflowStatus, 1.42 + nsBlockReflowState& aState); 1.43 + 1.44 + bool PlaceBlock(const nsHTMLReflowState& aReflowState, 1.45 + bool aForceFit, 1.46 + nsLineBox* aLine, 1.47 + nsCollapsingMargin& aBottomMarginResult /* out */, 1.48 + nsOverflowAreas& aOverflowAreas, 1.49 + nsReflowStatus aReflowStatus, 1.50 + nscoord aContainerWidth); 1.51 + 1.52 + nsCollapsingMargin& GetCarriedOutBottomMargin() { 1.53 + return mMetrics.mCarriedOutBottomMargin; 1.54 + } 1.55 + 1.56 + nscoord GetTopMargin() const { 1.57 + return mTopMargin.get(); 1.58 + } 1.59 + 1.60 + const nsHTMLReflowMetrics& GetMetrics() const { 1.61 + return mMetrics; 1.62 + } 1.63 + 1.64 + /** 1.65 + * Computes the collapsed top margin for a block whose reflow state is in aRS. 1.66 + * The computed margin is added into aMargin. 1.67 + * If aClearanceFrame is null then this is the first optimistic pass which shall assume 1.68 + * that no frames have clearance, and we clear the HasClearance on all frames encountered. 1.69 + * If non-null, this is the second pass and 1.70 + * the caller has decided aClearanceFrame needs clearance (and we will 1.71 + * therefore stop collapsing there); also, this function is responsible for marking 1.72 + * it with SetHasClearance. 1.73 + * If in the optimistic pass any frame is encountered that might possibly need 1.74 + * clearance (i.e., if we really needed the optimism assumption) then we set aMayNeedRetry 1.75 + * to true. 1.76 + * We return true if we changed the clearance state of any line and marked it dirty. 1.77 + */ 1.78 + static bool ComputeCollapsedTopMargin(const nsHTMLReflowState& aRS, 1.79 + nsCollapsingMargin* aMargin, nsIFrame* aClearanceFrame, 1.80 + bool* aMayNeedRetry, bool* aIsEmpty = nullptr); 1.81 + 1.82 +protected: 1.83 + nsPresContext* mPresContext; 1.84 + const nsHTMLReflowState& mOuterReflowState; 1.85 + 1.86 + nsIFrame* mFrame; 1.87 + nsRect mSpace; 1.88 + 1.89 + nscoord mX, mY; 1.90 + nsHTMLReflowMetrics mMetrics; 1.91 + nsCollapsingMargin mTopMargin; 1.92 +}; 1.93 + 1.94 +#endif /* nsBlockReflowContext_h___ */