|
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 /* |
|
7 * rendering object that is the root of the frame tree, which contains |
|
8 * the document's scrollbars and contains fixed-positioned elements |
|
9 */ |
|
10 |
|
11 #ifndef nsViewportFrame_h___ |
|
12 #define nsViewportFrame_h___ |
|
13 |
|
14 #include "mozilla/Attributes.h" |
|
15 #include "nsContainerFrame.h" |
|
16 |
|
17 class nsPresContext; |
|
18 |
|
19 /** |
|
20 * ViewportFrame is the parent of a single child - the doc root frame or a scroll frame |
|
21 * containing the doc root frame. ViewportFrame stores this child in its primary child |
|
22 * list. |
|
23 */ |
|
24 class ViewportFrame : public nsContainerFrame { |
|
25 public: |
|
26 NS_DECL_QUERYFRAME_TARGET(ViewportFrame) |
|
27 NS_DECL_QUERYFRAME |
|
28 NS_DECL_FRAMEARENA_HELPERS |
|
29 |
|
30 typedef nsContainerFrame Super; |
|
31 |
|
32 ViewportFrame(nsStyleContext* aContext) |
|
33 : nsContainerFrame(aContext) |
|
34 {} |
|
35 virtual ~ViewportFrame() { } // useful for debugging |
|
36 |
|
37 virtual void Init(nsIContent* aContent, |
|
38 nsIFrame* aParent, |
|
39 nsIFrame* asPrevInFlow) MOZ_OVERRIDE; |
|
40 |
|
41 virtual nsresult SetInitialChildList(ChildListID aListID, |
|
42 nsFrameList& aChildList) MOZ_OVERRIDE; |
|
43 |
|
44 virtual nsresult AppendFrames(ChildListID aListID, |
|
45 nsFrameList& aFrameList) MOZ_OVERRIDE; |
|
46 |
|
47 virtual nsresult InsertFrames(ChildListID aListID, |
|
48 nsIFrame* aPrevFrame, |
|
49 nsFrameList& aFrameList) MOZ_OVERRIDE; |
|
50 |
|
51 virtual nsresult RemoveFrame(ChildListID aListID, |
|
52 nsIFrame* aOldFrame) MOZ_OVERRIDE; |
|
53 |
|
54 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
|
55 const nsRect& aDirtyRect, |
|
56 const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
|
57 |
|
58 virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
|
59 virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
|
60 virtual nsresult Reflow(nsPresContext* aPresContext, |
|
61 nsHTMLReflowMetrics& aDesiredSize, |
|
62 const nsHTMLReflowState& aReflowState, |
|
63 nsReflowStatus& aStatus) MOZ_OVERRIDE; |
|
64 |
|
65 /** |
|
66 * Get the "type" of the frame |
|
67 * |
|
68 * @see nsGkAtoms::viewportFrame |
|
69 */ |
|
70 virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
|
71 |
|
72 /** |
|
73 * Adjust aReflowState to account for scrollbars and pres shell |
|
74 * GetScrollPositionClampingScrollPortSizeSet and |
|
75 * GetContentDocumentFixedPositionMargins adjustments. |
|
76 * @return the rect to use as containing block rect |
|
77 */ |
|
78 nsRect AdjustReflowStateAsContainingBlock(nsHTMLReflowState* aReflowState) const; |
|
79 |
|
80 #ifdef DEBUG_FRAME_DUMP |
|
81 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; |
|
82 #endif |
|
83 |
|
84 private: |
|
85 virtual mozilla::layout::FrameChildListID GetAbsoluteListID() const MOZ_OVERRIDE { return kFixedList; } |
|
86 |
|
87 protected: |
|
88 /** |
|
89 * Calculate how much room is available for fixed frames. That means |
|
90 * determining if the viewport is scrollable and whether the vertical and/or |
|
91 * horizontal scrollbars are visible. Adjust the computed width/height and |
|
92 * available width for aReflowState accordingly. |
|
93 * @return the current scroll position, or 0,0 if not scrollable |
|
94 */ |
|
95 nsPoint AdjustReflowStateForScrollbars(nsHTMLReflowState* aReflowState) const; |
|
96 }; |
|
97 |
|
98 |
|
99 #endif // nsViewportFrame_h___ |