Skip to content

Commit 1b0e86c

Browse files
Reland "Implement computeDryBaseline for RenderWrap (#146260)" (#148086)
This reverts commit 706f39b. Relanding the original PR with no code changes. Running partial TGP now (couldn't run full TGP because of throttling). Fixes flutter/flutter#71687 ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat [Data Driven Fixes]: https://github.com/flutter/flutter/wiki/Data-driven-Fixes
1 parent 5a663e6 commit 1b0e86c

3 files changed

Lines changed: 238 additions & 179 deletions

File tree

packages/flutter/lib/src/rendering/table.dart

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,8 @@ class RenderTable extends RenderBox {
806806
double? _baselineDistance;
807807
@override
808808
double? computeDistanceToActualBaseline(TextBaseline baseline) {
809-
// returns the baseline of the first cell that has a baseline in the first row
809+
// returns the baseline offset of the cell in the first row with
810+
// the lowest baseline, and uses `TableCellVerticalAlignment.baseline`.
810811
assert(!debugNeedsLayout);
811812
return _baselineDistance;
812813
}
@@ -1026,6 +1027,36 @@ class RenderTable extends RenderBox {
10261027
return Rect.fromLTRB(0.0, _rowTops[row], size.width, _rowTops[row + 1]);
10271028
}
10281029

1030+
@override
1031+
double? computeDryBaseline(covariant BoxConstraints constraints, TextBaseline baseline) {
1032+
if (rows * columns == 0) {
1033+
return null;
1034+
}
1035+
final List<double> widths = _computeColumnWidths(constraints);
1036+
double? baselineOffset;
1037+
for (int col = 0; col < columns; col += 1) {
1038+
final RenderBox? child = _children[col];
1039+
final BoxConstraints childConstraints = BoxConstraints.tightFor(width: widths[col]);
1040+
if (child == null) {
1041+
continue;
1042+
}
1043+
final TableCellParentData childParentData = child.parentData! as TableCellParentData;
1044+
final double? childBaseline = switch (childParentData.verticalAlignment ?? defaultVerticalAlignment) {
1045+
TableCellVerticalAlignment.baseline => child.getDryBaseline(childConstraints, baseline),
1046+
TableCellVerticalAlignment.baseline ||
1047+
TableCellVerticalAlignment.top ||
1048+
TableCellVerticalAlignment.middle ||
1049+
TableCellVerticalAlignment.bottom ||
1050+
TableCellVerticalAlignment.fill ||
1051+
TableCellVerticalAlignment.intrinsicHeight => null,
1052+
};
1053+
if (childBaseline != null && (baselineOffset == null || baselineOffset < childBaseline)) {
1054+
baselineOffset = childBaseline;
1055+
}
1056+
}
1057+
return baselineOffset;
1058+
}
1059+
10291060
@override
10301061
@protected
10311062
Size computeDryLayout(covariant BoxConstraints constraints) {

0 commit comments

Comments
 (0)