Bug 1596339 Part 2 - Implement operator<< for LogicalRect, and use it in frame tree dump. r=dholbert
authorTing-Yu Lin <tlin@mozilla.com>
Fri, 15 Nov 2019 03:51:56 +0000
changeset 502116 583f09d7e18124985da8eafd546b719f885ae898
parent 502115 591e273e2d9e111a9901b2639a593033130d7a10
child 502117 2b8b36ac14d520ad148a364ea4c4959180890e9f
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1596339
milestone72.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 1596339 Part 2 - Implement operator<< for LogicalRect, and use it in frame tree dump. r=dholbert This change uses parentheses, i.e. '(' and ')', to enclose the dimension of LogicalRect. This match the output of BaseRect's operator<<. Note: This introduces inconsistency in the frame tree dump because some of the output format still use braces to enclose the data. But in later patches, I'll gradually change the format to use parentheses. Differential Revision: https://phabricator.services.mozilla.com/D52963
layout/generic/WritingModes.h
layout/generic/nsFrame.cpp
layout/generic/nsLineBox.cpp
--- a/layout/generic/WritingModes.h
+++ b/layout/generic/WritingModes.h
@@ -1820,16 +1820,22 @@ class LogicalRect {
     }
 
     MOZ_ASSERT(
         (rectDebug.IsEmpty() && (mISize == 0 || mBSize == 0)) ||
         rectDebug.IsEqualEdges(nsRect(mIStart, mBStart, mISize, mBSize)));
     return mISize > 0 && mBSize > 0;
   }
 
+  friend std::ostream& operator<<(std::ostream& aStream,
+                                  const LogicalRect& aRect) {
+    return aStream << '(' << aRect.IStart() << ',' << aRect.BStart() << ','
+                   << aRect.ISize() << ',' << aRect.BSize() << ')';
+  }
+
  private:
   LogicalRect() = delete;
 
 #ifdef DEBUG
   WritingMode GetWritingMode() const { return mWritingMode; }
 #else
   WritingMode GetWritingMode() const { return WritingMode::Unknown(); }
 #endif
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -7852,20 +7852,19 @@ void nsIFrame::ListGeneric(nsACString& a
   }
 
   nsIFrame* parent = GetParent();
   if (parent) {
     WritingMode pWM = parent->GetWritingMode();
     if (pWM.IsVertical() || pWM.IsBidiRTL()) {
       nsSize containerSize = parent->mRect.Size();
       LogicalRect lr(pWM, mRect, containerSize);
-      aTo += nsPrintfCString(
-          " parent-wm=%s cs={%d,%d} logical-rect={%d,%d,%d,%d}",
-          ToString(pWM).c_str(), containerSize.width, containerSize.height,
-          lr.IStart(pWM), lr.BStart(pWM), lr.ISize(pWM), lr.BSize(pWM));
+      aTo += nsPrintfCString(" parent-wm=%s cs={%d,%d} logical-rect=%s",
+                             ToString(pWM).c_str(), containerSize.width,
+                             containerSize.height, ToString(lr).c_str());
     }
   }
   nsIFrame* f = const_cast<nsIFrame*>(this);
   if (f->HasOverflowAreas()) {
     nsRect vo = f->GetVisualOverflowRect();
     if (!vo.IsEqualEdges(mRect)) {
       aTo += nsPrintfCString(" vis-overflow={%d,%d,%d,%d}", vo.x, vo.y,
                              vo.width, vo.height);
--- a/layout/generic/nsLineBox.cpp
+++ b/layout/generic/nsLineBox.cpp
@@ -240,20 +240,19 @@ void nsLineBox::List(FILE* out, const ch
                          StateToString(cbuf, sizeof(cbuf)));
   if (IsBlock() && !GetCarriedOutBEndMargin().IsZero()) {
     str += nsPrintfCString("bm=%d ", GetCarriedOutBEndMargin().get());
   }
   nsRect bounds = GetPhysicalBounds();
   str += nsPrintfCString("{%d,%d,%d,%d} ", bounds.x, bounds.y, bounds.width,
                          bounds.height);
   if (mWritingMode.IsVertical() || mWritingMode.IsBidiRTL()) {
-    str += nsPrintfCString("wm=%s cs={%d,%d} logical-rect={%d,%d,%d,%d} ",
+    str += nsPrintfCString("wm=%s cs={%d,%d} logical-rect=%s ",
                            ToString(mWritingMode).c_str(), mContainerSize.width,
-                           mContainerSize.height, IStart(), BStart(), ISize(),
-                           BSize());
+                           mContainerSize.height, ToString(mBounds).c_str());
   }
   if (mData &&
       (!mData->mOverflowAreas.VisualOverflow().IsEqualEdges(bounds) ||
        !mData->mOverflowAreas.ScrollableOverflow().IsEqualEdges(bounds))) {
     str += nsPrintfCString("vis-overflow=%d,%d,%d,%d scr-overflow=%d,%d,%d,%d ",
                            mData->mOverflowAreas.VisualOverflow().x,
                            mData->mOverflowAreas.VisualOverflow().y,
                            mData->mOverflowAreas.VisualOverflow().width,