Line data Source code
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/. */
5 :
6 : /* base class for rendering objects that do not have child lists */
7 :
8 : #ifndef nsLeafFrame_h___
9 : #define nsLeafFrame_h___
10 :
11 : #include "mozilla/Attributes.h"
12 : #include "nsFrame.h"
13 : #include "nsDisplayList.h"
14 :
15 : /**
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.
20 : */
21 : class nsLeafFrame : public nsFrame {
22 : public:
23 : NS_DECL_ABSTRACT_FRAME(nsLeafFrame)
24 :
25 : // nsIFrame replacements
26 0 : virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
27 : const nsRect& aDirtyRect,
28 : const nsDisplayListSet& aLists) override {
29 0 : DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame");
30 0 : DisplayBorderBackgroundOutline(aBuilder, aLists);
31 0 : }
32 :
33 : /**
34 : * Both GetMinISize and GetPrefISize will return whatever GetIntrinsicISize
35 : * returns.
36 : */
37 : virtual nscoord GetMinISize(gfxContext *aRenderingContext) override;
38 : virtual nscoord GetPrefISize(gfxContext *aRenderingContext) override;
39 :
40 : /**
41 : * Our auto size is just intrinsic width and intrinsic height.
42 : */
43 : virtual mozilla::LogicalSize
44 : ComputeAutoSize(gfxContext* aRenderingContext,
45 : mozilla::WritingMode aWM,
46 : const mozilla::LogicalSize& aCBSize,
47 : nscoord aAvailableISize,
48 : const mozilla::LogicalSize& aMargin,
49 : const mozilla::LogicalSize& aBorder,
50 : const mozilla::LogicalSize& aPadding,
51 : ComputeSizeFlags aFlags) override;
52 :
53 : /**
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.
58 : */
59 : virtual void Reflow(nsPresContext* aPresContext,
60 : ReflowOutput& aDesiredSize,
61 : const ReflowInput& aReflowInput,
62 : nsReflowStatus& aStatus) override;
63 :
64 : /**
65 : * This method does most of the work that Reflow() above need done.
66 : */
67 : virtual void DoReflow(nsPresContext* aPresContext,
68 : ReflowOutput& aDesiredSize,
69 : const ReflowInput& aReflowInput,
70 : nsReflowStatus& aStatus);
71 :
72 1635 : virtual bool IsFrameOfType(uint32_t aFlags) const override
73 : {
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 1635 : return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplacedContainsBlock));
77 : }
78 :
79 : protected:
80 90 : nsLeafFrame(nsStyleContext* aContext, ClassID aID)
81 90 : : nsFrame(aContext, aID)
82 90 : {}
83 :
84 : virtual ~nsLeafFrame();
85 :
86 : /**
87 : * Return the intrinsic isize of the frame's content area. Note that this
88 : * should not include borders or padding and should not depend on the applied
89 : * styles.
90 : */
91 : virtual nscoord GetIntrinsicISize() = 0;
92 :
93 : /**
94 : * Return the intrinsic bsize of the frame's content area. This should not
95 : * include border or padding. This will only matter if the specified bsize
96 : * is auto. Note that subclasses must either implement this or override
97 : * Reflow and ComputeAutoSize; the default Reflow and ComputeAutoSize impls
98 : * call this method.
99 : */
100 : virtual nscoord GetIntrinsicBSize();
101 :
102 : /**
103 : * Set aDesiredSize to be the available size
104 : */
105 : void SizeToAvailSize(const ReflowInput& aReflowInput,
106 : ReflowOutput& aDesiredSize);
107 : };
108 :
109 : #endif /* nsLeafFrame_h___ */
|