Bug 1400421 part 2: Delete unused nsLeafFrame::Reflow override (and its DoReflow helper). r?mats draft
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 15 Sep 2017 15:55:21 -0700
changeset 665777 633a8fef7b05bd0326415f8dbaae2408da3b02b7
parent 665775 2d49cb14757348ce6277c6a87c8e20a7f7e815ad
child 731881 593f59986be992882c438301f02e9c20a20626dd
push id80172
push userdholbert@mozilla.com
push dateFri, 15 Sep 2017 22:55:31 +0000
reviewersmats
bugs1400421
milestone57.0a1
Bug 1400421 part 2: Delete unused nsLeafFrame::Reflow override (and its DoReflow helper). r?mats nsLeafFrame only exists as an abstract superclass, and every subclass actually brings along its own Reflow impl, so nsLeafFrame's own impl is just dead code. This patch makes sure it's really dead code by leaving in the Reflow() decl with " = 0;" so the compiler will enforce that all concrete subclasses *do* have a more specific override (and that they don't just inherit the stub nsFrame impl from further up the ancestor chain, for example). MozReview-Commit-ID: Co36IpuaeOc
layout/generic/nsLeafFrame.cpp
layout/generic/nsLeafFrame.h
--- a/layout/generic/nsLeafFrame.cpp
+++ b/layout/generic/nsLeafFrame.cpp
@@ -43,63 +43,16 @@ nsLeafFrame::ComputeAutoSize(gfxContext*
                              const LogicalSize&  aPadding,
                              ComputeSizeFlags    aFlags)
 {
   const WritingMode wm = GetWritingMode();
   LogicalSize result(wm, GetIntrinsicISize(), GetIntrinsicBSize());
   return result.ConvertTo(aWM, wm);
 }
 
-void
-nsLeafFrame::Reflow(nsPresContext* aPresContext,
-                    ReflowOutput& aMetrics,
-                    const ReflowInput& aReflowInput,
-                    nsReflowStatus& aStatus)
-{
-  MarkInReflow();
-  DO_GLOBAL_REFLOW_COUNT("nsLeafFrame");
-  NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
-                 ("enter nsLeafFrame::Reflow: aMaxSize=%d,%d",
-                  aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight()));
-
-  NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
-
-  DoReflow(aPresContext, aMetrics, aReflowInput, aStatus);
-
-  FinishAndStoreOverflow(&aMetrics, aReflowInput.mStyleDisplay);
-}
-
-void
-nsLeafFrame::DoReflow(nsPresContext* aPresContext,
-                      ReflowOutput& aMetrics,
-                      const ReflowInput& aReflowInput,
-                      nsReflowStatus& aStatus)
-{
-  NS_ASSERTION(aReflowInput.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
-               "Shouldn't have unconstrained stuff here "
-               "thanks to the rules of reflow");
-  NS_ASSERTION(NS_INTRINSICSIZE != aReflowInput.ComputedHeight(),
-               "Shouldn't have unconstrained stuff here "
-               "thanks to ComputeAutoSize");
-
-  // XXX how should border&padding effect baseline alignment?
-  // => descent = borderPadding.bottom for example
-  WritingMode wm = aReflowInput.GetWritingMode();
-  aMetrics.SetSize(wm, aReflowInput.ComputedSizeWithBorderPadding());
-
-  aStatus.Reset();
-
-  NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
-                 ("exit nsLeafFrame::DoReflow: size=%d,%d",
-                  aMetrics.ISize(wm), aMetrics.BSize(wm)));
-  NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aMetrics);
-
-  aMetrics.SetOverflowAreasToDesiredBounds();
-}
-
 nscoord
 nsLeafFrame::GetIntrinsicBSize()
 {
   NS_NOTREACHED("Someone didn't override Reflow or ComputeAutoSize");
   return 0;
 }
 
 void
--- a/layout/generic/nsLeafFrame.h
+++ b/layout/generic/nsLeafFrame.h
@@ -45,33 +45,22 @@ public:
                   const mozilla::LogicalSize& aCBSize,
                   nscoord                     aAvailableISize,
                   const mozilla::LogicalSize& aMargin,
                   const mozilla::LogicalSize& aBorder,
                   const mozilla::LogicalSize& aPadding,
                   ComputeSizeFlags            aFlags) override;
 
   /**
-   * Reflow our frame.  This will use the computed width plus borderpadding for
-   * the desired width, and use the return value of GetIntrinsicBSize plus
-   * borderpadding for the desired height.  Ascent will be set to the height,
-   * and descent will be set to 0.
+   * Each of our subclasses should provide its own Reflow impl:
    */
   virtual void Reflow(nsPresContext*      aPresContext,
-                      ReflowOutput& aDesiredSize,
-                      const ReflowInput& aReflowInput,
-                      nsReflowStatus&      aStatus) override;
-
-  /**
-   * This method does most of the work that Reflow() above need done.
-   */
-  virtual void DoReflow(nsPresContext*      aPresContext,
-                        ReflowOutput& aDesiredSize,
-                        const ReflowInput& aReflowInput,
-                        nsReflowStatus&      aStatus);
+                      ReflowOutput&       aDesiredSize,
+                      const ReflowInput&  aReflowInput,
+                      nsReflowStatus&     aStatus) override = 0;
 
   virtual bool IsFrameOfType(uint32_t aFlags) const override
   {
     // We don't actually contain a block, but we do always want a
     // computed width, so tell a little white lie here.
     return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplacedContainsBlock));
   }