Bug 574454 - Cleanup nsNativeThemeWin's GetMinimumWidgetSize a bit. r=roc.
[mozilla-central.git] / layout / generic / nsLeafFrame.h
blob73089dc6c2ec26aef3641c04a6275a7e45cbc087
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 /* base class for rendering objects that do not have child lists */
40 #ifndef nsLeafFrame_h___
41 #define nsLeafFrame_h___
43 #include "nsFrame.h"
44 #include "nsDisplayList.h"
46 /**
47 * Abstract class that provides simple fixed-size layout for leaf objects
48 * (e.g. images, form elements, etc.). Deriviations provide the implementation
49 * of the GetDesiredSize method. The rendering method knows how to render
50 * borders and backgrounds.
52 class nsLeafFrame : public nsFrame {
53 public:
54 NS_DECL_FRAMEARENA_HELPERS
56 // nsIFrame replacements
57 NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
58 const nsRect& aDirtyRect,
59 const nsDisplayListSet& aLists) {
60 DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame");
61 return DisplayBorderBackgroundOutline(aBuilder, aLists);
64 /**
65 * Both GetMinWidth and GetPrefWidth will return whatever GetIntrinsicWidth
66 * returns.
68 virtual nscoord GetMinWidth(nsIRenderingContext *aRenderingContext);
69 virtual nscoord GetPrefWidth(nsIRenderingContext *aRenderingContext);
71 /**
72 * Our auto size is just intrinsic width and intrinsic height.
74 virtual nsSize ComputeAutoSize(nsIRenderingContext *aRenderingContext,
75 nsSize aCBSize, nscoord aAvailableWidth,
76 nsSize aMargin, nsSize aBorder,
77 nsSize aPadding, PRBool aShrinkWrap);
79 /**
80 * Reflow our frame. This will use the computed width plus borderpadding for
81 * the desired width, and use the return value of GetIntrinsicHeight plus
82 * borderpadding for the desired height. Ascent will be set to the height,
83 * and descent will be set to 0.
85 NS_IMETHOD Reflow(nsPresContext* aPresContext,
86 nsHTMLReflowMetrics& aDesiredSize,
87 const nsHTMLReflowState& aReflowState,
88 nsReflowStatus& aStatus);
90 /**
91 * This method does most of the work that Reflow() above need done.
93 NS_IMETHOD DoReflow(nsPresContext* aPresContext,
94 nsHTMLReflowMetrics& aDesiredSize,
95 const nsHTMLReflowState& aReflowState,
96 nsReflowStatus& aStatus);
98 virtual PRBool IsFrameOfType(PRUint32 aFlags) const
100 // We don't actually contain a block, but we do always want a
101 // computed width, so tell a little white lie here.
102 return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplacedContainsBlock));
105 protected:
106 nsLeafFrame(nsStyleContext* aContext) : nsFrame(aContext) {}
107 virtual ~nsLeafFrame();
110 * Return the intrinsic width of the frame's content area. Note that this
111 * should not include borders or padding and should not depend on the applied
112 * styles.
114 virtual nscoord GetIntrinsicWidth() = 0;
117 * Return the intrinsic height of the frame's content area. This should not
118 * include border or padding. This will only matter if the specified height
119 * is auto. Note that subclasses must either implement this or override
120 * Reflow and ComputeAutoSize; the default Reflow and ComputeAutoSize impls
121 * call this method.
123 virtual nscoord GetIntrinsicHeight();
126 * Subroutine to add in borders and padding
128 void AddBordersAndPadding(const nsHTMLReflowState& aReflowState,
129 nsHTMLReflowMetrics& aDesiredSize);
132 * Set aDesiredSize to be the available size
134 void SizeToAvailSize(const nsHTMLReflowState& aReflowState,
135 nsHTMLReflowMetrics& aDesiredSize);
138 #endif /* nsLeafFrame_h___ */