1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* base class for rendering objects that do not have child lists */
9 #ifndef nsLeafFrame_h___
10 #define nsLeafFrame_h___
12 #include "mozilla/Attributes.h"
14 #include "nsDisplayList.h"
17 * Abstract class that provides simple fixed-size layout for leaf objects
18 * (e.g. images, form elements, etc.). Deriviations provide the implementation
19 * of the GetDesiredSize method. The rendering method knows how to render
20 * borders and backgrounds.
22 class nsLeafFrame
: public nsIFrame
{
24 NS_DECL_ABSTRACT_FRAME(nsLeafFrame
)
26 // nsIFrame replacements
27 void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
28 const nsDisplayListSet
& aLists
) override
;
31 * Both GetMinISize and GetPrefISize will return whatever GetIntrinsicISize
34 virtual nscoord
GetMinISize(gfxContext
* aRenderingContext
) override
;
35 virtual nscoord
GetPrefISize(gfxContext
* aRenderingContext
) override
;
38 * Our auto size is just intrinsic width and intrinsic height.
40 mozilla::LogicalSize
ComputeAutoSize(
41 gfxContext
* aRenderingContext
, mozilla::WritingMode aWM
,
42 const mozilla::LogicalSize
& aCBSize
, nscoord aAvailableISize
,
43 const mozilla::LogicalSize
& aMargin
,
44 const mozilla::LogicalSize
& aBorderPadding
,
45 const mozilla::StyleSizeOverrides
& aSizeOverrides
,
46 mozilla::ComputeSizeFlags aFlags
) override
;
49 * Each of our subclasses should provide its own Reflow impl:
51 virtual void Reflow(nsPresContext
* aPresContext
, ReflowOutput
& aDesiredSize
,
52 const ReflowInput
& aReflowInput
,
53 nsReflowStatus
& aStatus
) override
= 0;
55 virtual bool IsFrameOfType(uint32_t aFlags
) const override
{
56 // We don't actually contain a block, but we do always want a
57 // computed width, so tell a little white lie here.
58 return nsIFrame::IsFrameOfType(aFlags
&
59 ~(nsIFrame::eReplacedContainsBlock
));
63 nsLeafFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
, ClassID aID
)
64 : nsIFrame(aStyle
, aPresContext
, aID
) {}
66 virtual ~nsLeafFrame();
69 * Return the intrinsic isize of the frame's content area. Note that this
70 * should not include borders or padding and should not depend on the applied
73 virtual nscoord
GetIntrinsicISize() = 0;
76 * Return the intrinsic bsize of the frame's content area. This should not
77 * include border or padding. This will only matter if the specified bsize
78 * is auto. Note that subclasses must either implement this or override
79 * Reflow and ComputeAutoSize; the default Reflow and ComputeAutoSize impls
82 virtual nscoord
GetIntrinsicBSize();
85 * Set aDesiredSize to be the available size
87 void SizeToAvailSize(const ReflowInput
& aReflowInput
,
88 ReflowOutput
& aDesiredSize
);
91 #endif /* nsLeafFrame_h___ */