Fixed textfield rendering in nsNativeThemeQt
[mozilla-central.git] / layout / generic / nsBlockReflowContext.h
blob14bf3c750e543f98143808641edc809acc06b348
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 nsMargin& aComputedOffsets,
72 nsLineBox* aLine,
73 nsHTMLReflowState& aReflowState,
74 nsReflowStatus& aReflowStatus,
75 nsBlockReflowState& aState);
77 PRBool PlaceBlock(const nsHTMLReflowState& aReflowState,
78 PRBool aForceFit,
79 nsLineBox* aLine,
80 const nsMargin& aComputedOffsets,
81 nsCollapsingMargin& aBottomMarginResult /* out */,
82 nsRect& aInFlowBounds,
83 nsRect& aCombinedRect,
84 nsReflowStatus aReflowStatus);
86 nsCollapsingMargin& GetCarriedOutBottomMargin() {
87 return mMetrics.mCarriedOutBottomMargin;
90 nscoord GetTopMargin() const {
91 return mTopMargin.get();
94 const nsHTMLReflowMetrics& GetMetrics() const {
95 return mMetrics;
98 /**
99 * Computes the collapsed top margin for a block whose reflow state is in aRS.
100 * The computed margin is added into aMargin.
101 * If aClearanceFrame is null then this is the first optimistic pass which shall assume
102 * that no frames have clearance, and we clear the HasClearance on all frames encountered.
103 * If non-null, this is the second pass and
104 * the caller has decided aClearanceFrame needs clearance (and we will
105 * therefore stop collapsing there); also, this function is responsible for marking
106 * it with SetHasClearance.
107 * If in the optimistic pass any frame is encountered that might possibly need
108 * clearance (i.e., if we really needed the optimism assumption) then we set aMayNeedRetry
109 * to true.
110 * We return PR_TRUE if we changed the clearance state of any line and marked it dirty.
112 static PRBool ComputeCollapsedTopMargin(const nsHTMLReflowState& aRS,
113 nsCollapsingMargin* aMargin, nsIFrame* aClearanceFrame,
114 PRBool* aMayNeedRetry, PRBool* aIsEmpty = nsnull);
116 protected:
117 nsPresContext* mPresContext;
118 const nsHTMLReflowState& mOuterReflowState;
120 nsIFrame* mFrame;
121 nsRect mSpace;
123 nscoord mX, mY;
124 nsHTMLReflowMetrics mMetrics;
125 nsCollapsingMargin mTopMargin;
128 #endif /* nsBlockReflowContext_h___ */