Commit 055bc089 authored by Mats Palmgren's avatar Mats Palmgren
Browse files

Bug 1418727 part 1 - [css-grid] Introduce StateBitsForRange() that collects...

Bug 1418727 part 1 - [css-grid] Introduce StateBitsForRange() that collects the union of the state bits for a range of tracks (idempotent change).  r=dholbert

MozReview-Commit-ID: HzSxwPMkBEu
parent 01e424a4
Loading
Loading
Loading
Loading
+11 −26
Original line number Original line Diff line number Diff line
@@ -1092,15 +1092,9 @@ struct nsGridContainerFrame::Tracks
                  nscoord                     aContentBoxSize);
                  nscoord                     aContentBoxSize);


  /**
  /**
   * Return true if aRange spans at least one track with an intrinsic sizing
   * Return the union of the state bits for the tracks in aRange.
   * function and does not span any tracks with a <flex> max-sizing function.
   * @param aRange the span of tracks to check
   * @param aState will be set to the union of the state bits of all the spanned
   *               tracks, unless a flex track is found - then it only contains
   *               the union of the tracks up to and including the flex track.
   */
   */
  bool HasIntrinsicButNoFlexSizingInRange(const LineRange&      aRange,
   TrackSize::StateBits StateBitsForRange(const LineRange& aRange) const;
                                          TrackSize::StateBits* aState) const;


  // Some data we collect for aligning baseline-aligned items.
  // Some data we collect for aligning baseline-aligned items.
  struct ItemBaselineData
  struct ItemBaselineData
@@ -3755,28 +3749,17 @@ nsGridContainerFrame::Tracks::CalculateSizes(
  }
  }
}
}


bool
TrackSize::StateBits
nsGridContainerFrame::Tracks::HasIntrinsicButNoFlexSizingInRange(
nsGridContainerFrame::Tracks::StateBitsForRange(const LineRange& aRange) const
  const LineRange&      aRange,
  TrackSize::StateBits* aState) const
{
{
  MOZ_ASSERT(!aRange.IsAuto(), "must have a definite range");
  MOZ_ASSERT(!aRange.IsAuto(), "must have a definite range");
  TrackSize::StateBits state = TrackSize::StateBits(0);
  const uint32_t start = aRange.mStart;
  const uint32_t start = aRange.mStart;
  const uint32_t end = aRange.mEnd;
  const uint32_t end = aRange.mEnd;
  const TrackSize::StateBits selector =
    TrackSize::eIntrinsicMinSizing | TrackSize::eIntrinsicMaxSizing;
  bool foundIntrinsic = false;
  for (uint32_t i = start; i < end; ++i) {
  for (uint32_t i = start; i < end; ++i) {
    TrackSize::StateBits state = mSizes[i].mState;
    state |= mSizes[i].mState;
    *aState |= state;
    if (state & TrackSize::eFlexMaxSizing) {
      return false;
    }
    if (state & selector) {
      foundIntrinsic = true;
  }
  }
  }
  return state;
  return foundIntrinsic;
}
}


bool
bool
@@ -4215,8 +4198,10 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSize(
        gridItem.mState[mAxis] |= ItemState::eIsFlexing;
        gridItem.mState[mAxis] |= ItemState::eIsFlexing;
      }
      }
    } else {
    } else {
      TrackSize::StateBits state = TrackSize::StateBits(0);
      TrackSize::StateBits state = StateBitsForRange(lineRange);
      if (HasIntrinsicButNoFlexSizingInRange(lineRange, &state)) {
      if ((state & (TrackSize::eIntrinsicMinSizing |
                    TrackSize::eIntrinsicMaxSizing)) &&
          !(state & TrackSize::eFlexMaxSizing)) {
        // Collect data for Step 2.
        // Collect data for Step 2.
        maxSpan = std::max(maxSpan, span);
        maxSpan = std::max(maxSpan, span);
        if (span >= stateBitsPerSpan.Length()) {
        if (span >= stateBitsPerSpan.Length()) {