Attachment #8794320: part 6 - [css-grid] Update 'auto' min track sizing for span>1 to the latest Grid spec for bug #1255393

View | Details | Raw Unified | Return to bug 1255393
Collapse All | Expand All

(-)a/layout/generic/nsGridContainerFrame.cpp (-12 / +22 lines)
Line     Link Here 
 Lines 4136-4151   nsGridContainerFrame::Tracks::ResolveInt Link Here 
4136
  // We're also setting eIsFlexing on the item state here to speed up
4136
  // We're also setting eIsFlexing on the item state here to speed up
4137
  // FindUsedFlexFraction later.
4137
  // FindUsedFlexFraction later.
4138
  AutoTArray<TrackSize::StateBits, 16> stateBitsPerSpan;
4138
  AutoTArray<TrackSize::StateBits, 16> stateBitsPerSpan;
4139
  nsTArray<Step2ItemData> step2Items;
4139
  nsTArray<Step2ItemData> step2Items;
4140
  GridItemCSSOrderIterator& iter = aState.mIter;
4140
  GridItemCSSOrderIterator& iter = aState.mIter;
4141
  nsRenderingContext* rc = &aState.mRenderingContext;
4141
  nsRenderingContext* rc = &aState.mRenderingContext;
4142
  WritingMode wm = aState.mWM;
4142
  WritingMode wm = aState.mWM;
4143
  uint32_t maxSpan = 0; // max span of the step2Items items
4143
  uint32_t maxSpan = 0; // max span of the step2Items items
4144
  // Setup track selector for step 2.2:
4145
  const auto contentBasedMinSelector =
4146
    aConstraint == SizingConstraint::eMinContent ?
4147
    TrackSize::eIntrinsicMinSizing : TrackSize::eMinOrMaxContentMinSizing;
4148
  // Setup track selector for step 2.3:
4149
  const auto maxContentMinSelector =
4150
    aConstraint == SizingConstraint::eMaxContent ?
4151
    (TrackSize::eMaxContentMinSizing | TrackSize::eAutoMinSizing) :
4152
    TrackSize::eMaxContentMinSizing;
4144
  iter.Reset();
4153
  iter.Reset();
4145
  for (; !iter.AtEnd(); iter.Next()) {
4154
  for (; !iter.AtEnd(); iter.Next()) {
4146
    auto& gridItem = aGridItems[iter.GridItemIndex()];
4155
    auto& gridItem = aGridItems[iter.GridItemIndex()];
4147
    const GridArea& area = gridItem.mArea;
4156
    const GridArea& area = gridItem.mArea;
4148
    const LineRange& lineRange = area.*aRange;
4157
    const LineRange& lineRange = area.*aRange;
4149
    uint32_t span = lineRange.Extent();
4158
    uint32_t span = lineRange.Extent();
4150
    if (span == 1) {
4159
    if (span == 1) {
4151
      // Step 1. Size tracks to fit non-spanning items.
4160
      // Step 1. Size tracks to fit non-spanning items.
 Lines 4167-4189   nsGridContainerFrame::Tracks::ResolveInt Link Here 
4167
        }
4176
        }
4168
        stateBitsPerSpan[span] |= state;
4177
        stateBitsPerSpan[span] |= state;
4169
        CachedIntrinsicSizes cache;
4178
        CachedIntrinsicSizes cache;
4170
        nscoord minSize = 0;
4179
        nscoord minSize = 0;
4171
        if (state & TrackSize::eIntrinsicMinSizing) { // for 2.1
4180
        if (state & TrackSize::eIntrinsicMinSizing) { // for 2.1
4172
          minSize = MinSize(gridItem, aState, rc, wm, mAxis, &cache);
4181
          minSize = MinSize(gridItem, aState, rc, wm, mAxis, &cache);
4173
        }
4182
        }
4174
        nscoord minContent = 0;
4183
        nscoord minContent = 0;
4175
        if (state & (TrackSize::eMinOrMaxContentMinSizing | // for 2.2
4184
        if (state & (contentBasedMinSelector |          // for 2.2
4176
                     TrackSize::eIntrinsicMaxSizing)) {     // for 2.5
4185
                     TrackSize::eIntrinsicMaxSizing)) { // for 2.5
4177
          minContent = MinContentContribution(gridItem, aState,
4186
          minContent = MinContentContribution(gridItem, aState,
4178
                                              rc, wm, mAxis, &cache);
4187
                                              rc, wm, mAxis, &cache);
4179
        }
4188
        }
4180
        nscoord maxContent = 0;
4189
        nscoord maxContent = 0;
4181
        if (state & (TrackSize::eMaxContentMinSizing |         // for 2.3
4190
        if (state & (maxContentMinSelector |                   // for 2.3
4182
                     TrackSize::eAutoOrMaxContentMaxSizing)) { // for 2.6
4191
                     TrackSize::eAutoOrMaxContentMaxSizing)) { // for 2.6
4183
          maxContent = MaxContentContribution(gridItem, aState,
4192
          maxContent = MaxContentContribution(gridItem, aState,
4184
                                              rc, wm, mAxis, &cache);
4193
                                              rc, wm, mAxis, &cache);
4185
        }
4194
        }
4186
        step2Items.AppendElement(
4195
        step2Items.AppendElement(
4187
          Step2ItemData({span, state, lineRange, minSize,
4196
          Step2ItemData({span, state, lineRange, minSize,
4188
                         minContent, maxContent, *iter}));
4197
                         minContent, maxContent, *iter}));
4189
      } else if (state & TrackSize::eFlexMaxSizing) {
4198
      } else if (state & TrackSize::eFlexMaxSizing) {
 Lines 4231-4249   nsGridContainerFrame::Tracks::ResolveInt Link Here 
4231
                                  tracks);
4240
                                  tracks);
4232
          if (space > 0) {
4241
          if (space > 0) {
4233
            DistributeToTrackBases(space, plan, tracks, selector);
4242
            DistributeToTrackBases(space, plan, tracks, selector);
4234
            updatedBase = true;
4243
            updatedBase = true;
4235
          }
4244
          }
4236
        }
4245
        }
4237
      }
4246
      }
4238
4247
4239
      selector = TrackSize::eMinOrMaxContentMinSizing;
4248
      selector = contentBasedMinSelector;
4240
      if (stateBitsPerSpan[span] & selector) {
4249
      if (stateBitsPerSpan[span] & selector) {
4241
        // Step 2.2 MinContentContribution to min-/max-content min-sizing.
4250
        // Step 2.2 MinContentContribution to min-/max-content (and 'auto' when
4251
        // sizing under a min-content constraint) min-sizing.
4242
        for (i = spanGroupStartIndex; i < spanGroupEndIndex; ++i) {
4252
        for (i = spanGroupStartIndex; i < spanGroupEndIndex; ++i) {
4243
          Step2ItemData& item = step2Items[i];
4253
          Step2ItemData& item = step2Items[i];
4244
          if (!(item.mState & selector)) {
4254
          if (!(item.mState & selector)) {
4245
            continue;
4255
            continue;
4246
          }
4256
          }
4247
          nscoord space = item.mMinContentContribution;
4257
          nscoord space = item.mMinContentContribution;
4248
          if (space <= 0) {
4258
          if (space <= 0) {
4249
            continue;
4259
            continue;
 Lines 4253-4286   nsGridContainerFrame::Tracks::ResolveInt Link Here 
4253
                                  tracks);
4263
                                  tracks);
4254
          if (space > 0) {
4264
          if (space > 0) {
4255
            DistributeToTrackBases(space, plan, tracks, selector);
4265
            DistributeToTrackBases(space, plan, tracks, selector);
4256
            updatedBase = true;
4266
            updatedBase = true;
4257
          }
4267
          }
4258
        }
4268
        }
4259
      }
4269
      }
4260
4270
4261
      if (stateBitsPerSpan[span] & TrackSize::eMaxContentMinSizing) {
4271
      selector = maxContentMinSelector;
4262
        // Step 2.3 MaxContentContribution to max-content min-sizing.
4272
      if (stateBitsPerSpan[span] & selector) {
4273
        // Step 2.3 MaxContentContribution to max-content (and 'auto' when
4274
        // sizing under a max-content constraint) min-sizing.
4263
        for (i = spanGroupStartIndex; i < spanGroupEndIndex; ++i) {
4275
        for (i = spanGroupStartIndex; i < spanGroupEndIndex; ++i) {
4264
          Step2ItemData& item = step2Items[i];
4276
          Step2ItemData& item = step2Items[i];
4265
          if (!(item.mState & TrackSize::eMaxContentMinSizing)) {
4277
          if (!(item.mState & selector)) {
4266
            continue;
4278
            continue;
4267
          }
4279
          }
4268
          nscoord space = item.mMaxContentContribution;
4280
          nscoord space = item.mMaxContentContribution;
4269
          if (space <= 0) {
4281
          if (space <= 0) {
4270
            continue;
4282
            continue;
4271
          }
4283
          }
4272
          tracks.ClearAndRetainStorage();
4284
          tracks.ClearAndRetainStorage();
4273
          space = CollectGrowable(space, mSizes, item.mLineRange,
4285
          space = CollectGrowable(space, mSizes, item.mLineRange, selector,
4274
                                  TrackSize::eMaxContentMinSizing,
4275
                                  tracks);
4286
                                  tracks);
4276
          if (space > 0) {
4287
          if (space > 0) {
4277
            DistributeToTrackBases(space, plan, tracks,
4288
            DistributeToTrackBases(space, plan, tracks, selector);
4278
                                   TrackSize::eMaxContentMinSizing);
4279
            updatedBase = true;
4289
            updatedBase = true;
4280
          }
4290
          }
4281
        }
4291
        }
4282
      }
4292
      }
4283
4293
4284
      if (updatedBase) {
4294
      if (updatedBase) {
4285
        // Step 2.4
4295
        // Step 2.4
4286
        for (TrackSize& sz : mSizes) {
4296
        for (TrackSize& sz : mSizes) {

Return to bug 1255393