Title: [287977] trunk
- Revision
- 287977
- Author
- [email protected]
- Date
- 2022-01-13 06:41:12 -0800 (Thu, 13 Jan 2022)
Log Message
[css-grid] Fix rounding of distributed free space to flexible tracks
https://bugs.webkit.org/show_bug.cgi?id=234917
LayoutTests/imported/w3c:
Reviewed by Darin Adler.
Source/WebCore:
Reviewed by Darin Adler.
When computing the growth size for flex sized tracks, the flexFraction multiplied by the flex factor can result
in a non-integer size. However, we floor the stretched size to fit in a LayoutUnit. This means that we may lose
the fractional part of the computation which can cause the entire free space not being distributed evenly. This
fix is to sum up the leftover fractional part from every flexible track to avoid this issue.
It is an import of Chromium GridNG CL at https://chromium-review.googlesource.com/c/chromium/src/+/3193674.
* rendering/GridTrackSizingAlgorithm.cpp:
(WebCore::GridTrackSizingAlgorithm::computeFlexSizedTracksGrowth const):
Modified Paths
Diff
Modified: trunk/LayoutTests/TestExpectations (287976 => 287977)
--- trunk/LayoutTests/TestExpectations 2022-01-13 13:04:00 UTC (rev 287976)
+++ trunk/LayoutTests/TestExpectations 2022-01-13 14:41:12 UTC (rev 287977)
@@ -1415,8 +1415,6 @@
webkit.org/b/231021 imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-margin-dynamic.html [ ImageOnlyFailure ]
webkit.org/b/231021 imported/w3c/web-platform-tests/css/css-grid/grid-items/replaced-element-015.html [ ImageOnlyFailure ]
-webkit.org/b/234879 imported/w3c/web-platform-tests/css/css-grid/layout-algorithm/flex-tracks-with-fractional-size.html [ ImageOnlyFailure ]
-
imported/w3c/web-platform-tests/css/css-grid/masonry/tentative/masonry-align-content-001.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-grid/masonry/tentative/masonry-align-content-002.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-grid/masonry/tentative/masonry-align-content-003.html [ ImageOnlyFailure ]
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (287976 => 287977)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-01-13 13:04:00 UTC (rev 287976)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-01-13 14:41:12 UTC (rev 287977)
@@ -1,3 +1,10 @@
+2022-01-13 Ziran Sun <[email protected]>
+
+ [css-grid] Fix rounding of distributed free space to flexible tracks
+ https://bugs.webkit.org/show_bug.cgi?id=234917
+
+ Reviewed by Darin Adler.
+
2022-01-12 Sergio Villar Senin <[email protected]>
[css-flexbox] Import WPT tests - January edition
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (287976 => 287977)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2022-01-13 13:04:00 UTC (rev 287976)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2022-01-13 14:41:12 UTC (rev 287977)
@@ -1977,6 +1977,7 @@
webkit.org/b/228153 imported/w3c/web-platform-tests/css/css-grid/abspos/grid-positioned-item-dynamic-change-001.html [ ImageOnlyFailure ]
webkit.org/b/228153 imported/w3c/web-platform-tests/css/css-grid/abspos/grid-positioned-item-dynamic-change-002.html [ ImageOnlyFailure ]
webkit.org/b/228153 imported/w3c/web-platform-tests/css/css-grid/abspos/grid-positioned-item-dynamic-change-003.html [ ImageOnlyFailure ]
+webkit.org/b/235025 imported/w3c/web-platform-tests/css/css-grid/layout-algorithm/flex-tracks-with-fractional-size.html [ ImageOnlyFailure ]
webkit.org/b/228153 imported/w3c/web-platform-tests/css/css-lists/content-property/marker-text-matches-armenian.html [ ImageOnlyFailure ]
webkit.org/b/228153 imported/w3c/web-platform-tests/css/css-lists/content-property/marker-text-matches-decimal.html [ ImageOnlyFailure ]
webkit.org/b/228153 imported/w3c/web-platform-tests/css/css-lists/content-property/marker-text-matches-decimal-leading-zero.html [ ImageOnlyFailure ]
Modified: trunk/Source/WebCore/ChangeLog (287976 => 287977)
--- trunk/Source/WebCore/ChangeLog 2022-01-13 13:04:00 UTC (rev 287976)
+++ trunk/Source/WebCore/ChangeLog 2022-01-13 14:41:12 UTC (rev 287977)
@@ -1,3 +1,20 @@
+2022-01-13 Ziran Sun <[email protected]>
+
+ [css-grid] Fix rounding of distributed free space to flexible tracks
+ https://bugs.webkit.org/show_bug.cgi?id=234917
+
+ Reviewed by Darin Adler.
+
+ When computing the growth size for flex sized tracks, the flexFraction multiplied by the flex factor can result
+ in a non-integer size. However, we floor the stretched size to fit in a LayoutUnit. This means that we may lose
+ the fractional part of the computation which can cause the entire free space not being distributed evenly. This
+ fix is to sum up the leftover fractional part from every flexible track to avoid this issue.
+
+ It is an import of Chromium GridNG CL at https://chromium-review.googlesource.com/c/chromium/src/+/3193674.
+
+ * rendering/GridTrackSizingAlgorithm.cpp:
+ (WebCore::GridTrackSizingAlgorithm::computeFlexSizedTracksGrowth const):
+
2022-01-10 Sergio Villar Senin <[email protected]>
[css-flexbox] Incorrect height of flex items with aspect-ratio whenever the cross axis intrinsic size is larger than the viewport
Modified: trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp (287976 => 287977)
--- trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp 2022-01-13 13:04:00 UTC (rev 287976)
+++ trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp 2022-01-13 14:41:12 UTC (rev 287977)
@@ -727,14 +727,22 @@
size_t numFlexTracks = m_flexibleSizedTracksIndex.size();
ASSERT(increments.size() == numFlexTracks);
const Vector<GridTrack>& allTracks = tracks(m_direction);
+ // The flexFraction multiplied by the flex factor can result in a non-integer size. Since we floor the stretched size to fit in a LayoutUnit,
+ // we may lose the fractional part of the computation which can cause the entire free space not being distributed evenly. The leftover
+ // fractional part from every flexible track are accumulated here to avoid this issue.
+ double leftOverSize = 0;
for (size_t i = 0; i < numFlexTracks; ++i) {
unsigned trackIndex = m_flexibleSizedTracksIndex[i];
const auto& trackSize = allTracks[trackIndex].cachedTrackSize();
ASSERT(trackSize.maxTrackBreadth().isFlex());
LayoutUnit oldBaseSize = allTracks[trackIndex].baseSize();
- LayoutUnit newBaseSize = std::max(oldBaseSize, LayoutUnit(flexFraction * trackSize.maxTrackBreadth().flex()));
+ double frShare = flexFraction * trackSize.maxTrackBreadth().flex() + leftOverSize;
+ auto stretchedSize = LayoutUnit(frShare);
+ LayoutUnit newBaseSize = std::max(oldBaseSize, stretchedSize);
increments[i] = newBaseSize - oldBaseSize;
totalGrowth += increments[i];
+ // In the case that stretchedSize is greater than frShare, we floor it to 0 to avoid a negative leftover.
+ leftOverSize = std::max(frShare - stretchedSize.toDouble(), 0.0);
}
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes