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

Unified Diff: third_party/WebKit/Source/core/layout/GridTrackSizingAlgorithm.cpp

Issue 2852283002: [css-grid] Refactor the extent for baseline alignment computation (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/GridTrackSizingAlgorithm.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/GridTrackSizingAlgorithm.cpp
diff --git a/third_party/WebKit/Source/core/layout/GridTrackSizingAlgorithm.cpp b/third_party/WebKit/Source/core/layout/GridTrackSizingAlgorithm.cpp
index 3ff751250ed90084af9f35773ab0d64329f5831c..4740e44191213d586d177f5271cd317bbf4987ef 100644
--- a/third_party/WebKit/Source/core/layout/GridTrackSizingAlgorithm.cpp
+++ b/third_party/WebKit/Source/core/layout/GridTrackSizingAlgorithm.cpp
@@ -287,15 +287,10 @@ LayoutUnit GridTrackSizingAlgorithmStrategy::LogicalHeightForChild(
child.ClearOverrideLogicalContentHeight();
child.LayoutIfNeeded();
- GridAxis baseline_axis = GetLayoutGrid()->IsOrthogonalChild(child)
- ? kGridRowAxis
- : kGridColumnAxis;
- if (GetLayoutGrid()->IsBaselineAlignmentForChild(child, baseline_axis) &&
- GetLayoutGrid()->IsBaselineContextComputed(baseline_axis)) {
- auto& group =
- GetLayoutGrid()->GetBaselineGroupForChild(child, baseline_axis);
- return group.MaxAscent() + group.MaxDescent();
- }
+
+ if (auto baseline_extent = ExtentForBaselineAlignment(child))
+ return baseline_extent.value();
+
return child.LogicalHeight() + child.MarginLogicalHeight();
}
@@ -326,12 +321,8 @@ LayoutUnit GridTrackSizingAlgorithmStrategy::MinContentForChild(
if (Direction() == kForColumns && !AvailableSpace()) {
DCHECK(GetLayoutGrid()->IsOrthogonalChild(child));
- if (GetLayoutGrid()->IsBaselineAlignmentForChild(child, kGridRowAxis) &&
- GetLayoutGrid()->IsBaselineContextComputed(kGridRowAxis)) {
- auto& group =
- GetLayoutGrid()->GetBaselineGroupForChild(child, kGridRowAxis);
- return group.MaxAscent() + group.MaxDescent();
- }
+ if (auto baseline_extent = ExtentForBaselineAlignment(child))
+ return baseline_extent.value();
}
if (UpdateOverrideContainingBlockContentSizeForChild(child,
@@ -430,6 +421,20 @@ void GridTrackSizingAlgorithmStrategy::DistributeSpaceToTracks(
available_logical_space);
}
+Optional<LayoutUnit>
+GridTrackSizingAlgorithmStrategy::ExtentForBaselineAlignment(
+ LayoutBox& child) const {
+ auto grid = algorithm_.layout_grid_;
+ GridAxis baseline_axis =
+ grid->IsOrthogonalChild(child) ? kGridRowAxis : kGridColumnAxis;
+ if (!grid->IsBaselineAlignmentForChild(child, baseline_axis) ||
+ !grid->IsBaselineContextComputed(baseline_axis))
+ return WTF::kNullopt;
+
+ auto& group = grid->GetBaselineGroupForChild(child, baseline_axis);
+ return group.MaxAscent() + group.MaxDescent();
+}
+
LayoutUnit DefiniteSizeStrategy::MinLogicalWidthForChild(
LayoutBox& child,
Length child_min_size,
« no previous file with comments | « third_party/WebKit/Source/core/layout/GridTrackSizingAlgorithm.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698