Changeset 221931 in webkit
- Timestamp:
- Sep 12, 2017 12:19:45 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r221910 r221931 1 2017-09-12 Manuel Rego Casasnovas <rego@igalia.com> 2 3 [css-grid] Stretching auto tracks should be done as part of the track sizing algorithm 4 https://bugs.webkit.org/show_bug.cgi?id=176783 5 6 Reviewed by Sergio Villar Senin. 7 8 Import changes on the test related to the new behavior. 9 10 * web-platform-tests/css/css-grid-1/grid-items/grid-minimum-size-grid-items-021.html: 11 1 12 2017-09-12 Manuel Rego Casasnovas <rego@igalia.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid-1/grid-items/grid-minimum-size-grid-items-021.html
r221910 r221931 69 69 checkGridSizeTracksAndImageSize("grid-1", "img-1", "200px", "200px", "200px", "200px", "200px", "200px"); 70 70 checkGridSizeTracksAndImageSize("grid-2", "img-2", "10px", "10px", "200px", "200px", "200px", "200px"); 71 checkGridSizeTracksAndImageSize("grid-3", "img-3", "200px", " 50px", "200px", "50px", "200px", "200px");72 checkGridSizeTracksAndImageSize("grid-4", "img-4", "200px", "10px", "200px", " 50px", "200px", "200px");71 checkGridSizeTracksAndImageSize("grid-3", "img-3", "200px", "200px", "200px", "200px", "200px", "200px"); 72 checkGridSizeTracksAndImageSize("grid-4", "img-4", "200px", "10px", "200px", "200px", "200px", "200px"); 73 73 checkGridSizeTracksAndImageSize("grid-5", "img-5", "200px", "50px", "50px", "50px", "50px", "50px"); 74 74 checkGridSizeTracksAndImageSize("grid-6", "img-6", "200px", "10px", "50px", "50px", "50px", "50px"); 75 75 checkGridSizeTracksAndImageSize("grid-7", "img-7", "200px", "225px", "200px", "200px 25px", "200px", "200px"); 76 76 checkGridSizeTracksAndImageSize("grid-8", "img-8", "10px", "10px", "200px", "200px 25px", "200px", "200px"); 77 checkGridSizeTracksAndImageSize("grid-9", "img-9", "200px", " 125px", "200px", "100px 25px", "200px", "200px");78 checkGridSizeTracksAndImageSize("grid-10", "img-10", "200px", "10px", "200px", " 100px 25px", "200px", "200px");77 checkGridSizeTracksAndImageSize("grid-9", "img-9", "200px", "225px", "200px", "200px 25px", "200px", "200px"); 78 checkGridSizeTracksAndImageSize("grid-10", "img-10", "200px", "10px", "200px", "200px 25px", "200px", "200px"); 79 79 checkGridSizeTracksAndImageSize("grid-11", "img-11", "200px", "125px", "100px", "100px 25px", "100px", "100px"); 80 80 checkGridSizeTracksAndImageSize("grid-12", "img-12", "200px", "10px", "100px", "100px 25px", "100px", "100px"); -
trunk/Source/WebCore/ChangeLog
r221929 r221931 1 2017-09-12 Manuel Rego Casasnovas <rego@igalia.com> 2 3 [css-grid] Stretching auto tracks should be done as part of the track sizing algorithm 4 https://bugs.webkit.org/show_bug.cgi?id=176783 5 6 Reviewed by Sergio Villar Senin. 7 8 CSS WG has agreed to modify the track sizing algorithm to include 9 a new step: https://drafts.csswg.org/css-grid/#algo-stretch 10 We used to do the stretch of the "auto" tracks at the end of 11 the track sizing algorithm, however this change integrates it 12 into the algorithm itself as the last step. 13 See: https://github.com/w3c/csswg-drafts/issues/1150 14 15 The patch moves the method 16 RenderGrid::applyStretchAlignmentToTracksIfNeeded() to 17 GridTrackSizingAlgorithm::stretchAutoTracks(). 18 And then modifies the grid track sizing algorithm to execute 19 the new step. 20 21 This patch uses the WPT test updated to check the new behavior. 22 23 * rendering/GridTrackSizingAlgorithm.cpp: 24 (WebCore::GridTrackSizingAlgorithm::initializeTrackSizes): Initialize 25 the list of auto tracks. 26 (WebCore::GridTrackSizingAlgorithm::stretchFlexibleTracks): Add 27 early return if there are not flexible tracks. 28 (WebCore::GridTrackSizingAlgorithm::stretchAutoTracks): Code moved from 29 RenderGrid::applyStretchAlignmentToTracksIfNeeded(). 30 (WebCore::GridTrackSizingAlgorithm::setup): Reset list of auto tracks. 31 (WebCore::GridTrackSizingAlgorithm::run): Add new step 32 stretchAutoTracks(). 33 (WebCore::GridTrackSizingAlgorithm::reset): Reset auto tracks. 34 * rendering/GridTrackSizingAlgorithm.h: Add m_autoSizedTracksIndex. 35 * rendering/RenderGrid.cpp: 36 (WebCore::RenderGrid::layoutBlock): Avoid applying stretch here. 37 (WebCore::RenderGrid::contentAlignmentNormalBehaviorGrid): Make public. 38 (WebCore::RenderGrid::applyStretchAlignmentToTracksIfNeeded): Moved to 39 GridTrackSizingAlgorithm::stretchAutoTracks(). 40 * rendering/RenderGrid.h: 41 1 42 2017-09-12 Eric Carlson <eric.carlson@apple.com> 2 43 -
trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp
r221910 r221931 971 971 ASSERT(m_contentSizedTracksIndex.isEmpty()); 972 972 ASSERT(m_flexibleSizedTracksIndex.isEmpty()); 973 ASSERT(m_autoSizedTracksIndex.isEmpty()); 973 974 974 975 Vector<GridTrack>& allTracks = tracks(m_direction); … … 993 994 if (trackSize.maxTrackBreadth().isFlex()) 994 995 m_flexibleSizedTracksIndex.append(i); 996 if (trackSize.hasAutoMaxTrackBreadth()) 997 m_autoSizedTracksIndex.append(i); 995 998 } 996 999 } … … 1040 1043 void GridTrackSizingAlgorithm::stretchFlexibleTracks(std::optional<LayoutUnit> freeSpace) 1041 1044 { 1045 if (m_flexibleSizedTracksIndex.isEmpty()) 1046 return; 1047 1042 1048 double flexFraction = m_strategy->findUsedFlexFraction(m_flexibleSizedTracksIndex, m_direction, freeSpace); 1043 1049 … … 1062 1068 setFreeSpace(m_direction, this->freeSpace(m_direction).value() - totalGrowth); 1063 1069 m_maxContentSize += totalGrowth; 1070 } 1071 1072 void GridTrackSizingAlgorithm::stretchAutoTracks() 1073 { 1074 if (m_autoSizedTracksIndex.isEmpty()) 1075 return; 1076 1077 auto currentFreeSpace = freeSpace(m_direction); 1078 if (!currentFreeSpace 1079 || currentFreeSpace.value() <= 0 1080 || (m_direction == ForColumns && m_renderGrid->style().resolvedJustifyContentDistribution(m_renderGrid->contentAlignmentNormalBehaviorGrid()) != ContentDistributionStretch) 1081 || (m_direction == ForRows && m_renderGrid->style().resolvedAlignContentDistribution(m_renderGrid->contentAlignmentNormalBehaviorGrid()) != ContentDistributionStretch)) 1082 return; 1083 1084 Vector<GridTrack>& allTracks = tracks(m_direction); 1085 unsigned numberOfAutoSizedTracks = m_autoSizedTracksIndex.size(); 1086 LayoutUnit sizeToIncrease = currentFreeSpace.value() / numberOfAutoSizedTracks; 1087 for (const auto& trackIndex : m_autoSizedTracksIndex) { 1088 auto& track = allTracks[trackIndex]; 1089 track.setBaseSize(track.baseSize() + sizeToIncrease); 1090 } 1091 setFreeSpace(m_direction, LayoutUnit()); 1064 1092 } 1065 1093 … … 1118 1146 m_contentSizedTracksIndex.shrink(0); 1119 1147 m_flexibleSizedTracksIndex.shrink(0); 1148 m_autoSizedTracksIndex.shrink(0); 1120 1149 1121 1150 setFreeSpace(direction, freeSpace); … … 1151 1180 m_strategy->maximizeTracks(tracks(m_direction), m_direction == ForColumns ? m_freeSpaceColumns : m_freeSpaceRows); 1152 1181 1153 if (m_flexibleSizedTracksIndex.isEmpty())1154 return;1155 1156 1182 // Step 4. 1157 1183 stretchFlexibleTracks(initialFreeSpace); 1184 1185 // Step 5. 1186 stretchAutoTracks(); 1158 1187 } 1159 1188 … … 1165 1194 m_contentSizedTracksIndex.shrink(0); 1166 1195 m_flexibleSizedTracksIndex.shrink(0); 1196 m_autoSizedTracksIndex.shrink(0); 1167 1197 setAvailableSpace(ForRows, std::nullopt); 1168 1198 setAvailableSpace(ForColumns, std::nullopt); -
trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.h
r215800 r221931 154 154 void resolveIntrinsicTrackSizes(); 155 155 void stretchFlexibleTracks(std::optional<LayoutUnit> freeSpace); 156 void stretchAutoTracks(); 156 157 157 158 // State machine. … … 172 173 Vector<unsigned> m_contentSizedTracksIndex; 173 174 Vector<unsigned> m_flexibleSizedTracksIndex; 175 Vector<unsigned> m_autoSizedTracksIndex; 174 176 175 177 GridTrackSizingDirection m_direction; -
trunk/Source/WebCore/rendering/RenderGrid.cpp
r219315 r221931 306 306 } 307 307 308 applyStretchAlignmentToTracksIfNeeded(ForColumns);309 applyStretchAlignmentToTracksIfNeeded(ForRows);310 311 308 layoutGridItems(); 312 309 m_trackSizingAlgorithm.reset(); … … 881 878 } 882 879 883 static const StyleContentAlignmentData&contentAlignmentNormalBehaviorGrid()880 const StyleContentAlignmentData& RenderGrid::contentAlignmentNormalBehaviorGrid() 884 881 { 885 882 static const StyleContentAlignmentData normalBehavior = {ContentPositionNormal, ContentDistributionStretch}; 886 883 return normalBehavior; 887 }888 889 void RenderGrid::applyStretchAlignmentToTracksIfNeeded(GridTrackSizingDirection direction)890 {891 std::optional<LayoutUnit> freeSpace = m_trackSizingAlgorithm.freeSpace(direction);892 if (!freeSpace893 || freeSpace.value() <= 0894 || (direction == ForColumns && style().resolvedJustifyContentDistribution(contentAlignmentNormalBehaviorGrid()) != ContentDistributionStretch)895 || (direction == ForRows && style().resolvedAlignContentDistribution(contentAlignmentNormalBehaviorGrid()) != ContentDistributionStretch))896 return;897 898 // Spec defines auto-sized tracks as the ones with an 'auto' max-sizing function.899 Vector<GridTrack>& allTracks = m_trackSizingAlgorithm.tracks(direction);900 Vector<unsigned> autoSizedTracksIndex;901 for (unsigned i = 0; i < allTracks.size(); ++i) {902 const GridTrackSize& trackSize = m_trackSizingAlgorithm.gridTrackSize(direction, i);903 if (trackSize.hasAutoMaxTrackBreadth())904 autoSizedTracksIndex.append(i);905 }906 907 unsigned numberOfAutoSizedTracks = autoSizedTracksIndex.size();908 if (numberOfAutoSizedTracks < 1)909 return;910 911 LayoutUnit sizeToIncrease = freeSpace.value() / numberOfAutoSizedTracks;912 for (const auto& trackIndex : autoSizedTracksIndex) {913 auto& track = allTracks[trackIndex];914 track.setBaseSize(track.baseSize() + sizeToIncrease);915 }916 m_trackSizingAlgorithm.setFreeSpace(direction, LayoutUnit());917 884 } 918 885 -
trunk/Source/WebCore/rendering/RenderGrid.h
r219315 r221931 65 65 bool isOrthogonalChild(const RenderBox&) const; 66 66 LayoutUnit guttersSize(const Grid&, GridTrackSizingDirection, unsigned startLine, unsigned span, std::optional<LayoutUnit> availableSize) const; 67 68 static const StyleContentAlignmentData& contentAlignmentNormalBehaviorGrid(); 67 69 68 70 protected: … … 133 135 LayoutUnit gridAreaBreadthForChildIncludingAlignmentOffsets(const RenderBox&, GridTrackSizingDirection) const; 134 136 135 void applyStretchAlignmentToTracksIfNeeded(GridTrackSizingDirection);136 137 137 void paintChildren(PaintInfo& forSelf, const LayoutPoint& paintOffset, PaintInfo& forChild, bool usePrintRect) override; 138 138 LayoutUnit marginLogicalSizeForChild(GridTrackSizingDirection, const RenderBox&) const;
Note: See TracChangeset
for help on using the changeset viewer.