1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : // vim:cindent:ts=2:et:sw=2:
3 : /* ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is Mozilla Communicator client code.
17 : *
18 : * The Initial Developer of the Original Code is
19 : * Netscape Communications Corporation.
20 : * Portions created by the Initial Developer are Copyright (C) 1998
21 : * the Initial Developer. All Rights Reserved.
22 : *
23 : * Contributor(s):
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either of the GNU General Public License Version 2 or later (the "GPL"),
27 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : /* class that a parent frame uses to reflow a block frame */
40 :
41 : #ifndef nsBlockReflowContext_h___
42 : #define nsBlockReflowContext_h___
43 :
44 : #include "nsIFrame.h"
45 : #include "nsHTMLReflowMetrics.h"
46 :
47 : class nsBlockFrame;
48 : class nsBlockReflowState;
49 : struct nsHTMLReflowState;
50 : class nsLineBox;
51 : class nsIFrame;
52 : class nsPresContext;
53 : class nsLineLayout;
54 : struct nsStylePosition;
55 : struct nsBlockHorizontalAlign;
56 :
57 : /**
58 : * An encapsulation of the state and algorithm for reflowing block frames.
59 : */
60 : class nsBlockReflowContext {
61 : public:
62 : nsBlockReflowContext(nsPresContext* aPresContext,
63 : const nsHTMLReflowState& aParentRS);
64 0 : ~nsBlockReflowContext() { }
65 :
66 : nsresult ReflowBlock(const nsRect& aSpace,
67 : bool aApplyTopMargin,
68 : nsCollapsingMargin& aPrevMargin,
69 : nscoord aClearance,
70 : bool aIsAdjacentWithTop,
71 : nsLineBox* aLine,
72 : nsHTMLReflowState& aReflowState,
73 : nsReflowStatus& aReflowStatus,
74 : nsBlockReflowState& aState);
75 :
76 : bool PlaceBlock(const nsHTMLReflowState& aReflowState,
77 : bool aForceFit,
78 : nsLineBox* aLine,
79 : nsCollapsingMargin& aBottomMarginResult /* out */,
80 : nsRect& aInFlowBounds,
81 : nsOverflowAreas& aOverflowAreas,
82 : nsReflowStatus aReflowStatus);
83 :
84 : nsCollapsingMargin& GetCarriedOutBottomMargin() {
85 : return mMetrics.mCarriedOutBottomMargin;
86 : }
87 :
88 : nscoord GetTopMargin() const {
89 : return mTopMargin.get();
90 : }
91 :
92 0 : const nsHTMLReflowMetrics& GetMetrics() const {
93 0 : return mMetrics;
94 : }
95 :
96 : /**
97 : * Computes the collapsed top margin for a block whose reflow state is in aRS.
98 : * The computed margin is added into aMargin.
99 : * If aClearanceFrame is null then this is the first optimistic pass which shall assume
100 : * that no frames have clearance, and we clear the HasClearance on all frames encountered.
101 : * If non-null, this is the second pass and
102 : * the caller has decided aClearanceFrame needs clearance (and we will
103 : * therefore stop collapsing there); also, this function is responsible for marking
104 : * it with SetHasClearance.
105 : * If in the optimistic pass any frame is encountered that might possibly need
106 : * clearance (i.e., if we really needed the optimism assumption) then we set aMayNeedRetry
107 : * to true.
108 : * We return true if we changed the clearance state of any line and marked it dirty.
109 : */
110 : static bool ComputeCollapsedTopMargin(const nsHTMLReflowState& aRS,
111 : nsCollapsingMargin* aMargin, nsIFrame* aClearanceFrame,
112 : bool* aMayNeedRetry, bool* aIsEmpty = nsnull);
113 :
114 : protected:
115 : nsPresContext* mPresContext;
116 : const nsHTMLReflowState& mOuterReflowState;
117 :
118 : nsIFrame* mFrame;
119 : nsRect mSpace;
120 :
121 : nscoord mX, mY;
122 : nsHTMLReflowMetrics mMetrics;
123 : nsCollapsingMargin mTopMargin;
124 : };
125 :
126 : #endif /* nsBlockReflowContext_h___ */
|