Bug 775624 Part 10a - Move ReflowInput::SetTruncated() into nsReflowStatus. r?dholbert draft
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 20 Feb 2017 14:58:58 +0800
changeset 488472 dcf513cd9191031d45f34ee3d954bb99fe56e3c9
parent 488471 b1d5025e699132ff9839b7d305be43abe03ec25b
child 488473 7d289785024ce47eec3d4ba14b5f86373fc527e5
push id46538
push userbmo:tlin@mozilla.com
push dateThu, 23 Feb 2017 05:39:06 +0000
reviewersdholbert
bugs775624
milestone54.0a1
Bug 775624 Part 10a - Move ReflowInput::SetTruncated() into nsReflowStatus. r?dholbert Per bug 775624 comment 95, the method modifies only nsReflowStatus, and is lived in ReflowInput only because nsReflowStatus was an uint32_t. So it's better to move it into nsReflowStatus. MozReview-Commit-ID: DSY2u9az67A
layout/generic/ReflowInput.cpp
layout/generic/nsFrame.cpp
layout/generic/nsIFrame.h
--- a/layout/generic/ReflowInput.cpp
+++ b/layout/generic/ReflowInput.cpp
@@ -3036,34 +3036,16 @@ ReflowInput::ComputeMinMaxValues(const L
 
   // If the computed value of 'min-height' is greater than the value of
   // 'max-height', 'max-height' is set to the value of 'min-height'
   if (ComputedMinBSize() > ComputedMaxBSize()) {
     ComputedMaxBSize() = ComputedMinBSize();
   }
 }
 
-void
-ReflowInput::SetTruncated(const ReflowOutput& aMetrics,
-                                nsReflowStatus* aStatus) const
-{
-  const WritingMode containerWM = aMetrics.GetWritingMode();
-  if (GetWritingMode().IsOrthogonalTo(containerWM)) {
-    // Orthogonal flows are always reflowed with an unconstrained dimension,
-    // so should never end up truncated (see ReflowInput::Init()).
-    *aStatus &= ~NS_FRAME_TRUNCATED;
-  } else if (AvailableBSize() != NS_UNCONSTRAINEDSIZE &&
-             AvailableBSize() < aMetrics.BSize(containerWM) &&
-             !mFlags.mIsTopOfPage) {
-    *aStatus |= NS_FRAME_TRUNCATED;
-  } else {
-    *aStatus &= ~NS_FRAME_TRUNCATED;
-  }
-}
-
 bool
 ReflowInput::IsFloating() const
 {
   return mStyleDisplay->IsFloating(mFrame);
 }
 
 mozilla::StyleDisplay
 ReflowInput::GetDisplay() const
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -183,16 +183,34 @@ InitBoxMetrics(nsIFrame* aFrame, bool aC
 static bool
 IsXULBoxWrapped(const nsIFrame* aFrame)
 {
   return aFrame->GetParent() &&
          aFrame->GetParent()->IsXULBoxFrame() &&
          !aFrame->IsXULBoxFrame();
 }
 
+void
+nsReflowStatus::UpdateTruncated(const ReflowInput& aReflowInput,
+                                const ReflowOutput& aMetrics)
+{
+  const WritingMode containerWM = aMetrics.GetWritingMode();
+  if (aReflowInput.GetWritingMode().IsOrthogonalTo(containerWM)) {
+    // Orthogonal flows are always reflowed with an unconstrained dimension,
+    // so should never end up truncated (see ReflowInput::Init()).
+    mStatus &= ~NS_FRAME_TRUNCATED;
+  } else if (aReflowInput.AvailableBSize() != NS_UNCONSTRAINEDSIZE &&
+             aReflowInput.AvailableBSize() < aMetrics.BSize(containerWM) &&
+             !aReflowInput.mFlags.mIsTopOfPage) {
+    mStatus |= NS_FRAME_TRUNCATED;
+  } else {
+    mStatus &= ~NS_FRAME_TRUNCATED;
+  }
+}
+
 // Formerly the nsIFrameDebug interface
 
 #ifdef DEBUG
 static bool gShowFrameBorders = false;
 
 void nsFrame::ShowFrameBorders(bool aEnable)
 {
   gShowFrameBorders = aEnable;
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -281,16 +281,19 @@ public:
 
   // mNextInFlowNeedsReflow bit flag means that the next-in-flow is dirty,
   // and also needs to be reflowed. This status only makes sense for a frame
   // that is not complete, i.e. you wouldn't set mNextInFlowNeedsReflow when
   // IsComplete() is true.
   bool NextInFlowNeedsReflow() const { return mNextInFlowNeedsReflow; }
   void SetNextInFlowNeedsReflow() { mNextInFlowNeedsReflow = true; }
 
+  void UpdateTruncated(const mozilla::ReflowInput& aReflowInput,
+                       const mozilla::ReflowOutput& aMetrics);
+
 private:
   uint32_t mStatus;
 
   // Frame completion status bit flags.
   bool mIncomplete : 1;
   bool mOverflowIncomplete : 1;
   bool mNextInFlowNeedsReflow : 1;
 };
@@ -352,18 +355,18 @@ private:
 // A frame is "truncated" if the part of the frame before the first
 // possible break point was unable to fit in the available vertical
 // space.  Therefore, the entire frame should be moved to the next page.
 // A frame that begins at the top of the page must never be "truncated".
 // Doing so would likely cause an infinite loop.
 #define NS_FRAME_TRUNCATED  0x0010
 #define NS_FRAME_IS_TRUNCATED(status) \
   (0 != ((status) & NS_FRAME_TRUNCATED))
-#define NS_FRAME_SET_TRUNCATION(status, aReflowInput, aMetrics) \
-  aReflowInput.SetTruncated(aMetrics, &status);
+#define NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aMetrics) \
+  aStatus.UpdateTruncated(aReflowInput, aMetrics);
 
 // Merge the incompleteness, truncation and NS_FRAME_REFLOW_NEXTINFLOW
 // status from aSecondary into aPrimary.
 void NS_MergeReflowStatusInto(nsReflowStatus* aPrimary,
                               nsReflowStatus aSecondary);
 
 //----------------------------------------------------------------------