Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | // vim:cindent:ts=2:et:sw=2: |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | /* class that a parent frame uses to reflow a block frame */ |
michael@0 | 8 | |
michael@0 | 9 | #ifndef nsBlockReflowContext_h___ |
michael@0 | 10 | #define nsBlockReflowContext_h___ |
michael@0 | 11 | |
michael@0 | 12 | #include "nsIFrame.h" |
michael@0 | 13 | #include "nsHTMLReflowMetrics.h" |
michael@0 | 14 | |
michael@0 | 15 | class nsBlockReflowState; |
michael@0 | 16 | struct nsHTMLReflowState; |
michael@0 | 17 | class nsLineBox; |
michael@0 | 18 | class nsPresContext; |
michael@0 | 19 | class nsLineLayout; |
michael@0 | 20 | struct nsBlockHorizontalAlign; |
michael@0 | 21 | |
michael@0 | 22 | /** |
michael@0 | 23 | * An encapsulation of the state and algorithm for reflowing block frames. |
michael@0 | 24 | */ |
michael@0 | 25 | class nsBlockReflowContext { |
michael@0 | 26 | public: |
michael@0 | 27 | nsBlockReflowContext(nsPresContext* aPresContext, |
michael@0 | 28 | const nsHTMLReflowState& aParentRS); |
michael@0 | 29 | ~nsBlockReflowContext() { } |
michael@0 | 30 | |
michael@0 | 31 | nsresult ReflowBlock(const nsRect& aSpace, |
michael@0 | 32 | bool aApplyTopMargin, |
michael@0 | 33 | nsCollapsingMargin& aPrevMargin, |
michael@0 | 34 | nscoord aClearance, |
michael@0 | 35 | bool aIsAdjacentWithTop, |
michael@0 | 36 | nsLineBox* aLine, |
michael@0 | 37 | nsHTMLReflowState& aReflowState, |
michael@0 | 38 | nsReflowStatus& aReflowStatus, |
michael@0 | 39 | nsBlockReflowState& aState); |
michael@0 | 40 | |
michael@0 | 41 | bool PlaceBlock(const nsHTMLReflowState& aReflowState, |
michael@0 | 42 | bool aForceFit, |
michael@0 | 43 | nsLineBox* aLine, |
michael@0 | 44 | nsCollapsingMargin& aBottomMarginResult /* out */, |
michael@0 | 45 | nsOverflowAreas& aOverflowAreas, |
michael@0 | 46 | nsReflowStatus aReflowStatus, |
michael@0 | 47 | nscoord aContainerWidth); |
michael@0 | 48 | |
michael@0 | 49 | nsCollapsingMargin& GetCarriedOutBottomMargin() { |
michael@0 | 50 | return mMetrics.mCarriedOutBottomMargin; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | nscoord GetTopMargin() const { |
michael@0 | 54 | return mTopMargin.get(); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | const nsHTMLReflowMetrics& GetMetrics() const { |
michael@0 | 58 | return mMetrics; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | /** |
michael@0 | 62 | * Computes the collapsed top margin for a block whose reflow state is in aRS. |
michael@0 | 63 | * The computed margin is added into aMargin. |
michael@0 | 64 | * If aClearanceFrame is null then this is the first optimistic pass which shall assume |
michael@0 | 65 | * that no frames have clearance, and we clear the HasClearance on all frames encountered. |
michael@0 | 66 | * If non-null, this is the second pass and |
michael@0 | 67 | * the caller has decided aClearanceFrame needs clearance (and we will |
michael@0 | 68 | * therefore stop collapsing there); also, this function is responsible for marking |
michael@0 | 69 | * it with SetHasClearance. |
michael@0 | 70 | * If in the optimistic pass any frame is encountered that might possibly need |
michael@0 | 71 | * clearance (i.e., if we really needed the optimism assumption) then we set aMayNeedRetry |
michael@0 | 72 | * to true. |
michael@0 | 73 | * We return true if we changed the clearance state of any line and marked it dirty. |
michael@0 | 74 | */ |
michael@0 | 75 | static bool ComputeCollapsedTopMargin(const nsHTMLReflowState& aRS, |
michael@0 | 76 | nsCollapsingMargin* aMargin, nsIFrame* aClearanceFrame, |
michael@0 | 77 | bool* aMayNeedRetry, bool* aIsEmpty = nullptr); |
michael@0 | 78 | |
michael@0 | 79 | protected: |
michael@0 | 80 | nsPresContext* mPresContext; |
michael@0 | 81 | const nsHTMLReflowState& mOuterReflowState; |
michael@0 | 82 | |
michael@0 | 83 | nsIFrame* mFrame; |
michael@0 | 84 | nsRect mSpace; |
michael@0 | 85 | |
michael@0 | 86 | nscoord mX, mY; |
michael@0 | 87 | nsHTMLReflowMetrics mMetrics; |
michael@0 | 88 | nsCollapsingMargin mTopMargin; |
michael@0 | 89 | }; |
michael@0 | 90 | |
michael@0 | 91 | #endif /* nsBlockReflowContext_h___ */ |