Bug 1546223 Part 4 - Mechanically replace pointer with Maybe for ReflowInput's optional containing block size. r=dholbert

There's no behavior change in this patch.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ting-Yu Lin 2019-04-24 17:35:31 +00:00
Родитель ee7ae91e94
Коммит 49cfcc232c
18 изменённых файлов: 49 добавлений и 52 удалений

Просмотреть файл

@ -9163,7 +9163,7 @@ bool nsIPresShell::DoReflow(nsIFrame* target, bool aInterruptible,
// was reflowed by its parent.
nsMargin currentBorder = target->GetUsedBorder();
nsMargin currentPadding = target->GetUsedPadding();
reflowInput.Init(mPresContext, nullptr, &currentBorder, &currentPadding);
reflowInput.Init(mPresContext, Nothing(), &currentBorder, &currentPadding);
}
// fix the computed height

Просмотреть файл

@ -833,7 +833,7 @@ static bool RecomputePosition(nsIFrame* aFrame) {
cbSize -= nsSize(parentBorder.LeftRight(), parentBorder.TopBottom());
LogicalSize lcbSize(frameWM, cbSize);
ReflowInput reflowInput(aFrame->PresContext(), parentReflowInput, aFrame,
availSize, &lcbSize);
availSize, Some(lcbSize));
nsSize computedSize(reflowInput.ComputedWidth(),
reflowInput.ComputedHeight());
computedSize.width += reflowInput.ComputedPhysicalBorderPadding().LeftRight();

Просмотреть файл

@ -500,10 +500,10 @@ void nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
// reflow the content frame only if needed
if (reflowInner) {
ReflowInput kidReflowInput(aPresContext, aReflowInput, inner,
innerAvailSize, nullptr,
innerAvailSize, Nothing(),
ReflowInput::CALLER_WILL_INIT);
// Override computed padding, in case it's percentage padding
kidReflowInput.Init(aPresContext, nullptr, nullptr,
kidReflowInput.Init(aPresContext, Nothing(), nullptr,
&aReflowInput.ComputedPhysicalPadding());
// Our child is "height:100%" but we actually want its height to be reduced
// by the amount of content-height the legend is eating up, unless our

Просмотреть файл

@ -622,10 +622,10 @@ void nsTextControlFrame::ReflowTextControlChild(
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
ReflowInput kidReflowInput(aPresContext, aReflowInput, aKid, availSize,
nullptr, ReflowInput::CALLER_WILL_INIT);
Nothing(), ReflowInput::CALLER_WILL_INIT);
// Override padding with our computed padding in case we got it from theming
// or percentage
kidReflowInput.Init(aPresContext, nullptr, nullptr,
kidReflowInput.Init(aPresContext, Nothing(), nullptr,
&aReflowInput.ComputedPhysicalPadding());
// Set computed width and computed height for the child

Просмотреть файл

@ -164,7 +164,7 @@ SizeComputationInput::SizeComputationInput(
ReflowInput::ReflowInput(nsPresContext* aPresContext,
const ReflowInput& aParentReflowInput,
nsIFrame* aFrame, const LogicalSize& aAvailableSpace,
const LogicalSize* aContainingBlockSize,
const Maybe<LogicalSize>& aContainingBlockSize,
uint32_t aFlags)
: SizeComputationInput(aFrame, aParentReflowInput.mRenderingContext),
mParentReflowInput(&aParentReflowInput),
@ -329,7 +329,7 @@ void ReflowInput::MarkFrameChildrenDirty(nsIFrame* aFrame) {
}
void ReflowInput::Init(nsPresContext* aPresContext,
const LogicalSize* aContainingBlockSize,
const Maybe<LogicalSize>& aContainingBlockSize,
const nsMargin* aBorder, const nsMargin* aPadding) {
if ((mFrame->GetStateBits() & NS_FRAME_IS_DIRTY)) {
// FIXME (bug 1376530): It would be better for memory locality if we
@ -377,11 +377,8 @@ void ReflowInput::Init(nsPresContext* aPresContext,
InitFrameType(type);
LogicalSize cbSize(mWritingMode, -1, -1);
if (aContainingBlockSize) {
cbSize = *aContainingBlockSize;
}
LogicalSize cbSize =
aContainingBlockSize.valueOr(LogicalSize(mWritingMode, -1, -1));
InitConstraints(aPresContext, cbSize, aBorder, aPadding, type);
InitResizeFlags(aPresContext, type);

Просмотреть файл

@ -13,6 +13,7 @@
#include "nsStyleCoord.h"
#include "nsIFrame.h"
#include "mozilla/Assertions.h"
#include "mozilla/Maybe.h"
#include <algorithm>
class gfxContext;
@ -717,14 +718,15 @@ struct ReflowInput : public SizeComputationInput {
* members.
* @param aContainingBlockSize An optional size, in app units, specifying
* the containing block size to use instead of the default which is
* to use the aAvailableSpace.
* computed by ComputeContainingBlockRectangle().
* @param aFlags A set of flags used for additional boolean parameters (see
* below).
*/
ReflowInput(nsPresContext* aPresContext,
const ReflowInput& aParentReflowInput, nsIFrame* aFrame,
const mozilla::LogicalSize& aAvailableSpace,
const mozilla::LogicalSize* aContainingBlockSize = nullptr,
const mozilla::Maybe<mozilla::LogicalSize>& aContainingBlockSize =
mozilla::Nothing(),
uint32_t aFlags = 0);
// Values for |aFlags| passed to constructor
@ -764,7 +766,8 @@ struct ReflowInput : public SizeComputationInput {
// This method initializes various data members. It is automatically
// called by the various constructors
void Init(nsPresContext* aPresContext,
const mozilla::LogicalSize* aContainingBlockSize = nullptr,
const mozilla::Maybe<mozilla::LogicalSize>& aContainingBlockSize =
mozilla::Nothing(),
const nsMargin* aBorder = nullptr,
const nsMargin* aPadding = nullptr);

Просмотреть файл

@ -667,7 +667,7 @@ void nsAbsoluteContainingBlock::ReflowAbsoluteFrame(
}
ReflowInput kidReflowInput(aPresContext, aReflowInput, aKidFrame,
LogicalSize(wm, availISize, NS_UNCONSTRAINEDSIZE),
&logicalCBSize, rsFlags);
Some(logicalCBSize), rsFlags);
// Get the border values
WritingMode outerWM = aReflowInput.GetWritingMode();

Просмотреть файл

@ -3347,6 +3347,7 @@ void nsBlockFrame::ReflowBlockFrame(BlockReflowInput& aState,
// Construct the reflow input for the block.
Maybe<ReflowInput> blockReflowInput;
Maybe<LogicalSize> cbSize;
if (Style()->GetPseudoType() == PseudoStyleType::columnContent) {
// Calculate the multicol containing block's block size so that the
// children with percentage block size get correct percentage basis.
@ -3359,19 +3360,15 @@ void nsBlockFrame::ReflowBlockFrame(BlockReflowInput& aState,
// Use column-width as the containing block's inline-size, i.e. the column
// content's computed inline-size.
LogicalSize cbSize = LogicalSize(wm, aState.mReflowInput.ComputedISize(),
cbReflowInput->ComputedBSize())
.ConvertTo(frame->GetWritingMode(), wm);
blockReflowInput.emplace(
aState.mPresContext, aState.mReflowInput, frame,
availSpace.Size(wm).ConvertTo(frame->GetWritingMode(), wm), &cbSize);
} else {
blockReflowInput.emplace(
aState.mPresContext, aState.mReflowInput, frame,
availSpace.Size(wm).ConvertTo(frame->GetWritingMode(), wm));
cbSize.emplace(LogicalSize(wm, aState.mReflowInput.ComputedISize(),
cbReflowInput->ComputedBSize())
.ConvertTo(frame->GetWritingMode(), wm));
}
blockReflowInput.emplace(
aState.mPresContext, aState.mReflowInput, frame,
availSpace.Size(wm).ConvertTo(frame->GetWritingMode(), wm), cbSize);
nsFloatManager::SavedState floatManagerState;
nsReflowStatus frameReflowStatus;
do {
@ -6872,7 +6869,7 @@ void nsBlockFrame::ReflowOutsideMarker(nsIFrame* aMarkerFrame,
availSize.BSize(markerWM) = NS_UNCONSTRAINEDSIZE;
ReflowInput reflowInput(aState.mPresContext, ri, aMarkerFrame, availSize,
nullptr, ReflowInput::COMPUTE_SIZE_SHRINK_WRAP);
Nothing(), ReflowInput::COMPUTE_SIZE_SHRINK_WRAP);
nsReflowStatus status;
aMarkerFrame->Reflow(aState.mPresContext, aMetrics, reflowInput, status);

Просмотреть файл

@ -720,7 +720,7 @@ nsColumnSetFrame::ColumnBalanceData nsColumnSetFrame::ReflowChildren(
LogicalSize kidCBSize(wm, availSize.ISize(wm), computedSize.BSize(wm));
ReflowInput kidReflowInput(PresContext(), aReflowInput, child, availSize,
&kidCBSize);
Some(kidCBSize));
kidReflowInput.mFlags.mIsTopOfPage = true;
kidReflowInput.mFlags.mTableIsSplittable = false;
kidReflowInput.mFlags.mIsColumnBalancing = aConfig.mIsBalancing;

Просмотреть файл

@ -1834,7 +1834,7 @@ nscoord nsFlexContainerFrame::MeasureFlexItemContentBSize(
LogicalSize availSize = aParentReflowInput.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
ReflowInput childRIForMeasuringBSize(aPresContext, aParentReflowInput,
aFlexItem.Frame(), availSize, nullptr,
aFlexItem.Frame(), availSize, Nothing(),
ReflowInput::CALLER_WILL_INIT);
childRIForMeasuringBSize.mFlags.mIsFlexContainerMeasuringBSize = true;
childRIForMeasuringBSize.Init(aPresContext);

Просмотреть файл

@ -10233,8 +10233,8 @@ void nsFrame::BoxReflow(nsBoxLayoutState& aState, nsPresContext* aPresContext,
WritingMode wm = GetWritingMode();
LogicalSize logicalSize(wm, nsSize(aWidth, aHeight));
logicalSize.BSize(wm) = NS_INTRINSICSIZE;
ReflowInput reflowInput(aPresContext, *parentRI, this, logicalSize, nullptr,
ReflowInput::DUMMY_PARENT_REFLOW_INPUT);
ReflowInput reflowInput(aPresContext, *parentRI, this, logicalSize,
Nothing(), ReflowInput::DUMMY_PARENT_REFLOW_INPUT);
// XXX_jwir3: This is somewhat fishy. If this is actually changing the value
// here (which it might be), then we should make sure that it's

Просмотреть файл

@ -535,9 +535,9 @@ void nsHTMLScrollFrame::ReflowScrolledFrame(ScrollReflowInput* aState,
ReflowInput kidReflowInput(presContext, aState->mReflowInput,
mHelper.mScrolledFrame,
LogicalSize(wm, availISize, NS_UNCONSTRAINEDSIZE),
nullptr, ReflowInput::CALLER_WILL_INIT);
Nothing(), ReflowInput::CALLER_WILL_INIT);
const nsMargin physicalPadding = padding.GetPhysicalMargin(wm);
kidReflowInput.Init(presContext, nullptr, nullptr, &physicalPadding);
kidReflowInput.Init(presContext, Nothing(), nullptr, &physicalPadding);
kidReflowInput.mFlags.mAssumingHScrollbar = aAssumeHScroll;
kidReflowInput.mFlags.mAssumingVScrollbar = aAssumeVScroll;
kidReflowInput.SetComputedBSize(computedBSize);

Просмотреть файл

@ -3392,7 +3392,7 @@ static nscoord MeasuringReflow(nsIFrame* aChild,
} else {
aChild->DeleteProperty(nsIFrame::BClampMarginBoxMinSizeProperty());
}
ReflowInput childRI(pc, *rs, aChild, aAvailableSize, &aCBSize, riFlags);
ReflowInput childRI(pc, *rs, aChild, aAvailableSize, Some(aCBSize), riFlags);
// Because we pass ReflowInput::COMPUTE_SIZE_USE_AUTO_BSIZE, and the
// previous reflow of the child might not have, set the child's
@ -4838,7 +4838,7 @@ void nsGridContainerFrame::ReflowInFlowChild(
}
LogicalSize percentBasis(cb.Size(wm).ConvertTo(childWM, wm));
ReflowInput childRI(pc, *aState.mReflowInput, aChild, childCBSize,
&percentBasis, flags);
Some(percentBasis), flags);
childRI.mFlags.mIsTopOfPage =
aFragmentainer ? aFragmentainer->mIsTopOfPage : false;

Просмотреть файл

@ -302,7 +302,7 @@ void nsVideoFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics,
LogicalSize cbSize = aMetrics.Size(aMetrics.GetWritingMode())
.ConvertTo(wm, aMetrics.GetWritingMode());
ReflowInput kidReflowInput(aPresContext, aReflowInput, imageFrame,
availableSize, &cbSize);
availableSize, Some(cbSize));
nsRect posterRenderRect;
if (ShouldDisplayPoster()) {

Просмотреть файл

@ -2842,7 +2842,7 @@ void nsTableFrame::InitChildReflowInput(ReflowInput& aReflowInput) {
collapseBorder = border.GetPhysicalMargin(wm);
pCollapseBorder = &collapseBorder;
}
aReflowInput.Init(presContext, nullptr, pCollapseBorder, &padding);
aReflowInput.Init(presContext, Nothing(), pCollapseBorder, &padding);
NS_ASSERTION(!mBits.mResizedColumns ||
!aReflowInput.mParentReflowInput->mFlags.mSpecialBSizeReflow,
@ -2994,7 +2994,8 @@ nsresult nsTableFrame::SetupHeaderFooterChild(
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
ReflowInput kidReflowInput(presContext, aReflowInput.reflowInput, aFrame,
availSize, nullptr, ReflowInput::CALLER_WILL_INIT);
availSize, Nothing(),
ReflowInput::CALLER_WILL_INIT);
InitChildReflowInput(kidReflowInput);
kidReflowInput.mFlags.mIsTopOfPage = true;
ReflowOutput desiredSize(aReflowInput.reflowInput);
@ -3022,7 +3023,7 @@ void nsTableFrame::PlaceRepeatedFooter(TableReflowInput& aReflowInput,
kidAvailSize.BSize(wm) = aFooterHeight;
ReflowInput footerReflowInput(presContext, aReflowInput.reflowInput, aTfoot,
kidAvailSize, nullptr,
kidAvailSize, Nothing(),
ReflowInput::CALLER_WILL_INIT);
InitChildReflowInput(footerReflowInput);
aReflowInput.bCoord += GetRowSpacing(GetRowCount());
@ -3170,7 +3171,7 @@ void nsTableFrame::ReflowChildren(TableReflowInput& aReflowInput,
// Reflow the child into the available space
ReflowInput kidReflowInput(presContext, aReflowInput.reflowInput,
kidFrame, kidAvailSize, nullptr,
kidFrame, kidAvailSize, Nothing(),
ReflowInput::CALLER_WILL_INIT);
InitChildReflowInput(kidReflowInput);

Просмотреть файл

@ -33,7 +33,7 @@ struct TableCellReflowInput : public ReflowInput {
const ReflowInput& aParentReflowInput, nsIFrame* aFrame,
const LogicalSize& aAvailableSpace, uint32_t aFlags = 0)
: ReflowInput(aPresContext, aParentReflowInput, aFrame, aAvailableSpace,
nullptr, aFlags) {}
Nothing(), aFlags) {}
void FixUp(const LogicalSize& aAvailSpace);
};
@ -79,7 +79,7 @@ void nsTableRowFrame::InitChildReflowInput(nsPresContext& aPresContext,
pCollapseBorder = &collapseBorder;
}
}
aReflowInput.Init(&aPresContext, nullptr, pCollapseBorder);
aReflowInput.Init(&aPresContext, Nothing(), pCollapseBorder);
aReflowInput.FixUp(aAvailSize);
}

Просмотреть файл

@ -300,7 +300,7 @@ void nsTableRowGroupFrame::InitChildReflowInput(nsPresContext& aPresContext,
pCollapseBorder = &collapseBorder;
}
}
aReflowInput.Init(&aPresContext, nullptr, pCollapseBorder, &padding);
aReflowInput.Init(&aPresContext, Nothing(), pCollapseBorder, &padding);
}
static void CacheRowBSizesForPrinting(nsPresContext* aPresContext,
@ -372,7 +372,7 @@ void nsTableRowGroupFrame::ReflowChildren(
LogicalSize kidAvailSize = aReflowInput.availSize;
kidAvailSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
ReflowInput kidReflowInput(aPresContext, aReflowInput.reflowInput,
kidFrame, kidAvailSize, nullptr,
kidFrame, kidAvailSize, Nothing(),
ReflowInput::CALLER_WILL_INIT);
InitChildReflowInput(*aPresContext, borderCollapse, kidReflowInput);
@ -994,7 +994,7 @@ void nsTableRowGroupFrame::SplitSpanningCells(
rowAvailSize.height = std::min(rowAvailSize.height, rowRect.height);
ReflowInput rowReflowInput(
&aPresContext, aReflowInput, row,
LogicalSize(row->GetWritingMode(), rowAvailSize), nullptr,
LogicalSize(row->GetWritingMode(), rowAvailSize), Nothing(),
ReflowInput::CALLER_WILL_INIT);
InitChildReflowInput(aPresContext, borderCollapse, rowReflowInput);
rowReflowInput.mFlags.mIsTopOfPage = isTopOfPage; // set top of page
@ -1130,7 +1130,7 @@ nsresult nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
ReflowInput rowReflowInput(
aPresContext, aReflowInput, rowFrame,
LogicalSize(rowFrame->GetWritingMode(), availSize), nullptr,
LogicalSize(rowFrame->GetWritingMode(), availSize), Nothing(),
ReflowInput::CALLER_WILL_INIT);
InitChildReflowInput(*aPresContext, borderCollapse, rowReflowInput);

Просмотреть файл

@ -248,8 +248,7 @@ void nsTableWrapperFrame::InitChildReflowInput(nsPresContext& aPresContext,
cbSize.emplace(aOuterRI.mContainingBlockSize);
}
}
aReflowInput.Init(&aPresContext, cbSize.ptrOr(nullptr), pCollapseBorder,
pCollapsePadding);
aReflowInput.Init(&aPresContext, cbSize, pCollapseBorder, pCollapsePadding);
}
// get the margin and padding data. ReflowInput doesn't handle the
@ -269,7 +268,7 @@ void nsTableWrapperFrame::GetChildMargin(nsPresContext* aPresContext,
// XXX We really shouldn't construct a reflow input to do this.
WritingMode wm = aOuterRI.GetWritingMode();
LogicalSize availSize(wm, aAvailISize, aOuterRI.AvailableSize(wm).BSize(wm));
ReflowInput childRI(aPresContext, aOuterRI, aChildFrame, availSize, nullptr,
ReflowInput childRI(aPresContext, aOuterRI, aChildFrame, availSize, Nothing(),
ReflowInput::CALLER_WILL_INIT);
InitChildReflowInput(*aPresContext, aOuterRI, childRI);
@ -735,7 +734,7 @@ void nsTableWrapperFrame::OuterBeginReflowChild(nsPresContext* aPresContext,
LogicalSize availSize(wm, aAvailISize, availBSize);
// create and init the child reflow input, using passed-in Maybe<>,
// so that caller can use it after we return.
aChildRI.emplace(aPresContext, aOuterRI, aChildFrame, availSize, nullptr,
aChildRI.emplace(aPresContext, aOuterRI, aChildFrame, availSize, Nothing(),
ReflowInput::CALLER_WILL_INIT);
InitChildReflowInput(*aPresContext, aOuterRI, *aChildRI);