Bug 1546223 Part 4 - Mechanically replace pointer with Maybe for ReflowInput's optional containing block size. r=dholbert
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 24 Apr 2019 17:35:31 +0000
changeset 530043 b23e64dd2c7bd9e83db404bde4b033d02d18d61e
parent 530042 d59741bdae0bb0a23bf3dc77ea3929bde1ccfeca
child 530044 e5029a42a612c56a826a4634425c9f0670e9a111
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1546223
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
layout/base/PresShell.cpp
layout/base/RestyleManager.cpp
layout/forms/nsFieldSetFrame.cpp
layout/forms/nsTextControlFrame.cpp
layout/generic/ReflowInput.cpp
layout/generic/ReflowInput.h
layout/generic/nsAbsoluteContainingBlock.cpp
layout/generic/nsBlockFrame.cpp
layout/generic/nsColumnSetFrame.cpp
layout/generic/nsFlexContainerFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsGridContainerFrame.cpp
layout/generic/nsVideoFrame.cpp
layout/tables/nsTableFrame.cpp
layout/tables/nsTableRowFrame.cpp
layout/tables/nsTableRowGroupFrame.cpp
layout/tables/nsTableWrapperFrame.cpp
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -9158,17 +9158,17 @@ bool nsIPresShell::DoReflow(nsIFrame* ta
 
     mLastRootReflowHadUnconstrainedBSize = hasUnconstrainedBSize;
   } else {
     // Initialize reflow input with current used border and padding,
     // in case this was set specially by the parent frame when the reflow root
     // 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
   NS_ASSERTION(reflowInput.ComputedPhysicalMargin() == nsMargin(0, 0, 0, 0),
                "reflow input should not set margin for reflow roots");
   if (size.BSize(wm) != NS_UNCONSTRAINEDSIZE) {
     nscoord computedBSize =
         size.BSize(wm) -
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -828,17 +828,17 @@ static bool RecomputePosition(nsIFrame* 
           ? viewport->AdjustReflowInputAsContainingBlock(&parentReflowInput)
                 .Size()
           : aFrame->GetContainingBlock()->GetSize();
   const nsMargin& parentBorder =
       parentReflowInput.mStyleBorder->GetComputedBorder();
   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();
   if (computedSize.height != NS_INTRINSICSIZE) {
     computedSize.height +=
         reflowInput.ComputedPhysicalBorderPadding().TopBottom();
   }
   nsSize size = aFrame->GetSize();
--- a/layout/forms/nsFieldSetFrame.cpp
+++ b/layout/forms/nsFieldSetFrame.cpp
@@ -495,20 +495,20 @@ void nsFieldSetFrame::Reflow(nsPresConte
 
   // This containerSize is incomplete as yet: it does not include the size
   // of the |inner| frame itself.
   nsSize containerSize =
       (LogicalSize(wm, 0, mLegendSpace) + border.Size(wm)).GetPhysicalSize(wm);
   // 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
     // height is unconstrained (in which case the child's will be too).
     if (aReflowInput.ComputedBSize() != NS_UNCONSTRAINEDSIZE) {
       kidReflowInput.SetComputedBSize(
           std::max(0, aReflowInput.ComputedBSize() - mLegendSpace));
     }
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -617,20 +617,20 @@ void nsTextControlFrame::ReflowTextContr
     const ReflowInput& aReflowInput, nsReflowStatus& aStatus,
     ReflowOutput& aParentDesiredSize) {
   // compute available size and frame offsets for child
   WritingMode wm = aKid->GetWritingMode();
   LogicalSize availSize = aReflowInput.ComputedSizeWithPadding(wm);
   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
   kidReflowInput.SetComputedWidth(aReflowInput.ComputedWidth());
   kidReflowInput.SetComputedHeight(aReflowInput.ComputedHeight());
 
   // Offset the frame by the size of the parent's border
   nscoord xOffset = aReflowInput.ComputedPhysicalBorderPadding().left -
--- a/layout/generic/ReflowInput.cpp
+++ b/layout/generic/ReflowInput.cpp
@@ -159,17 +159,17 @@ SizeComputationInput::SizeComputationInp
 }
 
 // Initialize a reflow input for a child frame's reflow. Some state
 // is copied from the parent reflow input; the remaining state is
 // computed.
 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),
       mFloatManager(aParentReflowInput.mFloatManager),
       mLineLayout(mFrame->IsFrameOfType(nsIFrame::eLineParticipant)
                       ? aParentReflowInput.mLineLayout
                       : nullptr),
       mPercentBSizeObserver(
@@ -324,17 +324,17 @@ void ReflowInput::MarkFrameChildrenDirty
       if (!childFrame->IsTableColGroupFrame()) {
         childFrame->AddStateBits(NS_FRAME_IS_DIRTY);
       }
     }
   }
 }
 
 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
     // did this as we went.  However, we need to be careful not to do
     // this twice for any particular child if we reflow it twice.  The
     // easiest way to accomplish that is to do it at the start.
     MarkFrameChildrenDirty(mFrame);
   }
@@ -372,21 +372,18 @@ void ReflowInput::Init(nsPresContext* aP
     // Placeholders have a no-op Reflow method that doesn't need the rest of
     // this initialization, so we bail out early.
     ComputedBSize() = ComputedISize() = 0;
     return;
   }
 
   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);
   InitDynamicReflowRoot();
 
   nsIFrame* parent = mFrame->GetParent();
   if (parent && (parent->GetStateBits() & NS_FRAME_IN_CONSTRAINED_BSIZE) &&
       !(parent->IsScrollFrame() &&
--- a/layout/generic/ReflowInput.h
+++ b/layout/generic/ReflowInput.h
@@ -8,16 +8,17 @@
 
 #ifndef mozilla_ReflowInput_h
 #define mozilla_ReflowInput_h
 
 #include "nsMargin.h"
 #include "nsStyleCoord.h"
 #include "nsIFrame.h"
 #include "mozilla/Assertions.h"
+#include "mozilla/Maybe.h"
 #include <algorithm>
 
 class gfxContext;
 class nsFloatManager;
 struct nsHypotheticalPosition;
 class nsIPercentBSizeObserver;
 class nsLineLayout;
 class nsPlaceholderFrame;
@@ -712,24 +713,25 @@ struct ReflowInput : public SizeComputat
    * @param aPresContext Must be equal to aFrame->PresContext().
    * @param aParentReflowInput A reference to an ReflowInput object that
    *        is to be the parent of this object.
    * @param aFrame The frame for whose reflow input is being constructed.
    * @param aAvailableSpace See comments for availableHeight and availableWidth
    *        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
   enum {
     // Indicates that the parent of this reflow input is "fake" (see
     // mDummyParentReflowInput in mFlags).
     DUMMY_PARENT_REFLOW_INPUT = (1 << 0),
 
@@ -759,17 +761,18 @@ struct ReflowInput : public SizeComputat
 
     // Pass ComputeSizeFlags::eIApplyAutoMinSize to ComputeSize().
     I_APPLY_AUTO_MIN_SIZE = (1 << 7),
   };
 
   // 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);
 
   /**
    * Find the content isize of our containing block for the given writing mode,
    * which need not be the same as the reflow input's mode.
    */
   nscoord GetContainingBlockContentISize(
--- a/layout/generic/nsAbsoluteContainingBlock.cpp
+++ b/layout/generic/nsAbsoluteContainingBlock.cpp
@@ -662,17 +662,17 @@ void nsAbsoluteContainingBlock::ReflowAb
     // abs.pos. CB origin, and then we'll align & offset it from there.
     nsIFrame* placeholder = aKidFrame->GetPlaceholderFrame();
     if (placeholder && placeholder->GetParent() == aDelegatingFrame) {
       rsFlags |= ReflowInput::STATIC_POS_IS_CB_ORIGIN;
     }
   }
   ReflowInput kidReflowInput(aPresContext, aReflowInput, aKidFrame,
                              LogicalSize(wm, availISize, NS_UNCONSTRAINEDSIZE),
-                             &logicalCBSize, rsFlags);
+                             Some(logicalCBSize), rsFlags);
 
   // Get the border values
   WritingMode outerWM = aReflowInput.GetWritingMode();
   const LogicalMargin border(outerWM, aDelegatingFrame->GetUsedBorder());
 
   LogicalMargin margin =
       kidReflowInput.ComputedLogicalMargin().ConvertTo(outerWM, wm);
 
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -3342,40 +3342,37 @@ void nsBlockFrame::ReflowBlockFrame(Bloc
     aState.mBCoord -= bStartMargin;
     availSpace.BStart(wm) -= bStartMargin;
     if (NS_UNCONSTRAINEDSIZE != availSpace.BSize(wm)) {
       availSpace.BSize(wm) += bStartMargin;
     }
 
     // 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.
       const ReflowInput* cbReflowInput =
           StaticPrefs::layout_css_column_span_enabled()
               ? aState.mReflowInput.mParentReflowInput->mCBReflowInput
               : aState.mReflowInput.mCBReflowInput;
       MOZ_ASSERT(cbReflowInput->mFrame->StyleColumn()->IsColumnContainerStyle(),
                  "Get unexpected reflow input of multicol containing block!");
 
       // 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 {
       if (floatAvailableSpace.HasFloats()) {
         // Set if floatAvailableSpace.HasFloats() is true for any
         // iteration of the loop.
         aLine->SetLineIsImpactedByFloat(true);
@@ -6867,17 +6864,17 @@ void nsBlockFrame::ReflowOutsideMarker(n
 
   WritingMode markerWM = aMarkerFrame->GetWritingMode();
   LogicalSize availSize(markerWM);
   // Make up an inline-size since it doesn't really matter (XXX).
   availSize.ISize(markerWM) = aState.ContentISize();
   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);
 
   // Get the float available space using our saved state from before we
   // started reflowing the block, so that we ignore any floats inside
   // the block.
   // FIXME: aLineTop isn't actually set correctly by some callers, since
   // they reposition the line.
--- a/layout/generic/nsColumnSetFrame.cpp
+++ b/layout/generic/nsColumnSetFrame.cpp
@@ -715,17 +715,17 @@ nsColumnSetFrame::ColumnBalanceData nsCo
           StaticPrefs::layout_css_column_span_enabled()
               ? aReflowInput.mCBReflowInput->ComputedSize(wm)
               : aReflowInput.ComputedSize(wm);
 
       if (reflowNext) child->AddStateBits(NS_FRAME_IS_DIRTY);
 
       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;
 
       // We need to reflow any float placeholders, even if our column block-size
       // hasn't changed.
       kidReflowInput.mFlags.mMustReflowPlaceholders = !colBSizeChanged;
 
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -1829,17 +1829,17 @@ nscoord nsFlexContainerFrame::MeasureFle
     nsPresContext* aPresContext, FlexItem& aFlexItem,
     bool aForceBResizeForMeasuringReflow,
     const ReflowInput& aParentReflowInput) {
   // Set up a reflow input for measuring the flex item's auto-height:
   WritingMode wm = aFlexItem.Frame()->GetWritingMode();
   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);
 
   if (aFlexItem.IsStretched()) {
     childRIForMeasuringBSize.SetComputedISize(aFlexItem.GetCrossSize());
     childRIForMeasuringBSize.SetIResize(true);
   }
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -10228,18 +10228,18 @@ void nsFrame::BoxReflow(nsBoxLayoutState
       parentRI = &parentReflowInput;
     }
 
     // XXX Is it OK that this reflow input has only one ancestor?
     // (It used to have a bogus parent, skipping all the boxes).
     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
     //            correct the first time around, rather than changing it later.
     reflowInput.mCBReflowInput = parentRI;
 
     reflowInput.mReflowDepth = aState.GetReflowDepth();
 
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -530,19 +530,19 @@ void nsHTMLScrollFrame::ReflowScrolledFr
   }
 
   nsPresContext* presContext = PresContext();
 
   // Pass false for aInit so we can pass in the correct padding.
   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);
   kidReflowInput.ComputedMinBSize() = computedMinBSize;
   kidReflowInput.ComputedMaxBSize() = computedMaxBSize;
   if (aState->mReflowInput.IsBResizeForWM(kidReflowInput.GetWritingMode())) {
     kidReflowInput.SetBResize(true);
   }
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -3387,17 +3387,17 @@ static nscoord MeasuringReflow(nsIFrame*
   }
   if (aBMinSizeClamp != NS_MAXSIZE) {
     riFlags |= ReflowInput::B_CLAMP_MARGIN_BOX_MIN_SIZE;
     aChild->SetProperty(nsIFrame::BClampMarginBoxMinSizeProperty(),
                         aBMinSizeClamp);
   } 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
   // block-resize flag to true.
   // FIXME (perf): It would be faster to do this only if the previous
   // reflow of the child was not a measuring reflow, and only if the
   // child does some of the things that are affected by
   // ReflowInput::COMPUTE_SIZE_USE_AUTO_BSIZE.
@@ -4833,17 +4833,17 @@ void nsGridContainerFrame::ReflowInFlowC
     }
   }
 
   if (!isConstrainedBSize) {
     childCBSize.BSize(childWM) = NS_UNCONSTRAINEDSIZE;
   }
   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;
 
   // Because we pass ReflowInput::COMPUTE_SIZE_USE_AUTO_BSIZE, and the
   // previous reflow of the child might not have, set the child's
   // block-resize flag to true.
   // FIXME (perf): It would be faster to do this only if the previous
   // reflow of the child was a measuring reflow, and only if the child
--- a/layout/generic/nsVideoFrame.cpp
+++ b/layout/generic/nsVideoFrame.cpp
@@ -297,17 +297,17 @@ void nsVideoFrame::Reflow(nsPresContext*
       ReflowOutput kidDesiredSize(aReflowInput);
       WritingMode wm = imageFrame->GetWritingMode();
       LogicalSize availableSize = aReflowInput.AvailableSize(wm);
       availableSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
 
       LogicalSize cbSize = aMetrics.Size(aMetrics.GetWritingMode())
                                .ConvertTo(wm, aMetrics.GetWritingMode());
       ReflowInput kidReflowInput(aPresContext, aReflowInput, imageFrame,
-                                 availableSize, &cbSize);
+                                 availableSize, Some(cbSize));
 
       nsRect posterRenderRect;
       if (ShouldDisplayPoster()) {
         posterRenderRect =
             nsRect(nsPoint(borderPadding.left, borderPadding.top),
                    nsSize(aReflowInput.ComputedWidth(),
                           aReflowInput.ComputedHeight()));
       }
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -2837,17 +2837,17 @@ void nsTableFrame::InitChildReflowInput(
   if (IsBorderCollapse()) {
     nsTableRowGroupFrame* rgFrame =
         static_cast<nsTableRowGroupFrame*>(aReflowInput.mFrame);
     WritingMode wm = GetWritingMode();
     LogicalMargin border = rgFrame->GetBCBorderWidth(wm);
     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,
                "should not resize columns on special bsize reflow");
   if (mBits.mResizedColumns) {
     aReflowInput.SetIResize(true);
   }
 }
@@ -2989,17 +2989,18 @@ nsresult nsTableFrame::SetupHeaderFooter
   WritingMode wm = aFrame->GetWritingMode();
   LogicalSize availSize = aReflowInput.reflowInput.AvailableSize(wm);
 
   nsSize containerSize = availSize.GetPhysicalSize(wm);
   // XXX check for containerSize.* == NS_UNCONSTRAINEDSIZE
 
   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);
   desiredSize.ClearSize();
   nsReflowStatus status;
   ReflowChild(aFrame, presContext, desiredSize, kidReflowInput, wm,
               LogicalPoint(wm, aReflowInput.iCoord, aReflowInput.bCoord),
               containerSize, 0, status);
@@ -3017,17 +3018,17 @@ void nsTableFrame::PlaceRepeatedFooter(T
   WritingMode wm = aTfoot->GetWritingMode();
   LogicalSize kidAvailSize = aReflowInput.availSize;
 
   nsSize containerSize = kidAvailSize.GetPhysicalSize(wm);
   // XXX check for containerSize.* == NS_UNCONSTRAINEDSIZE
 
   kidAvailSize.BSize(wm) = aFooterHeight;
   ReflowInput footerReflowInput(presContext, aReflowInput.reflowInput, aTfoot,
-                                kidAvailSize, nullptr,
+                                kidAvailSize, Nothing(),
                                 ReflowInput::CALLER_WILL_INIT);
   InitChildReflowInput(footerReflowInput);
   aReflowInput.bCoord += GetRowSpacing(GetRowCount());
 
   nsRect origTfootRect = aTfoot->GetRect();
   nsRect origTfootVisualOverflow = aTfoot->GetVisualOverflowRect();
 
   nsReflowStatus footerStatus;
@@ -3165,17 +3166,17 @@ void nsTableFrame::ReflowChildren(TableR
       nsRect oldKidRect = kidFrame->GetRect();
       nsRect oldKidVisualOverflow = kidFrame->GetVisualOverflowRect();
 
       ReflowOutput desiredSize(aReflowInput.reflowInput);
       desiredSize.ClearSize();
 
       // Reflow the child into the available space
       ReflowInput kidReflowInput(presContext, aReflowInput.reflowInput,
-                                 kidFrame, kidAvailSize, nullptr,
+                                 kidFrame, kidAvailSize, Nothing(),
                                  ReflowInput::CALLER_WILL_INIT);
       InitChildReflowInput(kidReflowInput);
 
       // If this isn't the first row group, and the previous row group has a
       // nonzero YMost, then we can't be at the top of the page.
       // We ignore a repeated head row group in this check to avoid causing
       // infinite loops in some circumstances - see bug 344883.
       if (childX > ((thead && IsRepeatedFrame(thead)) ? 1u : 0u) &&
--- a/layout/tables/nsTableRowFrame.cpp
+++ b/layout/tables/nsTableRowFrame.cpp
@@ -28,17 +28,17 @@ using namespace mozilla;
 
 namespace mozilla {
 
 struct TableCellReflowInput : public ReflowInput {
   TableCellReflowInput(nsPresContext* aPresContext,
                        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);
 };
 
 }  // namespace mozilla
 
 void TableCellReflowInput::FixUp(const LogicalSize& aAvailSpace) {
   // fix the mComputed values during a pass 2 reflow since the cell can be a
@@ -74,17 +74,17 @@ void nsTableRowFrame::InitChildReflowInp
     // we only reflow cells, so don't need to check frame type
     nsBCTableCellFrame* bcCellFrame = (nsBCTableCellFrame*)aReflowInput.mFrame;
     if (bcCellFrame) {
       WritingMode wm = GetWritingMode();
       collapseBorder = bcCellFrame->GetBorderWidth(wm).GetPhysicalMargin(wm);
       pCollapseBorder = &collapseBorder;
     }
   }
-  aReflowInput.Init(&aPresContext, nullptr, pCollapseBorder);
+  aReflowInput.Init(&aPresContext, Nothing(), pCollapseBorder);
   aReflowInput.FixUp(aAvailSize);
 }
 
 void nsTableRowFrame::SetFixedBSize(nscoord aValue) {
   nscoord bsize = std::max(0, aValue);
   if (HasFixedBSize()) {
     if (bsize > mStyleFixedBSize) {
       mStyleFixedBSize = bsize;
--- a/layout/tables/nsTableRowGroupFrame.cpp
+++ b/layout/tables/nsTableRowGroupFrame.cpp
@@ -295,17 +295,17 @@ void nsTableRowGroupFrame::InitChildRefl
     nsTableRowFrame* rowFrame = do_QueryFrame(aReflowInput.mFrame);
     if (rowFrame) {
       WritingMode wm = GetWritingMode();
       LogicalMargin border = rowFrame->GetBCBorderWidth(wm);
       collapseBorder = border.GetPhysicalMargin(wm);
       pCollapseBorder = &collapseBorder;
     }
   }
-  aReflowInput.Init(&aPresContext, nullptr, pCollapseBorder, &padding);
+  aReflowInput.Init(&aPresContext, Nothing(), pCollapseBorder, &padding);
 }
 
 static void CacheRowBSizesForPrinting(nsPresContext* aPresContext,
                                       nsTableRowFrame* aFirstRow,
                                       WritingMode aWM) {
   for (nsTableRowFrame* row = aFirstRow; row; row = row->GetNextRow()) {
     if (!row->GetPrevInFlow()) {
       row->SetHasUnpaginatedBSize(true);
@@ -367,17 +367,17 @@ void nsTableRowGroupFrame::ReflowChildre
       desiredSize.ClearSize();
 
       // Reflow the child into the available space, giving it as much bsize as
       // it wants. We'll deal with splitting later after we've computed the row
       // bsizes, taking into account cells with row spans...
       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);
 
       // This can indicate that columns were resized.
       if (aReflowInput.reflowInput.IsIResize()) {
         kidReflowInput.SetIResize(true);
       }
 
@@ -989,17 +989,17 @@ void nsTableRowGroupFrame::SplitSpanning
         nsSize rowAvailSize(
             aReflowInput.AvailableWidth(),
             std::max(aReflowInput.AvailableHeight() - rowRect.y, 0));
         // don't let the available height exceed what
         // CalculateRowBSizes set for it
         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
 
         nscoord cellBSize =
             row->ReflowCellFrame(&aPresContext, rowReflowInput, isTopOfPage,
                                  cell, cellAvailBSize, status);
         aDesiredBSize = std::max(aDesiredBSize, rowPos.y + cellBSize);
@@ -1125,17 +1125,17 @@ nsresult nsTableRowGroupFrame::SplitRowG
           (availHeight - aDesiredSize.Height() > pageHeight / 20)) {
         nsSize availSize(availWidth, std::max(availHeight - rowRect.y, 0));
         // don't let the available height exceed what CalculateRowHeights set
         // for it
         availSize.height = std::min(availSize.height, rowRect.height);
 
         ReflowInput rowReflowInput(
             aPresContext, aReflowInput, rowFrame,
-            LogicalSize(rowFrame->GetWritingMode(), availSize), nullptr,
+            LogicalSize(rowFrame->GetWritingMode(), availSize), Nothing(),
             ReflowInput::CALLER_WILL_INIT);
 
         InitChildReflowInput(*aPresContext, borderCollapse, rowReflowInput);
         rowReflowInput.mFlags.mIsTopOfPage = isTopOfPage;  // set top of page
         ReflowOutput rowMetrics(aReflowInput);
 
         // Get the old size before we reflow.
         nsRect oldRowRect = rowFrame->GetRect();
--- a/layout/tables/nsTableWrapperFrame.cpp
+++ b/layout/tables/nsTableWrapperFrame.cpp
@@ -243,18 +243,17 @@ void nsTableWrapperFrame::InitChildReflo
       }
     }
     if (!cbSize) {
       // For inner table frames, the containing block is the same as for
       // the outer table frame.
       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
 // case of auto margins
 void nsTableWrapperFrame::GetChildMargin(nsPresContext* aPresContext,
                                          const ReflowInput& aOuterRI,
                                          nsIFrame* aChildFrame,
                                          nscoord aAvailISize,
@@ -264,17 +263,17 @@ void nsTableWrapperFrame::GetChildMargin
 
   // construct a reflow input to compute margin and padding. Auto margins
   // will not be computed at this time.
 
   // create and init the child reflow input
   // 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);
 
   aMargin = childRI.ComputedLogicalMargin();
 }
 
 static nsSize GetContainingBlockSize(const ReflowInput& aOuterRI) {
   nsSize size(0, 0);
@@ -730,17 +729,17 @@ void nsTableWrapperFrame::OuterBeginRefl
       NS_ASSERTION(NS_UNCONSTRAINEDSIZE != margin.BEnd(wm),
                    "No unconstrainedsize arithmetic, please");
       availBSize -= margin.BEnd(wm);
     }
   }
   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);
 
   // see if we need to reset top-of-page due to a caption
   if (aChildRI->mFlags.mIsTopOfPage &&
       mCaptionFrames.FirstChild() == aChildFrame) {
     uint8_t captionSide = GetCaptionSide();
     if (captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM ||