Bug 1298844 - Add PrintDisplayItemToStdout and PrintDisplayListToStdout helper functions for debugging. r?jrmuizel draft
authorMarkus Stange <mstange@themasta.com>
Mon, 22 Aug 2016 15:49:09 -0400
changeset 406795 afb35c4a73c4e92281dbc6bf33df452cdc52d1ad
parent 404063 3345f0e8ed3bd33d8af6e2b9bf1fd8bf397a45bc
child 529749 4235906f848b9e652660513c2ed7037323eaac21
push id27830
push usermstange@themasta.com
push dateMon, 29 Aug 2016 15:51:33 +0000
reviewersjrmuizel
bugs1298844
milestone51.0a1
Bug 1298844 - Add PrintDisplayItemToStdout and PrintDisplayListToStdout helper functions for debugging. r?jrmuizel MozReview-Commit-ID: 3Uv0H9z2aLk
layout/base/nsLayoutDebugger.cpp
--- a/layout/base/nsLayoutDebugger.cpp
+++ b/layout/base/nsLayoutDebugger.cpp
@@ -12,16 +12,17 @@
 
 #include "nsAttrValue.h"
 #include "nsFrame.h"
 #include "nsDisplayList.h"
 #include "FrameLayerBuilder.h"
 #include "nsPrintfCString.h"
 #include "DisplayItemScrollClip.h"
 
+#include <iostream>
 #include <stdio.h>
 
 using namespace mozilla;
 using namespace mozilla::layers;
 
 #ifdef DEBUG
 class nsLayoutDebugger : public nsILayoutDebugger {
 public:
@@ -243,16 +244,35 @@ void
 nsFrame::PrintDisplayList(nsDisplayListBuilder* aBuilder,
                           const nsDisplayList& aList,
                           std::stringstream& aStream,
                           bool aDumpHtml)
 {
   PrintDisplayListTo(aBuilder, aList, aStream, 0, aDumpHtml);
 }
 
+/**
+ * The two functions below are intended to be called from a debugger.
+ */
+void
+PrintDisplayItemToStdout(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem)
+{
+  std::stringstream stream;
+  PrintDisplayItemTo(aBuilder, aItem, stream, 0, true, false);
+  std::cout << stream.str() << std::endl;
+}
+
+void
+PrintDisplayListToStdout(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList)
+{
+  std::stringstream stream;
+  PrintDisplayListTo(aBuilder, aList, stream, 0, false);
+  std::cout << stream.str() << std::endl;
+}
+
 #ifdef MOZ_DUMP_PAINTING
 static void
 PrintDisplayListSetItem(nsDisplayListBuilder* aBuilder,
                         const char* aItemName,
                         const nsDisplayList& aList,
                         std::stringstream& aStream,
                         bool aDumpHtml)
 {