--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -593,21 +593,28 @@ struct nsGridContainerFrame::GridItemInf
// start/end edge (excluding grid-aligned abs.pos. frames)
eStartEdge = 0x200,
eEndEdge = 0x400,
eEdgeBits = eStartEdge | eEndEdge,
// Set if this item was auto-placed in this axis.
eAutoPlacement = 0x800,
// Set if this item is the last item in its track (masonry layout only)
eIsLastItemInMasonryTrack = 0x1000,
+ // bits set during the track sizing step
+ eTrackSizingBits = eIsFlexing | eApplyAutoMinSize | eClampMarginBoxMinSize,
// clang-format on
};
GridItemInfo(nsIFrame* aFrame, const GridArea& aArea);
+ /**
+ * Reset state in aAxis that were set during the track sizing step.
+ */
+ void ResetTrackSizingFlags(LogicalAxis aAxis);
+
static bool BaselineAlignmentAffectsEndSide(StateBits state) {
return state & StateBits::eEndSideBaseline;
}
/**
* Inhibit subgrid layout unless the item is placed in the first "track" in
* a parent masonry-axis, or has definite placement or spans all tracks in
* the parent grid-axis.
@@ -799,16 +806,20 @@ GridItemInfo::GridItemInfo(nsIFrame* aFr
mState[isOrthogonal ? eLogicalAxisInline : eLogicalAxisBlock] |=
StateBits::eIsSubgrid;
}
}
mBaselineOffset[eLogicalAxisBlock] = nscoord(0);
mBaselineOffset[eLogicalAxisInline] = nscoord(0);
}
+void GridItemInfo::ResetTrackSizingFlags(LogicalAxis aAxis) {
+ mState[aAxis] &= ~StateBits::eTrackSizingBits;
+}
+
void GridItemInfo::ReverseDirection(LogicalAxis aAxis, uint32_t aGridEnd) {
mArea.LineRangeForAxis(aAxis).ReverseDirection(aGridEnd);
ItemState& state = mState[aAxis];
ItemState newState = state & ~ItemState::eEdgeBits;
if (state & ItemState::eStartEdge) {
newState |= ItemState::eEndEdge;
}
if (state & ItemState::eEndEdge) {
@@ -2838,22 +2849,16 @@ struct MOZ_STACK_CLASS nsGridContainerFr
/**
* Calculate our track sizes in the given axis.
*/
void CalculateTrackSizesForAxis(LogicalAxis aAxis, const Grid& aGrid,
nscoord aCBSize,
SizingConstraint aConstraint);
/**
- * Calculate our track sizes.
- */
- void CalculateTrackSizes(const Grid& aGrid, const LogicalSize& aContentBox,
- SizingConstraint aConstraint);
-
- /**
* Return the percentage basis for a grid item in its writing-mode.
* If aAxis is eLogicalAxisInline then we return NS_UNCONSTRAINEDSIZE in
* both axes since we know all track sizes are indefinite at this point
* (we calculate column sizes before row sizes). Otherwise, assert that
* column sizes are known and calculate the size for aGridItem.mArea.mCols
* and use NS_UNCONSTRAINEDSIZE in the other axis.
* @param aAxis the axis we're currently calculating track sizes for
*/
@@ -3667,25 +3672,16 @@ void nsGridContainerFrame::GridReflowInp
(mFrame->HasSubgridItems() || mFrame->IsSubgrid())) {
mFrame->StoreUsedTrackSizes(aAxis, tracks.mSizes);
}
// positions and sizes are now final
tracks.mCanResolveLineRangeSize = true;
}
-void nsGridContainerFrame::GridReflowInput::CalculateTrackSizes(
- const Grid& aGrid, const LogicalSize& aContentBox,
- SizingConstraint aConstraint) {
- CalculateTrackSizesForAxis(eLogicalAxisInline, aGrid, aContentBox.ISize(mWM),
- aConstraint);
- CalculateTrackSizesForAxis(eLogicalAxisBlock, aGrid, aContentBox.BSize(mWM),
- aConstraint);
-}
-
// Align an item's margin box in its aAxis inside aCBSize.
static void AlignJustifySelf(StyleAlignFlags aAlignment, LogicalAxis aAxis,
AlignJustifyFlags aFlags, nscoord aBaselineAdjust,
nscoord aCBSize, const ReflowInput& aRI,
const LogicalSize& aChildSize,
LogicalPoint* aPos) {
MOZ_ASSERT(aAlignment != StyleAlignFlags::AUTO,
"unexpected 'auto' "
@@ -8503,38 +8499,57 @@ void nsGridContainerFrame::Reflow(nsPres
} else {
auto* subgrid = GetProperty(Subgrid::Prop());
MOZ_ASSERT(subgrid, "an ancestor forgot to call PlaceGridItems?");
gridReflowInput.mGridItems = subgrid->mGridItems.Clone();
gridReflowInput.mAbsPosItems = subgrid->mAbsPosItems.Clone();
grid.mGridColEnd = subgrid->mGridColEnd;
grid.mGridRowEnd = subgrid->mGridRowEnd;
}
- gridReflowInput.CalculateTrackSizes(grid, computedSize,
- SizingConstraint::NoConstraint);
+
+ gridReflowInput.CalculateTrackSizesForAxis(eLogicalAxisInline, grid,
+ aReflowInput.ComputedISize(),
+ SizingConstraint::NoConstraint);
+
+ bSize = aReflowInput.ComputedBSize();
+ if (bSize == NS_UNCONSTRAINEDSIZE && !IsMasonry(eLogicalAxisBlock)) {
+ // Do an intrinsic sizing step for the block axis so that we can resolve
+ // row gap/track percentage sizes in the final step.
+ gridReflowInput.CalculateTrackSizesForAxis(eLogicalAxisBlock, grid,
+ bSize, SizingConstraint::NoConstraint);
+ auto& rows = gridReflowInput.mRows;
+ if (MOZ_LIKELY(!IsSubgrid(eLogicalAxisBlock))) {
+ // Note: we can't use GridLineEdge here since we haven't calculated
+ // the rows' mPosition yet (happens in AlignJustifyContent later).
+ bSize = 0;
+ for (const auto& sz : rows.mSizes) {
+ bSize += sz.mBase;
+ }
+ bSize += rows.SumOfGridGaps();
+ } else {
+ bSize = rows.GridLineEdge(
+ rows.mSizes.Length(), GridLineSide::BeforeGridGap);
+ }
+ bSize = NS_CSS_MINMAX(bSize,
+ aReflowInput.ComputedMinBSize(),
+ aReflowInput.ComputedMaxBSize());
+ // Reset some track sizing state before final step below.
+ for (auto& item : gridReflowInput.mGridItems) {
+ item.ResetTrackSizingFlags(eLogicalAxisBlock);
+ }
+ rows.mCanResolveLineRangeSize = false;
+ }
+ gridReflowInput.CalculateTrackSizesForAxis(eLogicalAxisBlock, grid, bSize,
+ SizingConstraint::NoConstraint);
+
// XXX Technically incorrect: We're ignoring our row sizes, when really
// we should use them but *they* should be computed as if we had no
// children. To be fixed in bug 1488878.
- if (!aReflowInput.mStyleDisplay->IsContainSize()) {
- if (IsMasonry(eLogicalAxisBlock)) {
- bSize = computedBSize;
- } else {
- const auto& rowSizes = gridReflowInput.mRows.mSizes;
- if (MOZ_LIKELY(!IsSubgrid(eLogicalAxisBlock))) {
- // Note: we can't use GridLineEdge here since we haven't calculated
- // the rows' mPosition yet (happens in AlignJustifyContent below).
- for (const auto& sz : rowSizes) {
- bSize += sz.mBase;
- }
- bSize += gridReflowInput.mRows.SumOfGridGaps();
- } else if (computedBSize == NS_UNCONSTRAINEDSIZE) {
- bSize = gridReflowInput.mRows.GridLineEdge(
- rowSizes.Length(), GridLineSide::BeforeGridGap);
- }
- }
+ if (aReflowInput.mStyleDisplay->IsContainSize()) {
+ bSize = 0;
}
} else {
consumedBSize = ConsumedBSize(wm);
gridReflowInput.InitializeForContinuation(this, consumedBSize);
// XXX Technically incorrect: We're ignoring our row sizes, when really
// we should use them but *they* should be computed as if we had no
// children. To be fixed in bug 1488878.
if (!aReflowInput.mStyleDisplay->IsContainSize()) {
--- a/layout/reftests/css-grid/grid-max-sizing-flex-006-ref.html
+++ b/layout/reftests/css-grid/grid-max-sizing-flex-006-ref.html
@@ -33,18 +33,17 @@ span {
</body>
<head>
<div class="grid" style="grid-template-rows: 3px 6px 9px 6px 3px;">
<span class="c1"></span>
<span class="c2"></span>
<span class="c3"></span>
</div>
-
-<div class="grid" style="grid-template-rows: 0.9px 1.8px 2.7px 1.8px 0.9px;">
+<div class="grid" style="height: calc(486px / 60); grid-template-rows: minmax(0,0.1fr) minmax(0,0.2fr) minmax(0,0.3fr) minmax(0,0.2fr) minmax(0,0.1fr);">
<span class="c1"></span>
<span class="c2"></span>
<span class="c3"></span>
</div>
<div class="grid" style="grid-template-rows: 9px 18px 27px 18px 9px;">
<span class="c1"></span>
<span class="c2"></span>
--- a/layout/reftests/css-grid/grid-repeat-auto-fill-fit-002-ref.html
+++ b/layout/reftests/css-grid/grid-repeat-auto-fill-fit-002-ref.html
@@ -78,27 +78,24 @@ x:last-child {
fill,fit {
float: left;
height: 400px;
}
.zero-progress {
grid-row-gap: calc(10px - 1%);
- grid-template-rows: [a] 10px repeat(3, [b] calc(4px / 10) [c]) [d];
+ grid-template-rows: [a] 10px repeat(3, [b] 0 [c]) [d];
height:40px;
}
.w50.zero-progress {
- grid-row-gap: calc(10px - 1%);
- grid-template-rows: [a] 10px repeat(3, [b] 0 [c]) [d];
height:50px;
}
.mw50.zero-progress {
- grid-row-gap: calc(10px - 1%);
- grid-template-rows: [a] 10px repeat(4, [b] calc(5px / 10) [c]) [d];
+ grid-template-rows: [a] 10px repeat(4, [b] 0 [c]) [d];
height:50px;
}
</style>
</head>
<body>
<fill>
--- a/layout/reftests/css-grid/grid-track-percent-sizing-001-ref.html
+++ b/layout/reftests/css-grid/grid-track-percent-sizing-001-ref.html
@@ -89,24 +89,24 @@ x {
.tD {
grid-template-columns: 0;
grid-template-rows: 0;
}
</style>
</head>
<body>
-<div class="grid t0"><span><t></t></span><x></x></div>
-<div class="grid t1"><span><t></t></span><x></x></div>
-<div class="grid t2"><span><t></t></span><x></x></div>
+<div class="grid t0" style="height:15px; grid-template-rows:6px 10px"><span><t></t></span><x></x></div>
+<div class="grid t1" style="height:15px; grid-template-rows:16px 10px"><span><t></t></span><x></x></div>
+<div class="grid t2" style="height:15px; grid-template-rows:6px 10px"><span><t></t></span><x></x></div>
<div class="grid t3"><span><t></t></span><x></x></div>
<div class="grid t4"><span><t></t></span><x></x></div>
-<div class="grid t5"><span><t></t></span><x></x></div>
-<div class="grid t6"><span><t></t></span><x></x></div>
-<div class="grid t7"><span><t></t></span><x></x></div>
+<div class="grid t5" style="height:15px; grid-template-rows:10px 10px"><span><t></t></span><x></x></div>
+<div class="grid t6" style="height:15px; grid-template-rows:6px 10px"><span><t></t></span><x></x></div>
+<div class="grid t7" style="height:15px; grid-template-rows:6px 10px"><span><t></t></span><x></x></div>
<div class="grid t8"><span><t></t></span><x></x></div>
<div class="grid t9"><span><t></t></span><x></x></div>
<div class="grid tA"><span><t></t></span><x></x></div>
<div class="grid tD" style="width:0"><span><t></t></span><x></x></div>
<br clear="all">
<div class="grid sz t0"><span><t></t></span><x></x></div>
--- a/layout/reftests/css-grid/grid-track-percent-sizing-001.html
+++ b/layout/reftests/css-grid/grid-track-percent-sizing-001.html
@@ -83,16 +83,17 @@ body,html { color:black; background:whit
span {
background: grey;
min-width: 0;
min-height: 0;
line-height: 0;
align-self: start;
justify-self: start;
+ vertical-align: top;
}
t {
display: inline-block;
width: 30px;
height: 5px;
}
x {
background: lime;
--- a/testing/web-platform/meta/css/css-contain/contain-size-grid-004.html.ini
+++ b/testing/web-platform/meta/css/css-contain/contain-size-grid-004.html.ini
@@ -21,22 +21,16 @@
expected: FAIL
[.grid 2]
expected: FAIL
[.grid 4]
expected: FAIL
- [.grid 7]
- expected: FAIL
-
- [.grid 9]
- expected: FAIL
-
[.grid 8]
expected: FAIL
[.grid 26]
expected: FAIL
[.grid 20]
expected: FAIL
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-grid/alignment/grid-content-alignment-second-pass-002.html.ini
+++ /dev/null
@@ -1,25 +0,0 @@
-[grid-content-alignment-second-pass-002.html]
- [.grid 1]
- expected: FAIL
-
- [.grid 3]
- expected: FAIL
-
- [.grid 2]
- expected: FAIL
-
- [.grid 5]
- expected: FAIL
-
- [.grid 4]
- expected: FAIL
-
- [.grid 7]
- expected: FAIL
-
- [.grid 6]
- expected: FAIL
-
- [.grid 8]
- expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-grid/grid-definition/grid-percentage-rows-indefinite-height-001.html.ini
+++ /dev/null
@@ -1,313 +0,0 @@
-[grid-percentage-rows-indefinite-height-001.html]
- [.grid 2]
- expected: FAIL
-
- [.grid 3]
- expected: FAIL
-
- [.grid 5]
- expected: FAIL
-
- [.grid 6]
- expected: FAIL
-
- [.grid 8]
- expected: FAIL
-
- [.grid 9]
- expected: FAIL
-
- [.grid 11]
- expected: FAIL
-
- [.grid 12]
- expected: FAIL
-
- [.grid 14]
- expected: FAIL
-
- [.grid 15]
- expected: FAIL
-
- [.grid 17]
- expected: FAIL
-
- [.grid 18]
- expected: FAIL
-
- [.grid 20]
- expected: FAIL
-
- [.grid 21]
- expected: FAIL
-
- [.grid 23]
- expected: FAIL
-
- [.grid 24]
- expected: FAIL
-
- [.grid 25]
- expected: FAIL
-
- [.grid 26]
- expected: FAIL
-
- [.grid 27]
- expected: FAIL
-
- [.grid 28]
- expected: FAIL
-
- [.grid 29]
- expected: FAIL
-
- [.grid 30]
- expected: FAIL
-
- [.grid 31]
- expected: FAIL
-
- [.grid 32]
- expected: FAIL
-
- [.grid 33]
- expected: FAIL
-
- [.grid 34]
- expected: FAIL
-
- [.grid 35]
- expected: FAIL
-
- [.grid 36]
- expected: FAIL
-
- [.grid 37]
- expected: FAIL
-
- [.grid 38]
- expected: FAIL
-
- [.grid 39]
- expected: FAIL
-
- [.grid 40]
- expected: FAIL
-
- [.grid 41]
- expected: FAIL
-
- [.grid 42]
- expected: FAIL
-
- [.grid 43]
- expected: FAIL
-
- [.grid 44]
- expected: FAIL
-
- [.grid 45]
- expected: FAIL
-
- [.grid 46]
- expected: FAIL
-
- [.grid 47]
- expected: FAIL
-
- [.grid 48]
- expected: FAIL
-
- [.grid 49]
- expected: FAIL
-
- [.grid 50]
- expected: FAIL
-
- [.grid 51]
- expected: FAIL
-
- [.grid 52]
- expected: FAIL
-
- [.grid 53]
- expected: FAIL
-
- [.grid 54]
- expected: FAIL
-
- [.grid 55]
- expected: FAIL
-
- [.grid 56]
- expected: FAIL
-
- [.grid 57]
- expected: FAIL
-
- [.grid 58]
- expected: FAIL
-
- [.grid 59]
- expected: FAIL
-
- [.grid 60]
- expected: FAIL
-
- [.grid 61]
- expected: FAIL
-
- [.grid 62]
- expected: FAIL
-
- [.grid 63]
- expected: FAIL
-
- [.grid 64]
- expected: FAIL
-
- [.grid 65]
- expected: FAIL
-
- [.grid 66]
- expected: FAIL
-
- [.grid 67]
- expected: FAIL
-
- [.grid 68]
- expected: FAIL
-
- [.grid 69]
- expected: FAIL
-
- [.grid 70]
- expected: FAIL
-
- [.grid 71]
- expected: FAIL
-
- [.grid 72]
- expected: FAIL
-
- [.grid 74]
- expected: FAIL
-
- [.grid 75]
- expected: FAIL
-
- [.grid 76]
- expected: FAIL
-
- [.grid 77]
- expected: FAIL
-
- [.grid 78]
- expected: FAIL
-
- [.grid 80]
- expected: FAIL
-
- [.grid 81]
- expected: FAIL
-
- [.grid 82]
- expected: FAIL
-
- [.grid 83]
- expected: FAIL
-
- [.grid 84]
- expected: FAIL
-
- [.grid 86]
- expected: FAIL
-
- [.grid 87]
- expected: FAIL
-
- [.grid 88]
- expected: FAIL
-
- [.grid 89]
- expected: FAIL
-
- [.grid 90]
- expected: FAIL
-
- [.grid 92]
- expected: FAIL
-
- [.grid 93]
- expected: FAIL
-
- [.grid 94]
- expected: FAIL
-
- [.grid 95]
- expected: FAIL
-
- [.grid 96]
- expected: FAIL
-
- [.grid 98]
- expected: FAIL
-
- [.grid 99]
- expected: FAIL
-
- [.grid 100]
- expected: FAIL
-
- [.grid 101]
- expected: FAIL
-
- [.grid 102]
- expected: FAIL
-
- [.grid 104]
- expected: FAIL
-
- [.grid 105]
- expected: FAIL
-
- [.grid 106]
- expected: FAIL
-
- [.grid 107]
- expected: FAIL
-
- [.grid 108]
- expected: FAIL
-
- [.grid 110]
- expected: FAIL
-
- [.grid 111]
- expected: FAIL
-
- [.grid 112]
- expected: FAIL
-
- [.grid 113]
- expected: FAIL
-
- [.grid 114]
- expected: FAIL
-
- [.grid 116]
- expected: FAIL
-
- [.grid 117]
- expected: FAIL
-
- [.grid 118]
- expected: FAIL
-
- [.grid 119]
- expected: FAIL
-
- [.grid 120]
- expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-grid/grid-definition/grid-percentage-rows-indefinite-height-002.html.ini
+++ /dev/null
@@ -1,13 +0,0 @@
-[grid-percentage-rows-indefinite-height-002.html]
- [.grid 1]
- expected: FAIL
-
- [.grid 2]
- expected: FAIL
-
- [.grid 3]
- expected: FAIL
-
- [.grid 4]
- expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-grid/layout-algorithm/grid-container-percentage-002.html.ini
+++ /dev/null
@@ -1,58 +0,0 @@
-[grid-container-percentage-002.html]
- [.grid 19]
- expected: FAIL
-
- [.grid 18]
- expected: FAIL
-
- [.grid 15]
- expected: FAIL
-
- [.grid 17]
- expected: FAIL
-
- [.grid 16]
- expected: FAIL
-
- [.grid 11]
- expected: FAIL
-
- [.grid 10]
- expected: FAIL
-
- [.grid 13]
- expected: FAIL
-
- [.grid 12]
- expected: FAIL
-
- [.grid 1]
- expected: FAIL
-
- [.grid 5]
- expected: FAIL
-
- [.grid 4]
- expected: FAIL
-
- [.grid 7]
- expected: FAIL
-
- [.grid 6]
- expected: FAIL
-
- [.grid 9]
- expected: FAIL
-
- [.grid 24]
- expected: FAIL
-
- [.grid 21]
- expected: FAIL
-
- [.grid 22]
- expected: FAIL
-
- [.grid 23]
- expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-grid/layout-algorithm/grid-percent-rows-filled-shrinkwrap-001.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[grid-percent-rows-filled-shrinkwrap-001.html]
- expected: FAIL
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-grid/layout-algorithm/grid-percent-rows-spanned-shrinkwrap-001.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[grid-percent-rows-spanned-shrinkwrap-001.html]
- expected: FAIL
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-grid/parsing/grid-columns-rows-get-set-multiple.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[grid-columns-rows-get-set-multiple.html]
- [Test getting grid-template-columns and grid-template-rows set through CSS for element 'gridWithPercentWithoutSize' : grid-template-columns = '3.5px 7px', grid-template-rows = '4px 12px']
- expected: FAIL
-
--- a/testing/web-platform/tests/css/css-grid/layout-algorithm/grid-container-percentage-002.html
+++ b/testing/web-platform/tests/css/css-grid/layout-algorithm/grid-container-percentage-002.html
@@ -12,17 +12,18 @@
<style>
.wrapper {
position: relative;
clear: both;
}
.grid {
font: 10px/1 Ahem;
- width: fit-content;
+ display: inline-grid;
+ vertical-align: top;
}
.abspos {
position: absolute;
}
.fixedSize {
width: 200px;