Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutGrid.cpp

Issue 2150533003: [css-grid] Constify track sizing algorithm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 return valueForLength(trackGap, LayoutUnit()) * (span - 1); 509 return valueForLength(trackGap, LayoutUnit()) * (span - 1);
510 } 510 }
511 511
512 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const 512 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const
513 { 513 {
514 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(); 514 const_cast<LayoutGrid*>(this)->placeItemsOnGrid();
515 515
516 GridSizingData sizingData(gridColumnCount(), gridRowCount()); 516 GridSizingData sizingData(gridColumnCount(), gridRowCount());
517 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit(); 517 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit();
518 sizingData.sizingOperation = IntrinsicSizeComputation; 518 sizingData.sizingOperation = IntrinsicSizeComputation;
519 const_cast<LayoutGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, si zingData, minLogicalWidth, maxLogicalWidth); 519 computeUsedBreadthOfGridTracks(ForColumns, sizingData, minLogicalWidth, maxL ogicalWidth);
520 520
521 LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTrack s.size()); 521 LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTrack s.size());
522 minLogicalWidth += totalGuttersSize; 522 minLogicalWidth += totalGuttersSize;
523 maxLogicalWidth += totalGuttersSize; 523 maxLogicalWidth += totalGuttersSize;
524 524
525 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); 525 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth());
526 minLogicalWidth += scrollbarWidth; 526 minLogicalWidth += scrollbarWidth;
527 maxLogicalWidth += scrollbarWidth; 527 maxLogicalWidth += scrollbarWidth;
528 } 528 }
529 529
(...skipping 30 matching lines...) Expand all
560 return containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadd ing) - borderAndPadding; 560 return containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadd ing) - borderAndPadding;
561 ASSERT_NOT_REACHED(); 561 ASSERT_NOT_REACHED();
562 return LayoutUnit(); 562 return LayoutUnit();
563 } 563 }
564 564
565 static inline double normalizedFlexFraction(const GridTrack& track, double flexF actor) 565 static inline double normalizedFlexFraction(const GridTrack& track, double flexF actor)
566 { 566 {
567 return track.baseSize() / std::max<double>(1, flexFactor); 567 return track.baseSize() / std::max<double>(1, flexFactor);
568 } 568 }
569 569
570 void LayoutGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi on, GridSizingData& sizingData, LayoutUnit& baseSizesWithoutMaximization, Layout Unit& growthLimitsWithoutMaximization) 570 void LayoutGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi on, GridSizingData& sizingData, LayoutUnit& baseSizesWithoutMaximization, Layout Unit& growthLimitsWithoutMaximization) const
571 { 571 {
572 LayoutUnit& freeSpace = sizingData.freeSpaceForDirection(direction); 572 LayoutUnit& freeSpace = sizingData.freeSpaceForDirection(direction);
573 const LayoutUnit initialFreeSpace = freeSpace; 573 const LayoutUnit initialFreeSpace = freeSpace;
574 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks; 574 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks;
575 Vector<size_t> flexibleSizedTracksIndex; 575 Vector<size_t> flexibleSizedTracksIndex;
576 sizingData.contentSizedTracksIndex.shrink(0); 576 sizingData.contentSizedTracksIndex.shrink(0);
577 577
578 LayoutUnit maxSize = std::max(LayoutUnit(), initialFreeSpace); 578 LayoutUnit maxSize = std::max(LayoutUnit(), initialFreeSpace);
579 // Grid gutters were removed from freeSpace by the caller, but we must use t hem to compute relative (i.e. percentages) sizes. 579 // Grid gutters were removed from freeSpace by the caller, but we must use t hem to compute relative (i.e. percentages) sizes.
580 bool hasDefiniteFreeSpace = sizingData.sizingOperation == TrackSizing; 580 bool hasDefiniteFreeSpace = sizingData.sizingOperation == TrackSizing;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 minTrackBreadth = Length(Auto); 833 minTrackBreadth = Length(Auto);
834 834
835 return GridTrackSize(minTrackBreadth, maxTrackBreadth); 835 return GridTrackSize(minTrackBreadth, maxTrackBreadth);
836 } 836 }
837 837
838 bool LayoutGrid::isOrthogonalChild(const LayoutBox& child) const 838 bool LayoutGrid::isOrthogonalChild(const LayoutBox& child) const
839 { 839 {
840 return child.isHorizontalWritingMode() != isHorizontalWritingMode(); 840 return child.isHorizontalWritingMode() != isHorizontalWritingMode();
841 } 841 }
842 842
843 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, GridSizingData& s izingData) 843 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, GridSizingData& s izingData) const
844 { 844 {
845 GridTrackSizingDirection childBlockDirection = flowAwareDirectionForChild(ch ild, ForRows); 845 GridTrackSizingDirection childBlockDirection = flowAwareDirectionForChild(ch ild, ForRows);
846 SubtreeLayoutScope layoutScope(child); 846 SubtreeLayoutScope layoutScope(child);
847 // If |child| has a relative logical height, we shouldn't let it override it s intrinsic height, which is 847 // If |child| has a relative logical height, we shouldn't let it override it s intrinsic height, which is
848 // what we are interested in here. Thus we need to set the block-axis overri de size to -1 (no possible resolution). 848 // what we are interested in here. Thus we need to set the block-axis overri de size to -1 (no possible resolution).
849 if (shouldClearOverrideContainingBlockContentSizeForChild(child, ForRows)) { 849 if (shouldClearOverrideContainingBlockContentSizeForChild(child, ForRows)) {
850 setOverrideContainingBlockContentSizeForChild(child, childBlockDirection , LayoutUnit(-1)); 850 setOverrideContainingBlockContentSizeForChild(child, childBlockDirection , LayoutUnit(-1));
851 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged ); 851 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged );
852 } 852 }
853 853
854 // We need to clear the stretched height to properly compute logical height during layout. 854 // We need to clear the stretched height to properly compute logical height during layout.
855 if (child.needsLayout()) 855 if (child.needsLayout())
856 child.clearOverrideLogicalContentHeight(); 856 child.clearOverrideLogicalContentHeight();
857 857
858 child.layoutIfNeeded(); 858 child.layoutIfNeeded();
859 return child.logicalHeight() + child.marginLogicalHeight(); 859 return child.logicalHeight() + child.marginLogicalHeight();
860 } 860 }
861 861
862 GridTrackSizingDirection LayoutGrid::flowAwareDirectionForChild(const LayoutBox& child, GridTrackSizingDirection direction) const 862 GridTrackSizingDirection LayoutGrid::flowAwareDirectionForChild(const LayoutBox& child, GridTrackSizingDirection direction) const
863 { 863 {
864 return !isOrthogonalChild(child) ? direction : (direction == ForColumns ? Fo rRows : ForColumns); 864 return !isOrthogonalChild(child) ? direction : (direction == ForColumns ? Fo rRows : ForColumns);
865 } 865 }
866 866
867 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio n direction, GridSizingData& sizingData) 867 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio n direction, GridSizingData& sizingData) const
868 { 868 {
869 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(c hild, ForColumns); 869 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(c hild, ForColumns);
870 bool isRowAxis = direction == childInlineDirection; 870 bool isRowAxis = direction == childInlineDirection;
871 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil d.styleRef().logicalHeight(); 871 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil d.styleRef().logicalHeight();
872 const Length& childMinSize = isRowAxis ? child.styleRef().logicalMinWidth() : child.styleRef().logicalMinHeight(); 872 const Length& childMinSize = isRowAxis ? child.styleRef().logicalMinWidth() : child.styleRef().logicalMinHeight();
873 if (!childSize.isAuto() || childMinSize.isAuto()) 873 if (!childSize.isAuto() || childMinSize.isAuto())
874 return minContentForChild(child, direction, sizingData); 874 return minContentForChild(child, direction, sizingData);
875 875
876 bool overrideSizeHasChanged = updateOverrideContainingBlockContentSizeForChi ld(child, childInlineDirection, sizingData); 876 bool overrideSizeHasChanged = updateOverrideContainingBlockContentSizeForChi ld(child, childInlineDirection, sizingData);
877 if (isRowAxis) { 877 if (isRowAxis) {
878 LayoutUnit marginLogicalWidth = sizingData.sizingOperation == TrackSizin g ? computeMarginLogicalSizeForChild(InlineDirection, child) : marginIntrinsicLo gicalWidthForChild(child); 878 LayoutUnit marginLogicalWidth = sizingData.sizingOperation == TrackSizin g ? computeMarginLogicalSizeForChild(InlineDirection, child) : marginIntrinsicLo gicalWidthForChild(child);
879 return child.computeLogicalWidthUsing(MinSize, childMinSize, overrideCon tainingBlockContentSizeForChild(child, childInlineDirection), this) + marginLogi calWidth; 879 return child.computeLogicalWidthUsing(MinSize, childMinSize, overrideCon tainingBlockContentSizeForChild(child, childInlineDirection), this) + marginLogi calWidth;
880 } 880 }
881 881
882 if (overrideSizeHasChanged && (direction != ForColumns || sizingData.sizingO peration != IntrinsicSizeComputation)) 882 if (overrideSizeHasChanged && (direction != ForColumns || sizingData.sizingO peration != IntrinsicSizeComputation))
883 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); 883 child.setNeedsLayout(LayoutInvalidationReason::GridChanged);
884 child.layoutIfNeeded(); 884 child.layoutIfNeeded();
885 return child.computeLogicalHeightUsing(MinSize, childMinSize, child.intrinsi cLogicalHeight()) + child.marginLogicalHeight() + child.scrollbarLogicalHeight() ; 885 return child.computeLogicalHeightUsing(MinSize, childMinSize, child.intrinsi cLogicalHeight()) + child.marginLogicalHeight() + child.scrollbarLogicalHeight() ;
886 } 886 }
887 887
888 bool LayoutGrid::updateOverrideContainingBlockContentSizeForChild(LayoutBox& chi ld, GridTrackSizingDirection direction, GridSizingData& sizingData) 888 bool LayoutGrid::updateOverrideContainingBlockContentSizeForChild(LayoutBox& chi ld, GridTrackSizingDirection direction, GridSizingData& sizingData) const
889 { 889 {
890 LayoutUnit overrideSize = gridAreaBreadthForChild(child, direction, sizingDa ta); 890 LayoutUnit overrideSize = gridAreaBreadthForChild(child, direction, sizingDa ta);
891 if (hasOverrideContainingBlockContentSizeForChild(child, direction) && overr ideContainingBlockContentSizeForChild(child, direction) == overrideSize) 891 if (hasOverrideContainingBlockContentSizeForChild(child, direction) && overr ideContainingBlockContentSizeForChild(child, direction) == overrideSize)
892 return false; 892 return false;
893 893
894 setOverrideContainingBlockContentSizeForChild(child, direction, overrideSize ); 894 setOverrideContainingBlockContentSizeForChild(child, direction, overrideSize );
895 return true; 895 return true;
896 } 896 }
897 897
898 LayoutUnit LayoutGrid::minContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) 898 LayoutUnit LayoutGrid::minContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) const
899 { 899 {
900 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(c hild, ForColumns); 900 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(c hild, ForColumns);
901 if (direction == childInlineDirection) { 901 if (direction == childInlineDirection) {
902 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is 902 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is
903 // what we are interested in here. Thus we need to set the inline-axis o verride size to -1 (no possible resolution). 903 // what we are interested in here. Thus we need to set the inline-axis o verride size to -1 (no possible resolution).
904 if (shouldClearOverrideContainingBlockContentSizeForChild(child, ForColu mns)) 904 if (shouldClearOverrideContainingBlockContentSizeForChild(child, ForColu mns))
905 setOverrideContainingBlockContentSizeForChild(child, childInlineDire ction, LayoutUnit(-1)); 905 setOverrideContainingBlockContentSizeForChild(child, childInlineDire ction, LayoutUnit(-1));
906 906
907 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. 907 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width.
908 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html 908 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
909 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); 909 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child);
910 } 910 }
911 911
912 // All orthogonal flow boxes were already laid out during an early layout ph ase performed in FrameView::performLayout. 912 // All orthogonal flow boxes were already laid out during an early layout ph ase performed in FrameView::performLayout.
913 // It's true that grid track sizing was not completed at that time and it ma y afffect the final height of a 913 // It's true that grid track sizing was not completed at that time and it ma y afffect the final height of a
914 // grid item, but since it's forbidden to perform a layout during intrinsic width computation, we have to use 914 // grid item, but since it's forbidden to perform a layout during intrinsic width computation, we have to use
915 // that computed height for now. 915 // that computed height for now.
916 if (direction == ForColumns && sizingData.sizingOperation == IntrinsicSizeCo mputation) { 916 if (direction == ForColumns && sizingData.sizingOperation == IntrinsicSizeCo mputation) {
917 DCHECK(isOrthogonalChild(child)); 917 DCHECK(isOrthogonalChild(child));
918 return child.logicalHeight() + child.marginLogicalHeight(); 918 return child.logicalHeight() + child.marginLogicalHeight();
919 } 919 }
920 920
921 SubtreeLayoutScope layouter(child); 921 SubtreeLayoutScope layouter(child);
922 if (updateOverrideContainingBlockContentSizeForChild(child, childInlineDirec tion, sizingData)) 922 if (updateOverrideContainingBlockContentSizeForChild(child, childInlineDirec tion, sizingData))
923 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); 923 child.setNeedsLayout(LayoutInvalidationReason::GridChanged);
924 return logicalHeightForChild(child, sizingData); 924 return logicalHeightForChild(child, sizingData);
925 } 925 }
926 926
927 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) 927 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) const
928 { 928 {
929 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(c hild, ForColumns); 929 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(c hild, ForColumns);
930 if (direction == childInlineDirection) { 930 if (direction == childInlineDirection) {
931 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is 931 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is
932 // what we are interested in here. Thus we need to set the inline-axis o verride size to -1 (no possible resolution). 932 // what we are interested in here. Thus we need to set the inline-axis o verride size to -1 (no possible resolution).
933 if (shouldClearOverrideContainingBlockContentSizeForChild(child, ForColu mns)) 933 if (shouldClearOverrideContainingBlockContentSizeForChild(child, ForColu mns))
934 setOverrideContainingBlockContentSizeForChild(child, childInlineDire ction, LayoutUnit(-1)); 934 setOverrideContainingBlockContentSizeForChild(child, childInlineDire ction, LayoutUnit(-1));
935 935
936 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. 936 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width.
937 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html 937 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 { 979 {
980 for (const auto& trackPosition : span) { 980 for (const auto& trackPosition : span) {
981 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition, sizingOperation); 981 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition, sizingOperation);
982 if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth(). isFlex()) 982 if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth(). isFlex())
983 return true; 983 return true;
984 } 984 }
985 985
986 return false; 986 return false;
987 } 987 }
988 988
989 void LayoutGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio n direction, GridSizingData& sizingData) 989 void LayoutGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio n direction, GridSizingData& sizingData) const
990 { 990 {
991 sizingData.itemsSortedByIncreasingSpan.shrink(0); 991 sizingData.itemsSortedByIncreasingSpan.shrink(0);
992 if (!m_gridItemArea.isEmpty()) { 992 if (!m_gridItemArea.isEmpty()) {
993 HashSet<LayoutBox*> itemsSet; 993 HashSet<LayoutBox*> itemsSet;
994 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { 994 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) {
995 GridIterator iterator(m_grid, direction, trackIndex); 995 GridIterator iterator(m_grid, direction, trackIndex);
996 GridTrack& track = (direction == ForColumns) ? sizingData.columnTrac ks[trackIndex] : sizingData.rowTracks[trackIndex]; 996 GridTrack& track = (direction == ForColumns) ? sizingData.columnTrac ks[trackIndex] : sizingData.rowTracks[trackIndex];
997 while (LayoutBox* gridItem = iterator.nextGridItem()) { 997 while (LayoutBox* gridItem = iterator.nextGridItem()) {
998 if (itemsSet.add(gridItem).isNewEntry) { 998 if (itemsSet.add(gridItem).isNewEntry) {
999 const GridSpan& span = cachedGridSpan(*gridItem, direction); 999 const GridSpan& span = cachedGridSpan(*gridItem, direction);
(...skipping 20 matching lines...) Expand all
1020 it = spanGroupRange.rangeEnd; 1020 it = spanGroupRange.rangeEnd;
1021 } 1021 }
1022 1022
1023 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { 1023 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) {
1024 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex]; 1024 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex];
1025 if (track.growthLimitIsInfinite()) 1025 if (track.growthLimitIsInfinite())
1026 track.setGrowthLimit(track.baseSize()); 1026 track.setGrowthLimit(track.baseSize());
1027 } 1027 }
1028 } 1028 }
1029 1029
1030 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid TrackSizingDirection direction, const GridSpan& span, LayoutBox& gridItem, GridT rack& track, GridSizingData& sizingData) 1030 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid TrackSizingDirection direction, const GridSpan& span, LayoutBox& gridItem, GridT rack& track, GridSizingData& sizingData) const
1031 { 1031 {
1032 const size_t trackPosition = span.startLine(); 1032 const size_t trackPosition = span.startLine();
1033 GridTrackSize trackSize = gridTrackSize(direction, trackPosition, sizingData .sizingOperation); 1033 GridTrackSize trackSize = gridTrackSize(direction, trackPosition, sizingData .sizingOperation);
1034 1034
1035 if (trackSize.hasMinContentMinTrackBreadth()) 1035 if (trackSize.hasMinContentMinTrackBreadth())
1036 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem , direction, sizingData))); 1036 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem , direction, sizingData)));
1037 else if (trackSize.hasMaxContentMinTrackBreadth()) 1037 else if (trackSize.hasMaxContentMinTrackBreadth())
1038 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem , direction, sizingData))); 1038 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem , direction, sizingData)));
1039 else if (trackSize.hasAutoMinTrackBreadth()) 1039 else if (trackSize.hasAutoMinTrackBreadth())
1040 track.setBaseSize(std::max(track.baseSize(), minSizeForChild(gridItem, d irection, sizingData))); 1040 track.setBaseSize(std::max(track.baseSize(), minSizeForChild(gridItem, d irection, sizingData)));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 track.setGrowthLimit(track.plannedSize()); 1143 track.setGrowthLimit(track.plannedSize());
1144 return; 1144 return;
1145 case MaximizeTracks: 1145 case MaximizeTracks:
1146 ASSERT_NOT_REACHED(); 1146 ASSERT_NOT_REACHED();
1147 return; 1147 return;
1148 } 1148 }
1149 1149
1150 ASSERT_NOT_REACHED(); 1150 ASSERT_NOT_REACHED();
1151 } 1151 }
1152 1152
1153 LayoutUnit LayoutGrid::currentItemSizeForTrackSizeComputationPhase(TrackSizeComp utationPhase phase, LayoutBox& gridItem, GridTrackSizingDirection direction, Gri dSizingData& sizingData) 1153 LayoutUnit LayoutGrid::currentItemSizeForTrackSizeComputationPhase(TrackSizeComp utationPhase phase, LayoutBox& gridItem, GridTrackSizingDirection direction, Gri dSizingData& sizingData) const
1154 { 1154 {
1155 switch (phase) { 1155 switch (phase) {
1156 case ResolveIntrinsicMinimums: 1156 case ResolveIntrinsicMinimums:
1157 return minSizeForChild(gridItem, direction, sizingData); 1157 return minSizeForChild(gridItem, direction, sizingData);
1158 case ResolveContentBasedMinimums: 1158 case ResolveContentBasedMinimums:
1159 case ResolveIntrinsicMaximums: 1159 case ResolveIntrinsicMaximums:
1160 return minContentForChild(gridItem, direction, sizingData); 1160 return minContentForChild(gridItem, direction, sizingData);
1161 case ResolveMaxContentMinimums: 1161 case ResolveMaxContentMinimums:
1162 case ResolveMaxContentMaximums: 1162 case ResolveMaxContentMaximums:
1163 return maxContentForChild(gridItem, direction, sizingData); 1163 return maxContentForChild(gridItem, direction, sizingData);
1164 case MaximizeTracks: 1164 case MaximizeTracks:
1165 ASSERT_NOT_REACHED(); 1165 ASSERT_NOT_REACHED();
1166 return LayoutUnit(); 1166 return LayoutUnit();
1167 } 1167 }
1168 1168
1169 ASSERT_NOT_REACHED(); 1169 ASSERT_NOT_REACHED();
1170 return LayoutUnit(); 1170 return LayoutUnit();
1171 } 1171 }
1172 1172
1173 template <TrackSizeComputationPhase phase> 1173 template <TrackSizeComputationPhase phase>
1174 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing Direction direction, GridSizingData& sizingData, const GridItemsSpanGroupRange& gridItemsWithSpan) 1174 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing Direction direction, GridSizingData& sizingData, const GridItemsSpanGroupRange& gridItemsWithSpan) const
1175 { 1175 {
1176 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks; 1176 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks;
1177 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { 1177 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) {
1178 GridTrack& track = tracks[trackIndex]; 1178 GridTrack& track = tracks[trackIndex];
1179 track.setPlannedSize(trackSizeForTrackSizeComputationPhase(phase, track, AllowInfinity)); 1179 track.setPlannedSize(trackSizeForTrackSizeComputationPhase(phase, track, AllowInfinity));
1180 } 1180 }
1181 1181
1182 for (auto it = gridItemsWithSpan.rangeStart; it != gridItemsWithSpan.rangeEn d; ++it) { 1182 for (auto it = gridItemsWithSpan.rangeStart; it != gridItemsWithSpan.rangeEn d; ++it) {
1183 GridItemWithSpan& gridItemWithSpan = *it; 1183 GridItemWithSpan& gridItemWithSpan = *it;
1184 ASSERT(gridItemWithSpan.getGridSpan().integerSpan() > 1); 1184 ASSERT(gridItemWithSpan.getGridSpan().integerSpan() > 1);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 if (track1->infiniteGrowthPotential() && track2->infiniteGrowthPotential()) 1225 if (track1->infiniteGrowthPotential() && track2->infiniteGrowthPotential())
1226 return false; 1226 return false;
1227 1227
1228 if (track1->infiniteGrowthPotential() || track2->infiniteGrowthPotential()) 1228 if (track1->infiniteGrowthPotential() || track2->infiniteGrowthPotential())
1229 return track2->infiniteGrowthPotential(); 1229 return track2->infiniteGrowthPotential();
1230 1230
1231 return (track1->growthLimit() - track1->baseSize()) < (track2->growthLimit() - track2->baseSize()); 1231 return (track1->growthLimit() - track1->baseSize()) < (track2->growthLimit() - track2->baseSize());
1232 } 1232 }
1233 1233
1234 template <TrackSizeComputationPhase phase> 1234 template <TrackSizeComputationPhase phase>
1235 void LayoutGrid::distributeSpaceToTracks(Vector<GridTrack*>& tracks, const Vecto r<GridTrack*>* growBeyondGrowthLimitsTracks, GridSizingData& sizingData, LayoutU nit& availableLogicalSpace) 1235 void LayoutGrid::distributeSpaceToTracks(Vector<GridTrack*>& tracks, const Vecto r<GridTrack*>* growBeyondGrowthLimitsTracks, GridSizingData& sizingData, LayoutU nit& availableLogicalSpace) const
1236 { 1236 {
1237 ASSERT(availableLogicalSpace >= 0); 1237 ASSERT(availableLogicalSpace >= 0);
1238 1238
1239 for (auto* track : tracks) 1239 for (auto* track : tracks)
1240 track->setSizeDuringDistribution(trackSizeForTrackSizeComputationPhase(p hase, *track, ForbidInfinity)); 1240 track->setSizeDuringDistribution(trackSizeForTrackSizeComputationPhase(p hase, *track, ForbidInfinity));
1241 1241
1242 if (availableLogicalSpace > 0) { 1242 if (availableLogicalSpace > 0) {
1243 std::sort(tracks.begin(), tracks.end(), sortByGridTrackGrowthPotential); 1243 std::sort(tracks.begin(), tracks.end(), sortByGridTrackGrowthPotential);
1244 1244
1245 size_t tracksSize = tracks.size(); 1245 size_t tracksSize = tracks.size();
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; 2363 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation;
2364 } 2364 }
2365 2365
2366 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const 2366 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const
2367 { 2367 {
2368 if (!m_gridItemArea.isEmpty()) 2368 if (!m_gridItemArea.isEmpty())
2369 GridPainter(*this).paintChildren(paintInfo, paintOffset); 2369 GridPainter(*this).paintChildren(paintInfo, paintOffset);
2370 } 2370 }
2371 2371
2372 } // namespace blink 2372 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698