Bug 1174553 part 5 - [css-grid] Replace the ambiguous Dimension with LogicalAxis. r=dholbert

This commit is contained in:
Mats Palmgren 2015-09-04 22:06:58 +02:00
Родитель 4b66bd9d6c
Коммит 3be8c0c8f4
2 изменённых файлов: 37 добавлений и 44 удалений

Просмотреть файл

@ -228,7 +228,7 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::TrackSizingFunctions
*/
struct MOZ_STACK_CLASS nsGridContainerFrame::Tracks
{
explicit Tracks(Dimension aDimension) : mDimension(aDimension) {}
explicit Tracks(LogicalAxis aAxis) : mAxis(aAxis) {}
void Initialize(const TrackSizingFunctions& aFunctions,
uint32_t aNumTracks,
@ -599,7 +599,7 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::Tracks
#endif
nsAutoTArray<TrackSize, 32> mSizes;
Dimension mDimension;
LogicalAxis mAxis;
};
struct MOZ_STACK_CLASS nsGridContainerFrame::GridReflowState
@ -638,8 +638,8 @@ private:
const WritingMode& aWM)
: mIter(aFrame, kPrincipalList)
, mGridStyle(aGridStyle)
, mCols(eColDimension)
, mRows(eRowDimension)
, mCols(eLogicalAxisInline)
, mRows(eLogicalAxisBlock)
, mColFunctions({
mGridStyle->mGridTemplateColumns.mMinTrackSizingFunctions,
mGridStyle->mGridTemplateColumns.mMaxTrackSizingFunctions,
@ -1650,29 +1650,26 @@ nsGridContainerFrame::Tracks::Initialize(
static nscoord
MinSize(nsIFrame* aChild, nsRenderingContext* aRC, WritingMode aCBWM,
nsGridContainerFrame::Dimension aDimension,
nsLayoutUtils::IntrinsicISizeType aConstraint)
LogicalAxis aAxis, nsLayoutUtils::IntrinsicISizeType aConstraint)
{
PhysicalAxis axis(((aDimension == nsGridContainerFrame::eColDimension) ==
aCBWM.IsVertical()) ? eAxisVertical : eAxisHorizontal);
PhysicalAxis axis(aCBWM.PhysicalAxis(aAxis));
return nsLayoutUtils::MinSizeContributionForAxis(axis, aRC, aChild,
aConstraint);
}
/**
* Return the [min|max]-content contribution of aChild to its parent (i.e.
* the child's margin-box) in aDimension.
* the child's margin-box) in aAxis.
*/
static nscoord
ContentContribution(nsIFrame* aChild,
const nsHTMLReflowState* aReflowState,
nsRenderingContext* aRC,
WritingMode aCBWM,
nsGridContainerFrame::Dimension aDimension,
LogicalAxis aAxis,
nsLayoutUtils::IntrinsicISizeType aConstraint)
{
PhysicalAxis axis(((aDimension == nsGridContainerFrame::eColDimension) ==
aCBWM.IsVertical()) ? eAxisVertical : eAxisHorizontal);
PhysicalAxis axis(aCBWM.PhysicalAxis(aAxis));
nscoord size = nsLayoutUtils::IntrinsicForAxis(axis, aRC, aChild, aConstraint,
nsLayoutUtils::BAIL_IF_REFLOW_NEEDED);
if (size == NS_INTRINSIC_WIDTH_UNKNOWN) {
@ -1717,24 +1714,24 @@ ContentContribution(nsIFrame* aChild,
}
static nscoord
MinContentContribution(nsIFrame* aChild,
const nsHTMLReflowState* aRS,
nsRenderingContext* aRC,
WritingMode aCBWM,
nsGridContainerFrame::Dimension aDimension)
MinContentContribution(nsIFrame* aChild,
const nsHTMLReflowState* aRS,
nsRenderingContext* aRC,
WritingMode aCBWM,
LogicalAxis aAxis)
{
return ContentContribution(aChild, aRS, aRC, aCBWM, aDimension,
return ContentContribution(aChild, aRS, aRC, aCBWM, aAxis,
nsLayoutUtils::MIN_ISIZE);
}
static nscoord
MaxContentContribution(nsIFrame* aChild,
const nsHTMLReflowState* aRS,
nsRenderingContext* aRC,
WritingMode aCBWM,
nsGridContainerFrame::Dimension aDimension)
MaxContentContribution(nsIFrame* aChild,
const nsHTMLReflowState* aRS,
nsRenderingContext* aRC,
WritingMode aCBWM,
LogicalAxis aAxis)
{
return ContentContribution(aChild, aRS, aRC, aCBWM, aDimension,
return ContentContribution(aChild, aRS, aRC, aCBWM, aAxis,
nsLayoutUtils::PREF_ISIZE);
}
@ -1825,23 +1822,23 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSizeStep1(
const nsHTMLReflowState* rs = aState.mReflowState;
nsRenderingContext* rc = &aState.mRenderingContext;
if (sz.mState & TrackSize::eAutoMinSizing) {
nscoord s = MinSize(aGridItem, rc, wm, mDimension, aConstraint);
nscoord s = MinSize(aGridItem, rc, wm, mAxis, aConstraint);
sz.mBase = std::max(sz.mBase, s);
} else if ((sz.mState & TrackSize::eMinContentMinSizing) ||
(aConstraint == nsLayoutUtils::MIN_ISIZE &&
(sz.mState & TrackSize::eFlexMinSizing))) {
nscoord s = MinContentContribution(aGridItem, rs, rc, wm, mDimension);
nscoord s = MinContentContribution(aGridItem, rs, rc, wm, mAxis);
minContentContribution.emplace(s);
sz.mBase = std::max(sz.mBase, minContentContribution.value());
} else if (sz.mState & TrackSize::eMaxContentMinSizing) {
nscoord s = MaxContentContribution(aGridItem, rs, rc, wm, mDimension);
nscoord s = MaxContentContribution(aGridItem, rs, rc, wm, mAxis);
maxContentContribution.emplace(s);
sz.mBase = std::max(sz.mBase, maxContentContribution.value());
}
// max sizing
if (sz.mState & TrackSize::eMinContentMaxSizing) {
if (minContentContribution.isNothing()) {
nscoord s = MinContentContribution(aGridItem, rs, rc, wm, mDimension);
nscoord s = MinContentContribution(aGridItem, rs, rc, wm, mAxis);
minContentContribution.emplace(s);
}
if (sz.mLimit == NS_UNCONSTRAINEDSIZE) {
@ -1852,7 +1849,7 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSizeStep1(
} else if (sz.mState & (TrackSize::eAutoMaxSizing |
TrackSize::eMaxContentMaxSizing)) {
if (maxContentContribution.isNothing()) {
nscoord s = MaxContentContribution(aGridItem, rs, rc, wm, mDimension);
nscoord s = MaxContentContribution(aGridItem, rs, rc, wm, mAxis);
maxContentContribution.emplace(s);
}
if (sz.mLimit == NS_UNCONSTRAINEDSIZE) {
@ -1912,7 +1909,7 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSize(
uint32_t span = lineRange.Extent();
if (span == 1) {
// Step 1. Size tracks to fit non-spanning items.
aGridItems[iter.GridItemIndex()].mIsFlexing[mDimension] =
aGridItems[iter.GridItemIndex()].mIsFlexing[mAxis] =
ResolveIntrinsicSizeStep1(aState, aFunctions, aPercentageBasis,
aConstraint, lineRange, child);
} else {
@ -1930,25 +1927,25 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSize(
stateBitsPerSpan[span] |= state;
nscoord minSize = 0;
if (state & (flexMin | TrackSize::eIntrinsicMinSizing)) { // for 2.1
minSize = MinSize(child, rc, wm, mDimension, aConstraint);
minSize = MinSize(child, rc, wm, mAxis, aConstraint);
}
nscoord minContent = 0;
if (state & (flexMin | TrackSize::eMinOrMaxContentMinSizing | // for 2.2
TrackSize::eIntrinsicMaxSizing)) { // for 2.5
minContent = MinContentContribution(child, aState.mReflowState,
rc, wm, mDimension);
rc, wm, mAxis);
}
nscoord maxContent = 0;
if (state & (TrackSize::eMaxContentMinSizing | // for 2.3
TrackSize::eAutoOrMaxContentMaxSizing)) { // for 2.6
maxContent = MaxContentContribution(child, aState.mReflowState,
rc, wm, mDimension);
rc, wm, mAxis);
}
step2Items.AppendElement(
Step2ItemData({span, state, lineRange, minSize,
minContent, maxContent, child}));
} else {
aGridItems[iter.GridItemIndex()].mIsFlexing[mDimension] =
aGridItems[iter.GridItemIndex()].mIsFlexing[mAxis] =
!!(state & TrackSize::eFlexMaxSizing);
}
}
@ -2203,15 +2200,14 @@ nsGridContainerFrame::Tracks::FindUsedFlexFraction(
// a flex track with its max-content contribution as 'space to fill'
for (; !iter.AtEnd(); iter.Next()) {
const GridItemInfo& item = aGridItems[iter.GridItemIndex()];
if (item.mIsFlexing[mDimension]) {
nscoord spaceToFill = MaxContentContribution(*iter, rs, rc, wm,
mDimension);
if (item.mIsFlexing[mAxis]) {
nscoord spaceToFill = MaxContentContribution(*iter, rs, rc, wm, mAxis);
if (spaceToFill <= 0) {
continue;
}
// ... and all its spanned tracks as input.
const LineRange& range =
mDimension == eColDimension ? item.mArea.mCols : item.mArea.mRows;
mAxis == eLogicalAxisInline ? item.mArea.mCols : item.mArea.mRows;
nsTArray<uint32_t> itemFlexTracks;
for (uint32_t i = range.mStart, end = range.mEnd; i < end; ++i) {
if (mSizes[i].mState & TrackSize::eFlexMaxSizing) {

Просмотреть файл

@ -85,11 +85,6 @@ public:
StateBits mState;
};
// @note when used in a function that measures a child's size, eColDimension
// means we're calculating the child's contribution to the column sizing.
// (i.e. the child's inline size if its 'writing-mode' is horizontal)
enum Dimension { eColDimension, eRowDimension };
// @see nsAbsoluteContainingBlock::Reflow about this magic number
static const nscoord VERY_LIKELY_A_GRID_CONTAINER = -123456789;
@ -294,7 +289,9 @@ protected:
}
GridArea mArea;
bool mIsFlexing[2]; // does the item span a flex track? (index by Dimension)
bool mIsFlexing[2]; // does the item span a flex track? (LogicalAxis index)
static_assert(mozilla::eLogicalAxisBlock == 0, "unexpected index value");
static_assert(mozilla::eLogicalAxisInline == 1, "unexpected index value");
#ifdef DEBUG
nsIFrame* mFrame;
#endif