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/. */
8 * rendering object that is the root of the frame tree, which contains
9 * the document's scrollbars and contains fixed-positioned elements
12 #ifndef mozilla_ViewportFrame_h
13 #define mozilla_ViewportFrame_h
15 #include "mozilla/Attributes.h"
16 #include "nsContainerFrame.h"
22 class nsDisplayWrapList
;
23 class ServoRestyleState
;
26 * ViewportFrame is the parent of a single child - the doc root frame or a
27 * scroll frame containing the doc root frame. ViewportFrame stores this child
28 * in its primary child list.
30 class ViewportFrame
: public nsContainerFrame
{
33 NS_DECL_FRAMEARENA_HELPERS(ViewportFrame
)
35 explicit ViewportFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
)
36 : ViewportFrame(aStyle
, aPresContext
, kClassID
) {}
38 virtual ~ViewportFrame() = default; // useful for debugging
40 void Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
41 nsIFrame
* aPrevInFlow
) override
;
44 void AppendFrames(ChildListID aListID
, nsFrameList
&& aFrameList
) override
;
45 void InsertFrames(ChildListID aListID
, nsIFrame
* aPrevFrame
,
46 const nsLineList::iterator
* aPrevFrameLine
,
47 nsFrameList
&& aFrameList
) override
;
48 void RemoveFrame(DestroyContext
&, ChildListID
, nsIFrame
*) override
;
51 void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
52 const nsDisplayListSet
& aLists
) override
;
54 nsDisplayWrapList
* BuildDisplayListForTopLayer(nsDisplayListBuilder
* aBuilder
,
55 bool* aIsOpaque
= nullptr);
57 nscoord
GetMinISize(gfxContext
* aRenderingContext
) override
;
58 nscoord
GetPrefISize(gfxContext
* aRenderingContext
) override
;
59 void Reflow(nsPresContext
* aPresContext
, ReflowOutput
& aDesiredSize
,
60 const ReflowInput
& aReflowInput
,
61 nsReflowStatus
& aStatus
) override
;
63 bool ComputeCustomOverflow(mozilla::OverflowAreas
&) override
{ return false; }
66 * Adjust aReflowInput to account for scrollbars and pres shell
67 * GetVisualViewportSizeSet and
68 * GetContentDocumentFixedPositionMargins adjustments.
69 * @return the rect to use as containing block rect
71 nsRect
AdjustReflowInputAsContainingBlock(ReflowInput
* aReflowInput
) const;
74 * Update our style (and recursively the styles of any anonymous boxes we
77 void UpdateStyle(ServoRestyleState
& aStyleSet
);
80 * Return our single anonymous box child.
82 void AppendDirectlyOwnedAnonBoxes(nsTArray
<OwnedAnonBox
>& aResult
) override
;
84 // Returns adjusted viewport size to reflect the positions that position:fixed
85 // elements are attached.
86 nsSize
AdjustViewportSizeForFixedPosition(const nsRect
& aViewportRect
) const;
88 #ifdef DEBUG_FRAME_DUMP
89 virtual nsresult
GetFrameName(nsAString
& aResult
) const override
;
93 ViewportFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
, ClassID aID
)
94 : nsContainerFrame(aStyle
, aPresContext
, aID
), mView(nullptr) {}
97 * Calculate how much room is available for fixed frames. That means
98 * determining if the viewport is scrollable and whether the vertical and/or
99 * horizontal scrollbars are visible. Adjust the computed isize/bsize and
100 * available isize for aReflowInput accordingly.
101 * @return the current scroll position, or (0,0) if not scrollable.
103 nsPoint
AdjustReflowInputForScrollbars(ReflowInput
* aReflowInput
) const;
105 nsView
* GetViewInternal() const override
{ return mView
; }
106 void SetViewInternal(nsView
* aView
) override
{ mView
= aView
; }
109 mozilla::FrameChildListID
GetAbsoluteListID() const override
{
110 return FrameChildListID::Fixed
;
116 } // namespace mozilla
118 #endif // mozilla_ViewportFrame_h