| 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(scrollbarLogicalWidth()); | 459 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); |
| 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 25 matching lines...) Expand all Loading... |
| 505 void LayoutGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi
on, GridSizingData& sizingData, LayoutUnit& baseSizesWithoutMaximization, Layout
Unit& growthLimitsWithoutMaximization) | 504 void LayoutGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi
on, GridSizingData& sizingData, LayoutUnit& baseSizesWithoutMaximization, Layout
Unit& growthLimitsWithoutMaximization) |
| 506 { | 505 { |
| 507 LayoutUnit& freeSpace = sizingData.freeSpaceForDirection(direction); | 506 LayoutUnit& freeSpace = sizingData.freeSpaceForDirection(direction); |
| 508 const LayoutUnit initialFreeSpace = freeSpace; | 507 const LayoutUnit initialFreeSpace = freeSpace; |
| 509 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra
cks : sizingData.rowTracks; | 508 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra
cks : sizingData.rowTracks; |
| 510 Vector<size_t> flexibleSizedTracksIndex; | 509 Vector<size_t> flexibleSizedTracksIndex; |
| 511 sizingData.contentSizedTracksIndex.shrink(0); | 510 sizingData.contentSizedTracksIndex.shrink(0); |
| 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 == TrackSizing; |
| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 flexFactorSum += trackSize.maxTrackBreadth().flex(); | 678 flexFactorSum += trackSize.maxTrackBreadth().flex(); |
| 680 } | 679 } |
| 681 } | 680 } |
| 682 | 681 |
| 683 // The function is not called if we don't have <flex> grid tracks | 682 // The function is not called if we don't have <flex> grid tracks |
| 684 ASSERT(!flexibleTracksIndexes.isEmpty()); | 683 ASSERT(!flexibleTracksIndexes.isEmpty()); |
| 685 | 684 |
| 686 return computeFlexFactorUnitSize(tracks, direction, flexFactorSum, leftOverS
pace, flexibleTracksIndexes); | 685 return computeFlexFactorUnitSize(tracks, direction, flexFactorSum, leftOverS
pace, flexibleTracksIndexes); |
| 687 } | 686 } |
| 688 | 687 |
| 689 bool LayoutGrid::hasDefiniteLogicalSize(GridTrackSizingDirection direction) cons
t | |
| 690 { | |
| 691 return (direction == ForRows) ? hasDefiniteLogicalHeight() : hasDefiniteLogi
calWidth(); | |
| 692 } | |
| 693 | |
| 694 static bool hasOverrideContainingBlockContentSizeForChild(const LayoutBox& child
, GridTrackSizingDirection direction) | 688 static bool hasOverrideContainingBlockContentSizeForChild(const LayoutBox& child
, GridTrackSizingDirection direction) |
| 695 { | 689 { |
| 696 return direction == ForColumns ? child.hasOverrideContainingBlockLogicalWidt
h() : child.overrideContainingBlockContentLogicalHeight(); | 690 return direction == ForColumns ? child.hasOverrideContainingBlockLogicalWidt
h() : child.overrideContainingBlockContentLogicalHeight(); |
| 697 } | 691 } |
| 698 | 692 |
| 699 static LayoutUnit overrideContainingBlockContentSizeForChild(const LayoutBox& ch
ild, GridTrackSizingDirection direction) | 693 static LayoutUnit overrideContainingBlockContentSizeForChild(const LayoutBox& ch
ild, GridTrackSizingDirection direction) |
| 700 { | 694 { |
| 701 return direction == ForColumns ? child.overrideContainingBlockContentLogical
Width() : child.overrideContainingBlockContentLogicalHeight(); | 695 return direction == ForColumns ? child.overrideContainingBlockContentLogical
Width() : child.overrideContainingBlockContentLogicalHeight(); |
| 702 } | 696 } |
| 703 | 697 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 | 734 |
| 741 if (LIKELY(!repetitions) || untranslatedIndex < insertionPoint) | 735 if (LIKELY(!repetitions) || untranslatedIndex < insertionPoint) |
| 742 return trackStyles[untranslatedIndex]; | 736 return trackStyles[untranslatedIndex]; |
| 743 | 737 |
| 744 if (untranslatedIndex < (insertionPoint + repetitions)) | 738 if (untranslatedIndex < (insertionPoint + repetitions)) |
| 745 return autoRepeatTrackStyles[0]; | 739 return autoRepeatTrackStyles[0]; |
| 746 | 740 |
| 747 return trackStyles[untranslatedIndex - repetitions]; | 741 return trackStyles[untranslatedIndex - repetitions]; |
| 748 } | 742 } |
| 749 | 743 |
| 750 GridTrackSize LayoutGrid::gridTrackSize(GridTrackSizingDirection direction, size
_t translatedIndex) const | 744 GridTrackSize LayoutGrid::gridTrackSize(GridTrackSizingDirection direction, size
_t translatedIndex, SizingOperation sizingOperation) const |
| 751 { | 745 { |
| 752 const GridTrackSize& trackSize = rawGridTrackSize(direction, translatedIndex
); | 746 const GridTrackSize& trackSize = rawGridTrackSize(direction, translatedIndex
); |
| 753 | 747 |
| 754 GridLength minTrackBreadth = trackSize.minTrackBreadth(); | 748 GridLength minTrackBreadth = trackSize.minTrackBreadth(); |
| 755 GridLength maxTrackBreadth = trackSize.maxTrackBreadth(); | 749 GridLength maxTrackBreadth = trackSize.maxTrackBreadth(); |
| 756 | 750 |
| 757 // If the logical width/height of the grid container is indefinite, percenta
ge values are treated as <auto> | 751 // If the logical width/height of the grid container is indefinite, percenta
ge values are treated as <auto>. |
| 758 if (minTrackBreadth.hasPercentage() || maxTrackBreadth.hasPercentage()) { | 752 // For the inline axis this only happens when we're computing the intrinsic
sizes (AvailableSpaceIndefinite). |
| 759 if (!hasDefiniteLogicalSize(direction)) { | 753 if (sizingOperation == IntrinsicSizeComputation || (direction == ForRows &&
!hasDefiniteLogicalHeight())) { |
| 760 if (minTrackBreadth.hasPercentage()) | 754 if (minTrackBreadth.hasPercentage()) |
| 761 minTrackBreadth = Length(Auto); | 755 minTrackBreadth = Length(Auto); |
| 762 if (maxTrackBreadth.hasPercentage()) | 756 if (maxTrackBreadth.hasPercentage()) |
| 763 maxTrackBreadth = Length(Auto); | 757 maxTrackBreadth = Length(Auto); |
| 764 } | |
| 765 } | 758 } |
| 766 | 759 |
| 767 // Flex sizes are invalid as a min sizing function. However we still can hav
e a flexible |minTrackBreadth| | 760 // 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. | 761 // 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()) | 762 if (minTrackBreadth.isFlex()) |
| 770 minTrackBreadth = Length(Auto); | 763 minTrackBreadth = Length(Auto); |
| 771 | 764 |
| 772 return GridTrackSize(minTrackBreadth, maxTrackBreadth); | 765 return GridTrackSize(minTrackBreadth, maxTrackBreadth); |
| 773 } | 766 } |
| 774 | 767 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 return LayoutUnit(); | 801 return LayoutUnit(); |
| 809 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(c
hild, ForColumns); | 802 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(c
hild, ForColumns); |
| 810 bool isRowAxis = direction == childInlineDirection; | 803 bool isRowAxis = direction == childInlineDirection; |
| 811 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil
d.styleRef().logicalHeight(); | 804 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil
d.styleRef().logicalHeight(); |
| 812 const Length& childMinSize = isRowAxis ? child.styleRef().logicalMinWidth()
: child.styleRef().logicalMinHeight(); | 805 const Length& childMinSize = isRowAxis ? child.styleRef().logicalMinWidth()
: child.styleRef().logicalMinHeight(); |
| 813 if (!childSize.isAuto() || childMinSize.isAuto()) | 806 if (!childSize.isAuto() || childMinSize.isAuto()) |
| 814 return minContentForChild(child, direction, sizingData); | 807 return minContentForChild(child, direction, sizingData); |
| 815 | 808 |
| 816 bool overrideSizeHasChanged = updateOverrideContainingBlockContentSizeForChi
ld(child, childInlineDirection, sizingData); | 809 bool overrideSizeHasChanged = updateOverrideContainingBlockContentSizeForChi
ld(child, childInlineDirection, sizingData); |
| 817 if (isRowAxis) { | 810 if (isRowAxis) { |
| 818 LayoutUnit marginLogicalWidth = sizingData.sizingOperation == GridSizing
Data::TrackSizing ? computeMarginLogicalSizeForChild(InlineDirection, child) : m
arginIntrinsicLogicalWidthForChild(child); | 811 LayoutUnit marginLogicalWidth = sizingData.sizingOperation == TrackSizin
g ? computeMarginLogicalSizeForChild(InlineDirection, child) : marginIntrinsicLo
gicalWidthForChild(child); |
| 819 return child.computeLogicalWidthUsing(MinSize, childMinSize, overrideCon
tainingBlockContentSizeForChild(child, childInlineDirection), this) + marginLogi
calWidth; | 812 return child.computeLogicalWidthUsing(MinSize, childMinSize, overrideCon
tainingBlockContentSizeForChild(child, childInlineDirection), this) + marginLogi
calWidth; |
| 820 } | 813 } |
| 821 | 814 |
| 822 if (overrideSizeHasChanged) | 815 if (overrideSizeHasChanged) |
| 823 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | 816 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
| 824 child.layoutIfNeeded(); | 817 child.layoutIfNeeded(); |
| 825 return child.computeLogicalHeightUsing(MinSize, childMinSize, child.intrinsi
cLogicalHeight()) + child.marginLogicalHeight() + child.scrollbarLogicalHeight()
; | 818 return child.computeLogicalHeightUsing(MinSize, childMinSize, child.intrinsi
cLogicalHeight()) + child.marginLogicalHeight() + child.scrollbarLogicalHeight()
; |
| 826 } | 819 } |
| 827 | 820 |
| 828 bool LayoutGrid::updateOverrideContainingBlockContentSizeForChild(LayoutBox& chi
ld, GridTrackSizingDirection direction, GridSizingData& sizingData) | 821 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; } | 888 LayoutBox& gridItem() const { return *m_gridItem; } |
| 896 GridSpan getGridSpan() const { return m_gridSpan; } | 889 GridSpan getGridSpan() const { return m_gridSpan; } |
| 897 | 890 |
| 898 bool operator<(const GridItemWithSpan other) const { return m_gridSpan.integ
erSpan() < other.m_gridSpan.integerSpan(); } | 891 bool operator<(const GridItemWithSpan other) const { return m_gridSpan.integ
erSpan() < other.m_gridSpan.integerSpan(); } |
| 899 | 892 |
| 900 private: | 893 private: |
| 901 LayoutBox* m_gridItem; | 894 LayoutBox* m_gridItem; |
| 902 GridSpan m_gridSpan; | 895 GridSpan m_gridSpan; |
| 903 }; | 896 }; |
| 904 | 897 |
| 905 bool LayoutGrid::spanningItemCrossesFlexibleSizedTracks(const GridSpan& span, Gr
idTrackSizingDirection direction) const | 898 bool LayoutGrid::spanningItemCrossesFlexibleSizedTracks(const GridSpan& span, Gr
idTrackSizingDirection direction, SizingOperation sizingOperation) const |
| 906 { | 899 { |
| 907 for (const auto& trackPosition : span) { | 900 for (const auto& trackPosition : span) { |
| 908 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition)
; | 901 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition,
sizingOperation); |
| 909 if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth().
isFlex()) | 902 if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth().
isFlex()) |
| 910 return true; | 903 return true; |
| 911 } | 904 } |
| 912 | 905 |
| 913 return false; | 906 return false; |
| 914 } | 907 } |
| 915 | 908 |
| 916 void LayoutGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio
n direction, GridSizingData& sizingData) | 909 void LayoutGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio
n direction, GridSizingData& sizingData) |
| 917 { | 910 { |
| 918 sizingData.itemsSortedByIncreasingSpan.shrink(0); | 911 sizingData.itemsSortedByIncreasingSpan.shrink(0); |
| 919 if (!m_gridItemArea.isEmpty()) { | 912 if (!m_gridItemArea.isEmpty()) { |
| 920 HashSet<LayoutBox*> itemsSet; | 913 HashSet<LayoutBox*> itemsSet; |
| 921 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 914 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { |
| 922 GridIterator iterator(m_grid, direction, trackIndex); | 915 GridIterator iterator(m_grid, direction, trackIndex); |
| 923 GridTrack& track = (direction == ForColumns) ? sizingData.columnTrac
ks[trackIndex] : sizingData.rowTracks[trackIndex]; | 916 GridTrack& track = (direction == ForColumns) ? sizingData.columnTrac
ks[trackIndex] : sizingData.rowTracks[trackIndex]; |
| 924 while (LayoutBox* gridItem = iterator.nextGridItem()) { | 917 while (LayoutBox* gridItem = iterator.nextGridItem()) { |
| 925 if (itemsSet.add(gridItem).isNewEntry) { | 918 if (itemsSet.add(gridItem).isNewEntry) { |
| 926 const GridSpan& span = cachedGridSpan(*gridItem, direction); | 919 const GridSpan& span = cachedGridSpan(*gridItem, direction); |
| 927 if (span.integerSpan() == 1) { | 920 if (span.integerSpan() == 1) { |
| 928 resolveContentBasedTrackSizingFunctionsForNonSpanningIte
ms(direction, span, *gridItem, track, sizingData); | 921 resolveContentBasedTrackSizingFunctionsForNonSpanningIte
ms(direction, span, *gridItem, track, sizingData); |
| 929 } else if (!spanningItemCrossesFlexibleSizedTracks(span, dir
ection)) { | 922 } else if (!spanningItemCrossesFlexibleSizedTracks(span, dir
ection, sizingData.sizingOperation)) { |
| 930 sizingData.itemsSortedByIncreasingSpan.append(GridItemWi
thSpan(*gridItem, span)); | 923 sizingData.itemsSortedByIncreasingSpan.append(GridItemWi
thSpan(*gridItem, span)); |
| 931 } | 924 } |
| 932 } | 925 } |
| 933 } | 926 } |
| 934 } | 927 } |
| 935 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(), sizingData.ite
msSortedByIncreasingSpan.end()); | 928 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(), sizingData.ite
msSortedByIncreasingSpan.end()); |
| 936 } | 929 } |
| 937 | 930 |
| 938 auto it = sizingData.itemsSortedByIncreasingSpan.begin(); | 931 auto it = sizingData.itemsSortedByIncreasingSpan.begin(); |
| 939 auto end = sizingData.itemsSortedByIncreasingSpan.end(); | 932 auto end = sizingData.itemsSortedByIncreasingSpan.end(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 950 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 943 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { |
| 951 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t
rackIndex] : sizingData.rowTracks[trackIndex]; | 944 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t
rackIndex] : sizingData.rowTracks[trackIndex]; |
| 952 if (track.growthLimitIsInfinite()) | 945 if (track.growthLimitIsInfinite()) |
| 953 track.setGrowthLimit(track.baseSize()); | 946 track.setGrowthLimit(track.baseSize()); |
| 954 } | 947 } |
| 955 } | 948 } |
| 956 | 949 |
| 957 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid
TrackSizingDirection direction, const GridSpan& span, LayoutBox& gridItem, GridT
rack& track, GridSizingData& sizingData) | 950 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid
TrackSizingDirection direction, const GridSpan& span, LayoutBox& gridItem, GridT
rack& track, GridSizingData& sizingData) |
| 958 { | 951 { |
| 959 const size_t trackPosition = span.startLine(); | 952 const size_t trackPosition = span.startLine(); |
| 960 GridTrackSize trackSize = gridTrackSize(direction, trackPosition); | 953 GridTrackSize trackSize = gridTrackSize(direction, trackPosition, sizingData
.sizingOperation); |
| 961 | 954 |
| 962 if (trackSize.hasMinContentMinTrackBreadth()) | 955 if (trackSize.hasMinContentMinTrackBreadth()) |
| 963 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem
, direction, sizingData))); | 956 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem
, direction, sizingData))); |
| 964 else if (trackSize.hasMaxContentMinTrackBreadth()) | 957 else if (trackSize.hasMaxContentMinTrackBreadth()) |
| 965 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem
, direction, sizingData))); | 958 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem
, direction, sizingData))); |
| 966 else if (trackSize.hasAutoMinTrackBreadth()) | 959 else if (trackSize.hasAutoMinTrackBreadth()) |
| 967 track.setBaseSize(std::max(track.baseSize(), minSizeForChild(gridItem, d
irection, sizingData))); | 960 track.setBaseSize(std::max(track.baseSize(), minSizeForChild(gridItem, d
irection, sizingData))); |
| 968 | 961 |
| 969 if (trackSize.hasMinContentMaxTrackBreadth()) | 962 if (trackSize.hasMinContentMaxTrackBreadth()) |
| 970 track.setGrowthLimit(std::max(track.growthLimit(), minContentForChild(gr
idItem, direction, sizingData))); | 963 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) | 1187 for (auto* track : tracks) |
| 1195 track->setPlannedSize(track->plannedSize() == infinity ? track->sizeDuri
ngDistribution() : std::max(track->plannedSize(), track->sizeDuringDistribution(
))); | 1188 track->setPlannedSize(track->plannedSize() == infinity ? track->sizeDuri
ngDistribution() : std::max(track->plannedSize(), track->sizeDuringDistribution(
))); |
| 1196 } | 1189 } |
| 1197 | 1190 |
| 1198 #if ENABLE(ASSERT) | 1191 #if ENABLE(ASSERT) |
| 1199 bool LayoutGrid::tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection dire
ction, GridSizingData& sizingData) | 1192 bool LayoutGrid::tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection dire
ction, GridSizingData& sizingData) |
| 1200 { | 1193 { |
| 1201 const Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.col
umnTracks : sizingData.rowTracks; | 1194 const Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.col
umnTracks : sizingData.rowTracks; |
| 1202 LayoutUnit& maxSize = sizingData.freeSpaceForDirection(direction); | 1195 LayoutUnit& maxSize = sizingData.freeSpaceForDirection(direction); |
| 1203 for (size_t i = 0; i < tracks.size(); ++i) { | 1196 for (size_t i = 0; i < tracks.size(); ++i) { |
| 1204 GridTrackSize trackSize = gridTrackSize(direction, i); | 1197 GridTrackSize trackSize = gridTrackSize(direction, i, sizingData.sizingO
peration); |
| 1205 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); | 1198 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); |
| 1206 if (computeUsedBreadthOfMinLength(minTrackBreadth, maxSize) > tracks[i].
baseSize()) | 1199 if (computeUsedBreadthOfMinLength(minTrackBreadth, maxSize) > tracks[i].
baseSize()) |
| 1207 return false; | 1200 return false; |
| 1208 } | 1201 } |
| 1209 return true; | 1202 return true; |
| 1210 } | 1203 } |
| 1211 #endif | 1204 #endif |
| 1212 | 1205 |
| 1213 void LayoutGrid::ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize) | 1206 void LayoutGrid::ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize) |
| 1214 { | 1207 { |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2255 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData
)); | 2248 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData
)); |
| 2256 } | 2249 } |
| 2257 | 2250 |
| 2258 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2251 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
| 2259 { | 2252 { |
| 2260 if (!m_gridItemArea.isEmpty()) | 2253 if (!m_gridItemArea.isEmpty()) |
| 2261 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2254 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 2262 } | 2255 } |
| 2263 | 2256 |
| 2264 } // namespace blink | 2257 } // namespace blink |
| OLD | NEW |