1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /* base class for rendering objects that do not have child lists */
8 #ifndef nsLeafFrame_h___
9 #define nsLeafFrame_h___
11 #include "mozilla/Attributes.h"
13 #include "nsDisplayList.h"
16 * Abstract class that provides simple fixed-size layout for leaf objects
17 * (e.g. images, form elements, etc.). Deriviations provide the implementation
18 * of the GetDesiredSize method. The rendering method knows how to render
19 * borders and backgrounds.
21 class nsLeafFrame
: public nsFrame
{
23 NS_DECL_FRAMEARENA_HELPERS
25 // nsIFrame replacements
26 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
27 const nsRect
& aDirtyRect
,
28 const nsDisplayListSet
& aLists
) MOZ_OVERRIDE
{
29 DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame");
30 DisplayBorderBackgroundOutline(aBuilder
, aLists
);
34 * Both GetMinISize and GetPrefISize will return whatever GetIntrinsicISize
37 virtual nscoord
GetMinISize(nsRenderingContext
*aRenderingContext
) MOZ_OVERRIDE
;
38 virtual nscoord
GetPrefISize(nsRenderingContext
*aRenderingContext
) MOZ_OVERRIDE
;
41 * Our auto size is just intrinsic width and intrinsic height.
43 virtual mozilla::LogicalSize
44 ComputeAutoSize(nsRenderingContext
*aRenderingContext
,
45 mozilla::WritingMode aWritingMode
,
46 const mozilla::LogicalSize
& aCBSize
,
47 nscoord aAvailableISize
,
48 const mozilla::LogicalSize
& aMargin
,
49 const mozilla::LogicalSize
& aBorder
,
50 const mozilla::LogicalSize
& aPadding
,
51 bool aShrinkWrap
) MOZ_OVERRIDE
;
54 * Reflow our frame. This will use the computed width plus borderpadding for
55 * the desired width, and use the return value of GetIntrinsicBSize plus
56 * borderpadding for the desired height. Ascent will be set to the height,
57 * and descent will be set to 0.
59 virtual void Reflow(nsPresContext
* aPresContext
,
60 nsHTMLReflowMetrics
& aDesiredSize
,
61 const nsHTMLReflowState
& aReflowState
,
62 nsReflowStatus
& aStatus
) MOZ_OVERRIDE
;
65 * This method does most of the work that Reflow() above need done.
67 virtual void DoReflow(nsPresContext
* aPresContext
,
68 nsHTMLReflowMetrics
& aDesiredSize
,
69 const nsHTMLReflowState
& aReflowState
,
70 nsReflowStatus
& aStatus
);
72 virtual bool IsFrameOfType(uint32_t aFlags
) const MOZ_OVERRIDE
74 // We don't actually contain a block, but we do always want a
75 // computed width, so tell a little white lie here.
76 return nsFrame::IsFrameOfType(aFlags
& ~(nsIFrame::eReplacedContainsBlock
));
80 explicit nsLeafFrame(nsStyleContext
* aContext
) : nsFrame(aContext
) {}
81 virtual ~nsLeafFrame();
84 * Return the intrinsic width of the frame's content area. Note that this
85 * should not include borders or padding and should not depend on the applied
88 virtual nscoord
GetIntrinsicISize() = 0;
91 * Return the intrinsic height of the frame's content area. This should not
92 * include border or padding. This will only matter if the specified height
93 * is auto. Note that subclasses must either implement this or override
94 * Reflow and ComputeAutoSize; the default Reflow and ComputeAutoSize impls
97 virtual nscoord
GetIntrinsicBSize();
100 * Subroutine to add in borders and padding
102 void AddBordersAndPadding(const nsHTMLReflowState
& aReflowState
,
103 mozilla::LogicalSize
& aDesiredSize
);
106 * Set aDesiredSize to be the available size
108 void SizeToAvailSize(const nsHTMLReflowState
& aReflowState
,
109 nsHTMLReflowMetrics
& aDesiredSize
);
112 #endif /* nsLeafFrame_h___ */