Backed out changeset c59a7f7b8852 (bug 1878846) for causing Wr failures on align-items-baseline-row-vert.html
This commit is contained in:
@@ -4032,6 +4032,16 @@ static void AlignSelf(const nsGridContainerFrame::GridItemInfo& aGridItem,
|
||||
aAlignSelf == StyleAlignFlags::LAST_BASELINE) {
|
||||
aAlignSelf = aGridItem.GetSelfBaseline(aAlignSelf, eLogicalAxisBlock,
|
||||
&baselineAdjust);
|
||||
// Adjust the baseline alignment value if the baseline affects the opposite
|
||||
// side of what AlignJustifySelf expects.
|
||||
auto state = aGridItem.mState[eLogicalAxisBlock];
|
||||
if (aAlignSelf == StyleAlignFlags::LAST_BASELINE &&
|
||||
!GridItemInfo::BaselineAlignmentAffectsEndSide(state)) {
|
||||
aAlignSelf = StyleAlignFlags::BASELINE;
|
||||
} else if (aAlignSelf == StyleAlignFlags::BASELINE &&
|
||||
GridItemInfo::BaselineAlignmentAffectsEndSide(state)) {
|
||||
aAlignSelf = StyleAlignFlags::LAST_BASELINE;
|
||||
}
|
||||
}
|
||||
|
||||
bool isOrthogonal = aCBWM.IsOrthogonalTo(childWM);
|
||||
@@ -4073,6 +4083,16 @@ static void JustifySelf(const nsGridContainerFrame::GridItemInfo& aGridItem,
|
||||
aJustifySelf == StyleAlignFlags::LAST_BASELINE) {
|
||||
aJustifySelf = aGridItem.GetSelfBaseline(aJustifySelf, eLogicalAxisInline,
|
||||
&baselineAdjust);
|
||||
// Adjust the baseline alignment value if the baseline affects the opposite
|
||||
// side of what AlignJustifySelf expects.
|
||||
auto state = aGridItem.mState[eLogicalAxisInline];
|
||||
if (aJustifySelf == StyleAlignFlags::LAST_BASELINE &&
|
||||
!GridItemInfo::BaselineAlignmentAffectsEndSide(state)) {
|
||||
aJustifySelf = StyleAlignFlags::BASELINE;
|
||||
} else if (aJustifySelf == StyleAlignFlags::BASELINE &&
|
||||
GridItemInfo::BaselineAlignmentAffectsEndSide(state)) {
|
||||
aJustifySelf = StyleAlignFlags::LAST_BASELINE;
|
||||
}
|
||||
}
|
||||
|
||||
bool isOrthogonal = aCBWM.IsOrthogonalTo(childWM);
|
||||
@@ -5980,12 +6000,6 @@ void nsGridContainerFrame::Tracks::InitializeItemBaselines(
|
||||
const WritingMode containerWM = aState.mWM;
|
||||
ComputedStyle* containerStyle = aState.mFrame->Style();
|
||||
|
||||
// The physical side of the container's block start side. We use it to match
|
||||
// against the physical block start side of the child to determine its
|
||||
// baseline sharing group.
|
||||
auto containerBlockStartSide =
|
||||
containerWM.PhysicalSide(MakeLogicalSide(mAxis, eLogicalEdgeStart));
|
||||
|
||||
for (GridItemInfo& gridItem : aGridItems) {
|
||||
if (gridItem.IsSubgrid(mAxis)) {
|
||||
// A subgrid itself is never baseline-aligned.
|
||||
@@ -6081,27 +6095,6 @@ void nsGridContainerFrame::Tracks::InitializeItemBaselines(
|
||||
}
|
||||
|
||||
if (state & ItemState::eIsBaselineAligned) {
|
||||
// The item is baseline aligned, so calculate the baseline sharing group.
|
||||
// <https://drafts.csswg.org/css-align-3/#baseline-terms>
|
||||
BaselineSharingGroup baselineAlignment =
|
||||
(state & ItemState::eFirstBaseline) ? BaselineSharingGroup::First
|
||||
: BaselineSharingGroup::Last;
|
||||
|
||||
BaselineSharingGroup baselineSharingGroup = [&]() {
|
||||
{
|
||||
auto childAxis = isOrthogonal ? GetOrthogonalAxis(mAxis) : mAxis;
|
||||
auto childBlockStartSide = childWM.PhysicalSide(
|
||||
MakeLogicalSide(childAxis, eLogicalEdgeStart));
|
||||
bool isFirstBaseline = (state & ItemState::eFirstBaseline) != 0;
|
||||
const bool containerAndChildHasEqualBaselineSide =
|
||||
containerBlockStartSide == childBlockStartSide;
|
||||
|
||||
return isFirstBaseline == containerAndChildHasEqualBaselineSide
|
||||
? BaselineSharingGroup::First
|
||||
: BaselineSharingGroup::Last;
|
||||
}
|
||||
}();
|
||||
|
||||
// XXXmats if |child| is a descendant of a subgrid then the metrics
|
||||
// below needs to account for the accumulated MPB somehow...
|
||||
|
||||
@@ -6129,13 +6122,16 @@ void nsGridContainerFrame::Tracks::InitializeItemBaselines(
|
||||
: margin.BStartEnd(containerWM));
|
||||
|
||||
Maybe<nscoord> baseline;
|
||||
auto baselineSharingGroup = state & ItemState::eFirstBaseline
|
||||
? BaselineSharingGroup::First
|
||||
: BaselineSharingGroup::Last;
|
||||
if (grid) {
|
||||
baseline.emplace((isOrthogonal == isInlineAxis)
|
||||
? grid->GetBBaseline(baselineAlignment)
|
||||
: grid->GetIBaseline(baselineAlignment));
|
||||
? grid->GetBBaseline(baselineSharingGroup)
|
||||
: grid->GetIBaseline(baselineSharingGroup));
|
||||
} else {
|
||||
baseline = child->GetNaturalBaselineBOffset(
|
||||
childWM, baselineAlignment, BaselineExportContext::Other);
|
||||
childWM, baselineSharingGroup, BaselineExportContext::Other);
|
||||
|
||||
if (!baseline) {
|
||||
// If baseline alignment is specified on a grid item whose size in
|
||||
@@ -6160,7 +6156,7 @@ void nsGridContainerFrame::Tracks::InitializeItemBaselines(
|
||||
if (!isTrackAutoSize ||
|
||||
!gridItem.IsBSizeDependentOnContainerSize(containerWM)) {
|
||||
baseline.emplace(Baseline::SynthesizeBOffsetFromBorderBox(
|
||||
child, containerWM, baselineAlignment));
|
||||
child, containerWM, baselineSharingGroup));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6170,19 +6166,15 @@ void nsGridContainerFrame::Tracks::InitializeItemBaselines(
|
||||
NS_ASSERTION(finalBaseline != NS_INTRINSIC_ISIZE_UNKNOWN,
|
||||
"about to use an unknown baseline");
|
||||
|
||||
nscoord marginAdjust = 0;
|
||||
if (baselineSharingGroup == BaselineSharingGroup::First) {
|
||||
marginAdjust = isInlineAxis ? margin.IStart(containerWM)
|
||||
: margin.BStart(containerWM);
|
||||
} else {
|
||||
marginAdjust = isInlineAxis ? margin.IEnd(containerWM)
|
||||
: margin.BEnd(containerWM);
|
||||
finalBaseline += isInlineAxis ? margin.IStart(containerWM)
|
||||
: margin.BStart(containerWM);
|
||||
|
||||
// This flag is used in ::AlignSelf(...) to check whether the item is
|
||||
// last baseline aligned, but this flag should go away.
|
||||
state |= GridItemInfo::eEndSideBaseline;
|
||||
} else {
|
||||
finalBaseline += isInlineAxis ? margin.IEnd(containerWM)
|
||||
: margin.BEnd(containerWM);
|
||||
state |= ItemState::eEndSideBaseline;
|
||||
}
|
||||
finalBaseline += marginAdjust;
|
||||
|
||||
auto& baselineItems =
|
||||
(baselineSharingGroup == BaselineSharingGroup::First)
|
||||
@@ -7604,12 +7596,7 @@ void nsGridContainerFrame::ReflowInFlowChild(
|
||||
// This happens when the subtree overflows its track.
|
||||
// XXX spec issue? it's unclear how to handle this.
|
||||
baselineAdjust = nscoord(0);
|
||||
} else if (state & ItemState::eLastBaseline) {
|
||||
// FIXME: We're not setting the ItemState::eEndSideBaseline flag any
|
||||
// more as the new baseline sharing group calculation handles most of
|
||||
// the cases we need. For non-masonry grids this flag was always set
|
||||
// for LAST_BASELINE items, so we're just mimicking that behavior here.
|
||||
// That said, masonry grids might not work 100% any more..
|
||||
} else if (GridItemInfo::BaselineAlignmentAffectsEndSide(state)) {
|
||||
baselineAdjust = -baselineAdjust;
|
||||
}
|
||||
if (baselineAdjust != nscoord(0)) {
|
||||
|
||||
Reference in New Issue
Block a user