Bug 1298844 - Add PrintDisplayItemToStdout and PrintDisplayListToStdout helper functions for debugging. r?jrmuizel
MozReview-Commit-ID: 3Uv0H9z2aLk
--- 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)
{