Bug 1923763: Part 5 - Replace inset evaluations with anchor-resolved inset evaluations. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D231259
This commit is contained in:
@@ -742,8 +742,9 @@ void ReflowInput::InitResizeFlags(nsPresContext* aPresContext,
|
||||
!mStylePosition->BSize(wm).IsAuto()) ||
|
||||
mStylePosition->MinBSizeDependsOnContainer(wm) ||
|
||||
mStylePosition->MaxBSizeDependsOnContainer(wm) ||
|
||||
mStylePosition->GetInset(LogicalSide::BStart, wm).HasPercent() ||
|
||||
!mStylePosition->GetInset(LogicalSide::BEnd, wm).IsAuto();
|
||||
mStylePosition->mOffset.Get(LogicalSide::BStart, wm)
|
||||
.MaybePercentageAware() ||
|
||||
!mStylePosition->mOffset.Get(LogicalSide::BEnd, wm).MaybeAuto();
|
||||
|
||||
// If mFrame is a flex item, and mFrame's block axis is the flex container's
|
||||
// main axis (e.g. in a column-oriented flex container with same
|
||||
@@ -852,15 +853,18 @@ LogicalMargin ReflowInput::ComputeRelativeOffsets(WritingMode aWM,
|
||||
const LogicalSize& aCBSize) {
|
||||
LogicalMargin offsets(aWM);
|
||||
const nsStylePosition* position = aFrame->StylePosition();
|
||||
const auto positionProperty = aFrame->StyleDisplay()->mPosition;
|
||||
|
||||
// Compute the 'inlineStart' and 'inlineEnd' values. 'inlineStart'
|
||||
// moves the boxes to the end of the line, and 'inlineEnd' moves the
|
||||
// boxes to the start of the line. The computed values are always:
|
||||
// inlineStart=-inlineEnd
|
||||
const auto& inlineStart = position->GetInset(LogicalSide::IStart, aWM);
|
||||
const auto& inlineEnd = position->GetInset(LogicalSide::IEnd, aWM);
|
||||
bool inlineStartIsAuto = !inlineStart.IsLengthPercentage();
|
||||
bool inlineEndIsAuto = !inlineEnd.IsLengthPercentage();
|
||||
const auto& inlineStart = position->GetAnchorResolvedInset(
|
||||
LogicalSide::IStart, aWM, positionProperty);
|
||||
const auto& inlineEnd = position->GetAnchorResolvedInset(
|
||||
LogicalSide::IEnd, aWM, positionProperty);
|
||||
bool inlineStartIsAuto = inlineStart.IsAuto();
|
||||
bool inlineEndIsAuto = inlineEnd.IsAuto();
|
||||
|
||||
// If neither 'inlineStart' nor 'inlineEnd' is auto, then we're
|
||||
// over-constrained and we ignore one of them
|
||||
@@ -873,9 +877,12 @@ LogicalMargin ReflowInput::ComputeRelativeOffsets(WritingMode aWM,
|
||||
// If both are 'auto' (their initial values), the computed values are 0
|
||||
offsets.IStart(aWM) = offsets.IEnd(aWM) = 0;
|
||||
} else {
|
||||
// 'inlineEnd' isn't 'auto' so compute its value
|
||||
// 'inlineEnd' isn't being treated as 'auto' so compute its value
|
||||
offsets.IEnd(aWM) =
|
||||
nsLayoutUtils::ComputeCBDependentValue(aCBSize.ISize(aWM), inlineEnd);
|
||||
inlineEnd.IsAuto()
|
||||
? 0
|
||||
: nsLayoutUtils::ComputeCBDependentValue(
|
||||
aCBSize.ISize(aWM), inlineEnd.AsLengthPercentage());
|
||||
|
||||
// Computed value for 'inlineStart' is minus the value of 'inlineEnd'
|
||||
offsets.IStart(aWM) = -offsets.IEnd(aWM);
|
||||
@@ -885,8 +892,8 @@ LogicalMargin ReflowInput::ComputeRelativeOffsets(WritingMode aWM,
|
||||
NS_ASSERTION(inlineEndIsAuto, "unexpected specified constraint");
|
||||
|
||||
// 'InlineStart' isn't 'auto' so compute its value
|
||||
offsets.IStart(aWM) =
|
||||
nsLayoutUtils::ComputeCBDependentValue(aCBSize.ISize(aWM), inlineStart);
|
||||
offsets.IStart(aWM) = nsLayoutUtils::ComputeCBDependentValue(
|
||||
aCBSize.ISize(aWM), inlineStart.AsLengthPercentage());
|
||||
|
||||
// Computed value for 'inlineEnd' is minus the value of 'inlineStart'
|
||||
offsets.IEnd(aWM) = -offsets.IStart(aWM);
|
||||
@@ -896,8 +903,10 @@ LogicalMargin ReflowInput::ComputeRelativeOffsets(WritingMode aWM,
|
||||
// and 'blockEnd' properties move relatively positioned elements in
|
||||
// the block progression direction. They also must be each other's
|
||||
// negative
|
||||
const auto& blockStart = position->GetInset(LogicalSide::BStart, aWM);
|
||||
const auto& blockEnd = position->GetInset(LogicalSide::BEnd, aWM);
|
||||
const auto& blockStart = position->GetAnchorResolvedInset(
|
||||
LogicalSide::BStart, aWM, positionProperty);
|
||||
const auto& blockEnd = position->GetAnchorResolvedInset(
|
||||
LogicalSide::BEnd, aWM, positionProperty);
|
||||
bool blockStartIsAuto = blockStart.IsAuto();
|
||||
bool blockEndIsAuto = blockEnd.IsAuto();
|
||||
|
||||
@@ -922,9 +931,12 @@ LogicalMargin ReflowInput::ComputeRelativeOffsets(WritingMode aWM,
|
||||
// If both are 'auto' (their initial values), the computed values are 0
|
||||
offsets.BStart(aWM) = offsets.BEnd(aWM) = 0;
|
||||
} else {
|
||||
// 'blockEnd' isn't 'auto' so compute its value
|
||||
// 'blockEnd' isn't being treated as 'auto' so compute its value
|
||||
offsets.BEnd(aWM) =
|
||||
nsLayoutUtils::ComputeCBDependentValue(aCBSize.BSize(aWM), blockEnd);
|
||||
blockEnd.IsAuto()
|
||||
? 0
|
||||
: nsLayoutUtils::ComputeCBDependentValue(
|
||||
aCBSize.BSize(aWM), blockEnd.AsLengthPercentage());
|
||||
|
||||
// Computed value for 'blockStart' is minus the value of 'blockEnd'
|
||||
offsets.BStart(aWM) = -offsets.BEnd(aWM);
|
||||
@@ -934,8 +946,8 @@ LogicalMargin ReflowInput::ComputeRelativeOffsets(WritingMode aWM,
|
||||
NS_ASSERTION(blockEndIsAuto, "unexpected specified constraint");
|
||||
|
||||
// 'blockStart' isn't 'auto' so compute its value
|
||||
offsets.BStart(aWM) =
|
||||
nsLayoutUtils::ComputeCBDependentValue(aCBSize.BSize(aWM), blockStart);
|
||||
offsets.BStart(aWM) = nsLayoutUtils::ComputeCBDependentValue(
|
||||
aCBSize.BSize(aWM), blockStart.AsLengthPercentage());
|
||||
|
||||
// Computed value for 'blockEnd' is minus the value of 'blockStart'
|
||||
offsets.BEnd(aWM) = -offsets.BStart(aWM);
|
||||
@@ -1554,8 +1566,8 @@ void ReflowInput::CalculateHypotheticalPosition(
|
||||
bool ReflowInput::IsInlineSizeComputableByBlockSizeAndAspectRatio(
|
||||
nscoord aBlockSize) const {
|
||||
WritingMode wm = GetWritingMode();
|
||||
MOZ_ASSERT(!mStylePosition->GetInset(LogicalSide::BStart, wm).IsAuto() &&
|
||||
!mStylePosition->GetInset(LogicalSide::BEnd, wm).IsAuto(),
|
||||
MOZ_ASSERT(!mStylePosition->mOffset.Get(LogicalSide::BStart, wm).IsAuto() &&
|
||||
!mStylePosition->mOffset.Get(LogicalSide::BEnd, wm).IsAuto(),
|
||||
"If any of the block-start and block-end are auto, aBlockSize "
|
||||
"doesn't make sense");
|
||||
NS_WARNING_ASSERTION(
|
||||
@@ -1578,10 +1590,22 @@ bool ReflowInput::IsInlineSizeComputableByBlockSizeAndAspectRatio(
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto position = mStyleDisplay->mPosition;
|
||||
// If both inline insets are non-auto, mFrame->ComputeSize() should get a
|
||||
// possible inline size by those insets, so we don't rely on aspect-ratio.
|
||||
if (!mStylePosition->GetInset(LogicalSide::IStart, wm).IsAuto() &&
|
||||
!mStylePosition->GetInset(LogicalSide::IEnd, wm).IsAuto()) {
|
||||
if (!mStylePosition->GetAnchorResolvedInset(LogicalSide::IStart, wm, position)
|
||||
.IsAuto() &&
|
||||
!mStylePosition->GetAnchorResolvedInset(LogicalSide::IEnd, wm, position)
|
||||
.IsAuto()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If block direction insets reference use any anchor positioning function
|
||||
// that does not resolve, we can't rely on them.
|
||||
if (mStylePosition->GetAnchorResolvedInset(LogicalSide::BStart, wm, position)
|
||||
.IsAuto() ||
|
||||
mStylePosition->GetAnchorResolvedInset(LogicalSide::BEnd, wm, position)
|
||||
.IsAuto()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1661,12 +1685,14 @@ void ReflowInput::InitAbsoluteConstraints(const ReflowInput* aCBReflowInput,
|
||||
NS_ASSERTION(mFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW),
|
||||
"Why are we here?");
|
||||
|
||||
const auto& iStartOffset =
|
||||
mStylePosition->GetInset(LogicalSide::IStart, cbwm);
|
||||
const auto& iEndOffset = mStylePosition->GetInset(LogicalSide::IEnd, cbwm);
|
||||
const auto& bStartOffset =
|
||||
mStylePosition->GetInset(LogicalSide::BStart, cbwm);
|
||||
const auto& bEndOffset = mStylePosition->GetInset(LogicalSide::BEnd, cbwm);
|
||||
const auto& iStartOffset = mStylePosition->GetAnchorResolvedInset(
|
||||
LogicalSide::IStart, cbwm, StylePositionProperty::Absolute);
|
||||
const auto& iEndOffset = mStylePosition->GetAnchorResolvedInset(
|
||||
LogicalSide::IEnd, cbwm, StylePositionProperty::Absolute);
|
||||
const auto& bStartOffset = mStylePosition->GetAnchorResolvedInset(
|
||||
LogicalSide::BStart, cbwm, StylePositionProperty::Absolute);
|
||||
const auto& bEndOffset = mStylePosition->GetAnchorResolvedInset(
|
||||
LogicalSide::BEnd, cbwm, StylePositionProperty::Absolute);
|
||||
bool iStartIsAuto = iStartOffset.IsAuto();
|
||||
bool iEndIsAuto = iEndOffset.IsAuto();
|
||||
bool bStartIsAuto = bStartOffset.IsAuto();
|
||||
@@ -1752,13 +1778,13 @@ void ReflowInput::InitAbsoluteConstraints(const ReflowInput* aCBReflowInput,
|
||||
offsets.IStart(cbwm) = 0;
|
||||
} else {
|
||||
offsets.IStart(cbwm) = nsLayoutUtils::ComputeCBDependentValue(
|
||||
cbSize.ISize(cbwm), iStartOffset);
|
||||
cbSize.ISize(cbwm), iStartOffset.AsLengthPercentage());
|
||||
}
|
||||
if (iEndIsAuto) {
|
||||
offsets.IEnd(cbwm) = 0;
|
||||
} else {
|
||||
offsets.IEnd(cbwm) =
|
||||
nsLayoutUtils::ComputeCBDependentValue(cbSize.ISize(cbwm), iEndOffset);
|
||||
nsLayoutUtils::ComputeCBDependentValue(cbSize.ISize(cbwm), iEndOffset.AsLengthPercentage());
|
||||
}
|
||||
|
||||
if (iStartIsAuto && iEndIsAuto) {
|
||||
@@ -1775,13 +1801,13 @@ void ReflowInput::InitAbsoluteConstraints(const ReflowInput* aCBReflowInput,
|
||||
offsets.BStart(cbwm) = 0;
|
||||
} else {
|
||||
offsets.BStart(cbwm) = nsLayoutUtils::ComputeCBDependentValue(
|
||||
cbSize.BSize(cbwm), bStartOffset);
|
||||
cbSize.BSize(cbwm), bStartOffset.AsLengthPercentage());
|
||||
}
|
||||
if (bEndIsAuto) {
|
||||
offsets.BEnd(cbwm) = 0;
|
||||
} else {
|
||||
offsets.BEnd(cbwm) =
|
||||
nsLayoutUtils::ComputeCBDependentValue(cbSize.BSize(cbwm), bEndOffset);
|
||||
nsLayoutUtils::ComputeCBDependentValue(cbSize.BSize(cbwm), bEndOffset.AsLengthPercentage());
|
||||
}
|
||||
|
||||
if (bStartIsAuto && bEndIsAuto) {
|
||||
|
||||
Reference in New Issue
Block a user