|
Lines 229-234
public:
a/Source/WebCore/rendering/RenderGrid.cpp_sec1
|
| 229 |
Optional<LayoutUnit> freeSpaceForDirection(GridTrackSizingDirection direction) { return direction == ForColumns ? freeSpaceForColumns : freeSpaceForRows; } |
229 |
Optional<LayoutUnit> freeSpaceForDirection(GridTrackSizingDirection direction) { return direction == ForColumns ? freeSpaceForColumns : freeSpaceForRows; } |
| 230 |
void setFreeSpaceForDirection(GridTrackSizingDirection, Optional<LayoutUnit> freeSpace); |
230 |
void setFreeSpaceForDirection(GridTrackSizingDirection, Optional<LayoutUnit> freeSpace); |
| 231 |
|
231 |
|
|
|
232 |
enum SizingOperation { TrackSizing, IntrinsicSizeComputation }; |
| 233 |
SizingOperation sizingOperation { TrackSizing }; |
| 234 |
|
| 232 |
private: |
235 |
private: |
| 233 |
Optional<LayoutUnit> freeSpaceForColumns; |
236 |
Optional<LayoutUnit> freeSpaceForColumns; |
| 234 |
Optional<LayoutUnit> freeSpaceForRows; |
237 |
Optional<LayoutUnit> freeSpaceForRows; |
|
Lines 331-336
void RenderGrid::computeTrackSizesForDirection(GridTrackSizingDirection directio
a/Source/WebCore/rendering/RenderGrid.cpp_sec2
|
| 331 |
{ |
334 |
{ |
| 332 |
LayoutUnit totalGuttersSize = guttersSize(direction, direction == ForRows ? gridRowCount() : gridColumnCount()); |
335 |
LayoutUnit totalGuttersSize = guttersSize(direction, direction == ForRows ? gridRowCount() : gridColumnCount()); |
| 333 |
sizingData.setFreeSpaceForDirection(direction, freeSpace - totalGuttersSize); |
336 |
sizingData.setFreeSpaceForDirection(direction, freeSpace - totalGuttersSize); |
|
|
337 |
sizingData.sizingOperation = GridSizingData::TrackSizing; |
| 334 |
|
338 |
|
| 335 |
LayoutUnit baseSizes, growthLimits; |
339 |
LayoutUnit baseSizes, growthLimits; |
| 336 |
computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimits); |
340 |
computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimits); |
|
Lines 432-437
void RenderGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
a/Source/WebCore/rendering/RenderGrid.cpp_sec3
|
| 432 |
|
436 |
|
| 433 |
GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
437 |
GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
| 434 |
sizingData.setFreeSpaceForDirection(ForColumns, Nullopt); |
438 |
sizingData.setFreeSpaceForDirection(ForColumns, Nullopt); |
|
|
439 |
sizingData.sizingOperation = GridSizingData::IntrinsicSizeComputation; |
| 435 |
const_cast<RenderGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, sizingData, minLogicalWidth, maxLogicalWidth); |
440 |
const_cast<RenderGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, sizingData, minLogicalWidth, maxLogicalWidth); |
| 436 |
|
441 |
|
| 437 |
LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTracks.size()); |
442 |
LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTracks.size()); |
|
Lines 450-455
void RenderGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData)
a/Source/WebCore/rendering/RenderGrid.cpp_sec4
|
| 450 |
{ |
455 |
{ |
| 451 |
ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); |
456 |
ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); |
| 452 |
sizingData.setFreeSpaceForDirection(ForRows, Nullopt); |
457 |
sizingData.setFreeSpaceForDirection(ForRows, Nullopt); |
|
|
458 |
sizingData.sizingOperation = GridSizingData::IntrinsicSizeComputation; |
| 453 |
LayoutUnit minHeight, maxHeight; |
459 |
LayoutUnit minHeight, maxHeight; |
| 454 |
computeUsedBreadthOfGridTracks(ForRows, sizingData, minHeight, maxHeight); |
460 |
computeUsedBreadthOfGridTracks(ForRows, sizingData, minHeight, maxHeight); |
| 455 |
|
461 |
|
|
Lines 713-719
GridTrackSize RenderGrid::gridTrackSize(GridTrackSizingDirection direction, unsi
a/Source/WebCore/rendering/RenderGrid.cpp_sec5
|
| 713 |
return GridTrackSize(minTrackBreadth, maxTrackBreadth); |
719 |
return GridTrackSize(minTrackBreadth, maxTrackBreadth); |
| 714 |
} |
720 |
} |
| 715 |
|
721 |
|
| 716 |
LayoutUnit RenderGrid::logicalContentHeightForChild(RenderBox& child, GridSizingData& sizingData) |
722 |
LayoutUnit RenderGrid::logicalHeightForChild(RenderBox& child, GridSizingData& sizingData) |
| 717 |
{ |
723 |
{ |
| 718 |
Optional<LayoutUnit> oldOverrideContainingBlockContentLogicalWidth = child.hasOverrideContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth() : LayoutUnit(); |
724 |
Optional<LayoutUnit> oldOverrideContainingBlockContentLogicalWidth = child.hasOverrideContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth() : LayoutUnit(); |
| 719 |
LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForChild(child, ForColumns, sizingData.columnTracks); |
725 |
LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForChild(child, ForColumns, sizingData.columnTracks); |
|
Lines 724-730
LayoutUnit RenderGrid::logicalContentHeightForChild(RenderBox& child, GridSizing
a/Source/WebCore/rendering/RenderGrid.cpp_sec6
|
| 724 |
if (child.needsLayout()) |
730 |
if (child.needsLayout()) |
| 725 |
child.clearOverrideLogicalContentHeight(); |
731 |
child.clearOverrideLogicalContentHeight(); |
| 726 |
|
732 |
|
| 727 |
child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockContentLogicalWidth); |
|
|
| 728 |
// If |child| has a relative logical height, we shouldn't let it override its intrinsic height, which is |
733 |
// If |child| has a relative logical height, we shouldn't let it override its intrinsic height, which is |
| 729 |
// what we are interested in here. Thus we need to set the override logical height to Nullopt (no possible resolution). |
734 |
// what we are interested in here. Thus we need to set the override logical height to Nullopt (no possible resolution). |
| 730 |
if (child.hasRelativeLogicalHeight()) |
735 |
if (child.hasRelativeLogicalHeight()) |
|
Lines 747-756
LayoutUnit RenderGrid::minSizeForChild(RenderBox& child, GridTrackSizingDirectio
a/Source/WebCore/rendering/RenderGrid.cpp_sec7
|
| 747 |
if (!childSize.isAuto() || childMinSize.isAuto()) |
752 |
if (!childSize.isAuto() || childMinSize.isAuto()) |
| 748 |
return minContentForChild(child, direction, sizingData); |
753 |
return minContentForChild(child, direction, sizingData); |
| 749 |
|
754 |
|
| 750 |
if (isRowAxis) |
755 |
bool overrideLogicalWidthHasChanged = updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingData); |
| 751 |
return child.computeLogicalWidthInRegionUsing(MinSize, childMinSize, contentLogicalWidth(), *this, nullptr); |
756 |
if (isRowAxis) { |
|
|
757 |
LayoutUnit marginLogicalWidth = sizingData.sizingOperation == GridSizingData::TrackSizing ? computeMarginLogicalSizeForChild(ForColumns, child) : marginIntrinsicLogicalWidthForChild(child); |
| 758 |
return child.computeLogicalWidthInRegionUsing(MinSize, childMinSize, child.overrideContainingBlockContentLogicalWidth().valueOr(0), *this, nullptr) + marginLogicalWidth; |
| 759 |
} |
| 760 |
|
| 761 |
if (overrideLogicalWidthHasChanged) |
| 762 |
child.setNeedsLayout(MarkOnlyThis); |
| 763 |
child.layoutIfNeeded(); |
| 764 |
return child.computeLogicalHeightUsing(MinSize, childMinSize, Nullopt).valueOr(0) + child.marginLogicalHeight() + child.scrollbarLogicalHeight(); |
| 765 |
} |
| 766 |
|
| 767 |
bool RenderGrid::updateOverrideContainingBlockContentLogicalWidthForChild(RenderBox& child, GridSizingData& sizingData) |
| 768 |
{ |
| 769 |
LayoutUnit overrideWidth = gridAreaBreadthForChild(child, ForColumns, sizingData.columnTracks); |
| 770 |
if (child.hasOverrideContainingBlockLogicalWidth() && child.overrideContainingBlockContentLogicalWidth() == overrideWidth) |
| 771 |
return false; |
| 752 |
|
772 |
|
| 753 |
return child.computeLogicalHeightUsing(MinSize, childMinSize, Nullopt).valueOr(0); |
773 |
child.setOverrideContainingBlockContentLogicalWidth(overrideWidth); |
|
|
774 |
return true; |
| 754 |
} |
775 |
} |
| 755 |
|
776 |
|
| 756 |
LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirection direction, GridSizingData& sizingData) |
777 |
LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirection direction, GridSizingData& sizingData) |
|
Lines 771-777
LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirec
a/Source/WebCore/rendering/RenderGrid.cpp_sec8
|
| 771 |
return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthForChild(child); |
792 |
return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthForChild(child); |
| 772 |
} |
793 |
} |
| 773 |
|
794 |
|
| 774 |
return logicalContentHeightForChild(child, sizingData); |
795 |
if (updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingData)) |
|
|
796 |
child.setNeedsLayout(MarkOnlyThis); |
| 797 |
return logicalHeightForChild(child, sizingData); |
| 775 |
} |
798 |
} |
| 776 |
|
799 |
|
| 777 |
LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirection direction, GridSizingData& sizingData) |
800 |
LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirection direction, GridSizingData& sizingData) |
|
Lines 792-798
LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirec
a/Source/WebCore/rendering/RenderGrid.cpp_sec9
|
| 792 |
return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthForChild(child); |
815 |
return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthForChild(child); |
| 793 |
} |
816 |
} |
| 794 |
|
817 |
|
| 795 |
return logicalContentHeightForChild(child, sizingData); |
818 |
if (updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingData)) |
|
|
819 |
child.setNeedsLayout(MarkOnlyThis); |
| 820 |
return logicalHeightForChild(child, sizingData); |
| 796 |
} |
821 |
} |
| 797 |
|
822 |
|
| 798 |
class GridItemWithSpan { |
823 |
class GridItemWithSpan { |
|
Lines 1676-1691
LayoutUnit RenderGrid::marginLogicalHeightForChild(const RenderBox& child) const
a/Source/WebCore/rendering/RenderGrid.cpp_sec10
|
| 1676 |
return isHorizontalWritingMode() ? child.verticalMarginExtent() : child.horizontalMarginExtent(); |
1701 |
return isHorizontalWritingMode() ? child.verticalMarginExtent() : child.horizontalMarginExtent(); |
| 1677 |
} |
1702 |
} |
| 1678 |
|
1703 |
|
| 1679 |
LayoutUnit RenderGrid::computeMarginLogicalHeightForChild(const RenderBox& child) const |
1704 |
LayoutUnit RenderGrid::computeMarginLogicalSizeForChild(GridTrackSizingDirection direction, const RenderBox& child) const |
| 1680 |
{ |
1705 |
{ |
| 1681 |
if (!child.style().hasMargin()) |
1706 |
if (!child.style().hasMargin()) |
| 1682 |
return 0; |
1707 |
return 0; |
| 1683 |
|
1708 |
|
| 1684 |
LayoutUnit marginBefore; |
1709 |
LayoutUnit marginStart; |
| 1685 |
LayoutUnit marginAfter; |
1710 |
LayoutUnit marginEnd; |
| 1686 |
child.computeBlockDirectionMargins(*this, marginBefore, marginAfter); |
1711 |
if (direction == ForColumns) |
|
|
1712 |
child.computeInlineDirectionMargins(*this, child.containingBlockLogicalWidthForContentInRegion(nullptr), child.logicalWidth(), marginStart, marginEnd); |
| 1713 |
else |
| 1714 |
child.computeBlockDirectionMargins(*this, marginStart, marginEnd); |
| 1687 |
|
1715 |
|
| 1688 |
return marginBefore + marginAfter; |
1716 |
return marginStart + marginEnd; |
| 1689 |
} |
1717 |
} |
| 1690 |
|
1718 |
|
| 1691 |
LayoutUnit RenderGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUnit gridAreaBreadthForChild, const RenderBox& child) const |
1719 |
LayoutUnit RenderGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUnit gridAreaBreadthForChild, const RenderBox& child) const |
|
Lines 1693-1699
LayoutUnit RenderGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUni
a/Source/WebCore/rendering/RenderGrid.cpp_sec11
|
| 1693 |
// Because we want to avoid multiple layouts, stretching logic might be performed before |
1721 |
// Because we want to avoid multiple layouts, stretching logic might be performed before |
| 1694 |
// children are laid out, so we can't use the child cached values. Hence, we need to |
1722 |
// children are laid out, so we can't use the child cached values. Hence, we need to |
| 1695 |
// compute margins in order to determine the available height before stretching. |
1723 |
// compute margins in order to determine the available height before stretching. |
| 1696 |
return gridAreaBreadthForChild - (child.needsLayout() ? computeMarginLogicalHeightForChild(child) : marginLogicalHeightForChild(child)); |
1724 |
return gridAreaBreadthForChild - (child.needsLayout() ? computeMarginLogicalSizeForChild(ForRows, child) : marginLogicalHeightForChild(child)); |
| 1697 |
} |
1725 |
} |
| 1698 |
|
1726 |
|
| 1699 |
// FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to RenderBox. |
1727 |
// FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to RenderBox. |