Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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"
12 #include "nsFrame.h"
13 #include "nsDisplayList.h"
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_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);
31 }
33 /**
34 * Both GetMinWidth and GetPrefWidth will return whatever GetIntrinsicWidth
35 * returns.
36 */
37 virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
38 virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
40 /**
41 * Our auto size is just intrinsic width and intrinsic height.
42 */
43 virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
44 nsSize aCBSize, nscoord aAvailableWidth,
45 nsSize aMargin, nsSize aBorder,
46 nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE;
48 /**
49 * Reflow our frame. This will use the computed width plus borderpadding for
50 * the desired width, and use the return value of GetIntrinsicHeight plus
51 * borderpadding for the desired height. Ascent will be set to the height,
52 * and descent will be set to 0.
53 */
54 virtual nsresult Reflow(nsPresContext* aPresContext,
55 nsHTMLReflowMetrics& aDesiredSize,
56 const nsHTMLReflowState& aReflowState,
57 nsReflowStatus& aStatus) MOZ_OVERRIDE;
59 /**
60 * This method does most of the work that Reflow() above need done.
61 */
62 virtual nsresult DoReflow(nsPresContext* aPresContext,
63 nsHTMLReflowMetrics& aDesiredSize,
64 const nsHTMLReflowState& aReflowState,
65 nsReflowStatus& aStatus);
67 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
68 {
69 // We don't actually contain a block, but we do always want a
70 // computed width, so tell a little white lie here.
71 return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplacedContainsBlock));
72 }
74 protected:
75 nsLeafFrame(nsStyleContext* aContext) : nsFrame(aContext) {}
76 virtual ~nsLeafFrame();
78 /**
79 * Return the intrinsic width of the frame's content area. Note that this
80 * should not include borders or padding and should not depend on the applied
81 * styles.
82 */
83 virtual nscoord GetIntrinsicWidth() = 0;
85 /**
86 * Return the intrinsic height of the frame's content area. This should not
87 * include border or padding. This will only matter if the specified height
88 * is auto. Note that subclasses must either implement this or override
89 * Reflow and ComputeAutoSize; the default Reflow and ComputeAutoSize impls
90 * call this method.
91 */
92 virtual nscoord GetIntrinsicHeight();
94 /**
95 * Subroutine to add in borders and padding
96 */
97 void AddBordersAndPadding(const nsHTMLReflowState& aReflowState,
98 nsHTMLReflowMetrics& aDesiredSize);
100 /**
101 * Set aDesiredSize to be the available size
102 */
103 void SizeToAvailSize(const nsHTMLReflowState& aReflowState,
104 nsHTMLReflowMetrics& aDesiredSize);
105 };
107 #endif /* nsLeafFrame_h___ */