Bug 775624 Part 24 - Implement operator<< for nsReflowStatus to use mozilla::ToString. r=dholbert
authorTing-Yu Lin <tlin@mozilla.com>
Tue, 14 Feb 2017 18:41:41 +0800
changeset 373415 3095d085ef20df5588f4ee649d14c8e8762f1a72
parent 373414 672ba79a78402d839579d9a71d865ec2d85cef0a
child 373416 7ee8f1e428c099f81e0d5e1b1f30778a948da070
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs775624
milestone54.0a1
Bug 775624 Part 24 - Implement operator<< for nsReflowStatus to use mozilla::ToString. r=dholbert To print log in nsBlockFrame, run "GECKO_BLOCK_DEBUG_FLAGS=reflow ./mach run". Here is a sample nsReflowStatus string: [Complete=Y,NIF=N,Truncated=N,Break=N,FirstLetter=Y]. MozReview-Commit-ID: 4voGcXfJlN7
layout/generic/nsBlockFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsIFrame.h
layout/generic/nsSubDocumentFrame.cpp
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -1468,18 +1468,18 @@ nsBlockFrame::Reflow(nsPresContext*     
   // our floats list, since a first-in-flow might get pushed to a later
   // continuation of its containing block.  But it's not permitted
   // outside that time.
   nsLayoutUtils::AssertNoDuplicateContinuations(this, mFloats);
 
   if (gNoisyReflow) {
     IndentBy(stdout, gNoiseIndent);
     ListTag(stdout);
-    printf(": status=%x (%scomplete) metrics=%d,%d carriedMargin=%d",
-           aStatus, aStatus.IsComplete() ? "" : "not ",
+    printf(": status=%s metrics=%d,%d carriedMargin=%d",
+           ToString(aStatus).c_str(),
            aMetrics.ISize(parentWM), aMetrics.BSize(parentWM),
            aMetrics.mCarriedOutBEndMargin.get());
     if (HasOverflowAreas()) {
       printf(" overflow-vis={%d,%d,%d,%d}",
              aMetrics.VisualOverflow().x,
              aMetrics.VisualOverflow().y,
              aMetrics.VisualOverflow().width,
              aMetrics.VisualOverflow().height);
@@ -2740,18 +2740,18 @@ nsBlockFrame::ReflowDirtyLines(BlockRefl
   }
 
 #ifdef DEBUG
   VerifyLines(true);
   VerifyOverflowSituation();
   if (gNoisyReflow) {
     IndentBy(stdout, gNoiseIndent - 1);
     ListTag(stdout);
-    printf(": done reflowing dirty lines (status=%x)\n",
-           aState.mReflowStatus);
+    printf(": done reflowing dirty lines (status=%s)\n",
+           ToString(aState.mReflowStatus).c_str());
   }
 #endif
 }
 
 void
 nsBlockFrame::MarkLineDirtyForInterrupt(nsLineBox* aLine)
 {
   aLine->MarkDirty();
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -204,16 +204,43 @@ nsReflowStatus::UpdateTruncated(const Re
   } else {
     mTruncated = false;
   }
 }
 
 // Formerly the nsIFrameDebug interface
 
 #ifdef DEBUG
+std::ostream& operator<<(std::ostream& aStream,
+                         const nsReflowStatus& aStatus)
+{
+  char complete = 'Y';
+  if (aStatus.IsIncomplete()) {
+    complete = 'N';
+  } else if (aStatus.IsOverflowIncomplete()) {
+    complete = 'O';
+  }
+
+  char brk = 'N';
+  if (aStatus.IsInlineBreakBefore()) {
+    brk = 'B';
+  } else if (aStatus.IsInlineBreakAfter()) {
+    brk = 'A';
+  }
+
+  aStream << "["
+          << "Complete=" << complete << ","
+          << "NIF=" << (aStatus.NextInFlowNeedsReflow() ? 'Y' : 'N') << ","
+          << "Truncated=" << (aStatus.IsTruncated() ? 'Y' : 'N') << ","
+          << "Break=" << brk << ","
+          << "FirstLetter=" << (aStatus.FirstLetterComplete() ? 'Y' : 'N')
+          << "]";
+  return aStream;
+}
+
 static bool gShowFrameBorders = false;
 
 void nsFrame::ShowFrameBorders(bool aEnable)
 {
   gShowFrameBorders = aEnable;
 }
 
 bool nsFrame::GetShowFrameBorders()
@@ -11227,17 +11254,17 @@ void nsFrame::DisplayReflowExit(nsPresCo
     char height[16];
     char x[16];
     char y[16];
     DR_state->PrettyUC(aMetrics.Width(), width, 16);
     DR_state->PrettyUC(aMetrics.Height(), height, 16);
     printf("Reflow d=%s,%s", width, height);
 
     if (!aStatus.IsFullyComplete()) {
-      printf(" status=0x%x", aStatus);
+      printf(" status=%s", ToString(aStatus).c_str());
     }
     if (aFrame->HasOverflowAreas()) {
       DR_state->PrettyUC(aMetrics.VisualOverflow().x, x, 16);
       DR_state->PrettyUC(aMetrics.VisualOverflow().y, y, 16);
       DR_state->PrettyUC(aMetrics.VisualOverflow().width, width, 16);
       DR_state->PrettyUC(aMetrics.VisualOverflow().height, height, 16);
       printf(" vis-o=(%s,%s) %s x %s", x, y, width, height);
 
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -338,16 +338,22 @@ private:
   bool mInlineBreak : 1;
   bool mInlineBreakAfter : 1;
   bool mFirstLetterComplete : 1;
 };
 
 #define NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aMetrics) \
   aStatus.UpdateTruncated(aReflowInput, aMetrics);
 
+#ifdef DEBUG
+// Convert nsReflowStatus to a human-readable string.
+std::ostream&
+operator<<(std::ostream& aStream, const nsReflowStatus& aStatus);
+#endif
+
 //----------------------------------------------------------------------
 
 /**
  * DidReflow status values.
  */
 enum class nsDidReflowStatus : uint32_t {
   NOT_FINISHED,
   FINISHED
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -800,18 +800,18 @@ nsSubDocumentFrame::Reflow(nsPresContext
   FinishAndStoreOverflow(&aDesiredSize);
 
   if (!aPresContext->IsPaginated() && !mPostedReflowCallback) {
     PresContext()->PresShell()->PostReflowCallback(this);
     mPostedReflowCallback = true;
   }
 
   NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
-     ("exit nsSubDocumentFrame::Reflow: size=%d,%d status=%x",
-      aDesiredSize.Width(), aDesiredSize.Height(), aStatus));
+     ("exit nsSubDocumentFrame::Reflow: size=%d,%d status=%s",
+      aDesiredSize.Width(), aDesiredSize.Height(), ToString(aStatus).c_str()));
 
   NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
 }
 
 bool
 nsSubDocumentFrame::ReflowFinished()
 {
   if (mFrameLoader) {