author | Mats Palmgren <mats@mozilla.com> |
Wed, 21 Sep 2016 02:14:40 +0200 | |
changeset 314552 | 941f9bfc8b66224ca896710185c9d16dca5b565e |
parent 314551 | 8a25ca70d82f803a0f0c6965456595be6586ed23 |
child 314553 | 8c51ff54a0ea1e6d527a80b157d67112235db01f |
push id | 81928 |
push user | mpalmgren@mozilla.com |
push date | Wed, 21 Sep 2016 00:14:52 +0000 |
treeherder | mozilla-inbound@8c51ff54a0ea [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | dholbert |
bugs | 1280798 |
milestone | 52.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -5968,20 +5968,61 @@ nsGridContainerFrame::IntrinsicISize(nsR IntrinsicISizeType aConstraint) { RenumberList(); // Calculate the sum of column sizes under aConstraint. // http://dev.w3.org/csswg/css-grid/#intrinsic-sizes GridReflowInput state(this, *aRenderingContext); InitImplicitNamedAreas(state.mGridStyle); // XXX optimize + + auto GetDefiniteSizes = [] (const nsStyleCoord& aMinCoord, + const nsStyleCoord& aSizeCoord, + const nsStyleCoord& aMaxCoord, + nscoord* aMin, + nscoord* aSize, + nscoord* aMax) { + if (aMinCoord.ConvertsToLength()) { + *aMin = aMinCoord.ToLength(); + } + if (aMaxCoord.ConvertsToLength()) { + *aMax = std::max(*aMin, aMaxCoord.ToLength()); + } + if (aSizeCoord.ConvertsToLength()) { + *aSize = Clamp(aSizeCoord.ToLength(), *aMin, *aMax); + } + }; + // The min/sz/max sizes are the input to the "repeat-to-fill" algorithm: + // https://drafts.csswg.org/css-grid/#auto-repeat + // They're only used for auto-repeat so we skip computing them otherwise. LogicalSize min(state.mWM, 0, 0); - LogicalSize indefinite(state.mWM, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); + LogicalSize sz(state.mWM, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); + LogicalSize max(state.mWM, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); + if (state.mColFunctions.mHasRepeatAuto) { + GetDefiniteSizes(state.mGridStyle->MinISize(state.mWM), + state.mGridStyle->ISize(state.mWM), + state.mGridStyle->MaxISize(state.mWM), + &min.ISize(state.mWM), + &sz.ISize(state.mWM), + &max.ISize(state.mWM)); + } + if (state.mRowFunctions.mHasRepeatAuto && + !(state.mGridStyle->mGridAutoFlow & NS_STYLE_GRID_AUTO_FLOW_ROW)) { + // Only 'grid-auto-flow:column' can create new implicit columns, so that's + // the only case where our block-size can affect the number of columns. + GetDefiniteSizes(state.mGridStyle->MinBSize(state.mWM), + state.mGridStyle->BSize(state.mWM), + state.mGridStyle->MaxBSize(state.mWM), + &min.BSize(state.mWM), + &sz.BSize(state.mWM), + &max.BSize(state.mWM)); + } + Grid grid; - grid.PlaceGridItems(state, min, indefinite, indefinite); // XXX optimize + grid.PlaceGridItems(state, min, sz, max); // XXX optimize if (grid.mGridColEnd == 0) { return 0; } state.mCols.Initialize(state.mColFunctions, state.mGridStyle->mGridColumnGap, grid.mGridColEnd, NS_UNCONSTRAINEDSIZE); state.mCols.CalculateSizes(state, state.mGridItems, state.mColFunctions, NS_UNCONSTRAINEDSIZE, &GridArea::mCols, aConstraint);