michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * rendering object that is the root of the frame tree, which contains michael@0: * the document's scrollbars and contains fixed-positioned elements michael@0: */ michael@0: michael@0: #ifndef nsViewportFrame_h___ michael@0: #define nsViewportFrame_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsContainerFrame.h" michael@0: michael@0: class nsPresContext; michael@0: michael@0: /** michael@0: * ViewportFrame is the parent of a single child - the doc root frame or a scroll frame michael@0: * containing the doc root frame. ViewportFrame stores this child in its primary child michael@0: * list. michael@0: */ michael@0: class ViewportFrame : public nsContainerFrame { michael@0: public: michael@0: NS_DECL_QUERYFRAME_TARGET(ViewportFrame) michael@0: NS_DECL_QUERYFRAME michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: typedef nsContainerFrame Super; michael@0: michael@0: ViewportFrame(nsStyleContext* aContext) michael@0: : nsContainerFrame(aContext) michael@0: {} michael@0: virtual ~ViewportFrame() { } // useful for debugging michael@0: michael@0: virtual void Init(nsIContent* aContent, michael@0: nsIFrame* aParent, michael@0: nsIFrame* asPrevInFlow) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult SetInitialChildList(ChildListID aListID, michael@0: nsFrameList& aChildList) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult AppendFrames(ChildListID aListID, michael@0: nsFrameList& aFrameList) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult InsertFrames(ChildListID aListID, michael@0: nsIFrame* aPrevFrame, michael@0: nsFrameList& aFrameList) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult RemoveFrame(ChildListID aListID, michael@0: nsIFrame* aOldFrame) MOZ_OVERRIDE; michael@0: michael@0: virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, michael@0: const nsRect& aDirtyRect, michael@0: const nsDisplayListSet& aLists) MOZ_OVERRIDE; michael@0: michael@0: virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; michael@0: virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; michael@0: virtual nsresult Reflow(nsPresContext* aPresContext, michael@0: nsHTMLReflowMetrics& aDesiredSize, michael@0: const nsHTMLReflowState& aReflowState, michael@0: nsReflowStatus& aStatus) MOZ_OVERRIDE; michael@0: michael@0: /** michael@0: * Get the "type" of the frame michael@0: * michael@0: * @see nsGkAtoms::viewportFrame michael@0: */ michael@0: virtual nsIAtom* GetType() const MOZ_OVERRIDE; michael@0: michael@0: /** michael@0: * Adjust aReflowState to account for scrollbars and pres shell michael@0: * GetScrollPositionClampingScrollPortSizeSet and michael@0: * GetContentDocumentFixedPositionMargins adjustments. michael@0: * @return the rect to use as containing block rect michael@0: */ michael@0: nsRect AdjustReflowStateAsContainingBlock(nsHTMLReflowState* aReflowState) const; michael@0: michael@0: #ifdef DEBUG_FRAME_DUMP michael@0: virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: private: michael@0: virtual mozilla::layout::FrameChildListID GetAbsoluteListID() const MOZ_OVERRIDE { return kFixedList; } michael@0: michael@0: protected: michael@0: /** michael@0: * Calculate how much room is available for fixed frames. That means michael@0: * determining if the viewport is scrollable and whether the vertical and/or michael@0: * horizontal scrollbars are visible. Adjust the computed width/height and michael@0: * available width for aReflowState accordingly. michael@0: * @return the current scroll position, or 0,0 if not scrollable michael@0: */ michael@0: nsPoint AdjustReflowStateForScrollbars(nsHTMLReflowState* aReflowState) const; michael@0: }; michael@0: michael@0: michael@0: #endif // nsViewportFrame_h___