2014-02-26 23:45:29 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code is subject to the terms of the Mozilla Public License
|
|
|
|
* version 2.0 (the "License"). You can obtain a copy of the License at
|
|
|
|
* http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-05-12 14:16:05 -07:00
|
|
|
/* rendering object for CSS "display: grid | inline-grid" */
|
2014-02-26 23:45:29 -08:00
|
|
|
|
|
|
|
#ifndef nsGridContainerFrame_h___
|
|
|
|
#define nsGridContainerFrame_h___
|
|
|
|
|
|
|
|
#include "nsContainerFrame.h"
|
2015-01-14 13:59:59 -08:00
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsTHashtable.h"
|
2014-02-26 23:45:29 -08:00
|
|
|
|
2014-05-12 14:16:05 -07:00
|
|
|
/**
|
|
|
|
* Factory function.
|
|
|
|
* @return a newly allocated nsGridContainerFrame (infallible)
|
|
|
|
*/
|
2014-05-24 15:20:40 -07:00
|
|
|
nsContainerFrame* NS_NewGridContainerFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
2014-02-26 23:45:29 -08:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
class nsGridContainerFrame final : public nsContainerFrame
|
2014-05-12 14:16:05 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-02-26 23:45:29 -08:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsGridContainerFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
|
|
|
|
|
|
|
// nsIFrame overrides
|
2014-05-12 17:47:54 -07:00
|
|
|
void Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2015-03-21 09:28:04 -07:00
|
|
|
nsReflowStatus& aStatus) override;
|
|
|
|
virtual nsIAtom* GetType() const override;
|
2014-05-12 14:16:05 -07:00
|
|
|
|
2015-03-26 11:57:39 -07:00
|
|
|
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) override;
|
|
|
|
|
2014-02-26 23:45:29 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override;
|
2014-02-26 23:45:29 -08:00
|
|
|
#endif
|
|
|
|
|
2015-03-26 11:57:39 -07:00
|
|
|
/**
|
|
|
|
* Return the containing block for aChild which MUST be an abs.pos. child
|
|
|
|
* of a grid container. This is just a helper method for
|
|
|
|
* nsAbsoluteContainingBlock::Reflow - it's not meant to be used elsewhere.
|
|
|
|
*/
|
|
|
|
static const nsRect& GridItemCB(nsIFrame* aChild);
|
|
|
|
|
2015-03-18 02:02:32 -07:00
|
|
|
struct TrackSize {
|
|
|
|
nscoord mBase;
|
|
|
|
nscoord mLimit;
|
|
|
|
};
|
|
|
|
|
2015-03-26 11:57:39 -07:00
|
|
|
// @see nsAbsoluteContainingBlock::Reflow about this magic number
|
|
|
|
static const nscoord VERY_LIKELY_A_GRID_CONTAINER = -123456789;
|
|
|
|
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(GridItemContainingBlockRect, DeleteValue<nsRect>)
|
|
|
|
|
2014-02-26 23:45:29 -08:00
|
|
|
protected:
|
2015-04-30 11:42:50 -07:00
|
|
|
static const int32_t kAutoLine;
|
2015-03-26 11:57:39 -07:00
|
|
|
typedef mozilla::LogicalPoint LogicalPoint;
|
2015-03-18 02:02:32 -07:00
|
|
|
typedef mozilla::LogicalRect LogicalRect;
|
|
|
|
typedef mozilla::WritingMode WritingMode;
|
2015-03-18 02:02:32 -07:00
|
|
|
typedef mozilla::css::GridNamedArea GridNamedArea;
|
2015-03-26 11:57:39 -07:00
|
|
|
class GridItemCSSOrderIterator;
|
2014-05-24 15:20:40 -07:00
|
|
|
friend nsContainerFrame* NS_NewGridContainerFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
2014-08-31 20:36:37 -07:00
|
|
|
explicit nsGridContainerFrame(nsStyleContext* aContext) : nsContainerFrame(aContext) {}
|
2014-05-19 16:57:00 -07:00
|
|
|
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* A LineRange can be definite or auto - when it's definite it represents
|
|
|
|
* a consecutive set of tracks between a starting line and an ending line
|
|
|
|
* (both 1-based) where mStart < mEnd. Before it's definite it can also
|
|
|
|
* represent an auto position with a span, where mStart == 0 and mEnd is
|
|
|
|
* the (non-zero positive) span.
|
2015-03-26 11:57:39 -07:00
|
|
|
* In both states the invariant mEnd > mStart holds (for normal flow items).
|
|
|
|
*
|
|
|
|
* For abs.pos. grid items, mStart and mEnd may both be zero, meaning
|
|
|
|
* "attach this side to the grid container containing block edge".
|
|
|
|
* Additionally, mEnd >= mStart holds when both are definite (non-zero),
|
|
|
|
* i.e. the invariant is slightly relaxed compared to normal flow items.
|
2015-03-18 02:02:32 -07:00
|
|
|
*/
|
|
|
|
struct LineRange {
|
2015-04-30 11:42:50 -07:00
|
|
|
LineRange(int32_t aStart, int32_t aEnd)
|
2015-04-30 11:42:50 -07:00
|
|
|
: mStart(aStart), mEnd(aEnd)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (!IsAutoAuto()) {
|
|
|
|
if (IsAuto()) {
|
2015-04-30 11:42:50 -07:00
|
|
|
MOZ_ASSERT(mEnd >= nsStyleGridLine::kMinLine &&
|
|
|
|
mEnd <= nsStyleGridLine::kMaxLine, "invalid span");
|
2015-04-30 11:42:50 -07:00
|
|
|
} else {
|
2015-04-30 11:42:50 -07:00
|
|
|
MOZ_ASSERT(mStart >= nsStyleGridLine::kMinLine &&
|
|
|
|
mStart <= nsStyleGridLine::kMaxLine, "invalid start line");
|
2015-04-30 11:42:50 -07:00
|
|
|
MOZ_ASSERT(mEnd == kAutoLine ||
|
2015-04-30 11:42:50 -07:00
|
|
|
(mEnd >= nsStyleGridLine::kMinLine &&
|
|
|
|
mEnd <= nsStyleGridLine::kMaxLine), "invalid end line");
|
2015-04-30 11:42:50 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
bool IsAutoAuto() const { return mStart == kAutoLine && mEnd == kAutoLine; }
|
|
|
|
bool IsAuto() const { return mStart == kAutoLine; }
|
|
|
|
bool IsDefinite() const { return mStart != kAutoLine; }
|
|
|
|
uint32_t Extent() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mEnd != kAutoLine, "Extent is undefined for abs.pos. 'auto'");
|
|
|
|
if (IsAuto()) {
|
|
|
|
MOZ_ASSERT(mEnd >= 1 && mEnd < nsStyleGridLine::kMaxLine,
|
|
|
|
"invalid span");
|
|
|
|
return mEnd;
|
|
|
|
}
|
|
|
|
return mEnd - mStart;
|
|
|
|
}
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* Resolve this auto range to start at aStart, making it definite.
|
|
|
|
* Precondition: this range IsAuto()
|
|
|
|
*/
|
2015-04-30 11:42:50 -07:00
|
|
|
void ResolveAutoPosition(int32_t aStart)
|
2015-03-18 02:02:32 -07:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsAuto(), "Why call me?");
|
2015-04-30 11:42:50 -07:00
|
|
|
MOZ_ASSERT(aStart >= 0, "expected a zero-based line number");
|
2015-03-18 02:02:32 -07:00
|
|
|
mStart = aStart;
|
|
|
|
mEnd += aStart;
|
|
|
|
}
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* Return the contribution of this line range for step 2 in
|
|
|
|
* http://dev.w3.org/csswg/css-grid/#auto-placement-algo
|
|
|
|
*/
|
2015-04-30 11:42:50 -07:00
|
|
|
uint32_t HypotheticalEnd() const { return mEnd; }
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* Given an array of track sizes, return the starting position and length
|
|
|
|
* of the tracks in this line range.
|
|
|
|
*/
|
|
|
|
void ToPositionAndLength(const nsTArray<TrackSize>& aTrackSizes,
|
|
|
|
nscoord* aPos, nscoord* aLength) const;
|
2015-03-26 11:57:39 -07:00
|
|
|
/**
|
|
|
|
* Given an array of track sizes and a grid origin coordinate, adjust the
|
|
|
|
* abs.pos. containing block along an axis given by aPos and aLength.
|
|
|
|
* aPos and aLength should already be initialized to the grid container
|
|
|
|
* containing block for this axis before calling this method.
|
|
|
|
*/
|
|
|
|
void ToPositionAndLengthForAbsPos(const nsTArray<TrackSize>& aTrackSizes,
|
|
|
|
nscoord aGridOrigin,
|
|
|
|
nscoord* aPos, nscoord* aLength) const;
|
2015-03-18 02:02:32 -07:00
|
|
|
|
2015-04-30 11:42:50 -07:00
|
|
|
int32_t mStart; // the start line, or kAutoLine for 'auto'
|
2015-04-30 11:42:50 -07:00
|
|
|
int32_t mEnd; // the end line, or the span length for 'auto'
|
2015-03-18 02:02:32 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A GridArea is the area in the grid for a grid item.
|
|
|
|
* The area is represented by two LineRanges, both of which can be auto
|
|
|
|
* (@see LineRange) in intermediate steps while the item is being placed.
|
|
|
|
* @see PlaceGridItems
|
|
|
|
*/
|
|
|
|
struct GridArea {
|
|
|
|
GridArea(const LineRange& aCols, const LineRange& aRows)
|
|
|
|
: mCols(aCols), mRows(aRows) {}
|
|
|
|
bool IsDefinite() const { return mCols.IsDefinite() && mRows.IsDefinite(); }
|
|
|
|
LineRange mCols;
|
|
|
|
LineRange mRows;
|
|
|
|
};
|
|
|
|
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* A CellMap holds state for each cell in the grid.
|
|
|
|
* It's row major. It's sparse in the sense that it only has enough rows to
|
|
|
|
* cover the last row that has a grid item. Each row only has enough entries
|
|
|
|
* to cover columns that are occupied *on that row*, i.e. it's not a full
|
|
|
|
* matrix covering the entire implicit grid. An absent Cell means that it's
|
|
|
|
* unoccupied by any grid item.
|
|
|
|
*/
|
|
|
|
struct CellMap {
|
|
|
|
struct Cell {
|
|
|
|
Cell() : mIsOccupied(false) {}
|
|
|
|
bool mIsOccupied : 1;
|
|
|
|
};
|
|
|
|
void Fill(const GridArea& aGridArea);
|
|
|
|
void ClearOccupied();
|
|
|
|
#if DEBUG
|
|
|
|
void Dump() const;
|
|
|
|
#endif
|
|
|
|
nsTArray<nsTArray<Cell>> mCells;
|
|
|
|
};
|
|
|
|
|
2015-03-18 02:02:32 -07:00
|
|
|
enum LineRangeSide {
|
|
|
|
eLineRangeSideStart, eLineRangeSideEnd
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* Return a line number for (non-auto) aLine, per:
|
|
|
|
* http://dev.w3.org/csswg/css-grid/#line-placement
|
|
|
|
* @param aLine style data for the line (must be non-auto)
|
|
|
|
* @param aNth a number of lines to find from aFromIndex, negative if the
|
|
|
|
* search should be in reverse order. In the case aLine has
|
|
|
|
* a specified line name, it's permitted to pass in zero which
|
|
|
|
* will be treated as one.
|
|
|
|
* @param aFromIndex the zero-based index to start counting from
|
|
|
|
* @param aLineNameList the explicit named lines
|
|
|
|
* @param aAreaStart a pointer to GridNamedArea::mColumnStart/mRowStart
|
|
|
|
* @param aAreaEnd a pointer to GridNamedArea::mColumnEnd/mRowEnd
|
|
|
|
* @param aExplicitGridEnd the last line in the explicit grid
|
|
|
|
* @param aEdge indicates whether we are resolving a start or end line
|
|
|
|
* @param aStyle the StylePosition() for the grid container
|
|
|
|
* @return a definite line number, or zero in case aLine is a <custom-ident>
|
|
|
|
* that can't be found.
|
|
|
|
*/
|
2015-04-30 11:42:50 -07:00
|
|
|
int32_t ResolveLine(const nsStyleGridLine& aLine,
|
|
|
|
int32_t aNth,
|
|
|
|
uint32_t aFromIndex,
|
|
|
|
const nsTArray<nsTArray<nsString>>& aLineNameList,
|
|
|
|
uint32_t GridNamedArea::* aAreaStart,
|
|
|
|
uint32_t GridNamedArea::* aAreaEnd,
|
|
|
|
uint32_t aExplicitGridEnd,
|
|
|
|
LineRangeSide aEdge,
|
|
|
|
const nsStylePosition* aStyle);
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* Return a LineRange based on the given style data. Non-auto lines
|
|
|
|
* are resolved to a definite line number per:
|
|
|
|
* http://dev.w3.org/csswg/css-grid/#line-placement
|
|
|
|
* with placement errors corrected per:
|
|
|
|
* http://dev.w3.org/csswg/css-grid/#grid-placement-errors
|
|
|
|
* @param aStyle the StylePosition() for the grid container
|
|
|
|
* @param aStart style data for the start line
|
|
|
|
* @param aEnd style data for the end line
|
|
|
|
* @param aLineNameList the explicit named lines
|
|
|
|
* @param aAreaStart a pointer to GridNamedArea::mColumnStart/mRowStart
|
|
|
|
* @param aAreaEnd a pointer to GridNamedArea::mColumnEnd/mRowEnd
|
|
|
|
* @param aExplicitGridEnd the last line in the explicit grid
|
|
|
|
* @param aStyle the StylePosition() for the grid container
|
|
|
|
*/
|
|
|
|
LineRange ResolveLineRange(const nsStyleGridLine& aStart,
|
|
|
|
const nsStyleGridLine& aEnd,
|
|
|
|
const nsTArray<nsTArray<nsString>>& aLineNameList,
|
|
|
|
uint32_t GridNamedArea::* aAreaStart,
|
|
|
|
uint32_t GridNamedArea::* aAreaEnd,
|
|
|
|
uint32_t aExplicitGridEnd,
|
|
|
|
const nsStylePosition* aStyle);
|
|
|
|
|
2015-03-26 11:57:39 -07:00
|
|
|
/**
|
|
|
|
* As above but for an abs.pos. child. Any 'auto' lines will be represented
|
2015-04-30 11:42:50 -07:00
|
|
|
* by kAutoLine in the LineRange result.
|
2015-04-30 11:42:50 -07:00
|
|
|
* @param aGridStart the first line in the final, but untranslated grid
|
|
|
|
* @param aGridEnd the last line in the final, but untranslated grid
|
2015-03-26 11:57:39 -07:00
|
|
|
*/
|
|
|
|
LineRange
|
|
|
|
ResolveAbsPosLineRange(const nsStyleGridLine& aStart,
|
|
|
|
const nsStyleGridLine& aEnd,
|
|
|
|
const nsTArray<nsTArray<nsString>>& aLineNameList,
|
|
|
|
uint32_t GridNamedArea::* aAreaStart,
|
|
|
|
uint32_t GridNamedArea::* aAreaEnd,
|
|
|
|
uint32_t aExplicitGridEnd,
|
2015-04-30 11:42:50 -07:00
|
|
|
int32_t aGridStart,
|
|
|
|
int32_t aGridEnd,
|
2015-03-26 11:57:39 -07:00
|
|
|
const nsStylePosition* aStyle);
|
|
|
|
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* Return a GridArea with non-auto lines placed at a definite line number
|
|
|
|
* and with placement errors resolved. One or both positions may still be
|
|
|
|
* 'auto'.
|
|
|
|
* @param aChild the grid item
|
|
|
|
* @param aStyle the StylePosition() for the grid container
|
|
|
|
*/
|
|
|
|
GridArea PlaceDefinite(nsIFrame* aChild, const nsStylePosition* aStyle);
|
|
|
|
|
|
|
|
/**
|
2015-03-18 02:02:32 -07:00
|
|
|
* Place aArea in the first column (in row aArea->mRows.mStart) starting at
|
|
|
|
* aStartCol without overlapping other items. The resulting aArea may
|
|
|
|
* overflow the current implicit grid bounds.
|
|
|
|
* Pre-condition: aArea->mRows.IsDefinite() is true.
|
|
|
|
* Post-condition: aArea->IsDefinite() is true.
|
|
|
|
*/
|
|
|
|
void PlaceAutoCol(uint32_t aStartCol, GridArea* aArea) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the first column in row aLockedRow starting at aStartCol where aArea
|
|
|
|
* could be placed without overlapping other items. The returned column may
|
|
|
|
* cause aArea to overflow the current implicit grid bounds if placed there.
|
|
|
|
*/
|
|
|
|
uint32_t FindAutoCol(uint32_t aStartCol, uint32_t aLockedRow,
|
|
|
|
const GridArea* aArea) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Place aArea in the first row (in column aArea->mCols.mStart) starting at
|
|
|
|
* aStartRow without overlapping other items. The resulting aArea may
|
|
|
|
* overflow the current implicit grid bounds.
|
|
|
|
* Pre-condition: aArea->mCols.IsDefinite() is true.
|
|
|
|
* Post-condition: aArea->IsDefinite() is true.
|
|
|
|
*/
|
|
|
|
void PlaceAutoRow(uint32_t aStartRow, GridArea* aArea) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the first row in column aLockedCol starting at aStartRow where aArea
|
|
|
|
* could be placed without overlapping other items. The returned row may
|
|
|
|
* cause aArea to overflow the current implicit grid bounds if placed there.
|
|
|
|
*/
|
|
|
|
uint32_t FindAutoRow(uint32_t aLockedCol, uint32_t aStartRow,
|
|
|
|
const GridArea* aArea) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Place aArea in the first column starting at aStartCol,aStartRow without
|
|
|
|
* causing it to overlap other items or overflow mGridColEnd.
|
|
|
|
* If there's no such column in aStartRow, continue in position 1,aStartRow+1.
|
|
|
|
* Pre-condition: aArea->mCols.IsAuto() && aArea->mRows.IsAuto() is true.
|
|
|
|
* Post-condition: aArea->IsDefinite() is true.
|
|
|
|
*/
|
|
|
|
void PlaceAutoAutoInRowOrder(uint32_t aStartCol, uint32_t aStartRow,
|
|
|
|
GridArea* aArea) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Place aArea in the first row starting at aStartCol,aStartRow without
|
|
|
|
* causing it to overlap other items or overflow mGridRowEnd.
|
|
|
|
* If there's no such row in aStartCol, continue in position aStartCol+1,1.
|
|
|
|
* Pre-condition: aArea->mCols.IsAuto() && aArea->mRows.IsAuto() is true.
|
|
|
|
* Post-condition: aArea->IsDefinite() is true.
|
|
|
|
*/
|
|
|
|
void PlaceAutoAutoInColOrder(uint32_t aStartCol, uint32_t aStartRow,
|
|
|
|
GridArea* aArea) const;
|
|
|
|
|
2015-03-26 11:57:39 -07:00
|
|
|
/**
|
|
|
|
* Place an abs.pos. child and return its grid area.
|
|
|
|
* @note the resulting area may still have 'auto' lines in one or both
|
2015-04-30 11:42:50 -07:00
|
|
|
* dimensions (represented as kAutoLine).
|
2015-03-26 11:57:39 -07:00
|
|
|
* @param aChild the abs.pos. grid item to place
|
|
|
|
* @param aStyle the StylePosition() for the grid container
|
|
|
|
*/
|
|
|
|
GridArea PlaceAbsPos(nsIFrame* aChild, const nsStylePosition* aStyle);
|
|
|
|
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* Place all child frames into the grid and expand the (implicit) grid as
|
|
|
|
* needed. The allocated GridAreas are stored in the GridAreaProperty
|
|
|
|
* frame property on the child frame.
|
2015-03-26 11:57:39 -07:00
|
|
|
* @param aIter a grid item iterator
|
2015-03-18 02:02:32 -07:00
|
|
|
* @param aStyle the StylePosition() for the grid container
|
|
|
|
*/
|
2015-03-26 11:57:39 -07:00
|
|
|
void PlaceGridItems(GridItemCSSOrderIterator& aIter,
|
|
|
|
const nsStylePosition* aStyle);
|
2015-03-18 02:02:32 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the end lines of the Explicit Grid (mExplicitGridCol[Row]End).
|
|
|
|
* This is determined by the larger of the number of rows/columns defined
|
|
|
|
* by 'grid-template-areas' and the 'grid-template-rows'/'-columns', plus one.
|
|
|
|
* Also initialize the Implicit Grid (mGridCol[Row]End) to the same values.
|
|
|
|
* @param aStyle the StylePosition() for the grid container
|
|
|
|
*/
|
|
|
|
void InitializeGridBounds(const nsStylePosition* aStyle);
|
|
|
|
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* Inflate the implicit grid to include aArea.
|
|
|
|
* @param aArea may be definite or auto
|
|
|
|
*/
|
|
|
|
void InflateGridFor(const GridArea& aArea)
|
|
|
|
{
|
|
|
|
mGridColEnd = std::max(mGridColEnd, aArea.mCols.HypotheticalEnd());
|
|
|
|
mGridRowEnd = std::max(mGridRowEnd, aArea.mRows.HypotheticalEnd());
|
2015-04-30 11:42:50 -07:00
|
|
|
MOZ_ASSERT(mGridColEnd <= uint32_t(nsStyleGridLine::kMaxLine -
|
2015-04-30 11:42:50 -07:00
|
|
|
nsStyleGridLine::kMinLine - 1) &&
|
2015-04-30 11:42:50 -07:00
|
|
|
mGridRowEnd <= uint32_t(nsStyleGridLine::kMaxLine -
|
2015-04-30 11:42:50 -07:00
|
|
|
nsStyleGridLine::kMinLine - 1));
|
2015-03-18 02:02:32 -07:00
|
|
|
}
|
|
|
|
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* Calculate track sizes.
|
|
|
|
*/
|
|
|
|
void CalculateTrackSizes(const mozilla::LogicalSize& aPercentageBasis,
|
|
|
|
const nsStylePosition* aStyle,
|
|
|
|
nsTArray<TrackSize>& aColSizes,
|
|
|
|
nsTArray<TrackSize>& aRowSizes);
|
|
|
|
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* Helper method for ResolveLineRange.
|
|
|
|
* @see ResolveLineRange
|
|
|
|
* @return a pair (start,end) of lines
|
|
|
|
*/
|
2015-04-30 11:42:50 -07:00
|
|
|
typedef std::pair<int32_t, int32_t> LinePair;
|
2015-03-18 02:02:32 -07:00
|
|
|
LinePair ResolveLineRangeHelper(const nsStyleGridLine& aStart,
|
|
|
|
const nsStyleGridLine& aEnd,
|
|
|
|
const nsTArray<nsTArray<nsString>>& aLineNameList,
|
|
|
|
uint32_t GridNamedArea::* aAreaStart,
|
|
|
|
uint32_t GridNamedArea::* aAreaEnd,
|
|
|
|
uint32_t aExplicitGridEnd,
|
|
|
|
const nsStylePosition* aStyle);
|
|
|
|
|
2015-01-14 13:59:59 -08:00
|
|
|
/**
|
|
|
|
* XXX temporary - move the ImplicitNamedAreas stuff to the style system.
|
|
|
|
* The implicit area names that come from x-start .. x-end lines in
|
|
|
|
* grid-template-columns / grid-template-rows are stored in this frame
|
|
|
|
* property when needed, as a ImplicitNamedAreas* value.
|
|
|
|
*/
|
2015-02-04 15:22:27 -08:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(ImplicitNamedAreasProperty,
|
|
|
|
DeleteValue<ImplicitNamedAreas>)
|
2015-01-14 13:59:59 -08:00
|
|
|
void InitImplicitNamedAreas(const nsStylePosition* aStyle);
|
|
|
|
void AddImplicitNamedAreas(const nsTArray<nsTArray<nsString>>& aLineNameLists);
|
|
|
|
typedef nsTHashtable<nsStringHashKey> ImplicitNamedAreas;
|
|
|
|
ImplicitNamedAreas* GetImplicitNamedAreas() const {
|
|
|
|
return static_cast<ImplicitNamedAreas*>(Properties().Get(ImplicitNamedAreasProperty()));
|
|
|
|
}
|
2015-03-18 02:02:32 -07:00
|
|
|
bool HasImplicitNamedArea(const nsString& aName) const {
|
|
|
|
ImplicitNamedAreas* areas = GetImplicitNamedAreas();
|
|
|
|
return areas && areas->Contains(aName);
|
|
|
|
}
|
2015-01-14 13:59:59 -08:00
|
|
|
|
2015-03-18 02:02:32 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(GridAreaProperty, DeleteValue<GridArea>)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A convenience method to get the stored GridArea* for a frame.
|
|
|
|
*/
|
|
|
|
static GridArea* GetGridAreaForChild(nsIFrame* aChild) {
|
|
|
|
return static_cast<GridArea*>(aChild->Properties().Get(GridAreaProperty()));
|
|
|
|
}
|
|
|
|
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* Return the containing block for a grid item occupying aArea.
|
|
|
|
* @param aColSizes column track sizes
|
|
|
|
* @param aRowSizes row track sizes
|
|
|
|
*/
|
|
|
|
LogicalRect ContainingBlockFor(const WritingMode& aWM,
|
|
|
|
const GridArea& aArea,
|
|
|
|
const nsTArray<TrackSize>& aColSizes,
|
|
|
|
const nsTArray<TrackSize>& aRowSizes) const;
|
|
|
|
|
2015-03-26 11:57:39 -07:00
|
|
|
/**
|
|
|
|
* Return the containing block for an abs.pos. grid item occupying aArea.
|
|
|
|
* Any 'auto' lines in the grid area will be aligned with grid container
|
|
|
|
* containing block on that side.
|
|
|
|
* @param aColSizes column track sizes
|
|
|
|
* @param aRowSizes row track sizes
|
|
|
|
* @param aGridOrigin the origin of the grid
|
|
|
|
* @param aGridCB the grid container containing block (its padding area)
|
|
|
|
*/
|
|
|
|
LogicalRect ContainingBlockForAbsPos(const WritingMode& aWM,
|
|
|
|
const GridArea& aArea,
|
|
|
|
const nsTArray<TrackSize>& aColSizes,
|
|
|
|
const nsTArray<TrackSize>& aRowSizes,
|
|
|
|
const LogicalPoint& aGridOrigin,
|
|
|
|
const LogicalRect& aGridCB) const;
|
|
|
|
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* Reflow and place our children.
|
|
|
|
*/
|
2015-03-26 11:57:39 -07:00
|
|
|
void ReflowChildren(GridItemCSSOrderIterator& aIter,
|
|
|
|
const LogicalRect& aContentArea,
|
2015-03-18 02:02:32 -07:00
|
|
|
const nsTArray<TrackSize>& aColSizes,
|
|
|
|
const nsTArray<TrackSize>& aRowSizes,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
2014-05-19 16:57:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
void SanityCheckAnonymousGridItems() const;
|
|
|
|
#endif // DEBUG
|
2015-03-18 02:02:32 -07:00
|
|
|
|
|
|
|
private:
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* State for each cell in the grid.
|
|
|
|
*/
|
|
|
|
CellMap mCellMap;
|
|
|
|
|
2015-03-18 02:02:32 -07:00
|
|
|
/**
|
|
|
|
* The last column grid line (1-based) in the explicit grid.
|
|
|
|
* (i.e. the number of explicit columns + 1)
|
|
|
|
*/
|
|
|
|
uint32_t mExplicitGridColEnd;
|
|
|
|
/**
|
|
|
|
* The last row grid line (1-based) in the explicit grid.
|
|
|
|
* (i.e. the number of explicit rows + 1)
|
|
|
|
*/
|
|
|
|
uint32_t mExplicitGridRowEnd;
|
2015-04-30 11:42:50 -07:00
|
|
|
// Same for the implicit grid, except these become zero-based after
|
|
|
|
// resolving definite lines.
|
|
|
|
uint32_t mGridColEnd;
|
|
|
|
uint32_t mGridRowEnd;
|
2015-04-30 11:42:50 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Offsets from the start of the implicit grid to the start of the translated
|
|
|
|
* explicit grid. They are zero if there are no implicit lines before 1,1.
|
|
|
|
* e.g. "grid-column: span 3 / 1" makes mExplicitGridOffsetCol = 3 and the
|
2015-04-30 11:42:50 -07:00
|
|
|
* corresponding GridArea::mCols will be 0 / 3 in the zero-based translated
|
|
|
|
* grid.
|
2015-04-30 11:42:50 -07:00
|
|
|
*/
|
|
|
|
uint32_t mExplicitGridOffsetCol;
|
|
|
|
uint32_t mExplicitGridOffsetRow;
|
|
|
|
|
2015-03-26 11:57:39 -07:00
|
|
|
/**
|
|
|
|
* True iff the normal flow children are already in CSS 'order' in the
|
|
|
|
* order they occur in the child frame list.
|
|
|
|
*/
|
|
|
|
bool mIsNormalFlowInCSSOrder : 1;
|
2014-02-26 23:45:29 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsGridContainerFrame_h___ */
|