Bug 54488 - "[Mac] Non-draggable widgets in background windows should look disabled...
[mozilla-central.git] / layout / generic / nsBlockReflowContext.h
bloba5ec77eeef13dc625544d1c0b731ea34872384a2
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
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/
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.
16 * The Original Code is Mozilla Communicator client code.
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.
23 * Contributor(s):
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.
37 * ***** END LICENSE BLOCK ***** */
39 /* class that a parent frame uses to reflow a block frame */
41 #ifndef nsBlockReflowContext_h___
42 #define nsBlockReflowContext_h___
44 #include "nsIFrame.h"
45 #include "nsHTMLReflowMetrics.h"
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;
57 /**
58 * An encapsulation of the state and algorithm for reflowing block frames.
60 class nsBlockReflowContext {
61 public:
62 nsBlockReflowContext(nsPresContext* aPresContext,
63 const nsHTMLReflowState& aParentRS);
64 ~nsBlockReflowContext() { }
66 nsresult ReflowBlock(const nsRect& aSpace,
67 PRBool aApplyTopMargin,
68 nsCollapsingMargin& aPrevMargin,
69 nscoord aClearance,
70 PRBool aIsAdjacentWithTop,
71 nsLineBox* aLine,
72 nsHTMLReflowState& aReflowState,
73 nsReflowStatus& aReflowStatus,
74 nsBlockReflowState& aState);
76 PRBool PlaceBlock(const nsHTMLReflowState& aReflowState,
77 PRBool aForceFit,
78 nsLineBox* aLine,
79 nsCollapsingMargin& aBottomMarginResult /* out */,
80 nsRect& aInFlowBounds,
81 nsRect& aCombinedRect,
82 nsReflowStatus aReflowStatus);
84 nsCollapsingMargin& GetCarriedOutBottomMargin() {
85 return mMetrics.mCarriedOutBottomMargin;
88 nscoord GetTopMargin() const {
89 return mTopMargin.get();
92 const nsHTMLReflowMetrics& GetMetrics() const {
93 return mMetrics;
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 PR_TRUE if we changed the clearance state of any line and marked it dirty.
110 static PRBool ComputeCollapsedTopMargin(const nsHTMLReflowState& aRS,
111 nsCollapsingMargin* aMargin, nsIFrame* aClearanceFrame,
112 PRBool* aMayNeedRetry, PRBool* aIsEmpty = nsnull);
114 protected:
115 nsPresContext* mPresContext;
116 const nsHTMLReflowState& mOuterReflowState;
118 nsIFrame* mFrame;
119 nsRect mSpace;
121 nscoord mX, mY;
122 nsHTMLReflowMetrics mMetrics;
123 nsCollapsingMargin mTopMargin;
126 #endif /* nsBlockReflowContext_h___ */