Bug 1552287 part 2: [css-contain] Adjust various reflow & baseline methods so that layout-contained frames behave as if they have no baseline. r=TYLin

We previously (in bug 1491235) adjusted some utility code to make
layout-contained frames behave as if they have no baseline.

But that's not sufficient. To make frames fully report lack-of-a-baseline,
we now do the following for layout-contained frames, as of this patch:

 (a) We now leave the ReflowOutput outparam's BlockStartAscent member at its
     default value (which is what we do for frames without a baseline like
     e.g. nsCheckboxRadioFrame and nsHTMLCanvasFrame). And if the parent cares
     about the baseline, it'll then ask directly, using a baseline getter.

 (b) We now return 'false' in more implementations of bool-returning
     baseline-getter-methods (where 'false' indicates 'no baseline').

 (c) We now return the margin-box-bottom edge, in the nscoord-returning
     'GetLogicalBaseline()' getter method. (We typically do this by deferring
     to the inherited method, which ultimately comes from nsFrame's
     implementation). It's appropriate to use the margin-box-bottom edge when
     there's no baseline, per the definition of 'vertical-align: baseline',
     here: https://drafts.csswg.org/css2/visudet.html#propdef-vertical-align

Depends on D32182

Differential Revision: https://phabricator.services.mozilla.com/D32183

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Daniel Holbert 2019-05-24 04:46:17 +00:00
parent c016e21c54
commit 0f84d86e05
16 changed files with 138 additions and 124 deletions

View File

@ -185,11 +185,15 @@ void nsDateTimeControlFrame::Reflow(nsPresContext* aPresContext,
FinishReflowChild(inputAreaFrame, aPresContext, childDesiredSize,
&childReflowOuput, myWM, childOffset, borderBoxSize, 0);
nsSize contentBoxSize = LogicalSize(myWM, contentBoxISize, contentBoxBSize)
.GetPhysicalSize(myWM);
aDesiredSize.SetBlockStartAscent(
childDesiredSize.BlockStartAscent() +
inputAreaFrame->BStart(aReflowInput.GetWritingMode(), contentBoxSize));
if (!aReflowInput.mStyleDisplay->IsContainLayout()) {
nsSize contentBoxSize =
LogicalSize(myWM, contentBoxISize, contentBoxBSize)
.GetPhysicalSize(myWM);
aDesiredSize.SetBlockStartAscent(
childDesiredSize.BlockStartAscent() +
inputAreaFrame->BStart(aReflowInput.GetWritingMode(),
contentBoxSize));
} // else: we're layout-contained, and so we have no baseline.
}
LogicalSize logicalDesiredSize(myWM, borderBoxISize, borderBoxBSize);

View File

@ -311,24 +311,14 @@ void nsHTMLButtonControlFrame::ReflowButtonContents(
// within our frame... unless it's orthogonal, in which case we'll use the
// contents inline-size as an approximation for now.
// XXX is there a better strategy? should we include border-padding?
if (aButtonReflowInput.mStyleDisplay->IsContainLayout()) {
// If we're layout-contained, then for the purposes of computing the
// ascent, we should pretend our button-contents frame had 0 height. In
// other words, we use the <button> content-rect's central block-axis
// position as our baseline.
// NOTE: This should be the same ascent that we'd get from the final 'else'
// clause here, if we had no DOM children. In that no-children scenario,
// the final 'else' clause's BlockStartAscent() term would be 0, and its
// childPos.B(wm) term would be equal to the same central offset that we're
// independently calculating here.
nscoord containAscent = (buttonContentBox.BSize(wm) / 2) + clbp.BStart(wm);
aButtonDesiredSize.SetBlockStartAscent(containAscent);
} else if (aButtonDesiredSize.GetWritingMode().IsOrthogonalTo(wm)) {
aButtonDesiredSize.SetBlockStartAscent(contentsDesiredSize.ISize(wm));
} else {
aButtonDesiredSize.SetBlockStartAscent(
contentsDesiredSize.BlockStartAscent() + childPos.B(wm));
}
if (!aButtonReflowInput.mStyleDisplay->IsContainLayout()) {
if (aButtonDesiredSize.GetWritingMode().IsOrthogonalTo(wm)) {
aButtonDesiredSize.SetBlockStartAscent(contentsDesiredSize.ISize(wm));
} else {
aButtonDesiredSize.SetBlockStartAscent(
contentsDesiredSize.BlockStartAscent() + childPos.B(wm));
}
} // else: we're layout-contained, and so we have no baseline.
aButtonDesiredSize.SetOverflowAreasToDesiredBounds();
}

View File

@ -213,12 +213,15 @@ void nsNumberControlFrame::Reflow(nsPresContext* aPresContext,
&wrapperReflowInput, myWM, wrapperOffset, borderBoxSize,
0);
nsSize contentBoxSize = LogicalSize(myWM, contentBoxISize, contentBoxBSize)
.GetPhysicalSize(myWM);
aDesiredSize.SetBlockStartAscent(
wrappersDesiredSize.BlockStartAscent() +
outerWrapperFrame->BStart(aReflowInput.GetWritingMode(),
contentBoxSize));
if (!aReflowInput.mStyleDisplay->IsContainLayout()) {
nsSize contentBoxSize =
LogicalSize(myWM, contentBoxISize, contentBoxBSize)
.GetPhysicalSize(myWM);
aDesiredSize.SetBlockStartAscent(
wrappersDesiredSize.BlockStartAscent() +
outerWrapperFrame->BStart(aReflowInput.GetWritingMode(),
contentBoxSize));
} // else: we're layout-contained, and so we have no baseline.
}
LogicalSize logicalDesiredSize(myWM, borderBoxISize, borderBoxBSize);

View File

@ -581,19 +581,21 @@ void nsTextControlFrame::Reflow(nsPresContext* aPresContext,
aReflowInput.ComputedLogicalBorderPadding().BStartEnd(wm));
aDesiredSize.SetSize(wm, finalSize);
// Calculate the baseline and store it in mFirstBaseline.
nscoord lineHeight = aReflowInput.ComputedBSize();
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
if (!IsSingleLineTextControl()) {
lineHeight = ReflowInput::CalcLineHeight(
GetContent(), Style(), PresContext(), NS_AUTOHEIGHT, inflation);
}
RefPtr<nsFontMetrics> fontMet =
nsLayoutUtils::GetFontMetricsForFrame(this, inflation);
mFirstBaseline = nsLayoutUtils::GetCenteredFontBaseline(fontMet, lineHeight,
wm.IsLineInverted()) +
aReflowInput.ComputedLogicalBorderPadding().BStart(wm);
aDesiredSize.SetBlockStartAscent(mFirstBaseline);
if (!aReflowInput.mStyleDisplay->IsContainLayout()) {
// Calculate the baseline and store it in mFirstBaseline.
nscoord lineHeight = aReflowInput.ComputedBSize();
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
if (!IsSingleLineTextControl()) {
lineHeight = ReflowInput::CalcLineHeight(
GetContent(), Style(), PresContext(), NS_AUTOHEIGHT, inflation);
}
RefPtr<nsFontMetrics> fontMet =
nsLayoutUtils::GetFontMetricsForFrame(this, inflation);
mFirstBaseline = nsLayoutUtils::GetCenteredFontBaseline(
fontMet, lineHeight, wm.IsLineInverted()) +
aReflowInput.ComputedLogicalBorderPadding().BStart(wm);
aDesiredSize.SetBlockStartAscent(mFirstBaseline);
} // else: we're layout-contained, and so we have no baseline.
// overflow handling
aDesiredSize.SetOverflowAreasToDesiredBounds();

View File

@ -69,7 +69,7 @@ class nsTextControlFrame final : public nsContainerFrame,
bool GetNaturalBaselineBOffset(mozilla::WritingMode aWM,
BaselineSharingGroup aBaselineGroup,
nscoord* aBaseline) const override {
if (!IsSingleLineTextControl()) {
if (StyleDisplay()->IsContainLayout() || !IsSingleLineTextControl()) {
return false;
}
NS_ASSERTION(mFirstBaseline != NS_INTRINSIC_ISIZE_UNKNOWN,
@ -337,7 +337,7 @@ class nsTextControlFrame final : public nsContainerFrame,
nsString mCachedValue;
// Our first baseline, or NS_INTRINSIC_ISIZE_UNKNOWN if we have a pending
// Reflow.
// Reflow (or if we're contain:layout, which means we have no baseline).
nscoord mFirstBaseline;
// these packed bools could instead use the high order bits on mState, saving

View File

@ -2930,8 +2930,11 @@ void nsBlockFrame::ReflowDirtyLines(BlockReflowInput& aState) {
if (!MarkerIsEmpty()) {
// There are no lines so we have to fake up some y motion so that
// we end up with *some* height.
if (metrics.BlockStartAscent() == ReflowOutput::ASK_FOR_BASELINE) {
// (Note: if we're layout-contained, we have to be sure to leave our
// ReflowOutput's BlockStartAscent() (i.e. the baseline) untouched,
// because layout-contained frames have no baseline.)
if (!aState.mReflowInput.mStyleDisplay->IsContainLayout() &&
metrics.BlockStartAscent() == ReflowOutput::ASK_FOR_BASELINE) {
nscoord ascent;
WritingMode wm = aState.mReflowInput.GetWritingMode();
if (nsLayoutUtils::GetFirstLineBaseline(wm, marker, &ascent)) {

View File

@ -4553,9 +4553,8 @@ void nsFlexContainerFrame::DoFlexLayout(
if ((lines.getFirst()->IsEmpty() && !lines.getFirst()->getNext()) ||
aReflowInput.mStyleDisplay->IsContainLayout()) {
// If have no flex items, or if we are layout contained and
// want to behave as if we have none, our parent
// should synthesize a baseline if needed.
// We have no flex items, or we're layout-contained. So, we have no
// baseline, and our parent should synthesize a baseline if needed.
AddStateBits(NS_STATE_FLEX_SYNTHESIZE_BASELINE);
} else {
RemoveStateBits(NS_STATE_FLEX_SYNTHESIZE_BASELINE);
@ -4919,7 +4918,8 @@ void nsFlexContainerFrame::DoFlexLayout(
// if we didn't do a bsize measuring reflow of the item earlier (since
// that is normally when we deal with -webkit-line-clamp ellipses) but
// not all flex items need such a reflow.
if (!itemNeedsReflow && aHasLineClampEllipsis && GetLineClampValue() == 0) {
if (!itemNeedsReflow && aHasLineClampEllipsis &&
GetLineClampValue() == 0) {
item->BlockFrame()->ClearLineClampEllipsis();
}

View File

@ -979,7 +979,8 @@ nscoord nsHTMLScrollFrame::GetLogicalBaseline(WritingMode aWritingMode) const {
// GetLogicalBaseline() impl, which synthesizes a baseline from the
// margin-box. Otherwise, we defer to our scrolled frame, considering it
// to be scrolled to its initial scroll position.
if (mHelper.mScrolledFrame->IsBlockFrameOrSubclass()) {
if (mHelper.mScrolledFrame->IsBlockFrameOrSubclass() ||
StyleDisplay()->IsContainLayout()) {
return nsContainerFrame::GetLogicalBaseline(aWritingMode);
}

View File

@ -46,8 +46,8 @@ typedef nsTHashtable<nsPtrHashKey<nsIFrame>> FrameHashtable;
typedef mozilla::CSSAlignUtils::AlignJustifyFlags AlignJustifyFlags;
typedef nsLayoutUtils::IntrinsicISizeType IntrinsicISizeType;
static const nsFrameState kIsSubgridBits = (NS_STATE_GRID_IS_COL_SUBGRID |
NS_STATE_GRID_IS_ROW_SUBGRID);
static const nsFrameState kIsSubgridBits =
(NS_STATE_GRID_IS_COL_SUBGRID | NS_STATE_GRID_IS_ROW_SUBGRID);
// https://drafts.csswg.org/css-sizing/#constraints
enum class SizingConstraint {
@ -153,8 +153,7 @@ struct RepeatTrackSizingInput {
: mMin(aMin), mSize(aSize), mMax(aMax) {}
void SetDefiniteSizes(LogicalAxis aAxis, WritingMode aWM,
const StyleSize& aMinCoord,
const StyleSize& aSizeCoord,
const StyleSize& aMinCoord, const StyleSize& aSizeCoord,
const StyleMaxSize& aMaxCoord) {
nscoord& min = mMin.Size(aAxis, aWM);
nscoord& size = mSize.Size(aAxis, aWM);
@ -772,7 +771,8 @@ struct nsGridContainerFrame::Subgrid {
// The margin+border+padding for the subgrid box in its parent grid's WM.
// (This also includes the size of any scrollbars.)
LogicalMargin mMarginBorderPadding;
// Does the subgrid frame have orthogonal writing-mode to its parent grid container?
// Does the subgrid frame have orthogonal writing-mode to its parent grid
// container?
bool mIsOrthogonal;
NS_DECLARE_FRAME_PROPERTY_DELETABLE(Prop, Subgrid)
@ -1274,11 +1274,12 @@ struct nsGridContainerFrame::TrackSizingFunctions {
// the mLineNameList, so we suppress that so that we can use this struct
// also when it's true. This can happen when a specified 'subgrid' has
// no grid parent, which will behave as 'none'.
: TrackSizingFunctions(aGridTemplate.mMinTrackSizingFunctions,
aGridTemplate.mMaxTrackSizingFunctions,
aAutoMinSizing, aAutoMaxSizing,
!aGridTemplate.mIsSubgrid && aGridTemplate.HasRepeatAuto(),
aGridTemplate.mRepeatAutoIndex) {}
: TrackSizingFunctions(
aGridTemplate.mMinTrackSizingFunctions,
aGridTemplate.mMaxTrackSizingFunctions, aAutoMinSizing,
aAutoMaxSizing,
!aGridTemplate.mIsSubgrid && aGridTemplate.HasRepeatAuto(),
aGridTemplate.mRepeatAutoIndex) {}
/**
* Initialize the number of auto-fill/fit tracks to use and return that.
@ -1448,14 +1449,15 @@ struct nsGridContainerFrame::TrackSizingFunctions {
* function had that size and all other rows were infinite."
* https://drafts.csswg.org/css-grid-2/#subgrid-sizing
*/
struct MOZ_STACK_CLASS nsGridContainerFrame::SubgridFallbackTrackSizingFunctions {
SubgridFallbackTrackSizingFunctions(nsGridContainerFrame* aSubgridFrame,
const Subgrid* aSubgrid,
nsGridContainerFrame* aParentGridContainer,
LogicalAxis aParentAxis) {
struct MOZ_STACK_CLASS
nsGridContainerFrame::SubgridFallbackTrackSizingFunctions {
SubgridFallbackTrackSizingFunctions(
nsGridContainerFrame* aSubgridFrame, const Subgrid* aSubgrid,
nsGridContainerFrame* aParentGridContainer, LogicalAxis aParentAxis) {
MOZ_ASSERT(aSubgrid);
MOZ_ASSERT(aSubgridFrame->IsSubgrid(
aSubgrid->mIsOrthogonal ? GetOrthogonalAxis(aParentAxis) : aParentAxis));
MOZ_ASSERT(aSubgridFrame->IsSubgrid(aSubgrid->mIsOrthogonal
? GetOrthogonalAxis(aParentAxis)
: aParentAxis));
nsGridContainerFrame* parent = aParentGridContainer;
auto parentAxis = aParentAxis;
LineRange range = aSubgrid->mArea.LineRangeForAxis(parentAxis);
@ -1464,17 +1466,20 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::SubgridFallbackTrackSizingFunctions
const auto* parentSubgrid = parent->GetProperty(Subgrid::Prop());
auto* grandParent = parent->ParentGridContainerForSubgrid();
auto grandParentWM = grandParent->GetWritingMode();
bool isSameDirInAxis = parent->GetWritingMode().
ParallelAxisStartsOnSameSide(parentAxis, grandParentWM);
bool isSameDirInAxis =
parent->GetWritingMode().ParallelAxisStartsOnSameSide(parentAxis,
grandParentWM);
if (MOZ_UNLIKELY(!isSameDirInAxis)) {
auto end = parentAxis == eLogicalAxisBlock ? parentSubgrid->mGridRowEnd
: parentSubgrid->mGridColEnd;
range.ReverseDirection(end);
// range is now in the same direction as the grand-parent's axis
}
auto grandParentAxis = parentSubgrid->mIsOrthogonal ?
GetOrthogonalAxis(parentAxis) : parentAxis;
const auto& parentRange = parentSubgrid->mArea.LineRangeForAxis(grandParentAxis);
auto grandParentAxis = parentSubgrid->mIsOrthogonal
? GetOrthogonalAxis(parentAxis)
: parentAxis;
const auto& parentRange =
parentSubgrid->mArea.LineRangeForAxis(grandParentAxis);
range.Translate(parentRange.mStart);
// range is now in the grand-parent's coordinates
parentAxis = grandParentAxis;
@ -1482,12 +1487,12 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::SubgridFallbackTrackSizingFunctions
}
const auto* pos = parent->StylePosition();
const auto isInlineAxis = parentAxis == eLogicalAxisInline;
const auto& szf = isInlineAxis ? pos->GridTemplateColumns()
: pos->GridTemplateRows();
const auto& minAuto = isInlineAxis ? pos->mGridAutoColumnsMin
: pos->mGridAutoRowsMin;
const auto& maxAuto = isInlineAxis ? pos->mGridAutoColumnsMax
: pos->mGridAutoRowsMax;
const auto& szf =
isInlineAxis ? pos->GridTemplateColumns() : pos->GridTemplateRows();
const auto& minAuto =
isInlineAxis ? pos->mGridAutoColumnsMin : pos->mGridAutoRowsMin;
const auto& maxAuto =
isInlineAxis ? pos->mGridAutoColumnsMax : pos->mGridAutoRowsMax;
TrackSizingFunctions tsf(szf, minAuto, maxAuto);
for (auto i : range.Range()) {
mMinSizingFunctions.AppendElement(tsf.MinSizingFor(i));
@ -2280,7 +2285,7 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::GridReflowInput {
prop = new UsedTrackSizes();
aGridContainerFrame->SetProperty(UsedTrackSizes::Prop(), prop);
}
prop->mCanResolveLineRangeSize = { true, true };
prop->mCanResolveLineRangeSize = {true, true};
prop->mSizes[eLogicalAxisInline] = mCols.mSizes;
prop->mSizes[eLogicalAxisBlock] = mRows.mSizes;
}
@ -2874,10 +2879,11 @@ static Subgrid* SubgridComputeMarginBorderPadding(
{
auto wm = subgridFrame->GetWritingMode();
auto pmPercentageBasis = cbWM.IsOrthogonalTo(wm)
? aPercentageBasis.BSize(wm) : aPercentageBasis.ISize(wm);
? aPercentageBasis.BSize(wm)
: aPercentageBasis.ISize(wm);
SizeComputationInput sz(subgridFrame, nullptr, cbWM, pmPercentageBasis);
physicalMBP = sz.ComputedPhysicalMargin() +
sz.ComputedPhysicalBorderPadding();
physicalMBP =
sz.ComputedPhysicalMargin() + sz.ComputedPhysicalBorderPadding();
}
auto* subgrid = subgridFrame->GetProperty(Subgrid::Prop());
subgrid->mMarginBorderPadding = LogicalMargin(cbWM, physicalMBP);
@ -2931,15 +2937,14 @@ static void CopyUsedTrackSizes(nsTArray<TrackSize>& aResult,
// Note that all subgrids are inside a parent (sub)grid container.
const nsIFrame* outerGridItemFrame = aSubgridFrame;
for (nsIFrame* parent = aSubgridFrame->GetParent();
parent != aUsedTrackSizesFrame;
parent = parent->GetParent()) {
parent != aUsedTrackSizesFrame; parent = parent->GetParent()) {
MOZ_ASSERT(!parent->IsGridContainerFrame());
outerGridItemFrame = parent;
}
auto sizeInAxis = range.ToLength(aUsedTrackSizes->mSizes[parentAxis]);
LogicalSize pmPercentageBasis = aSubgrid->mIsOrthogonal
? LogicalSize(wm, nscoord(0), sizeInAxis)
: LogicalSize(wm, sizeInAxis, nscoord(0));
LogicalSize pmPercentageBasis =
aSubgrid->mIsOrthogonal ? LogicalSize(wm, nscoord(0), sizeInAxis)
: LogicalSize(wm, sizeInAxis, nscoord(0));
GridItemInfo info(const_cast<nsIFrame*>(outerGridItemFrame),
aSubgrid->mArea);
SubgridComputeMarginBorderPadding(info, pmPercentageBasis);
@ -2973,7 +2978,7 @@ static void CopyUsedTrackSizes(nsTArray<TrackSize>& aResult,
}
void nsGridContainerFrame::UsedTrackSizes::ResolveTrackSizesForAxis(
nsGridContainerFrame* aFrame, LogicalAxis aAxis, gfxContext& aRC) {
nsGridContainerFrame* aFrame, LogicalAxis aAxis, gfxContext& aRC) {
if (mCanResolveLineRangeSize[aAxis]) {
return;
}
@ -2994,7 +2999,7 @@ void nsGridContainerFrame::UsedTrackSizes::ResolveTrackSizesForAxis(
}
auto* subgrid = aFrame->GetProperty(Subgrid::Prop());
const auto parentAxis =
subgrid->mIsOrthogonal ? GetOrthogonalAxis(aAxis) : aAxis;
subgrid->mIsOrthogonal ? GetOrthogonalAxis(aAxis) : aAxis;
parentSizes->ResolveTrackSizesForAxis(parent, parentAxis, aRC);
if (!parentSizes->mCanResolveLineRangeSize[parentAxis]) {
if (aFrame->IsSubgrid(aAxis)) {
@ -3120,10 +3125,10 @@ void nsGridContainerFrame::GridReflowInput::CalculateTrackSizesForAxis(
void nsGridContainerFrame::GridReflowInput::CalculateTrackSizes(
const Grid& aGrid, const LogicalSize& aContentBox,
SizingConstraint aConstraint) {
CalculateTrackSizesForAxis(eLogicalAxisInline, aGrid,
aContentBox.ISize(mWM), aConstraint);
CalculateTrackSizesForAxis(eLogicalAxisBlock, aGrid,
aContentBox.BSize(mWM), aConstraint);
CalculateTrackSizesForAxis(eLogicalAxisInline, aGrid, aContentBox.ISize(mWM),
aConstraint);
CalculateTrackSizesForAxis(eLogicalAxisBlock, aGrid, aContentBox.BSize(mWM),
aConstraint);
}
/**
@ -3859,7 +3864,7 @@ void nsGridContainerFrame::Grid::PlaceGridItems(
if (aState.mFrame->HasSubgridItems()) {
if (auto* uts = aState.mFrame->GetUsedTrackSizes()) {
uts->mCanResolveLineRangeSize = { false, false };
uts->mCanResolveLineRangeSize = {false, false};
uts->mSizes[eLogicalAxisInline].ClearAndRetainStorage();
uts->mSizes[eLogicalAxisBlock].ClearAndRetainStorage();
}
@ -4489,18 +4494,20 @@ static nscoord ContentContribution(
// Note that this can also be negative since it's considered a margin.
if (itemEdgeBits != ItemState::eEdgeBits) {
auto subgridAxis = aCBWM.IsOrthogonalTo(subgridFrame->GetWritingMode())
? GetOrthogonalAxis(aAxis) : aAxis;
auto& gapStyle = subgridAxis == eLogicalAxisBlock ?
subgridFrame->StylePosition()->mRowGap :
subgridFrame->StylePosition()->mColumnGap;
? GetOrthogonalAxis(aAxis)
: aAxis;
auto& gapStyle = subgridAxis == eLogicalAxisBlock
? subgridFrame->StylePosition()->mRowGap
: subgridFrame->StylePosition()->mColumnGap;
if (!gapStyle.IsNormal()) {
auto subgridExtent =
subgridAxis == eLogicalAxisBlock ? subgrid->mGridRowEnd
: subgrid->mGridColEnd;
auto subgridExtent = subgridAxis == eLogicalAxisBlock
? subgrid->mGridRowEnd
: subgrid->mGridColEnd;
if (subgridExtent > 1) {
nscoord subgridGap =
nsLayoutUtils::ResolveGapToLength(gapStyle, NS_UNCONSTRAINEDSIZE);
auto& tracks = aAxis == eLogicalAxisBlock ? aState.mRows : aState.mCols;
auto& tracks =
aAxis == eLogicalAxisBlock ? aState.mRows : aState.mCols;
auto gapDelta = subgridGap - tracks.mGridGap;
if (!itemEdgeBits) {
extraMargin += gapDelta;
@ -4532,7 +4539,8 @@ static nscoord ContentContribution(
// to use as the CB/Available size in the MeasuringReflow that follows.
if (child->GetParent() != aState.mFrame) {
// This item is a child of a subgrid descendant.
auto* subgridFrame = static_cast<nsGridContainerFrame*>(child->GetParent());
auto* subgridFrame =
static_cast<nsGridContainerFrame*>(child->GetParent());
MOZ_ASSERT(subgridFrame->IsGridContainerFrame());
auto* uts = subgridFrame->GetProperty(UsedTrackSizes::Prop());
if (!uts) {
@ -4541,8 +4549,8 @@ static nscoord ContentContribution(
}
// The grid-item's inline-axis as expressed in the subgrid's WM.
auto subgridAxis = childWM.IsOrthogonalTo(subgridFrame->GetWritingMode())
? eLogicalAxisBlock
: eLogicalAxisInline;
? eLogicalAxisBlock
: eLogicalAxisInline;
uts->ResolveTrackSizesForAxis(subgridFrame, subgridAxis, *aRC);
if (uts->mCanResolveLineRangeSize[subgridAxis]) {
auto* subgrid =
@ -5255,10 +5263,8 @@ void nsGridContainerFrame::Tracks::ResolveIntrinsicSize(
AddSubgridContribution(mSizes[lineRange.mStart],
mbp.StartEnd(mAxis, wm));
} else {
AddSubgridContribution(mSizes[lineRange.mStart],
mbp.Start(mAxis, wm));
AddSubgridContribution(mSizes[lineRange.mEnd - 1],
mbp.End(mAxis, wm));
AddSubgridContribution(mSizes[lineRange.mStart], mbp.Start(mAxis, wm));
AddSubgridContribution(mSizes[lineRange.mEnd - 1], mbp.End(mAxis, wm));
}
continue;
}
@ -7039,8 +7045,10 @@ void nsGridContainerFrame::Reflow(nsPresContext* aPresContext,
} else {
RemoveStateBits(NS_STATE_GRID_NORMAL_FLOW_CHILDREN_IN_CSS_ORDER);
}
if (gridReflowInput.mIter.AtEnd()) {
// We have no grid items, our parent should synthesize a baseline if needed.
if (gridReflowInput.mIter.AtEnd() ||
aReflowInput.mStyleDisplay->IsContainLayout()) {
// We have no grid items, or we're layout-contained. So, we have no
// baseline, and our parent should synthesize a baseline if needed.
AddStateBits(NS_STATE_GRID_SYNTHESIZE_BASELINE);
} else {
RemoveStateBits(NS_STATE_GRID_SYNTHESIZE_BASELINE);
@ -7118,7 +7126,7 @@ void nsGridContainerFrame::Reflow(nsPresContext* aPresContext,
stylePos->mRowGap.AsLengthPercentage().HasPercent()) {
// Re-resolve the row-gap now that we know our intrinsic block-size.
gridReflowInput.mRows.mGridGap =
nsLayoutUtils::ResolveGapToLength(stylePos->mRowGap, bSize);
nsLayoutUtils::ResolveGapToLength(stylePos->mRowGap, bSize);
}
gridReflowInput.mRows.AlignJustifyContent(stylePos, wm, bSize, false);
} else {
@ -7498,8 +7506,7 @@ void nsGridContainerFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
bits = ComputeSelfSubgridBits();
} else {
bits = aPrevInFlow->GetStateBits() &
(kIsSubgridBits |
NS_STATE_GRID_HAS_COL_SUBGRID_ITEM |
(kIsSubgridBits | NS_STATE_GRID_HAS_COL_SUBGRID_ITEM |
NS_STATE_GRID_HAS_ROW_SUBGRID_ITEM);
}
AddStateBits(bits);
@ -7509,7 +7516,7 @@ void nsGridContainerFrame::DidSetComputedStyle(ComputedStyle* aOldStyle) {
nsContainerFrame::DidSetComputedStyle(aOldStyle);
if (!aOldStyle) {
return; // Init() already initialized the bits.
return; // Init() already initialized the bits.
}
UpdateSubgridFrameState();
}

View File

@ -48,7 +48,7 @@ fuzzy-if(webrender&&winWidget,0-24,0-2) == contain-size-inline-flex-001.html con
== contain-layout-ignored-cases-no-principal-box-002.html contain-layout-ignored-cases-no-principal-box-002-ref.html
== contain-layout-ignored-cases-no-principal-box-003.html contain-layout-ignored-cases-no-principal-box-003-ref.html
== contain-layout-suppress-baseline-001.html contain-layout-suppress-baseline-001-ref.html
fails == contain-layout-suppress-baseline-002.html contain-layout-suppress-baseline-002-ref.html # bug 1552287
== contain-layout-suppress-baseline-002.html contain-layout-suppress-baseline-002-ref.html
# The following lines are duplicates of other lines from further up in this
# manifest. They're listed again here so we can re-run these tests with

View File

@ -31,6 +31,12 @@ using namespace mozilla::layout;
/* virtual */
nscoord nsTableWrapperFrame::GetLogicalBaseline(
WritingMode aWritingMode) const {
if (StyleDisplay()->IsContainLayout()) {
// We have no baseline. Fall back to the inherited impl which is
// appropriate for this situation.
return nsContainerFrame::GetLogicalBaseline(aWritingMode);
}
nsIFrame* kid = mFrames.FirstChild();
if (!kid) {
MOZ_ASSERT_UNREACHABLE("no inner table");

View File

@ -70,6 +70,9 @@ class nsTableWrapperFrame : public nsContainerFrame {
bool GetNaturalBaselineBOffset(mozilla::WritingMode aWM,
BaselineSharingGroup aBaselineGroup,
nscoord* aBaseline) const override {
if (StyleDisplay()->IsContainLayout()) {
return false;
}
auto innerTable = InnerTableFrame();
nscoord offset;
if (innerTable->GetNaturalBaselineBOffset(aWM, aBaselineGroup, &offset)) {

View File

@ -1,2 +0,0 @@
[contain-layout-baseline-005.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[contain-layout-button-001.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[contain-layout-grid-001.html]
expected: FAIL

View File

@ -1,2 +1,3 @@
[contain-layout-suppress-baseline-002.html]
expected: FAIL
expected:
if os == "win": FAIL