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 : /*
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 mozilla_ViewportFrame_h
12 : #define mozilla_ViewportFrame_h
13 :
14 : #include "mozilla/Attributes.h"
15 : #include "nsContainerFrame.h"
16 :
17 : class nsPresContext;
18 :
19 : namespace mozilla {
20 :
21 : class ServoRestyleState;
22 :
23 : /**
24 : * ViewportFrame is the parent of a single child - the doc root frame or a scroll frame
25 : * containing the doc root frame. ViewportFrame stores this child in its primary child
26 : * list.
27 : */
28 : class ViewportFrame : public nsContainerFrame {
29 : public:
30 : NS_DECL_QUERYFRAME
31 210 : NS_DECL_FRAMEARENA_HELPERS(ViewportFrame)
32 :
33 24 : explicit ViewportFrame(nsStyleContext* aContext)
34 24 : : ViewportFrame(aContext, kClassID)
35 24 : {}
36 :
37 0 : virtual ~ViewportFrame() { } // useful for debugging
38 :
39 : virtual void Init(nsIContent* aContent,
40 : nsContainerFrame* aParent,
41 : nsIFrame* aPrevInFlow) override;
42 :
43 : #ifdef DEBUG
44 : virtual void AppendFrames(ChildListID aListID,
45 : nsFrameList& aFrameList) override;
46 : virtual void InsertFrames(ChildListID aListID,
47 : nsIFrame* aPrevFrame,
48 : nsFrameList& aFrameList) override;
49 : virtual void RemoveFrame(ChildListID aListID,
50 : nsIFrame* aOldFrame) override;
51 : #endif
52 :
53 : virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
54 : const nsRect& aDirtyRect,
55 : const nsDisplayListSet& aLists) override;
56 :
57 : void BuildDisplayListForTopLayer(nsDisplayListBuilder* aBuilder,
58 : nsDisplayList* aList);
59 :
60 : virtual nscoord GetMinISize(gfxContext *aRenderingContext) override;
61 : virtual nscoord GetPrefISize(gfxContext *aRenderingContext) override;
62 : virtual void Reflow(nsPresContext* aPresContext,
63 : ReflowOutput& aDesiredSize,
64 : const ReflowInput& aReflowInput,
65 : nsReflowStatus& aStatus) override;
66 :
67 : virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override;
68 :
69 : /**
70 : * Adjust aReflowInput to account for scrollbars and pres shell
71 : * GetScrollPositionClampingScrollPortSizeSet and
72 : * GetContentDocumentFixedPositionMargins adjustments.
73 : * @return the rect to use as containing block rect
74 : */
75 : nsRect AdjustReflowInputAsContainingBlock(ReflowInput* aReflowInput) const;
76 :
77 : /**
78 : * Update our style (and recursively the styles of any anonymous boxes we
79 : * might own)
80 : */
81 : void UpdateStyle(ServoRestyleState& aStyleSet);
82 :
83 : /**
84 : * Return our single anonymous box child.
85 : */
86 : void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
87 :
88 : #ifdef DEBUG_FRAME_DUMP
89 : virtual nsresult GetFrameName(nsAString& aResult) const override;
90 : #endif
91 :
92 : protected:
93 24 : ViewportFrame(nsStyleContext* aContext, ClassID aID)
94 24 : : nsContainerFrame(aContext, aID)
95 24 : , mView(nullptr)
96 24 : {}
97 :
98 : /**
99 : * Calculate how much room is available for fixed frames. That means
100 : * determining if the viewport is scrollable and whether the vertical and/or
101 : * horizontal scrollbars are visible. Adjust the computed width/height and
102 : * available width for aReflowInput accordingly.
103 : * @return the current scroll position, or 0,0 if not scrollable
104 : */
105 : nsPoint AdjustReflowInputForScrollbars(ReflowInput* aReflowInput) const;
106 :
107 4417 : nsView* GetViewInternal() const override { return mView; }
108 24 : void SetViewInternal(nsView* aView) override { mView = aView; }
109 :
110 : private:
111 221 : virtual mozilla::layout::FrameChildListID GetAbsoluteListID() const override { return kFixedList; }
112 :
113 : nsView* mView;
114 : };
115 :
116 : } // namespace mozilla
117 :
118 : #endif // mozilla_ViewportFrame_h
|