Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 Vector<GridTrack> rowTracks; | 243 Vector<GridTrack> rowTracks; |
| 244 Vector<size_t> contentSizedTracksIndex; | 244 Vector<size_t> contentSizedTracksIndex; |
| 245 | 245 |
| 246 // Performance optimization: hold onto these Vectors until the end of Layout to avoid repeated malloc / free. | 246 // Performance optimization: hold onto these Vectors until the end of Layout to avoid repeated malloc / free. |
| 247 Vector<GridTrack*> filteredTracks; | 247 Vector<GridTrack*> filteredTracks; |
| 248 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan; | 248 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan; |
| 249 Vector<GridTrack*> growBeyondGrowthLimitsTracks; | 249 Vector<GridTrack*> growBeyondGrowthLimitsTracks; |
| 250 | 250 |
| 251 LayoutUnit& freeSpaceForDirection(GridTrackSizingDirection direction) { retu rn direction == ForColumns ? freeSpaceForColumns : freeSpaceForRows; } | 251 LayoutUnit& freeSpaceForDirection(GridTrackSizingDirection direction) { retu rn direction == ForColumns ? freeSpaceForColumns : freeSpaceForRows; } |
| 252 | 252 |
| 253 enum SizingOperation { TrackSizing, IntrinsicSizeComputation }; | |
| 254 SizingOperation sizingOperation { TrackSizing }; | 253 SizingOperation sizingOperation { TrackSizing }; |
| 255 | 254 |
| 256 private: | 255 private: |
| 257 LayoutUnit freeSpaceForColumns { }; | 256 LayoutUnit freeSpaceForColumns { }; |
| 258 LayoutUnit freeSpaceForRows { }; | 257 LayoutUnit freeSpaceForRows { }; |
| 259 }; | 258 }; |
| 260 | 259 |
| 261 struct GridItemsSpanGroupRange { | 260 struct GridItemsSpanGroupRange { |
| 262 Vector<GridItemWithSpan>::iterator rangeStart; | 261 Vector<GridItemWithSpan>::iterator rangeStart; |
| 263 Vector<GridItemWithSpan>::iterator rangeEnd; | 262 Vector<GridItemWithSpan>::iterator rangeEnd; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 logicalHeight += row.baseSize(); | 349 logicalHeight += row.baseSize(); |
| 351 | 350 |
| 352 logicalHeight += guttersSize(ForRows, sizingData.rowTracks.size()); | 351 logicalHeight += guttersSize(ForRows, sizingData.rowTracks.size()); |
| 353 | 352 |
| 354 return logicalHeight; | 353 return logicalHeight; |
| 355 } | 354 } |
| 356 | 355 |
| 357 void LayoutGrid::computeTrackSizesForDirection(GridTrackSizingDirection directio n, GridSizingData& sizingData, LayoutUnit freeSpace) | 356 void LayoutGrid::computeTrackSizesForDirection(GridTrackSizingDirection directio n, GridSizingData& sizingData, LayoutUnit freeSpace) |
| 358 { | 357 { |
| 359 sizingData.freeSpaceForDirection(direction) = freeSpace - guttersSize(direct ion, direction == ForRows ? gridRowCount() : gridColumnCount()); | 358 sizingData.freeSpaceForDirection(direction) = freeSpace - guttersSize(direct ion, direction == ForRows ? gridRowCount() : gridColumnCount()); |
| 360 sizingData.sizingOperation = GridSizingData::TrackSizing; | 359 sizingData.sizingOperation = TrackSizing; |
| 361 | 360 |
| 362 LayoutUnit baseSizes, growthLimits; | 361 LayoutUnit baseSizes, growthLimits; |
| 363 computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimit s); | 362 computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimit s); |
| 364 ASSERT(tracksAreWiderThanMinTrackBreadth(direction, sizingData)); | 363 ASSERT(tracksAreWiderThanMinTrackBreadth(direction, sizingData)); |
| 365 } | 364 } |
| 366 | 365 |
| 367 void LayoutGrid::layoutBlock(bool relayoutChildren) | 366 void LayoutGrid::layoutBlock(bool relayoutChildren) |
| 368 { | 367 { |
| 369 ASSERT(needsLayout()); | 368 ASSERT(needsLayout()); |
| 370 | 369 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 443 const Length& trackGap = direction == ForColumns ? styleRef().gridColumnGap( ) : styleRef().gridRowGap(); | 442 const Length& trackGap = direction == ForColumns ? styleRef().gridColumnGap( ) : styleRef().gridRowGap(); |
| 444 return valueForLength(trackGap, LayoutUnit()) * (span - 1); | 443 return valueForLength(trackGap, LayoutUnit()) * (span - 1); |
| 445 } | 444 } |
| 446 | 445 |
| 447 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const | 446 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const |
| 448 { | 447 { |
| 449 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(); | 448 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(); |
| 450 | 449 |
| 451 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 450 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
| 452 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit(); | 451 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit(); |
| 453 sizingData.sizingOperation = GridSizingData::IntrinsicSizeComputation; | 452 sizingData.sizingOperation = IntrinsicSizeComputation; |
| 454 const_cast<LayoutGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, si zingData, minLogicalWidth, maxLogicalWidth); | 453 const_cast<LayoutGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, si zingData, minLogicalWidth, maxLogicalWidth); |
| 455 | 454 |
| 456 LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTrack s.size()); | 455 LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTrack s.size()); |
| 457 minLogicalWidth += totalGuttersSize; | 456 minLogicalWidth += totalGuttersSize; |
| 458 maxLogicalWidth += totalGuttersSize; | 457 maxLogicalWidth += totalGuttersSize; |
| 459 | 458 |
| 460 LayoutUnit scrollbarWidth = LayoutUnit(intrinsicScrollbarLogicalWidth()); | 459 LayoutUnit scrollbarWidth = LayoutUnit(intrinsicScrollbarLogicalWidth()); |
| 461 minLogicalWidth += scrollbarWidth; | 460 minLogicalWidth += scrollbarWidth; |
| 462 maxLogicalWidth += scrollbarWidth; | 461 maxLogicalWidth += scrollbarWidth; |
| 463 } | 462 } |
| 464 | 463 |
| 465 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData) | 464 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData) |
| 466 { | 465 { |
| 467 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); | 466 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); |
| 468 sizingData.freeSpaceForDirection(ForRows) = LayoutUnit(); | 467 sizingData.freeSpaceForDirection(ForRows) = LayoutUnit(); |
| 469 sizingData.sizingOperation = GridSizingData::IntrinsicSizeComputation; | 468 sizingData.sizingOperation = IntrinsicSizeComputation; |
| 470 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma xContentHeight); | 469 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma xContentHeight); |
| 471 | 470 |
| 472 LayoutUnit totalGuttersSize = guttersSize(ForRows, gridRowCount()); | 471 LayoutUnit totalGuttersSize = guttersSize(ForRows, gridRowCount()); |
| 473 m_minContentHeight += totalGuttersSize; | 472 m_minContentHeight += totalGuttersSize; |
| 474 m_maxContentHeight += totalGuttersSize; | 473 m_maxContentHeight += totalGuttersSize; |
| 475 | 474 |
| 476 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData)); | 475 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData)); |
| 477 } | 476 } |
| 478 | 477 |
| 479 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi ng) const | 478 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi ng) const |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 512 | 511 |
| 513 LayoutUnit maxSize = std::max(LayoutUnit(), initialFreeSpace); | 512 LayoutUnit maxSize = std::max(LayoutUnit(), initialFreeSpace); |
| 514 // Grid gutters were removed from freeSpace by the caller, but we must use t hem to compute relative (i.e. percentages) sizes. | 513 // Grid gutters were removed from freeSpace by the caller, but we must use t hem to compute relative (i.e. percentages) sizes. |
| 515 bool hasDefiniteFreeSpace = sizingData.sizingOperation == GridSizingData::Tr ackSizing; | 514 bool hasDefiniteFreeSpace = sizingData.sizingOperation == GridSizingData::Tr ackSizing; |
| 516 if (hasDefiniteFreeSpace) | 515 if (hasDefiniteFreeSpace) |
| 517 maxSize += guttersSize(direction, direction == ForRows ? gridRowCount() : gridColumnCount()); | 516 maxSize += guttersSize(direction, direction == ForRows ? gridRowCount() : gridColumnCount()); |
| 518 | 517 |
| 519 // 1. Initialize per Grid track variables. | 518 // 1. Initialize per Grid track variables. |
| 520 for (size_t i = 0; i < tracks.size(); ++i) { | 519 for (size_t i = 0; i < tracks.size(); ++i) { |
| 521 GridTrack& track = tracks[i]; | 520 GridTrack& track = tracks[i]; |
| 522 GridTrackSize trackSize = gridTrackSize(direction, i); | 521 GridTrackSize trackSize = gridTrackSize(direction, i, sizingData.sizingO peration); |
| 523 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); | 522 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); |
| 524 const GridLength& maxTrackBreadth = trackSize.maxTrackBreadth(); | 523 const GridLength& maxTrackBreadth = trackSize.maxTrackBreadth(); |
| 525 | 524 |
| 526 track.setBaseSize(computeUsedBreadthOfMinLength(minTrackBreadth, maxSize )); | 525 track.setBaseSize(computeUsedBreadthOfMinLength(minTrackBreadth, maxSize )); |
| 527 track.setGrowthLimit(computeUsedBreadthOfMaxLength(maxTrackBreadth, trac k.baseSize(), maxSize)); | 526 track.setGrowthLimit(computeUsedBreadthOfMaxLength(maxTrackBreadth, trac k.baseSize(), maxSize)); |
| 528 track.setInfinitelyGrowable(false); | 527 track.setInfinitelyGrowable(false); |
| 529 | 528 |
| 530 if (trackSize.isContentSized()) | 529 if (trackSize.isContentSized()) |
| 531 sizingData.contentSizedTracksIndex.append(i); | 530 sizingData.contentSizedTracksIndex.append(i); |
| 532 if (trackSize.maxTrackBreadth().isFlex()) | 531 if (trackSize.maxTrackBreadth().isFlex()) |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 740 | 739 |
| 741 if (LIKELY(!repetitions) || untranslatedIndex < insertionPoint) | 740 if (LIKELY(!repetitions) || untranslatedIndex < insertionPoint) |
| 742 return trackStyles[untranslatedIndex]; | 741 return trackStyles[untranslatedIndex]; |
| 743 | 742 |
| 744 if (untranslatedIndex < (insertionPoint + repetitions)) | 743 if (untranslatedIndex < (insertionPoint + repetitions)) |
| 745 return autoRepeatTrackStyles[0]; | 744 return autoRepeatTrackStyles[0]; |
| 746 | 745 |
| 747 return trackStyles[untranslatedIndex - repetitions]; | 746 return trackStyles[untranslatedIndex - repetitions]; |
| 748 } | 747 } |
| 749 | 748 |
| 750 GridTrackSize LayoutGrid::gridTrackSize(GridTrackSizingDirection direction, size _t translatedIndex) const | 749 GridTrackSize LayoutGrid::gridTrackSize(GridTrackSizingDirection direction, size _t translatedIndex, SizingOperation sizingOperation) const |
| 751 { | 750 { |
| 752 const GridTrackSize& trackSize = rawGridTrackSize(direction, translatedIndex ); | 751 const GridTrackSize& trackSize = rawGridTrackSize(direction, translatedIndex ); |
| 753 | 752 |
| 754 GridLength minTrackBreadth = trackSize.minTrackBreadth(); | 753 GridLength minTrackBreadth = trackSize.minTrackBreadth(); |
| 755 GridLength maxTrackBreadth = trackSize.maxTrackBreadth(); | 754 GridLength maxTrackBreadth = trackSize.maxTrackBreadth(); |
| 756 | 755 |
| 757 // If the logical width/height of the grid container is indefinite, percenta ge values are treated as <auto> | 756 // If the logical width/height of the grid container is indefinite, percenta ge values are treated as <auto>. |
| 758 if (minTrackBreadth.hasPercentage() || maxTrackBreadth.hasPercentage()) { | 757 // For the inline axis this only happens when we're computing the intrinsic sizes (AvailableSpaceIndefinite). |
| 759 if (!hasDefiniteLogicalSize(direction)) { | 758 if (sizingOperation == IntrinsicSizeComputation || (direction == ForRows && !hasDefiniteLogicalHeight())) { |
| 760 if (minTrackBreadth.hasPercentage()) | 759 if (minTrackBreadth.hasPercentage()) |
| 761 minTrackBreadth = Length(Auto); | 760 minTrackBreadth = Length(Auto); |
| 762 if (maxTrackBreadth.hasPercentage()) | 761 if (maxTrackBreadth.hasPercentage()) |
| 763 maxTrackBreadth = Length(Auto); | 762 maxTrackBreadth = Length(Auto); |
| 764 } | |
| 765 } | 763 } |
| 766 | 764 |
| 767 // Flex sizes are invalid as a min sizing function. However we still can hav e a flexible |minTrackBreadth| | 765 // Flex sizes are invalid as a min sizing function. However we still can hav e a flexible |minTrackBreadth| |
| 768 // if the track had a flex size directly (e.g. "1fr"), the spec says that in this case it implies an automatic minimum. | 766 // if the track had a flex size directly (e.g. "1fr"), the spec says that in this case it implies an automatic minimum. |
| 769 if (minTrackBreadth.isFlex()) | 767 if (minTrackBreadth.isFlex()) |
| 770 minTrackBreadth = Length(Auto); | 768 minTrackBreadth = Length(Auto); |
| 771 | 769 |
| 772 return GridTrackSize(minTrackBreadth, maxTrackBreadth); | 770 return GridTrackSize(minTrackBreadth, maxTrackBreadth); |
| 773 } | 771 } |
| 774 | 772 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 808 return LayoutUnit(); | 806 return LayoutUnit(); |
| 809 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(c hild, ForColumns); | 807 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(c hild, ForColumns); |
| 810 bool isRowAxis = direction == childInlineDirection; | 808 bool isRowAxis = direction == childInlineDirection; |
| 811 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil d.styleRef().logicalHeight(); | 809 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil d.styleRef().logicalHeight(); |
| 812 const Length& childMinSize = isRowAxis ? child.styleRef().logicalMinWidth() : child.styleRef().logicalMinHeight(); | 810 const Length& childMinSize = isRowAxis ? child.styleRef().logicalMinWidth() : child.styleRef().logicalMinHeight(); |
| 813 if (!childSize.isAuto() || childMinSize.isAuto()) | 811 if (!childSize.isAuto() || childMinSize.isAuto()) |
| 814 return minContentForChild(child, direction, sizingData); | 812 return minContentForChild(child, direction, sizingData); |
| 815 | 813 |
| 816 bool overrideSizeHasChanged = updateOverrideContainingBlockContentSizeForChi ld(child, childInlineDirection, sizingData); | 814 bool overrideSizeHasChanged = updateOverrideContainingBlockContentSizeForChi ld(child, childInlineDirection, sizingData); |
| 817 if (isRowAxis) { | 815 if (isRowAxis) { |
| 818 LayoutUnit marginLogicalWidth = sizingData.sizingOperation == GridSizing Data::TrackSizing ? computeMarginLogicalSizeForChild(InlineDirection, child) : m arginIntrinsicLogicalWidthForChild(child); | 816 LayoutUnit marginLogicalWidth = sizingData.sizingOperation == TrackSizin g ? computeMarginLogicalSizeForChild(InlineDirection, child) : marginIntrinsicLo gicalWidthForChild(child); |
|
jfernandez
2016/06/02 21:58:28
Is this code orthogonality-independent ? I know t
Manuel Rego
2016/06/03 07:09:06
We've a TODO at the beginning of the method:
Layou
jfernandez
2016/06/03 07:20:58
That TODO is for supporting orthogonal flows, but
Manuel Rego
2016/06/03 08:56:14
I think both parts of the if are the same, as we c
| |
| 819 return child.computeLogicalWidthUsing(MinSize, childMinSize, overrideCon tainingBlockContentSizeForChild(child, childInlineDirection), this) + marginLogi calWidth; | 817 return child.computeLogicalWidthUsing(MinSize, childMinSize, overrideCon tainingBlockContentSizeForChild(child, childInlineDirection), this) + marginLogi calWidth; |
| 820 } | 818 } |
| 821 | 819 |
| 822 if (overrideSizeHasChanged) | 820 if (overrideSizeHasChanged) |
| 823 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | 821 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
| 824 child.layoutIfNeeded(); | 822 child.layoutIfNeeded(); |
| 825 return child.computeLogicalHeightUsing(MinSize, childMinSize, child.intrinsi cLogicalHeight()) + child.marginLogicalHeight() + child.scrollbarLogicalHeight() ; | 823 return child.computeLogicalHeightUsing(MinSize, childMinSize, child.intrinsi cLogicalHeight()) + child.marginLogicalHeight() + child.scrollbarLogicalHeight() ; |
| 826 } | 824 } |
| 827 | 825 |
| 828 bool LayoutGrid::updateOverrideContainingBlockContentSizeForChild(LayoutBox& chi ld, GridTrackSizingDirection direction, GridSizingData& sizingData) | 826 bool LayoutGrid::updateOverrideContainingBlockContentSizeForChild(LayoutBox& chi ld, GridTrackSizingDirection direction, GridSizingData& sizingData) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 895 LayoutBox& gridItem() const { return *m_gridItem; } | 893 LayoutBox& gridItem() const { return *m_gridItem; } |
| 896 GridSpan getGridSpan() const { return m_gridSpan; } | 894 GridSpan getGridSpan() const { return m_gridSpan; } |
| 897 | 895 |
| 898 bool operator<(const GridItemWithSpan other) const { return m_gridSpan.integ erSpan() < other.m_gridSpan.integerSpan(); } | 896 bool operator<(const GridItemWithSpan other) const { return m_gridSpan.integ erSpan() < other.m_gridSpan.integerSpan(); } |
| 899 | 897 |
| 900 private: | 898 private: |
| 901 LayoutBox* m_gridItem; | 899 LayoutBox* m_gridItem; |
| 902 GridSpan m_gridSpan; | 900 GridSpan m_gridSpan; |
| 903 }; | 901 }; |
| 904 | 902 |
| 905 bool LayoutGrid::spanningItemCrossesFlexibleSizedTracks(const GridSpan& span, Gr idTrackSizingDirection direction) const | 903 bool LayoutGrid::spanningItemCrossesFlexibleSizedTracks(const GridSpan& span, Gr idTrackSizingDirection direction, SizingOperation sizingOperation) const |
| 906 { | 904 { |
| 907 for (const auto& trackPosition : span) { | 905 for (const auto& trackPosition : span) { |
| 908 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition) ; | 906 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition, sizingOperation); |
| 909 if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth(). isFlex()) | 907 if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth(). isFlex()) |
| 910 return true; | 908 return true; |
| 911 } | 909 } |
| 912 | 910 |
| 913 return false; | 911 return false; |
| 914 } | 912 } |
| 915 | 913 |
| 916 void LayoutGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio n direction, GridSizingData& sizingData) | 914 void LayoutGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio n direction, GridSizingData& sizingData) |
| 917 { | 915 { |
| 918 sizingData.itemsSortedByIncreasingSpan.shrink(0); | 916 sizingData.itemsSortedByIncreasingSpan.shrink(0); |
| 919 if (!m_gridItemArea.isEmpty()) { | 917 if (!m_gridItemArea.isEmpty()) { |
| 920 HashSet<LayoutBox*> itemsSet; | 918 HashSet<LayoutBox*> itemsSet; |
| 921 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 919 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { |
| 922 GridIterator iterator(m_grid, direction, trackIndex); | 920 GridIterator iterator(m_grid, direction, trackIndex); |
| 923 GridTrack& track = (direction == ForColumns) ? sizingData.columnTrac ks[trackIndex] : sizingData.rowTracks[trackIndex]; | 921 GridTrack& track = (direction == ForColumns) ? sizingData.columnTrac ks[trackIndex] : sizingData.rowTracks[trackIndex]; |
| 924 while (LayoutBox* gridItem = iterator.nextGridItem()) { | 922 while (LayoutBox* gridItem = iterator.nextGridItem()) { |
| 925 if (itemsSet.add(gridItem).isNewEntry) { | 923 if (itemsSet.add(gridItem).isNewEntry) { |
| 926 const GridSpan& span = cachedGridSpan(*gridItem, direction); | 924 const GridSpan& span = cachedGridSpan(*gridItem, direction); |
| 927 if (span.integerSpan() == 1) { | 925 if (span.integerSpan() == 1) { |
| 928 resolveContentBasedTrackSizingFunctionsForNonSpanningIte ms(direction, span, *gridItem, track, sizingData); | 926 resolveContentBasedTrackSizingFunctionsForNonSpanningIte ms(direction, span, *gridItem, track, sizingData); |
| 929 } else if (!spanningItemCrossesFlexibleSizedTracks(span, dir ection)) { | 927 } else if (!spanningItemCrossesFlexibleSizedTracks(span, dir ection, sizingData.sizingOperation)) { |
| 930 sizingData.itemsSortedByIncreasingSpan.append(GridItemWi thSpan(*gridItem, span)); | 928 sizingData.itemsSortedByIncreasingSpan.append(GridItemWi thSpan(*gridItem, span)); |
| 931 } | 929 } |
| 932 } | 930 } |
| 933 } | 931 } |
| 934 } | 932 } |
| 935 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(), sizingData.ite msSortedByIncreasingSpan.end()); | 933 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(), sizingData.ite msSortedByIncreasingSpan.end()); |
| 936 } | 934 } |
| 937 | 935 |
| 938 auto it = sizingData.itemsSortedByIncreasingSpan.begin(); | 936 auto it = sizingData.itemsSortedByIncreasingSpan.begin(); |
| 939 auto end = sizingData.itemsSortedByIncreasingSpan.end(); | 937 auto end = sizingData.itemsSortedByIncreasingSpan.end(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 950 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 948 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { |
| 951 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex]; | 949 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex]; |
| 952 if (track.growthLimitIsInfinite()) | 950 if (track.growthLimitIsInfinite()) |
| 953 track.setGrowthLimit(track.baseSize()); | 951 track.setGrowthLimit(track.baseSize()); |
| 954 } | 952 } |
| 955 } | 953 } |
| 956 | 954 |
| 957 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid TrackSizingDirection direction, const GridSpan& span, LayoutBox& gridItem, GridT rack& track, GridSizingData& sizingData) | 955 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid TrackSizingDirection direction, const GridSpan& span, LayoutBox& gridItem, GridT rack& track, GridSizingData& sizingData) |
| 958 { | 956 { |
| 959 const size_t trackPosition = span.startLine(); | 957 const size_t trackPosition = span.startLine(); |
| 960 GridTrackSize trackSize = gridTrackSize(direction, trackPosition); | 958 GridTrackSize trackSize = gridTrackSize(direction, trackPosition, sizingData .sizingOperation); |
| 961 | 959 |
| 962 if (trackSize.hasMinContentMinTrackBreadth()) | 960 if (trackSize.hasMinContentMinTrackBreadth()) |
| 963 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem , direction, sizingData))); | 961 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem , direction, sizingData))); |
| 964 else if (trackSize.hasMaxContentMinTrackBreadth()) | 962 else if (trackSize.hasMaxContentMinTrackBreadth()) |
| 965 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem , direction, sizingData))); | 963 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem , direction, sizingData))); |
| 966 else if (trackSize.hasAutoMinTrackBreadth()) | 964 else if (trackSize.hasAutoMinTrackBreadth()) |
| 967 track.setBaseSize(std::max(track.baseSize(), minSizeForChild(gridItem, d irection, sizingData))); | 965 track.setBaseSize(std::max(track.baseSize(), minSizeForChild(gridItem, d irection, sizingData))); |
| 968 | 966 |
| 969 if (trackSize.hasMinContentMaxTrackBreadth()) | 967 if (trackSize.hasMinContentMaxTrackBreadth()) |
| 970 track.setGrowthLimit(std::max(track.growthLimit(), minContentForChild(gr idItem, direction, sizingData))); | 968 track.setGrowthLimit(std::max(track.growthLimit(), minContentForChild(gr idItem, direction, sizingData))); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1194 for (auto* track : tracks) | 1192 for (auto* track : tracks) |
| 1195 track->setPlannedSize(track->plannedSize() == infinity ? track->sizeDuri ngDistribution() : std::max(track->plannedSize(), track->sizeDuringDistribution( ))); | 1193 track->setPlannedSize(track->plannedSize() == infinity ? track->sizeDuri ngDistribution() : std::max(track->plannedSize(), track->sizeDuringDistribution( ))); |
| 1196 } | 1194 } |
| 1197 | 1195 |
| 1198 #if ENABLE(ASSERT) | 1196 #if ENABLE(ASSERT) |
| 1199 bool LayoutGrid::tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection dire ction, GridSizingData& sizingData) | 1197 bool LayoutGrid::tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection dire ction, GridSizingData& sizingData) |
| 1200 { | 1198 { |
| 1201 const Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.col umnTracks : sizingData.rowTracks; | 1199 const Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.col umnTracks : sizingData.rowTracks; |
| 1202 LayoutUnit& maxSize = sizingData.freeSpaceForDirection(direction); | 1200 LayoutUnit& maxSize = sizingData.freeSpaceForDirection(direction); |
| 1203 for (size_t i = 0; i < tracks.size(); ++i) { | 1201 for (size_t i = 0; i < tracks.size(); ++i) { |
| 1204 GridTrackSize trackSize = gridTrackSize(direction, i); | 1202 GridTrackSize trackSize = gridTrackSize(direction, i, sizingData.sizingO peration); |
| 1205 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); | 1203 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); |
| 1206 if (computeUsedBreadthOfMinLength(minTrackBreadth, maxSize) > tracks[i]. baseSize()) | 1204 if (computeUsedBreadthOfMinLength(minTrackBreadth, maxSize) > tracks[i]. baseSize()) |
| 1207 return false; | 1205 return false; |
| 1208 } | 1206 } |
| 1209 return true; | 1207 return true; |
| 1210 } | 1208 } |
| 1211 #endif | 1209 #endif |
| 1212 | 1210 |
| 1213 void LayoutGrid::ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize) | 1211 void LayoutGrid::ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize) |
| 1214 { | 1212 { |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2255 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); | 2253 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); |
| 2256 } | 2254 } |
| 2257 | 2255 |
| 2258 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 2256 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const |
| 2259 { | 2257 { |
| 2260 if (!m_gridItemArea.isEmpty()) | 2258 if (!m_gridItemArea.isEmpty()) |
| 2261 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2259 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 2262 } | 2260 } |
| 2263 | 2261 |
| 2264 } // namespace blink | 2262 } // namespace blink |
| OLD | NEW |