Skip to content

Commit

Permalink
Bug 1881495 part 1: Add ShrinkWrap flag for grid items that are self-…
Browse files Browse the repository at this point in the history
…aligned (not stretched) in MeasuringReflow(). r=dholbert

Bug 1350037 Part 3 [1] removed the code in ReflowInput that adds `ShrinkWrap`
flag self-aligned grid items, to prevent the table-caption from getting aligned
behavior, but it accidentally broke self-aligned behavior for other types of
frames that are grid items.

We actually already check if we need to add `ShrinkWrap` in grid item's final
reflow [2], but we were missing the same logic in `MeasuringReflow()`. This
patch adds that.

[1] https://hg.mozilla.org/mozilla-central/rev/6e8085865f74
[2] https://searchfox.org/mozilla-central/rev/202c48686136360a23b73a49b611a19e64f3e1b8/layout/generic/nsGridContainerFrame.cpp#7651,7657

Differential Revision: https://phabricator.services.mozilla.com/D203514
  • Loading branch information
aethanyc committed Mar 5, 2024
1 parent 2c8769c commit 5d27842
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion layout/generic/nsGridContainerFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5300,7 +5300,8 @@ static nscoord MeasuringReflow(nsIFrame* aChild,
const LogicalSize& aCBSize,
nscoord aIMinSizeClamp = NS_MAXSIZE,
nscoord aBMinSizeClamp = NS_MAXSIZE) {
nsContainerFrame* parent = aChild->GetParent();
MOZ_ASSERT(aChild->IsGridItem(), "aChild should be a grid item!");
auto* parent = static_cast<nsGridContainerFrame*>(aChild->GetParent());
nsPresContext* pc = aChild->PresContext();
Maybe<ReflowInput> dummyParentState;
const ReflowInput* rs = aReflowInput;
Expand All @@ -5319,6 +5320,11 @@ static nscoord MeasuringReflow(nsIFrame* aChild,
#endif
auto wm = aChild->GetWritingMode();
ComputeSizeFlags csFlags = ComputeSizeFlag::IsGridMeasuringReflow;
// Shrink-wrap grid items that will be aligned (rather than stretched) in
// their own inline axis.
if (!parent->GridItemShouldStretch(aChild, eLogicalAxisInline)) {
csFlags += ComputeSizeFlag::ShrinkWrap;
}
if (aAvailableSize.ISize(wm) == INFINITE_ISIZE_COORD) {
csFlags += ComputeSizeFlag::ShrinkWrap;
}
Expand Down

0 comments on commit 5d27842

Please sign in to comment.