Bug 1348857 part 1 - [css-grid] Add a bit on GridItemInfo that says if we should apply Automatic Minimum Size or not (idempotent patch). r=dholbert

This renames ShouldClampMinSize to ShouldApplyAutoMinSize, which is more
accurate, and caches the value on the grid item for later use.
No functional changes other than that.

MozReview-Commit-ID: E1mvBZsMIxh
This commit is contained in:
Mats Palmgren 2017-04-18 22:35:04 +02:00
Родитель dc68da3cd9
Коммит a243aa1c80
1 изменённых файлов: 26 добавлений и 12 удалений

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

@ -573,8 +573,11 @@ struct nsGridContainerFrame::GridItemInfo
// Ditto *-content:[last ]baseline. Mutually exclusive w. eSelfBaseline.
eContentBaseline = 0x10,
eAllBaselineBits = eIsBaselineAligned | eSelfBaseline | eContentBaseline,
// Should apply Automatic Minimum Size per:
// https://drafts.csswg.org/css-grid/#min-size-auto
eApplyAutoMinSize = 0x20,
// Clamp per https://drafts.csswg.org/css-grid/#min-size-auto
eClampMarginBoxMinSize = 0x20,
eClampMarginBoxMinSize = 0x40,
};
explicit GridItemInfo(nsIFrame* aFrame,
@ -606,11 +609,11 @@ struct nsGridContainerFrame::GridItemInfo
return aAlign;
}
// Return true if we should we clamp this item's Automatic Minimum Size.
// Return true if we should apply Automatic Minimum Size to this item.
// https://drafts.csswg.org/css-grid/#min-size-auto
bool ShouldClampMinSize(WritingMode aContainerWM,
LogicalAxis aContainerAxis,
nscoord aPercentageBasis) const
bool ShouldApplyAutoMinSize(WritingMode aContainerWM,
LogicalAxis aContainerAxis,
nscoord aPercentageBasis) const
{
const auto pos = mFrame->StylePosition();
const auto& size = aContainerAxis == eLogicalAxisInline ?
@ -3744,9 +3747,9 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSizeStep1(
WritingMode wm = aState.mWM;
// Calculate data for "Automatic Minimum Size" clamping, if needed.
bool needed = ((sz.mState & TrackSize::eIntrinsicMinSizing) ||
aConstraint == SizingConstraint::eNoConstraint);
if (needed && TrackSize::IsDefiniteMaxSizing(sz.mState) &&
aGridItem.ShouldClampMinSize(wm, mAxis, aPercentageBasis)) {
aConstraint == SizingConstraint::eNoConstraint) &&
(aGridItem.mState[mAxis] & ItemState::eApplyAutoMinSize);
if (needed && TrackSize::IsDefiniteMaxSizing(sz.mState)) {
if (sz.mState & TrackSize::eIntrinsicMinSizing) {
auto maxCoord = aFunctions.MaxSizingFor(aRange.mStart);
cache.mMinSizeClamp =
@ -4149,6 +4152,14 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSize(
iter.Reset();
for (; !iter.AtEnd(); iter.Next()) {
auto& gridItem = aGridItems[iter.ItemIndex()];
// Check if we need to apply "Automatic Minimum Size" and cache it.
MOZ_ASSERT(!(gridItem.mState[mAxis] & ItemState::eApplyAutoMinSize),
"Why is eApplyAutoMinSize set already?");
if (gridItem.ShouldApplyAutoMinSize(wm, mAxis, aPercentageBasis)) {
gridItem.mState[mAxis] |= ItemState::eApplyAutoMinSize;
}
const GridArea& area = gridItem.mArea;
const LineRange& lineRange = area.*aRange;
uint32_t span = lineRange.Extent();
@ -4174,9 +4185,9 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSize(
CachedIntrinsicSizes cache;
// Calculate data for "Automatic Minimum Size" clamping, if needed.
bool needed = ((state & TrackSize::eIntrinsicMinSizing) ||
aConstraint == SizingConstraint::eNoConstraint);
if (needed && TrackSize::IsDefiniteMaxSizing(state) &&
gridItem.ShouldClampMinSize(wm, mAxis, aPercentageBasis)) {
aConstraint == SizingConstraint::eNoConstraint) &&
(gridItem.mState[mAxis] & ItemState::eApplyAutoMinSize);
if (needed && TrackSize::IsDefiniteMaxSizing(state)) {
nscoord minSizeClamp = 0;
for (auto i = lineRange.mStart, end = lineRange.mEnd; i < end; ++i) {
auto maxCoord = aFunctions.MaxSizingFor(i);
@ -4212,11 +4223,14 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSize(
gridItem.mState[mAxis] |= ItemState::eIsFlexing;
} else if (aConstraint == SizingConstraint::eNoConstraint &&
TrackSize::IsDefiniteMaxSizing(state) &&
gridItem.ShouldClampMinSize(wm, mAxis, aPercentageBasis)) {
(gridItem.mState[mAxis] & ItemState::eApplyAutoMinSize)) {
gridItem.mState[mAxis] |= ItemState::eClampMarginBoxMinSize;
}
}
}
MOZ_ASSERT(!(gridItem.mState[mAxis] & ItemState::eClampMarginBoxMinSize) ||
(gridItem.mState[mAxis] & ItemState::eApplyAutoMinSize),
"clamping only applies to Automatic Minimum Size");
}
// Step 2.