gecko-dev/layout/xul/grid/nsGridLayout2.h
Masayuki Nakano 2f9688c14e Bug 1544343 - part 2: Make factory methods take mozilla::PresShell instead of nsIPresShell r=emilio
Additionally, this patch makes `nsFrame.h` stop including `nsIPresShell.h`
and makes each users include `mozilla/PresShell.h` instead.  So, this improves
rebuild performance of `nsIPresShell.h` (and `mozilla/PresShell.h` in the
future).

Note that due to `nsIFrame::PresShell()`, `mozilla::` prefix is necessary for
`PresShell` in a lot of classes which are derived from `nsIFrame` even in
`.cpp` files.

Differential Revision: https://phabricator.services.mozilla.com/D27476

--HG--
extra : moz-landing-system : lando
2019-04-16 07:24:49 +00:00

86 lines
3.2 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsGridLayout2_h___
#define nsGridLayout2_h___
#include "mozilla/Attributes.h"
#include "nsStackLayout.h"
#include "nsIGridPart.h"
#include "nsCoord.h"
#include "nsGrid.h"
class nsGridRowGroupLayout;
class nsGridRowLayout;
class nsGridRow;
class nsBoxLayoutState;
/**
* The nsBoxLayout implementation for a grid.
*/
class nsGridLayout2 final : public nsStackLayout, public nsIGridPart {
public:
friend nsresult NS_NewGridLayout2(nsBoxLayout** aNewLayout);
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD XULLayout(nsIFrame* aBox,
nsBoxLayoutState& aBoxLayoutState) override;
virtual void IntrinsicISizesDirty(nsIFrame* aBox,
nsBoxLayoutState& aBoxLayoutState) override;
virtual nsGridRowGroupLayout* CastToRowGroupLayout() override {
return nullptr;
}
virtual nsGridLayout2* CastToGridLayout() override { return this; }
virtual nsGrid* GetGrid(nsIFrame* aBox, int32_t* aIndex,
nsGridRowLayout* aRequestor = nullptr) override;
virtual nsIGridPart* GetParentGridPart(nsIFrame* aBox,
nsIFrame** aParentBox) override {
MOZ_ASSERT_UNREACHABLE("Should not be called");
return nullptr;
}
virtual nsSize GetXULMinSize(nsIFrame* aBox,
nsBoxLayoutState& aBoxLayoutState) override;
virtual nsSize GetXULMaxSize(nsIFrame* aBox,
nsBoxLayoutState& aBoxLayoutState) override;
virtual nsSize GetXULPrefSize(nsIFrame* aBox,
nsBoxLayoutState& aBoxLayoutState) override;
virtual void CountRowsColumns(nsIFrame* aBox, int32_t& aRowCount,
int32_t& aComputedColumnCount) override {
aRowCount++;
}
virtual void DirtyRows(nsIFrame* aBox, nsBoxLayoutState& aState) override {}
virtual int32_t BuildRows(nsIFrame* aBox, nsGridRow* aRows) override;
virtual nsMargin GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal) override;
virtual Type GetType() override { return eGrid; }
virtual void ChildrenInserted(
nsIFrame* aBox, nsBoxLayoutState& aState, nsIFrame* aPrevBox,
const nsFrameList::Slice& aNewChildren) override;
virtual void ChildrenAppended(
nsIFrame* aBox, nsBoxLayoutState& aState,
const nsFrameList::Slice& aNewChildren) override;
virtual void ChildrenRemoved(nsIFrame* aBox, nsBoxLayoutState& aState,
nsIFrame* aChildList) override;
virtual void ChildrenSet(nsIFrame* aBox, nsBoxLayoutState& aState,
nsIFrame* aChildList) override;
virtual nsIGridPart* AsGridPart() override { return this; }
static void AddOffset(nsIFrame* aChild, nsSize& aSize);
protected:
explicit nsGridLayout2() = default;
virtual ~nsGridLayout2() = default;
nsGrid mGrid;
private:
void AddWidth(nsSize& aSize, nscoord aSize2, bool aIsHorizontal);
}; // class nsGridLayout2
#endif