ViewportFrame.h (3824B)
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/. */ 6 7 /* 8 * rendering object that is the root of the frame tree, which contains 9 * contains fixed-positioned elements 10 */ 11 12 #ifndef mozilla_ViewportFrame_h 13 #define mozilla_ViewportFrame_h 14 15 #include "nsContainerFrame.h" 16 17 class nsPresContext; 18 19 namespace mozilla { 20 21 class nsDisplayWrapList; 22 class ServoRestyleState; 23 24 /** 25 * ViewportFrame is the parent of a single child -- the root canvas frame or a 26 * scroll container frame containing the root canvas frame. See 27 * nsCSSFrameConstructor::SetUpDocElementContainingBlock() for the root frame 28 * hierarchy. ViewportFrame stores this child in its primary child list. 29 */ 30 class ViewportFrame : public nsContainerFrame { 31 public: 32 NS_DECL_QUERYFRAME 33 NS_DECL_FRAMEARENA_HELPERS(ViewportFrame) 34 35 explicit ViewportFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) 36 : ViewportFrame(aStyle, aPresContext, kClassID) {} 37 38 virtual ~ViewportFrame() = default; // useful for debugging 39 40 void Init(nsIContent* aContent, nsContainerFrame* aParent, 41 nsIFrame* aPrevInFlow) override; 42 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 50 51 void Destroy(DestroyContext&) override; 52 void BuildDisplayList(nsDisplayListBuilder* aBuilder, 53 const nsDisplayListSet& aLists) override; 54 55 nsDisplayWrapList* BuildDisplayListForContentTopLayer( 56 nsDisplayListBuilder* aBuilder, bool* aIsOpaque = nullptr); 57 58 nsDisplayWrapList* BuildDisplayListForViewTransitionsAndNACTopLayer( 59 nsDisplayListBuilder* aBuilder); 60 61 nscoord IntrinsicISize(const IntrinsicSizeInput& aInput, 62 IntrinsicISizeType aType) override; 63 64 void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize, 65 const ReflowInput& aReflowInput, 66 nsReflowStatus& aStatus) override; 67 68 bool ComputeCustomOverflow(mozilla::OverflowAreas&) override { return false; } 69 70 /** 71 * Get the containing block rect when ViewportFrame serves as a containing 72 * block. This method accounts for scrollbars, visual viewport, and dynamic 73 * toolbar sizes. 74 */ 75 nsRect GetContainingBlockAdjustedForScrollbars( 76 const ReflowInput& aReflowInput) const; 77 78 /** 79 * Update our style (and recursively the styles of any anonymous boxes we 80 * might own) 81 */ 82 void UpdateStyle(ServoRestyleState& aStyleSet); 83 84 /** 85 * Return our single anonymous box child. 86 */ 87 void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override; 88 89 // Returns adjusted viewport size to reflect the positions that position:fixed 90 // elements are attached. 91 nsSize AdjustViewportSizeForFixedPosition(const nsRect& aViewportRect) const; 92 93 #ifdef DEBUG_FRAME_DUMP 94 virtual nsresult GetFrameName(nsAString& aResult) const override; 95 #endif 96 97 protected: 98 ViewportFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID) 99 : nsContainerFrame(aStyle, aPresContext, aID) {} 100 101 private: 102 nsDisplayWrapList* MaybeWrapTopLayerList(nsDisplayListBuilder*, 103 uint16_t aIndex, nsDisplayList&); 104 105 mozilla::FrameChildListID GetAbsoluteListID() const override { 106 return FrameChildListID::Fixed; 107 } 108 }; 109 110 } // namespace mozilla 111 112 #endif // mozilla_ViewportFrame_h