@@ -614,22 +614,22 @@ struct nsGridContainerFrame::GridItemInfo
614
614
LogicalAxis aContainerAxis,
615
615
nscoord aPercentageBasis) const
616
616
{
617
- const auto pos = mFrame ->StylePosition ();
617
+ const auto * pos = mFrame ->IsTableWrapperFrame () ?
618
+ mFrame ->PrincipalChildList ().FirstChild ()->StylePosition () :
619
+ mFrame ->StylePosition ();
618
620
const auto & size = aContainerAxis == eLogicalAxisInline ?
619
621
pos->ISize (aContainerWM) : pos->BSize (aContainerWM);
620
- // NOTE: if we have a definite or 'max-content' size then our automatic
621
- // minimum size can't affect our size. Excluding these simplifies applying
622
+ // NOTE: if we have a definite size then our automatic minimum size
623
+ // can't affect our size. Excluding these simplifies applying
622
624
// the clamping in the right cases later.
623
- if (size.GetUnit () == eStyleUnit_Auto ||
624
- ::IsPercentOfIndefiniteSize (size, aPercentageBasis) || // same as 'auto'
625
- (size.GetUnit() == eStyleUnit_Enumerated &&
626
- size.GetIntValue() != NS_STYLE_WIDTH_MAX_CONTENT)) {
627
- const auto & minSize = aContainerAxis == eLogicalAxisInline ?
628
- pos->MinISize (aContainerWM) : pos->MinBSize (aContainerWM);
629
- return minSize.GetUnit () == eStyleUnit_Auto &&
630
- mFrame ->StyleDisplay ()->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE;
625
+ if (size.GetUnit () != eStyleUnit_Auto &&
626
+ !::IsPercentOfIndefiniteSize (size, aPercentageBasis)) {
627
+ return false ;
631
628
}
632
- return false ;
629
+ const auto & minSize = aContainerAxis == eLogicalAxisInline ?
630
+ pos->MinISize (aContainerWM) : pos->MinBSize (aContainerWM);
631
+ return minSize.GetUnit () == eStyleUnit_Auto &&
632
+ mFrame ->StyleDisplay ()->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE;
633
633
}
634
634
635
635
#ifdef DEBUG
@@ -3779,33 +3779,25 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSizeStep1(
3779
3779
TrackSize& sz = mSizes [aRange.mStart ];
3780
3780
WritingMode wm = aState.mWM ;
3781
3781
3782
- // Check if we need to apply "Automatic Minimum Size" and cache it.
3783
- if ((sz.mState & TrackSize::eAutoMinSizing) &&
3784
- aGridItem.ShouldApplyAutoMinSize (wm, mAxis , aPercentageBasis)) {
3785
- aGridItem.mState [mAxis ] |= ItemState::eApplyAutoMinSize;
3786
- }
3787
-
3788
- // Calculate data for "Automatic Minimum Size" clamping, if needed.
3789
- bool needed = ((sz.mState & TrackSize::eIntrinsicMinSizing) ||
3790
- aConstraint == SizingConstraint::eNoConstraint) &&
3791
- (aGridItem.mState [mAxis ] & ItemState::eApplyAutoMinSize);
3792
- if (needed && TrackSize::IsDefiniteMaxSizing (sz.mState )) {
3793
- if (sz.mState & TrackSize::eIntrinsicMinSizing) {
3794
- auto maxCoord = aFunctions.MaxSizingFor (aRange.mStart );
3795
- cache.mMinSizeClamp = maxCoord.ComputeCoordPercentCalc (aPercentageBasis);
3796
- }
3797
- aGridItem.mState [mAxis ] |= ItemState::eClampMarginBoxMinSize;
3798
- }
3799
3782
// min sizing
3800
3783
gfxContext* rc = &aState.mRenderingContext ;
3801
3784
if (sz.mState & TrackSize::eAutoMinSizing) {
3802
3785
nscoord s;
3803
- if (aConstraint == SizingConstraint::eMinContent) {
3804
- s = MinContentContribution (aGridItem, aState, rc, wm, mAxis , &cache);
3805
- } else if (aConstraint == SizingConstraint::eMaxContent) {
3806
- s = MaxContentContribution (aGridItem, aState, rc, wm, mAxis , &cache);
3786
+ // Check if we need to apply "Automatic Minimum Size" and cache it.
3787
+ if (aGridItem.ShouldApplyAutoMinSize (wm, mAxis , aPercentageBasis)) {
3788
+ aGridItem.mState [mAxis ] |= ItemState::eApplyAutoMinSize;
3789
+ // Clamp it if it's spanning a definite track max-sizing function.
3790
+ if (TrackSize::IsDefiniteMaxSizing (sz.mState )) {
3791
+ auto maxCoord = aFunctions.MaxSizingFor (aRange.mStart );
3792
+ cache.mMinSizeClamp = maxCoord.ComputeCoordPercentCalc (aPercentageBasis);
3793
+ aGridItem.mState [mAxis ] |= ItemState::eClampMarginBoxMinSize;
3794
+ }
3795
+ if (aConstraint != SizingConstraint::eMaxContent) {
3796
+ s = MinContentContribution (aGridItem, aState, rc, wm, mAxis , &cache);
3797
+ } else {
3798
+ s = MaxContentContribution (aGridItem, aState, rc, wm, mAxis , &cache);
3799
+ }
3807
3800
} else {
3808
- MOZ_ASSERT (aConstraint == SizingConstraint::eNoConstraint);
3809
3801
s = MinSize (aGridItem, aState, rc, wm, mAxis , &cache);
3810
3802
}
3811
3803
sz.mBase = std::max (sz.mBase , s);
@@ -5073,18 +5065,31 @@ nsGridContainerFrame::ReflowInFlowChild(nsIFrame* aChild,
5073
5065
// Setup the ClampMarginBoxMinSize reflow flags and property, if needed.
5074
5066
uint32_t flags = 0 ;
5075
5067
if (aGridItemInfo) {
5068
+ // Clamp during reflow if we're stretching in that axis.
5069
+ auto * pos = aChild->StylePosition ();
5070
+ auto j = pos->UsedJustifySelf (StyleContext ());
5071
+ auto a = pos->UsedAlignSelf (StyleContext ());
5072
+ bool stretch[2 ];
5073
+ stretch[eLogicalAxisInline] = j == NS_STYLE_JUSTIFY_NORMAL ||
5074
+ j == NS_STYLE_JUSTIFY_STRETCH;
5075
+ stretch[eLogicalAxisBlock] = a == NS_STYLE_ALIGN_NORMAL ||
5076
+ a == NS_STYLE_ALIGN_STRETCH;
5076
5077
auto childIAxis = isOrthogonal ? eLogicalAxisBlock : eLogicalAxisInline;
5077
- if (aGridItemInfo->mState [childIAxis] & ItemState::eClampMarginBoxMinSize) {
5078
+ if (stretch[childIAxis] &&
5079
+ aGridItemInfo->mState [childIAxis] & ItemState::eClampMarginBoxMinSize) {
5078
5080
flags |= ReflowInput::I_CLAMP_MARGIN_BOX_MIN_SIZE;
5079
5081
}
5082
+
5080
5083
auto childBAxis = GetOrthogonalAxis (childIAxis);
5081
- if (aGridItemInfo->mState [childBAxis] & ItemState::eClampMarginBoxMinSize) {
5084
+ if (stretch[childBAxis] &&
5085
+ aGridItemInfo->mState [childBAxis] & ItemState::eClampMarginBoxMinSize) {
5082
5086
flags |= ReflowInput::B_CLAMP_MARGIN_BOX_MIN_SIZE;
5083
5087
aChild->SetProperty (BClampMarginBoxMinSizeProperty (),
5084
5088
childCBSize.BSize (childWM));
5085
5089
} else {
5086
5090
aChild->DeleteProperty (BClampMarginBoxMinSizeProperty ());
5087
5091
}
5092
+
5088
5093
if ((aGridItemInfo->mState [childIAxis] & ItemState::eApplyAutoMinSize)) {
5089
5094
flags |= ReflowInput::I_APPLY_AUTO_MIN_SIZE;
5090
5095
}
0 commit comments