зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1795196 Part 1 - Remove ComputedISize() and ComputedBSize() that return writable references. r=emilio
Users of these two getters should use setters such as SetComputedISize() instead. Differential Revision: https://phabricator.services.mozilla.com/D159352
This commit is contained in:
Родитель
968de3c515
Коммит
261c24ebe5
|
@ -210,10 +210,10 @@ void nsHTMLButtonControlFrame::ReflowButtonContents(
|
|||
childPos.B(wm) = 0; // This will be set properly later, after reflowing the
|
||||
// child to determine its size.
|
||||
|
||||
const LayoutFrameType frameType = aFirstKid->Type();
|
||||
if (frameType == LayoutFrameType::FlexContainer ||
|
||||
frameType == LayoutFrameType::GridContainer) {
|
||||
contentsReflowInput.ComputedBSize() = aButtonReflowInput.ComputedBSize();
|
||||
if (aFirstKid->IsFlexOrGridContainer()) {
|
||||
// XXX: Should we use ResetResizeFlags::Yes?
|
||||
contentsReflowInput.SetComputedBSize(aButtonReflowInput.ComputedBSize(),
|
||||
ReflowInput::ResetResizeFlags::No);
|
||||
contentsReflowInput.ComputedMinBSize() =
|
||||
aButtonReflowInput.ComputedMinBSize();
|
||||
contentsReflowInput.ComputedMaxBSize() =
|
||||
|
|
|
@ -271,7 +271,8 @@ bool ReflowInput::ShouldReflowAllKids() const {
|
|||
mFrame->HasAnyStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE));
|
||||
}
|
||||
|
||||
void ReflowInput::SetComputedISize(nscoord aComputedISize) {
|
||||
void ReflowInput::SetComputedISize(nscoord aComputedISize,
|
||||
ResetResizeFlags aFlags) {
|
||||
// It'd be nice to assert that |frame| is not in reflow, but this fails for
|
||||
// two reasons:
|
||||
//
|
||||
|
@ -287,40 +288,37 @@ void ReflowInput::SetComputedISize(nscoord aComputedISize) {
|
|||
|
||||
NS_WARNING_ASSERTION(aComputedISize >= 0, "Invalid computed inline-size!");
|
||||
if (ComputedISize() != aComputedISize) {
|
||||
ComputedISize() = std::max(0, aComputedISize);
|
||||
mComputedSize.ISize(mWritingMode) = std::max(0, aComputedISize);
|
||||
const LayoutFrameType frameType = mFrame->Type();
|
||||
if (frameType != LayoutFrameType::Viewport) {
|
||||
if (aFlags == ResetResizeFlags::Yes &&
|
||||
frameType != LayoutFrameType::Viewport) {
|
||||
InitResizeFlags(mFrame->PresContext(), frameType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReflowInput::SetComputedBSize(nscoord aComputedBSize) {
|
||||
void ReflowInput::SetComputedBSize(nscoord aComputedBSize,
|
||||
ResetResizeFlags aFlags) {
|
||||
// It'd be nice to assert that |frame| is not in reflow, but this fails
|
||||
// because:
|
||||
// for two reasons:
|
||||
//
|
||||
// nsIFrame::BoxReflow creates a reflow input for its parent. This reflow
|
||||
// 1) Viewport frames reset the computed block size on a copy of their reflow
|
||||
// input when reflowing fixed-pos kids. In that case we actually don't want
|
||||
// to mess with the resize flags, because comparing the frame's rect to the
|
||||
// munged computed bsize is pointless.
|
||||
// 2) nsIFrame::BoxReflow creates a reflow input for its parent. This reflow
|
||||
// input is not used to reflow the parent, but just as a parent for the
|
||||
// frame's own reflow input. So given a nsBoxFrame inside some non-XUL
|
||||
// (like a text control, for example), we'll end up creating a reflow
|
||||
// input for the parent while the parent is reflowing.
|
||||
|
||||
NS_WARNING_ASSERTION(aComputedBSize >= 0, "Invalid computed block-size!");
|
||||
if (ComputedBSize() != aComputedBSize) {
|
||||
SetComputedBSizeWithoutResettingResizeFlags(aComputedBSize);
|
||||
mComputedSize.BSize(mWritingMode) = std::max(0, aComputedBSize);
|
||||
InitResizeFlags(mFrame->PresContext(), mFrame->Type());
|
||||
}
|
||||
}
|
||||
|
||||
void ReflowInput::SetComputedBSizeWithoutResettingResizeFlags(
|
||||
nscoord aComputedBSize) {
|
||||
// Viewport frames reset the computed block size on a copy of their reflow
|
||||
// input when reflowing fixed-pos kids. In that case we actually don't
|
||||
// want to mess with the resize flags, because comparing the frame's rect
|
||||
// to the munged computed isize is pointless.
|
||||
NS_WARNING_ASSERTION(aComputedBSize >= 0, "Invalid computed block-size!");
|
||||
ComputedBSize() = std::max(0, aComputedBSize);
|
||||
}
|
||||
|
||||
void ReflowInput::Init(nsPresContext* aPresContext,
|
||||
const Maybe<LogicalSize>& aContainingBlockSize,
|
||||
const Maybe<LogicalMargin>& aBorder,
|
||||
|
@ -354,7 +352,7 @@ void ReflowInput::Init(nsPresContext* aPresContext,
|
|||
if (type == mozilla::LayoutFrameType::Placeholder) {
|
||||
// Placeholders have a no-op Reflow method that doesn't need the rest of
|
||||
// this initialization, so we bail out early.
|
||||
ComputedBSize() = ComputedISize() = 0;
|
||||
mComputedSize.SizeTo(mWritingMode, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -423,7 +421,7 @@ void ReflowInput::Init(nsPresContext* aPresContext,
|
|||
// columns in the container's block direction
|
||||
if (type == LayoutFrameType::ColumnSet &&
|
||||
mStylePosition->ISize(mWritingMode).IsAuto()) {
|
||||
ComputedISize() = NS_UNCONSTRAINEDSIZE;
|
||||
SetComputedISize(NS_UNCONSTRAINEDSIZE, ResetResizeFlags::No);
|
||||
} else {
|
||||
SetAvailableBSize(NS_UNCONSTRAINEDSIZE);
|
||||
}
|
||||
|
@ -1766,8 +1764,7 @@ void ReflowInput::InitAbsoluteConstraints(nsPresContext* aPresContext,
|
|||
ComputedLogicalMargin(wm).Size(wm) +
|
||||
ComputedLogicalOffsets(wm).Size(wm),
|
||||
ComputedLogicalBorderPadding(wm).Size(wm), {}, mComputeSizeFlags);
|
||||
ComputedISize() = sizeResult.mLogicalSize.ISize(wm);
|
||||
ComputedBSize() = sizeResult.mLogicalSize.BSize(wm);
|
||||
mComputedSize = sizeResult.mLogicalSize;
|
||||
NS_ASSERTION(ComputedISize() >= 0, "Bogus inline-size");
|
||||
NS_ASSERTION(
|
||||
ComputedBSize() == NS_UNCONSTRAINEDSIZE || ComputedBSize() >= 0,
|
||||
|
@ -1915,8 +1912,7 @@ void ReflowInput::InitAbsoluteConstraints(nsPresContext* aPresContext,
|
|||
ComputeAbsPosBlockAutoMargin(availMarginSpace, cbwm, marginBStartIsAuto,
|
||||
marginBEndIsAuto, margin, offsets);
|
||||
}
|
||||
ComputedBSize() = computedSize.ConvertTo(wm, cbwm).BSize(wm);
|
||||
ComputedISize() = computedSize.ConvertTo(wm, cbwm).ISize(wm);
|
||||
mComputedSize = computedSize.ConvertTo(wm, cbwm);
|
||||
|
||||
SetComputedLogicalOffsets(cbwm, offsets);
|
||||
SetComputedLogicalMargin(cbwm, margin);
|
||||
|
@ -2174,18 +2170,14 @@ void ReflowInput::InitConstraints(
|
|||
SetComputedLogicalOffsets(wm, LogicalMargin(wm));
|
||||
|
||||
const auto borderPadding = ComputedLogicalBorderPadding(wm);
|
||||
ComputedISize() = AvailableISize() - borderPadding.IStartEnd(wm);
|
||||
if (ComputedISize() < 0) {
|
||||
ComputedISize() = 0;
|
||||
}
|
||||
if (AvailableBSize() != NS_UNCONSTRAINEDSIZE) {
|
||||
ComputedBSize() = AvailableBSize() - borderPadding.BStartEnd(wm);
|
||||
if (ComputedBSize() < 0) {
|
||||
ComputedBSize() = 0;
|
||||
}
|
||||
} else {
|
||||
ComputedBSize() = NS_UNCONSTRAINEDSIZE;
|
||||
}
|
||||
SetComputedISize(
|
||||
std::max(0, AvailableISize() - borderPadding.IStartEnd(wm)),
|
||||
ResetResizeFlags::No);
|
||||
SetComputedBSize(
|
||||
AvailableBSize() != NS_UNCONSTRAINEDSIZE
|
||||
? std::max(0, AvailableBSize() - borderPadding.BStartEnd(wm))
|
||||
: NS_UNCONSTRAINEDSIZE,
|
||||
ResetResizeFlags::No);
|
||||
|
||||
ComputedMinISize() = ComputedMinBSize() = 0;
|
||||
ComputedMaxBSize() = ComputedMaxBSize() = NS_UNCONSTRAINEDSIZE;
|
||||
|
@ -2304,19 +2296,22 @@ void ReflowInput::InitConstraints(
|
|||
// calc() with both percentages and lengths act like auto on internal
|
||||
// table elements
|
||||
if (isAutoISize || inlineSize.HasLengthAndPercentage()) {
|
||||
ComputedISize() = AvailableISize();
|
||||
|
||||
if ((ComputedISize() != NS_UNCONSTRAINEDSIZE) && !rowOrRowGroup) {
|
||||
if (AvailableISize() != NS_UNCONSTRAINEDSIZE && !rowOrRowGroup) {
|
||||
// Internal table elements don't have margins. Only tables and
|
||||
// cells have border and padding
|
||||
ComputedISize() -= ComputedLogicalBorderPadding(wm).IStartEnd(wm);
|
||||
if (ComputedISize() < 0) ComputedISize() = 0;
|
||||
SetComputedISize(
|
||||
std::max(0, AvailableISize() -
|
||||
ComputedLogicalBorderPadding(wm).IStartEnd(wm)),
|
||||
ResetResizeFlags::No);
|
||||
} else {
|
||||
SetComputedISize(AvailableISize(), ResetResizeFlags::No);
|
||||
}
|
||||
NS_ASSERTION(ComputedISize() >= 0, "Bogus computed isize");
|
||||
|
||||
} else {
|
||||
ComputedISize() =
|
||||
ComputeISizeValue(cbSize, mStylePosition->mBoxSizing, inlineSize);
|
||||
SetComputedISize(
|
||||
ComputeISizeValue(cbSize, mStylePosition->mBoxSizing, inlineSize),
|
||||
ResetResizeFlags::No);
|
||||
}
|
||||
|
||||
// Calculate the computed block size
|
||||
|
@ -2328,11 +2323,12 @@ void ReflowInput::InitConstraints(
|
|||
// calc() with both percentages and lengths acts like 'auto' on internal
|
||||
// table elements
|
||||
if (isAutoBSize || blockSize.HasLengthAndPercentage()) {
|
||||
ComputedBSize() = NS_UNCONSTRAINEDSIZE;
|
||||
SetComputedBSize(NS_UNCONSTRAINEDSIZE, ResetResizeFlags::No);
|
||||
} else {
|
||||
ComputedBSize() =
|
||||
SetComputedBSize(
|
||||
ComputeBSizeValue(cbSize.BSize(wm), mStylePosition->mBoxSizing,
|
||||
blockSize.AsLengthPercentage());
|
||||
blockSize.AsLengthPercentage()),
|
||||
ResetResizeFlags::No);
|
||||
}
|
||||
|
||||
// Doesn't apply to internal table elements
|
||||
|
|
|
@ -341,8 +341,6 @@ struct ReflowInput : public SizeComputationInput {
|
|||
mAvailableSize.BSize(mWritingMode) = aAvailableBSize;
|
||||
}
|
||||
|
||||
nscoord& ComputedISize() { return mComputedSize.ISize(mWritingMode); }
|
||||
nscoord& ComputedBSize() { return mComputedSize.BSize(mWritingMode); }
|
||||
nscoord& ComputedMinISize() { return mComputedMinSize.ISize(mWritingMode); }
|
||||
nscoord& ComputedMaxISize() { return mComputedMaxSize.ISize(mWritingMode); }
|
||||
nscoord& ComputedMinBSize() { return mComputedMinSize.BSize(mWritingMode); }
|
||||
|
@ -814,14 +812,19 @@ struct ReflowInput : public SizeComputationInput {
|
|||
}
|
||||
}
|
||||
|
||||
// Use "No" to request SetComputedISize/SetComputedBSize not to reset resize
|
||||
// flags.
|
||||
enum class ResetResizeFlags : bool { No, Yes };
|
||||
|
||||
// This method doesn't apply min/max computed inline-sizes to the value passed
|
||||
// in.
|
||||
void SetComputedISize(nscoord aComputedISize);
|
||||
void SetComputedISize(nscoord aComputedISize,
|
||||
ResetResizeFlags aFlags = ResetResizeFlags::Yes);
|
||||
|
||||
// These methods don't apply min/max computed block-sizes to the value passed
|
||||
// in.
|
||||
void SetComputedBSize(nscoord aComputedBSize);
|
||||
void SetComputedBSizeWithoutResettingResizeFlags(nscoord aComputedBSize);
|
||||
void SetComputedBSize(nscoord aComputedBSize,
|
||||
ResetResizeFlags aFlags = ResetResizeFlags::Yes);
|
||||
|
||||
bool WillReflowAgainForClearance() const {
|
||||
return mDiscoveredClearance && *mDiscoveredClearance;
|
||||
|
|
|
@ -310,8 +310,9 @@ nsPoint ViewportFrame::AdjustReflowInputForScrollbars(
|
|||
scrollbars.IStartEnd(wm));
|
||||
aReflowInput->SetAvailableISize(aReflowInput->AvailableISize() -
|
||||
scrollbars.IStartEnd(wm));
|
||||
aReflowInput->SetComputedBSizeWithoutResettingResizeFlags(
|
||||
aReflowInput->ComputedBSize() - scrollbars.BStartEnd(wm));
|
||||
aReflowInput->SetComputedBSize(
|
||||
aReflowInput->ComputedBSize() - scrollbars.BStartEnd(wm),
|
||||
ReflowInput::ResetResizeFlags::No);
|
||||
return nsPoint(scrollbars.Left(wm), scrollbars.Top(wm));
|
||||
}
|
||||
return nsPoint(0, 0);
|
||||
|
|
Загрузка…
Ссылка в новой задаче