Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / generic / ViewportFrame.h
blob2d3f8efc1b6e053b7a57934ea64a7ce5d7a4e74f
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/. */
7 /*
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"
18 class nsPresContext;
20 namespace mozilla {
22 class nsDisplayWrapList;
23 class ServoRestyleState;
25 /**
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 {
31 public:
32 NS_DECL_QUERYFRAME
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;
43 #ifdef DEBUG
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;
49 #endif
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; }
65 /**
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;
73 /**
74 * Update our style (and recursively the styles of any anonymous boxes we
75 * might own)
77 void UpdateStyle(ServoRestyleState& aStyleSet);
79 /**
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;
90 #endif
92 protected:
93 ViewportFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID)
94 : nsContainerFrame(aStyle, aPresContext, aID), mView(nullptr) {}
96 /**
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 width/height and
100 * available width 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; }
108 private:
109 mozilla::FrameChildListID GetAbsoluteListID() const override {
110 return FrameChildListID::Fixed;
113 nsView* mView;
116 } // namespace mozilla
118 #endif // mozilla_ViewportFrame_h