michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: 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: #ifndef nsGridLayout2_h___ michael@0: #define nsGridLayout2_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsStackLayout.h" michael@0: #include "nsIGridPart.h" michael@0: #include "nsCoord.h" michael@0: #include "nsGrid.h" michael@0: michael@0: class nsIPresContext; michael@0: class nsGridRowGroupLayout; michael@0: class nsGridRowLayout; michael@0: class nsGridRow; michael@0: class nsBoxLayoutState; michael@0: class nsGridCell; michael@0: michael@0: /** michael@0: * The nsBoxLayout implementation for a grid. michael@0: */ michael@0: class nsGridLayout2 : public nsStackLayout, michael@0: public nsIGridPart michael@0: { michael@0: public: michael@0: michael@0: friend nsresult NS_NewGridLayout2(nsIPresShell* aPresShell, nsBoxLayout** aNewLayout); michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: NS_IMETHOD Layout(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; michael@0: virtual void IntrinsicWidthsDirty(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; michael@0: michael@0: virtual nsGridRowGroupLayout* CastToRowGroupLayout() MOZ_OVERRIDE { return nullptr; } michael@0: virtual nsGridLayout2* CastToGridLayout() MOZ_OVERRIDE { return this; } michael@0: virtual nsGrid* GetGrid(nsIFrame* aBox, int32_t* aIndex, nsGridRowLayout* aRequestor=nullptr) MOZ_OVERRIDE; michael@0: virtual nsIGridPart* GetParentGridPart(nsIFrame* aBox, nsIFrame** aParentBox) MOZ_OVERRIDE { michael@0: NS_NOTREACHED("Should not be called"); return nullptr; michael@0: } michael@0: virtual nsSize GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; michael@0: virtual nsSize GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; michael@0: virtual nsSize GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; michael@0: virtual void CountRowsColumns(nsIFrame* aBox, int32_t& aRowCount, int32_t& aComputedColumnCount) MOZ_OVERRIDE { aRowCount++; } michael@0: virtual void DirtyRows(nsIFrame* aBox, nsBoxLayoutState& aState) MOZ_OVERRIDE { } michael@0: virtual int32_t BuildRows(nsIFrame* aBox, nsGridRow* aRows) MOZ_OVERRIDE; michael@0: virtual nsMargin GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal) MOZ_OVERRIDE; michael@0: virtual Type GetType() MOZ_OVERRIDE { return eGrid; } michael@0: virtual void ChildrenInserted(nsIFrame* aBox, nsBoxLayoutState& aState, michael@0: nsIFrame* aPrevBox, michael@0: const nsFrameList::Slice& aNewChildren) MOZ_OVERRIDE; michael@0: virtual void ChildrenAppended(nsIFrame* aBox, nsBoxLayoutState& aState, michael@0: const nsFrameList::Slice& aNewChildren) MOZ_OVERRIDE; michael@0: virtual void ChildrenRemoved(nsIFrame* aBox, nsBoxLayoutState& aState, michael@0: nsIFrame* aChildList) MOZ_OVERRIDE; michael@0: virtual void ChildrenSet(nsIFrame* aBox, nsBoxLayoutState& aState, michael@0: nsIFrame* aChildList) MOZ_OVERRIDE; michael@0: michael@0: virtual nsIGridPart* AsGridPart() MOZ_OVERRIDE { return this; } michael@0: michael@0: static void AddOffset(nsBoxLayoutState& aState, nsIFrame* aChild, nsSize& aSize); michael@0: michael@0: protected: michael@0: michael@0: nsGridLayout2(nsIPresShell* aShell); michael@0: nsGrid mGrid; michael@0: michael@0: private: michael@0: void AddWidth(nsSize& aSize, nscoord aSize2, bool aIsHorizontal); michael@0: michael@0: michael@0: }; // class nsGridLayout2 michael@0: michael@0: michael@0: #endif michael@0: