Bug 1444920, remove the debug='true' flag from xul elements and the corresponding debug frame flags, r=dholbert
authorNeil Deakin <neil@mozilla.com>
Wed, 02 May 2018 10:32:54 -0400
changeset 416714 3ab2fbb175bd7fa720d4e990dbaaa0a5fe0c32a9
parent 416713 ef231f04c4ec6710dfb179a93cd526e019fc09a6
child 416715 76855675e353231dd10ec0a1f8ca7c1211b281f1
push id33933
push userrgurzau@mozilla.com
push dateWed, 02 May 2018 21:05:42 +0000
treeherdermozilla-central@2d83e1843241 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1444920
milestone61.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 1444920, remove the debug='true' flag from xul elements and the corresponding debug frame flags, r=dholbert
layout/generic/nsFrame.cpp
layout/generic/nsFrame.h
layout/generic/nsFrameStateBits.h
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsIFrame.h
layout/xul/nsBox.cpp
layout/xul/nsBox.h
layout/xul/nsBoxFrame.cpp
layout/xul/nsBoxFrame.h
layout/xul/nsLeafBoxFrame.cpp
layout/xul/nsLeafBoxFrame.h
layout/xul/nsMenuFrame.cpp
layout/xul/nsMenuFrame.h
layout/xul/nsSliderFrame.cpp
layout/xul/nsSprocketLayout.cpp
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -11501,23 +11501,16 @@ nsAdaptorPrintReason(ReflowInput& aReflo
           reflowReasonString = "unknown";
           break;
     }
 
     printf("%s",reflowReasonString);
 }
 
 #endif
-#ifdef DEBUG_LAYOUT
-void
-nsFrame::GetBoxName(nsAutoString& aName)
-{
-  GetFrameName(aName);
-}
-#endif
 
 #ifdef DEBUG
 static void
 GetTagName(nsFrame* aFrame, nsIContent* aContent, int aResultSize,
            char* aResult)
 {
   if (aContent) {
     snprintf(aResult, aResultSize, "%s@%p",
--- a/layout/generic/nsFrame.h
+++ b/layout/generic/nsFrame.h
@@ -674,20 +674,16 @@ protected:
                                       int32_t* aContentOffset,
                                       int32_t* aTarget);
 
   // Fills aCursor with the appropriate information from ui
   static void FillCursorInformationFromStyle(const nsStyleUserInterface* ui,
                                              nsIFrame::Cursor& aCursor);
   NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState) override;
 
-#ifdef DEBUG_LAYOUT
-  void GetBoxName(nsAutoString& aName) override;
-#endif
-
   nsBoxLayoutMetrics* BoxMetrics() const;
 
   // Fire DOM event. If no aContent argument use frame's mContent.
   void FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent = nullptr);
 
 private:
   void BoxReflow(nsBoxLayoutState& aState,
                  nsPresContext*    aPresContext,
--- a/layout/generic/nsFrameStateBits.h
+++ b/layout/generic/nsFrameStateBits.h
@@ -294,19 +294,17 @@ FRAME_STATE_BIT(Generic, 59, NS_FRAME_IS
 
 FRAME_STATE_GROUP(Box, nsBoxFrame)
 
 FRAME_STATE_BIT(Box, 20, NS_STATE_BOX_CHILD_RESERVED)
 FRAME_STATE_BIT(Box, 21, NS_STATE_STACK_NOT_POSITIONED)
 FRAME_STATE_BIT(Box, 22, NS_STATE_IS_HORIZONTAL)
 FRAME_STATE_BIT(Box, 23, NS_STATE_AUTO_STRETCH)
 FRAME_STATE_BIT(Box, 24, NS_STATE_IS_ROOT)
-FRAME_STATE_BIT(Box, 25, NS_STATE_CURRENTLY_IN_DEBUG)
-FRAME_STATE_BIT(Box, 26, NS_STATE_SET_TO_DEBUG)
-FRAME_STATE_BIT(Box, 27, NS_STATE_DEBUG_WAS_SET)
+/* Bits 25, 26, and 27 were used for xul debug flags but are now unused */
 FRAME_STATE_BIT(Box, 28, NS_STATE_MENU_HAS_POPUP_LIST)
 FRAME_STATE_BIT(Box, 29, NS_STATE_BOX_WRAPS_KIDS_IN_BLOCK)
 FRAME_STATE_BIT(Box, 30, NS_STATE_EQUAL_SIZE)
 FRAME_STATE_BIT(Box, 31, NS_STATE_IS_DIRECTION_NORMAL)
 FRAME_STATE_BIT(Box, 60, NS_FRAME_MOUSE_THROUGH_ALWAYS)
 FRAME_STATE_BIT(Box, 61, NS_FRAME_MOUSE_THROUGH_NEVER)
 
 
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -1568,20 +1568,16 @@ nsXULScrollFrame::GetXULBoxAscent(nsBoxL
   ascent += m.top;
 
   return ascent;
 }
 
 nsSize
 nsXULScrollFrame::GetXULPrefSize(nsBoxLayoutState& aState)
 {
-#ifdef DEBUG_LAYOUT
-  PropagateDebug(aState);
-#endif
-
   nsSize pref = mHelper.mScrolledFrame->GetXULPrefSize(aState);
 
   ScrollbarStyles styles = GetScrollbarStyles();
 
   // scrolled frames don't have their own margins
 
   if (mHelper.mVScrollbarBox &&
       styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
@@ -1601,20 +1597,16 @@ nsXULScrollFrame::GetXULPrefSize(nsBoxLa
   bool widthSet, heightSet;
   nsIFrame::AddXULPrefSize(this, pref, widthSet, heightSet);
   return pref;
 }
 
 nsSize
 nsXULScrollFrame::GetXULMinSize(nsBoxLayoutState& aState)
 {
-#ifdef DEBUG_LAYOUT
-  PropagateDebug(aState);
-#endif
-
   nsSize min = mHelper.mScrolledFrame->GetXULMinSizeForScrollArea(aState);
 
   ScrollbarStyles styles = GetScrollbarStyles();
 
   if (mHelper.mVScrollbarBox &&
       styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
      nsSize vSize = mHelper.mVScrollbarBox->GetXULMinSize(aState);
      AddMargin(mHelper.mVScrollbarBox, vSize);
@@ -1636,20 +1628,16 @@ nsXULScrollFrame::GetXULMinSize(nsBoxLay
   bool widthSet, heightSet;
   nsIFrame::AddXULMinSize(aState, this, min, widthSet, heightSet);
   return min;
 }
 
 nsSize
 nsXULScrollFrame::GetXULMaxSize(nsBoxLayoutState& aState)
 {
-#ifdef DEBUG_LAYOUT
-  PropagateDebug(aState);
-#endif
-
   nsSize maxSize(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
 
   AddBorderAndPadding(maxSize);
   bool widthSet, heightSet;
   nsIFrame::AddXULMaxSize(this, maxSize, widthSet, heightSet);
   return maxSize;
 }
 
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -3740,23 +3740,16 @@ public:
   virtual Halignment GetXULHAlign() const = 0;
 
   bool IsXULHorizontal() const { return (mState & NS_STATE_IS_HORIZONTAL) != 0; }
   bool IsXULNormalDirection() const { return (mState & NS_STATE_IS_DIRECTION_NORMAL) != 0; }
 
   nsresult XULRedraw(nsBoxLayoutState& aState);
   virtual nsresult XULRelayoutChildAtOrdinal(nsIFrame* aChild)=0;
 
-#ifdef DEBUG_LAYOUT
-  virtual nsresult SetXULDebug(nsBoxLayoutState& aState, bool aDebug)=0;
-  virtual nsresult GetXULDebug(bool& aDebug)=0;
-
-  virtual nsresult XULDumpBox(FILE* out)=0;
-#endif
-
   static bool AddXULPrefSize(nsIFrame* aBox, nsSize& aSize, bool& aWidth, bool& aHeightSet);
   static bool AddXULMinSize(nsBoxLayoutState& aState, nsIFrame* aBox,
                             nsSize& aSize, bool& aWidth, bool& aHeightSet);
   static bool AddXULMaxSize(nsIFrame* aBox, nsSize& aSize, bool& aWidth, bool& aHeightSet);
   static bool AddXULFlex(nsIFrame* aBox, nscoord& aFlex);
 
   // END OF BOX LAYOUT METHODS
   // The above methods have been migrated from nsIBox and are in the process of
--- a/layout/xul/nsBox.cpp
+++ b/layout/xul/nsBox.cpp
@@ -20,118 +20,19 @@
 #include "nsBoxLayout.h"
 #include "FrameLayerBuilder.h"
 #include "mozilla/dom/Attr.h"
 #include "mozilla/dom/Element.h"
 #include <algorithm>
 
 using namespace mozilla;
 
-#ifdef DEBUG_LAYOUT
-int32_t gIndent = 0;
-#endif
-
-#ifdef DEBUG_LAYOUT
-void
-nsBoxAddIndents()
-{
-    for(int32_t i=0; i < gIndent; i++)
-    {
-        printf(" ");
-    }
-}
-#endif
-
-#ifdef DEBUG_LAYOUT
-void
-nsBox::AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult)
-{
-   aResult.Append(aAttribute);
-   aResult.AppendLiteral("='");
-   aResult.Append(aValue);
-   aResult.AppendLiteral("' ");
-}
-
-void
-nsBox::ListBox(nsAutoString& aResult)
-{
-    nsAutoString name;
-    GetBoxName(name);
-
-    char addr[100];
-    sprintf(addr, "[@%p] ", static_cast<void*>(this));
-
-    aResult.AppendASCII(addr);
-    aResult.Append(name);
-    aResult.Append(' ');
-
-    nsIContent* content = GetContent();
-
-    // add on all the set attributes
-    if (content && content->IsElement()) {
-      RefPtr<nsDOMAttributeMap> namedMap = content->AsElement()->Attributes();
-
-      uint32_t length = namedMap->Length();
-
-      RefPtr<dom::Attr> attribute;
-      for (uint32_t i = 0; i < length; ++i)
-      {
-        attribute = namedMap->Item(i);
-        attribute->GetName(name);
-        nsAutoString value;
-        attribute->GetValue(value);
-        AppendAttribute(name, value, aResult);
-      }
-    }
-}
-
-nsresult
-nsBox::XULDumpBox(FILE* aFile)
-{
-  nsAutoString s;
-  ListBox(s);
-  fprintf(aFile, "%s", NS_LossyConvertUTF16toASCII(s).get());
-  return NS_OK;
-}
-
-void
-nsBox::PropagateDebug(nsBoxLayoutState& aState)
-{
-  // propagate debug information
-  if (mState & NS_STATE_DEBUG_WAS_SET) {
-    if (mState & NS_STATE_SET_TO_DEBUG)
-      SetXULDebug(aState, true);
-    else
-      SetXULDebug(aState, false);
-  } else if (mState & NS_STATE_IS_ROOT) {
-    SetXULDebug(aState, gDebug);
-  }
-}
-#endif
-
-#ifdef DEBUG_LAYOUT
-void
-nsBox::GetBoxName(nsAutoString& aName)
-{
-  aName.AssignLiteral("Box");
-}
-#endif
-
 nsresult
 nsBox::BeginXULLayout(nsBoxLayoutState& aState)
 {
-#ifdef DEBUG_LAYOUT
-
-  nsBoxAddIndents();
-  printf("XULLayout: ");
-  XULDumpBox(stdout);
-  printf("\n");
-  gIndent++;
-#endif
-
   // mark ourselves as dirty so no child under us
   // can post an incremental layout.
   // XXXldb Is this still needed?
   AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
 
   if (GetStateBits() & NS_FRAME_IS_DIRTY)
   {
     // If the parent is dirty, all the children are dirty (ReflowInput
@@ -142,49 +43,38 @@ nsBox::BeginXULLayout(nsBoxLayoutState& 
   }
 
   // Another copy-over from ReflowInput.
   // Since we are in reflow, we don't need to store these properties anymore.
   DeleteProperty(UsedBorderProperty());
   DeleteProperty(UsedPaddingProperty());
   DeleteProperty(UsedMarginProperty());
 
-#ifdef DEBUG_LAYOUT
-  PropagateDebug(aState);
-#endif
-
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBox::DoXULLayout(nsBoxLayoutState& aState)
 {
   return NS_OK;
 }
 
 nsresult
 nsBox::EndXULLayout(nsBoxLayoutState& aState)
 {
-
-  #ifdef DEBUG_LAYOUT
-      --gIndent;
-  #endif
-
   return SyncLayout(aState);
 }
 
 bool nsBox::gGotTheme = false;
 nsITheme* nsBox::gTheme = nullptr;
 
 nsBox::nsBox(ClassID aID)
   : nsIFrame(aID)
 {
   MOZ_COUNT_CTOR(nsBox);
-  //mX = 0;
-  //mY = 0;
   if (!gGotTheme) {
     gGotTheme = true;
     CallGetService("@mozilla.org/chrome/chrome-native-theme;1", &gTheme);
   }
 }
 
 nsBox::~nsBox()
 {
@@ -218,26 +108,22 @@ nsIFrame::GetXULClientRect(nsRect& aClie
   aClientRect.Deflate(borderPadding);
 
   if (aClientRect.width < 0)
      aClientRect.width = 0;
 
   if (aClientRect.height < 0)
      aClientRect.height = 0;
 
- // NS_ASSERTION(aClientRect.width >=0 && aClientRect.height >= 0, "Content Size < 0");
-
   return NS_OK;
 }
 
 void
 nsBox::SetXULBounds(nsBoxLayoutState& aState, const nsRect& aRect, bool aRemoveOverflowAreas)
 {
-    NS_BOX_ASSERTION(this, aRect.width >=0 && aRect.height >= 0, "SetXULBounds Size < 0");
-
     nsRect rect(mRect);
 
     uint32_t flags = GetXULLayoutFlags();
 
     uint32_t stateFlags = aState.LayoutFlags();
 
     flags |= stateFlags;
 
@@ -254,29 +140,16 @@ nsBox::SetXULBounds(nsBoxLayoutState& aS
     }
 
     if (!(flags & NS_FRAME_NO_MOVE_VIEW))
     {
       nsContainerFrame::PositionFrameView(this);
       if ((rect.x != aRect.x) || (rect.y != aRect.y))
         nsContainerFrame::PositionChildViews(this);
     }
-
-
-   /*
-    // only if the origin changed
-    if ((rect.x != aRect.x) || (rect.y != aRect.y))  {
-      if (frame->HasView()) {
-        nsContainerFrame::PositionFrameView(presContext, frame,
-                                            frame->GetView());
-      } else {
-        nsContainerFrame::PositionChildViews(presContext, frame);
-      }
-    }
-    */
 }
 
 nsresult
 nsIFrame::GetXULBorderAndPadding(nsMargin& aBorderAndPadding)
 {
   aBorderAndPadding.SizeTo(0, 0, 0, 0);
   nsresult rv = GetXULBorder(aBorderAndPadding);
   if (NS_FAILED(rv))
@@ -928,53 +801,8 @@ nsBox::GetNextXULBox(const nsIFrame* aFr
 
 /*static*/ nsIFrame*
 nsBox::GetParentXULBox(const nsIFrame* aFrame)
 {
   return aFrame->GetParent() &&
     aFrame->GetParent()->IsXULBoxFrame() ? aFrame->GetParent() : nullptr;
 }
 
-#ifdef DEBUG_LAYOUT
-nsresult
-nsBox::SetXULDebug(nsBoxLayoutState& aState, bool aDebug)
-{
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsBox::GetDebugBoxAt( const nsPoint& aPoint,
-                      nsIFrame**     aBox)
-{
-  nsRect thisRect(nsPoint(0,0), GetSize());
-  if (!thisRect.Contains(aPoint))
-    return NS_ERROR_FAILURE;
-
-  nsIFrame* child = nsBox::GetChildXULBox(this);
-  nsIFrame* hit = nullptr;
-
-  *aBox = nullptr;
-  while (nullptr != child) {
-    nsresult rv = child->GetDebugBoxAt(aPoint - child->GetOffsetTo(this), &hit);
-
-    if (NS_SUCCEEDED(rv) && hit) {
-      *aBox = hit;
-    }
-    child = GetNextXULBox(child);
-  }
-
-  // found a child
-  if (*aBox) {
-    return NS_OK;
-  }
-
-  return NS_ERROR_FAILURE;
-}
-
-
-nsresult
-nsBox::GetXULDebug(bool& aDebug)
-{
-  aDebug = false;
-  return NS_OK;
-}
-
-#endif
--- a/layout/xul/nsBox.h
+++ b/layout/xul/nsBox.h
@@ -37,31 +37,21 @@ public:
   virtual nsresult GetXULPadding(nsMargin& aBorderAndPadding) override;
   virtual nsresult GetXULMargin(nsMargin& aMargin) override;
 
   virtual Valignment GetXULVAlign() const override { return vAlign_Top; }
   virtual Halignment GetXULHAlign() const override { return hAlign_Left; }
 
   virtual nsresult XULRelayoutChildAtOrdinal(nsIFrame* aChild) override;
 
-#ifdef DEBUG_LAYOUT
-  NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIFrame** aBox) override;
-  virtual nsresult GetXULDebug(bool& aDebug) override;
-  virtual nsresult SetXULDebug(nsBoxLayoutState& aState, bool aDebug) override;
-
-  virtual nsresult XULDumpBox(FILE* out) override;
-  void PropagateDebug(nsBoxLayoutState& aState);
-#endif
-
   nsBox(ClassID aID);
   virtual ~nsBox();
 
   /**
-   * Returns true if this box clips its children, e.g., if this box is an sc
-rollbox.
+   * Returns true if this box clips its children, e.g., if this box is an scrollbox.
   */
   virtual bool DoesClipChildren();
   virtual bool ComputesOwnOverflowArea() = 0;
 
   nsresult SyncLayout(nsBoxLayoutState& aBoxLayoutState);
 
   bool DoesNeedRecalc(const nsSize& aSize);
   bool DoesNeedRecalc(nscoord aCoord);
@@ -79,50 +69,24 @@ rollbox.
   static nscoord BoundsCheck(nscoord aMinSize, nscoord aPrefSize, nscoord aMaxSize);
 
   static nsIFrame* GetChildXULBox(const nsIFrame* aFrame);
   static nsIFrame* GetNextXULBox(const nsIFrame* aFrame);
   static nsIFrame* GetParentXULBox(const nsIFrame* aFrame);
 
 protected:
 
-#ifdef DEBUG_LAYOUT
-  virtual void AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult);
-
-  virtual void ListBox(nsAutoString& aResult);
-#endif
-
   nsresult BeginXULLayout(nsBoxLayoutState& aState);
   NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState);
   nsresult EndXULLayout(nsBoxLayoutState& aState);
 
-#ifdef DEBUG_LAYOUT
-  virtual void GetBoxName(nsAutoString& aName);
-  void PropagateDebug(nsBoxLayoutState& aState);
-#endif
-
   static bool gGotTheme;
   static nsITheme* gTheme;
 
   enum eMouseThrough {
     unset,
     never,
     always
   };
-
-private:
-
-  //nscoord mX;
-  //nscoord mY;
 };
 
-#ifdef DEBUG_LAYOUT
-#define NS_BOX_ASSERTION(box,expr,str) \
-  if (!(expr)) { \
-       box->XULDumpBox(stdout); \
-       NS_DebugBreak(NSDebugAssertion, str, #expr, __FILE__, __LINE__); \
-  }
-#else
-#define NS_BOX_ASSERTION(box,expr,str) {}
-#endif
-
 #endif
 
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -71,33 +71,16 @@
 #include "nsIURI.h"
 
 #include "mozilla/TouchEvents.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
-//define DEBUG_REDRAW
-
-#define DEBUG_SPRING_SIZE 8
-#define DEBUG_BORDER_SIZE 2
-#define COIL_SIZE 8
-
-//#define TEST_SANITY
-
-#ifdef DEBUG_rods
-//#define DO_NOISY_REFLOW
-#endif
-
-#ifdef DEBUG_LAYOUT
-bool nsBoxFrame::gDebug = false;
-nsIFrame* nsBoxFrame::mDebugChild = nullptr;
-#endif
-
 nsIFrame*
 NS_NewBoxFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle, bool aIsRoot, nsBoxLayout* aLayoutManager)
 {
   return new (aPresShell) nsBoxFrame(aStyle, nsBoxFrame::kClassID,
                                      aIsRoot, aLayoutManager);
 }
 
 nsIFrame*
@@ -181,23 +164,16 @@ nsBoxFrame::Init(nsIContent*       aCont
   if (GetStateBits() & NS_FRAME_FONT_INFLATION_CONTAINER) {
     AddStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT);
   }
 
   MarkIntrinsicISizesDirty();
 
   CacheAttributes();
 
-#ifdef DEBUG_LAYOUT
-    // if we are root and this
-  if (mState & NS_STATE_IS_ROOT) {
-    GetDebugPref();
-  }
-#endif
-
   UpdateMouseThrough();
 
   // register access key
   RegUnregAccessKey(true);
 }
 
 void nsBoxFrame::UpdateMouseThrough()
 {
@@ -252,53 +228,18 @@ nsBoxFrame::CacheAttributes()
         RemoveStateBits(NS_STATE_EQUAL_SIZE);
 
   bool autostretch = !!(mState & NS_STATE_AUTO_STRETCH);
   GetInitialAutoStretch(autostretch);
   if (autostretch)
         AddStateBits(NS_STATE_AUTO_STRETCH);
      else
         RemoveStateBits(NS_STATE_AUTO_STRETCH);
-
-
-#ifdef DEBUG_LAYOUT
-  bool debug = mState & NS_STATE_SET_TO_DEBUG;
-  bool debugSet = GetInitialDebug(debug);
-  if (debugSet) {
-        AddStateBits(NS_STATE_DEBUG_WAS_SET);
-        if (debug)
-            AddStateBits(NS_STATE_SET_TO_DEBUG);
-        else
-            RemoveStateBits(NS_STATE_SET_TO_DEBUG);
-  } else {
-        RemoveStateBits(NS_STATE_DEBUG_WAS_SET);
-  }
-#endif
 }
 
-#ifdef DEBUG_LAYOUT
-bool
-nsBoxFrame::GetInitialDebug(bool& aDebug)
-{
-  if (!GetContent() || !GetContent()->IsElement())
-    return false;
-
-  static Element::AttrValuesArray strings[] =
-    {&nsGkAtoms::_false, &nsGkAtoms::_true, nullptr};
-  int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None,
-      nsGkAtoms::debug, strings, eCaseMatters);
-  if (index >= 0) {
-    aDebug = index == 1;
-    return true;
-  }
-
-  return false;
-}
-#endif
-
 bool
 nsBoxFrame::GetInitialHAlignment(nsBoxFrame::Halignment& aHalign)
 {
   if (!GetContent() || !GetContent()->IsElement())
     return false;
 
   Element* element = GetContent()->AsElement();
   // XXXdwh Everything inside this if statement is deprecated code.
@@ -767,20 +708,16 @@ nsBoxFrame::GetXULPrefSize(nsBoxLayoutSt
 
   nsSize size(0,0);
   DISPLAY_PREF_SIZE(this, size);
   if (!DoesNeedRecalc(mPrefSize)) {
     size = mPrefSize;
     return size;
   }
 
-#ifdef DEBUG_LAYOUT
-  PropagateDebug(aBoxLayoutState);
-#endif
-
   if (IsXULCollapsed())
     return size;
 
   // if the size was not completely redefined in CSS then ask our children
   bool widthSet, heightSet;
   if (!nsIFrame::AddXULPrefSize(this, size, widthSet, heightSet))
   {
     if (mLayoutManager) {
@@ -803,20 +740,16 @@ nsBoxFrame::GetXULPrefSize(nsBoxLayoutSt
 }
 
 nscoord
 nsBoxFrame::GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState)
 {
   if (!DoesNeedRecalc(mAscent))
      return mAscent;
 
-#ifdef DEBUG_LAYOUT
-  PropagateDebug(aBoxLayoutState);
-#endif
-
   if (IsXULCollapsed())
     return 0;
 
   if (mLayoutManager)
     mAscent = mLayoutManager->GetAscent(this, aBoxLayoutState);
   else
     mAscent = nsBox::GetXULBoxAscent(aBoxLayoutState);
 
@@ -831,20 +764,16 @@ nsBoxFrame::GetXULMinSize(nsBoxLayoutSta
 
   nsSize size(0,0);
   DISPLAY_MIN_SIZE(this, size);
   if (!DoesNeedRecalc(mMinSize)) {
     size = mMinSize;
     return size;
   }
 
-#ifdef DEBUG_LAYOUT
-  PropagateDebug(aBoxLayoutState);
-#endif
-
   if (IsXULCollapsed())
     return size;
 
   // if the size was not completely redefined in CSS then ask our children
   bool widthSet, heightSet;
   if (!nsIFrame::AddXULMinSize(aBoxLayoutState, this, size, widthSet, heightSet))
   {
     if (mLayoutManager) {
@@ -872,20 +801,16 @@ nsBoxFrame::GetXULMaxSize(nsBoxLayoutSta
 
   nsSize size(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
   DISPLAY_MAX_SIZE(this, size);
   if (!DoesNeedRecalc(mMaxSize)) {
     size = mMaxSize;
     return size;
   }
 
-#ifdef DEBUG_LAYOUT
-  PropagateDebug(aBoxLayoutState);
-#endif
-
   if (IsXULCollapsed())
     return size;
 
   // if the size was not completely redefined in CSS then ask our children
   bool widthSet, heightSet;
   if (!nsIFrame::AddXULMaxSize(this, size, widthSet, heightSet))
   {
     if (mLayoutManager) {
@@ -977,42 +902,16 @@ nsBoxFrame::DestroyFrom(nsIFrame* aDestr
   RegUnregAccessKey(false);
 
   // clean up the container box's layout manager and child boxes
   SetXULLayoutManager(nullptr);
 
   nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
 }
 
-#ifdef DEBUG_LAYOUT
-nsresult
-nsBoxFrame::SetXULDebug(nsBoxLayoutState& aState, bool aDebug)
-{
-  // see if our state matches the given debug state
-  bool debugSet = mState & NS_STATE_CURRENTLY_IN_DEBUG;
-  bool debugChanged = (!aDebug && debugSet) || (aDebug && !debugSet);
-
-  // if it doesn't then tell each child below us the new debug state
-  if (debugChanged)
-  {
-     if (aDebug) {
-         AddStateBits(NS_STATE_CURRENTLY_IN_DEBUG);
-     } else {
-         RemoveStateBits(NS_STATE_CURRENTLY_IN_DEBUG);
-     }
-
-     SetDebugOnChildList(aState, mFirstChild, aDebug);
-
-    MarkIntrinsicISizesDirty();
-  }
-
-  return NS_OK;
-}
-#endif
-
 /* virtual */ void
 nsBoxFrame::MarkIntrinsicISizesDirty()
 {
   SizeNeedsRecalc(mPrefSize);
   SizeNeedsRecalc(mMinSize);
   SizeNeedsRecalc(mMaxSize);
   CoordNeedsRecalc(mFlex);
   CoordNeedsRecalc(mAscent);
@@ -1070,22 +969,16 @@ nsBoxFrame::InsertFrames(ChildListID    
      mLayoutManager->ChildrenInserted(this, state, aPrevFrame, newFrames);
 
    // Make sure to check box order _after_ notifying the layout
    // manager; otherwise the slice we give the layout manager will
    // just be bogus.  If the layout manager cares about the order, we
    // just lose.
    CheckBoxOrder();
 
-#ifdef DEBUG_LAYOUT
-   // if we are in debug make sure our children are in debug as well.
-   if (mState & NS_STATE_CURRENTLY_IN_DEBUG)
-       SetDebugOnChildList(state, mFrames.FirstChild(), true);
-#endif
-
    PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange,
                                  NS_FRAME_HAS_DIRTY_CHILDREN);
 }
 
 
 void
 nsBoxFrame::AppendFrames(ChildListID     aListID,
                          nsFrameList&    aFrameList)
@@ -1101,22 +994,16 @@ nsBoxFrame::AppendFrames(ChildListID    
      mLayoutManager->ChildrenAppended(this, state, newFrames);
 
    // Make sure to check box order _after_ notifying the layout
    // manager; otherwise the slice we give the layout manager will
    // just be bogus.  If the layout manager cares about the order, we
    // just lose.
    CheckBoxOrder();
 
-#ifdef DEBUG_LAYOUT
-   // if we are in debug make sure our children are in debug as well.
-   if (mState & NS_STATE_CURRENTLY_IN_DEBUG)
-       SetDebugOnChildList(state, mFrames.FirstChild(), true);
-#endif
-
    // XXXbz why is this NS_FRAME_FIRST_REFLOW check here?
    if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
      PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange,
                                    NS_FRAME_HAS_DIRTY_CHILDREN);
    }
 }
 
 /* virtual */ nsContainerFrame*
@@ -1169,19 +1056,16 @@ nsBoxFrame::AttributeChanged(int32_t aNa
       aAttribute == nsGkAtoms::dir          ||
       aAttribute == nsGkAtoms::mousethrough ||
       aAttribute == nsGkAtoms::equalsize) {
 
     if (aAttribute == nsGkAtoms::align  ||
         aAttribute == nsGkAtoms::valign ||
         aAttribute == nsGkAtoms::orient  ||
         aAttribute == nsGkAtoms::pack    ||
-#ifdef DEBUG_LAYOUT
-        aAttribute == nsGkAtoms::debug   ||
-#endif
         aAttribute == nsGkAtoms::dir) {
 
       mValign = nsBoxFrame::vAlign_Top;
       mHalign = nsBoxFrame::hAlign_Left;
 
       bool orient = true;
       GetInitialOrientation(orient);
       if (orient)
@@ -1201,31 +1085,16 @@ nsBoxFrame::AttributeChanged(int32_t aNa
 
       bool equalSize = false;
       GetInitialEqualSize(equalSize);
       if (equalSize)
         AddStateBits(NS_STATE_EQUAL_SIZE);
       else
         RemoveStateBits(NS_STATE_EQUAL_SIZE);
 
-#ifdef DEBUG_LAYOUT
-      bool debug = mState & NS_STATE_SET_TO_DEBUG;
-      bool debugSet = GetInitialDebug(debug);
-      if (debugSet) {
-        AddStateBits(NS_STATE_DEBUG_WAS_SET);
-
-        if (debug)
-          AddStateBits(NS_STATE_SET_TO_DEBUG);
-        else
-          RemoveStateBits(NS_STATE_SET_TO_DEBUG);
-      } else {
-        RemoveStateBits(NS_STATE_DEBUG_WAS_SET);
-      }
-#endif
-
       bool autostretch = !!(mState & NS_STATE_AUTO_STRETCH);
       GetInitialAutoStretch(autostretch);
       if (autostretch)
         AddStateBits(NS_STATE_AUTO_STRETCH);
       else
         RemoveStateBits(NS_STATE_AUTO_STRETCH);
     }
     else if (aAttribute == nsGkAtoms::left ||
@@ -1269,63 +1138,16 @@ nsBoxFrame::AttributeChanged(int32_t aNa
     // nsTreeBodyFrame's layout reads this from its parent (this frame).
     PresShell()->FrameNeedsReflow(this, nsIPresShell::eStyleChange,
                                   NS_FRAME_IS_DIRTY);
   }
 
   return rv;
 }
 
-#ifdef DEBUG_LAYOUT
-void
-nsBoxFrame::GetDebugPref()
-{
-  gDebug = Preferences::GetBool("xul.debug.box");
-}
-
-class nsDisplayXULDebug : public nsDisplayItem {
-public:
-  nsDisplayXULDebug(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame) :
-    nsDisplayItem(aBuilder, aFrame) {
-    MOZ_COUNT_CTOR(nsDisplayXULDebug);
-  }
-#ifdef NS_BUILD_REFCNT_LOGGING
-  virtual ~nsDisplayXULDebug() {
-    MOZ_COUNT_DTOR(nsDisplayXULDebug);
-  }
-#endif
-
-  virtual void HitTest(nsDisplayListBuilder* aBuilder, nsRect aRect,
-                       HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) {
-    nsPoint rectCenter(aRect.x + aRect.width / 2, aRect.y + aRect.height / 2);
-    static_cast<nsBoxFrame*>(mFrame)->
-      DisplayDebugInfoFor(this, rectCenter - ToReferenceFrame());
-    aOutFrames->AppendElement(this);
-  }
-  virtual void Paint(nsDisplayListBuilder* aBuilder
-                     gfxContext* aCtx);
-  NS_DISPLAY_DECL_NAME("XULDebug", TYPE_XUL_DEBUG)
-};
-
-void
-nsDisplayXULDebug::Paint(nsDisplayListBuilder* aBuilder,
-                         gfxContext* aCtx)
-{
-  static_cast<nsBoxFrame*>(mFrame)->
-    PaintXULDebugOverlay(*aCtx->GetDrawTarget(), ToReferenceFrame());
-}
-
-static void
-PaintXULDebugBackground(nsIFrame* aFrame, DrawTarget* aDrawTarget,
-                        const nsRect& aDirtyRect, nsPoint aPt)
-{
-  static_cast<nsBoxFrame*>(aFrame)->PaintXULDebugBackground(aDrawTarget, aPt);
-}
-#endif
-
 void
 nsBoxFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                              const nsDisplayListSet& aLists)
 {
   bool forceLayer = false;
 
   if (GetContent()->IsXULElement()) {
     // forcelayer is only supported on XUL elements with box layout
@@ -1342,26 +1164,16 @@ nsBoxFrame::BuildDisplayList(nsDisplayLi
     }
   }
 
   nsDisplayListCollection tempLists(aBuilder);
   const nsDisplayListSet& destination = forceLayer ? tempLists : aLists;
 
   DisplayBorderBackgroundOutline(aBuilder, destination);
 
-#ifdef DEBUG_LAYOUT
-  if (mState & NS_STATE_CURRENTLY_IN_DEBUG) {
-    destination.BorderBackground()->AppendToTop(
-      MakeDisplayItem<nsDisplayGeneric>(aBuilder, this, PaintXULDebugBackground,
-                       "XULDebugBackground"));
-    destination.Outlines()->AppendToTop(
-      MakeDisplayItem<nsDisplayXULDebug>(aBuilder, this));
-  }
-#endif
-
   Maybe<nsDisplayListBuilder::AutoContainerASRTracker> contASRTracker;
   if (forceLayer) {
     contASRTracker.emplace(aBuilder);
   }
 
   BuildDisplayListForChildren(aBuilder, destination);
 
   // see if we have to draw a selection frame around this container
@@ -1402,486 +1214,24 @@ nsBoxFrame::BuildDisplayListForChildren(
   nsDisplayListSet set(aLists, aLists.BlockBorderBackgrounds());
   // The children should be in the right order
   while (kid) {
     BuildDisplayListForChild(aBuilder, kid, set);
     kid = kid->GetNextSibling();
   }
 }
 
-// REVIEW: PaintChildren did a few things none of which are a big deal
-// anymore:
-// * Paint some debugging rects for this frame.
-// This is done by nsDisplayXULDebugBackground, which goes in the
-// BorderBackground() layer so it isn't clipped by OVERFLOW_CLIP.
-// * Apply OVERFLOW_CLIP to the children.
-// This is now in nsFrame::BuildDisplayListForStackingContext/Child.
-// * Actually paint the children.
-// Moved to BuildDisplayList.
-// * Paint per-kid debug information.
-// This is done by nsDisplayXULDebug, which is in the Outlines()
-// layer so it goes on top. This means it is not clipped by OVERFLOW_CLIP,
-// whereas it did used to respect OVERFLOW_CLIP, but too bad.
-#ifdef DEBUG_LAYOUT
-void
-nsBoxFrame::PaintXULDebugBackground(DrawTarget* aDrawTarget, nsPoint aPt)
-{
-  nsMargin border;
-  GetXULBorder(border);
-
-  nsMargin debugBorder;
-  nsMargin debugMargin;
-  nsMargin debugPadding;
-
-  bool isHorizontal = IsXULHorizontal();
-
-  GetDebugBorder(debugBorder);
-  PixelMarginToTwips(debugBorder);
-
-  GetDebugMargin(debugMargin);
-  PixelMarginToTwips(debugMargin);
-
-  GetDebugPadding(debugPadding);
-  PixelMarginToTwips(debugPadding);
-
-  nsRect inner(mRect);
-  inner.MoveTo(aPt);
-  inner.Deflate(debugMargin);
-  inner.Deflate(border);
-  //nsRect borderRect(inner);
-
-  int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
-
-  ColorPattern color(ToDeviceColor(isHorizontal ? Color(0.f, 0.f, 1.f, 1.f) :
-                                                  Color(1.f, 0.f, 0.f, 1.f)));
-
-  //left
-  nsRect r(inner);
-  r.width = debugBorder.left;
-  aDrawTarget->FillRect(NSRectToRect(r, appUnitsPerDevPixel), color);
-
-  // top
-  r = inner;
-  r.height = debugBorder.top;
-  aDrawTarget->FillRect(NSRectToRect(r, appUnitsPerDevPixel), color);
-
-  //right
-  r = inner;
-  r.x = r.x + r.width - debugBorder.right;
-  r.width = debugBorder.right;
-  aDrawTarget->FillRect(NSRectToRect(r, appUnitsPerDevPixel), color);
-
-  //bottom
-  r = inner;
-  r.y = r.y + r.height - debugBorder.bottom;
-  r.height = debugBorder.bottom;
-  aDrawTarget->FillRect(NSRectToRect(r, appUnitsPerDevPixel), color);
-
-  // If we have dirty children or we are dirty place a green border around us.
-  if (NS_SUBTREE_DIRTY(this)) {
-    nsRect dirty(inner);
-    ColorPattern green(ToDeviceColor(Color(0.f, 1.f, 0.f, 1.f)));
-    aDrawTarget->StrokeRect(NSRectToRect(dirty, appUnitsPerDevPixel), green);
-  }
-}
-
-void
-nsBoxFrame::PaintXULDebugOverlay(DrawTarget& aDrawTarget, nsPoint aPt)
-{
-  nsMargin border;
-  GetXULBorder(border);
-
-  nsMargin debugMargin;
-  GetDebugMargin(debugMargin);
-  PixelMarginToTwips(debugMargin);
-
-  nsRect inner(mRect);
-  inner.MoveTo(aPt);
-  inner.Deflate(debugMargin);
-  inner.Deflate(border);
-
-  nscoord onePixel = GetPresContext()->IntScaledPixelsToTwips(1);
-
-  kid = nsBox::GetChildXULBox(this);
-  while (nullptr != kid) {
-    bool isHorizontal = IsXULHorizontal();
-
-    nscoord x, y, borderSize, spacerSize;
-
-    nsRect cr(kid->mRect);
-    nsMargin margin;
-    kid->GetXULMargin(margin);
-    cr.Inflate(margin);
-
-    if (isHorizontal)
-    {
-        cr.y = inner.y;
-        x = cr.x;
-        y = cr.y + onePixel;
-        spacerSize = debugBorder.top - onePixel*4;
-    } else {
-        cr.x = inner.x;
-        x = cr.y;
-        y = cr.x + onePixel;
-        spacerSize = debugBorder.left - onePixel*4;
-    }
-
-    nscoord flex = kid->GetXULFlex();
-
-    if (!kid->IsXULCollapsed()) {
-      if (isHorizontal)
-          borderSize = cr.width;
-      else
-          borderSize = cr.height;
-
-      DrawSpacer(GetPresContext(), aDrawTarget, isHorizontal, flex, x, y, borderSize, spacerSize);
-    }
-
-    kid = GetNextXULBox(kid);
-  }
-}
-#endif
-
-#ifdef DEBUG_LAYOUT
-void
-nsBoxFrame::GetBoxName(nsAutoString& aName)
-{
-   GetFrameName(aName);
-}
-#endif
-
 #ifdef DEBUG_FRAME_DUMP
 nsresult
 nsBoxFrame::GetFrameName(nsAString& aResult) const
 {
   return MakeFrameName(NS_LITERAL_STRING("Box"), aResult);
 }
 #endif
 
-#ifdef DEBUG_LAYOUT
-nsresult
-nsBoxFrame::GetXULDebug(bool& aDebug)
-{
-  aDebug = (mState & NS_STATE_CURRENTLY_IN_DEBUG);
-  return NS_OK;
-}
-#endif
-
-// REVIEW: nsBoxFrame::GetFrameForPoint is a problem because of 'mousethrough'
-// attribute support. Here's how it works:
-// * For each child frame F, we determine the target frame T(F) by recursively
-// invoking GetFrameForPoint on the child
-// * Let F' be the last child frame such that T(F') doesn't have mousethrough.
-// If F' exists, return T(F')
-// * Otherwise let F'' be the first child frame such that T(F'') is non-null.
-// If F'' exists, return T(F'')
-// * Otherwise return this frame, if this frame contains the point
-// * Otherwise return null
-// It's not clear how this should work for more complex z-ordering situations.
-// The basic principle seems to be that if a frame F has a descendant
-// 'mousethrough' frame that includes the target position, then F
-// will not receive events (unless it overrides GetFrameForPoint).
-// A 'mousethrough' frame will only receive an event if, after applying that rule,
-// all eligible frames are 'mousethrough'; the bottom-most inner-most 'mousethrough'
-// frame is then chosen (the first eligible frame reached in a
-// traversal of the frame tree --- pre/post is irrelevant since ancestors
-// of the mousethrough frames can't be eligible).
-// IMHO this is very bogus and adds a great deal of complexity for something
-// that is very rarely used. So I'm redefining 'mousethrough' to the following:
-// a frame with mousethrough is transparent to mouse events. This is compatible
-// with the way 'mousethrough' is used in Seamonkey's navigator.xul and
-// Firefox's browser.xul. The only other place it's used is in the 'expander'
-// XBL binding, which in our tree is only used by Thunderbird SMIME Advanced
-// Preferences, and I can't figure out what that does, so I'll have to test it.
-// If it's broken I'll probably just change the binding to use it more sensibly.
-// This new behaviour is implemented in nsDisplayList::HitTest.
-// REVIEW: This debug-box stuff is annoying. I'm just going to put debug boxes
-// in the outline layer and avoid GetDebugBoxAt.
-
-// REVIEW: GetCursor had debug-only event dumping code. I have replaced it
-// with instrumentation in nsDisplayXULDebug.
-
-#ifdef DEBUG_LAYOUT
-void
-nsBoxFrame::DrawLine(DrawTarget& aDrawTarget, bool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2)
-{
-    nsPoint p1(x1, y1);
-    nsPoint p2(x2, y2);
-    if (!aHorizontal) {
-      Swap(p1.x, p1.y);
-      Swap(p2.x, p2.y);
-    }
-    ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
-    StrokeLineWithSnapping(p1, p2, PresContext()->AppUnitsPerDevPixel(),
-                           aDrawTarget, color);
-}
-
-void
-nsBoxFrame::FillRect(DrawTarget& aDrawTarget, bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height)
-{
-    Rect rect = NSRectToSnappedRect(aHorizontal ? nsRect(x, y, width, height) :
-                                                  nsRect(y, x, height, width),
-                                    PresContext()->AppUnitsPerDevPixel(),
-                                    aDrawTarget);
-    ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
-    aDrawTarget.FillRect(rect, white);
-}
-
-void
-nsBoxFrame::DrawSpacer(nsPresContext* aPresContext, DrawTarget& aDrawTarget,
-                       bool aHorizontal, int32_t flex, nscoord x, nscoord y,
-                       nscoord size, nscoord spacerSize)
-{
-         nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
-
-     // if we do draw the coils
-        int distance = 0;
-        int center = 0;
-        int offset = 0;
-        int coilSize = COIL_SIZE*onePixel;
-        int halfSpacer = spacerSize/2;
-
-        distance = size;
-        center = y + halfSpacer;
-        offset = x;
-
-        int coils = distance/coilSize;
-
-        int halfCoilSize = coilSize/2;
-
-        if (flex == 0) {
-            DrawLine(aDrawTarget, aHorizontal, x,y + spacerSize/2, x + size, y + spacerSize/2);
-        } else {
-            for (int i=0; i < coils; i++)
-            {
-                   DrawLine(aDrawTarget, aHorizontal, offset, center+halfSpacer, offset+halfCoilSize, center-halfSpacer);
-                   DrawLine(aDrawTarget, aHorizontal, offset+halfCoilSize, center-halfSpacer, offset+coilSize, center+halfSpacer);
-
-                   offset += coilSize;
-            }
-        }
-
-        FillRect(aDrawTarget, aHorizontal, x + size - spacerSize/2, y, spacerSize/2, spacerSize);
-        FillRect(aDrawTarget, aHorizontal, x, y, spacerSize/2, spacerSize);
-}
-
-void
-nsBoxFrame::GetDebugBorder(nsMargin& aInset)
-{
-    aInset.SizeTo(2,2,2,2);
-
-    if (IsXULHorizontal())
-       aInset.top = 10;
-    else
-       aInset.left = 10;
-}
-
-void
-nsBoxFrame::GetDebugMargin(nsMargin& aInset)
-{
-    aInset.SizeTo(2,2,2,2);
-}
-
-void
-nsBoxFrame::GetDebugPadding(nsMargin& aPadding)
-{
-    aPadding.SizeTo(2,2,2,2);
-}
-
-void
-nsBoxFrame::PixelMarginToTwips(nsMargin& aMarginPixels)
-{
-  nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
-  aMarginPixels.left   *= onePixel;
-  aMarginPixels.right  *= onePixel;
-  aMarginPixels.top    *= onePixel;
-  aMarginPixels.bottom *= onePixel;
-}
-
-void
-nsBoxFrame::GetValue(nsPresContext* aPresContext, const nsSize& a, const nsSize& b, char* ch)
-{
-    float p2t = aPresContext->ScaledPixelsToTwips();
-
-    char width[100];
-    char height[100];
-
-    if (a.width == NS_INTRINSICSIZE)
-        sprintf(width,"%s","INF");
-    else
-        sprintf(width,"%d", nscoord(a.width/*/p2t*/));
-
-    if (a.height == NS_INTRINSICSIZE)
-        sprintf(height,"%s","INF");
-    else
-        sprintf(height,"%d", nscoord(a.height/*/p2t*/));
-
-
-    sprintf(ch, "(%s%s, %s%s)", width, (b.width != NS_INTRINSICSIZE ? "[SET]" : ""),
-                    height, (b.height != NS_INTRINSICSIZE ? "[SET]" : ""));
-
-}
-
-void
-nsBoxFrame::GetValue(nsPresContext* aPresContext, int32_t a, int32_t b, char* ch)
-{
-    if (a == NS_INTRINSICSIZE)
-      sprintf(ch, "%d[SET]", b);
-    else
-      sprintf(ch, "%d", a);
-}
-
-nsresult
-nsBoxFrame::DisplayDebugInfoFor(nsIFrame*  aBox,
-                                nsPoint& aPoint)
-{
-    nsBoxLayoutState state(GetPresContext());
-
-    nscoord x = aPoint.x;
-    nscoord y = aPoint.y;
-
-    // get the area inside our border but not our debug margins.
-    nsRect insideBorder(aBox->mRect);
-    insideBorder.MoveTo(0,0):
-    nsMargin border(0,0,0,0);
-    aBox->GetXULBorderAndPadding(border);
-    insideBorder.Deflate(border);
-
-    bool isHorizontal = IsXULHorizontal();
-
-    if (!insideBorder.Contains(nsPoint(x,y)))
-        return NS_ERROR_FAILURE;
-
-    //printf("%%%%%% inside box %%%%%%%\n");
-
-    int count = 0;
-    nsIFrame* child = nsBox::GetChildXULBox(aBox);
-
-    nsMargin m;
-    nsMargin m2;
-    GetDebugBorder(m);
-    PixelMarginToTwips(m);
-
-    GetDebugMargin(m2);
-    PixelMarginToTwips(m2);
-
-    m += m2;
-
-    if ((isHorizontal && y < insideBorder.y + m.top) ||
-        (!isHorizontal && x < insideBorder.x + m.left)) {
-        //printf("**** inside debug border *******\n");
-        while (child)
-        {
-            const nsRect& r = child->mRect;
-
-            // if we are not in the child. But in the spacer above the child.
-            if ((isHorizontal && x >= r.x && x < r.x + r.width) ||
-                (!isHorizontal && y >= r.y && y < r.y + r.height)) {
-                aCursor = NS_STYLE_CURSOR_POINTER;
-                   // found it but we already showed it.
-                    if (mDebugChild == child)
-                        return NS_OK;
-
-                    if (aBox->GetContent()) {
-                      printf("---------------\n");
-                      XULDumpBox(stdout);
-                      printf("\n");
-                    }
-
-                    if (child->GetContent()) {
-                        printf("child #%d: ", count);
-                        child->XULDumpBox(stdout);
-                        printf("\n");
-                    }
-
-                    mDebugChild = child;
-
-                    nsSize prefSizeCSS(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
-                    nsSize minSizeCSS (NS_INTRINSICSIZE, NS_INTRINSICSIZE);
-                    nsSize maxSizeCSS (NS_INTRINSICSIZE, NS_INTRINSICSIZE);
-                    nscoord flexCSS = NS_INTRINSICSIZE;
-
-                    bool widthSet, heightSet;
-                    nsIFrame::AddXULPrefSize(child, prefSizeCSS, widthSet, heightSet);
-                    nsIFrame::AddXULMinSize (state, child, minSizeCSS, widthSet, heightSet);
-                    nsIFrame::AddXULMaxSize (child, maxSizeCSS, widthSet, heightSet);
-                    nsIFrame::AddXULFlex    (child, flexCSS);
-
-                    nsSize prefSize = child->GetXULPrefSize(state);
-                    nsSize minSize = child->GetXULMinSize(state);
-                    nsSize maxSize = child->GetXULMaxSize(state);
-                    nscoord flexSize = child->GetXULFlex();
-                    nscoord ascentSize = child->GetXULBoxAscent(state);
-
-                    char min[100];
-                    char pref[100];
-                    char max[100];
-                    char calc[100];
-                    char flex[100];
-                    char ascent[100];
-
-                    nsSize actualSize;
-                    GetFrameSizeWithMargin(child, actualSize);
-                    nsSize actualSizeCSS (NS_INTRINSICSIZE, NS_INTRINSICSIZE);
-
-                    GetValue(aPresContext, minSize,  minSizeCSS, min);
-                    GetValue(aPresContext, prefSize, prefSizeCSS, pref);
-                    GetValue(aPresContext, maxSize,  maxSizeCSS, max);
-                    GetValue(aPresContext, actualSize, actualSizeCSS, calc);
-                    GetValue(aPresContext, flexSize,  flexCSS, flex);
-                    GetValue(aPresContext, ascentSize,  NS_INTRINSICSIZE, ascent);
-
-
-                    printf("min%s, pref%s, max%s, actual%s, flex=%s, ascent=%s\n\n",
-                        min,
-                        pref,
-                        max,
-                        calc,
-                        flex,
-                        ascent
-                    );
-
-                    return NS_OK;
-            }
-
-          child = GetNextXULBox(child);
-          count++;
-        }
-    } else {
-    }
-
-    mDebugChild = nullptr;
-
-    return NS_OK;
-}
-
-void
-nsBoxFrame::SetDebugOnChildList(nsBoxLayoutState& aState, nsIFrame* aChild, bool aDebug)
-{
-    nsIFrame* child = nsBox::GetChildXULBox(this);
-     while (child)
-     {
-        child->SetXULDebug(aState, aDebug);
-        child = GetNextXULBox(child);
-     }
-}
-
-nsresult
-nsBoxFrame::GetFrameSizeWithMargin(nsIFrame* aBox, nsSize& aSize)
-{
-  nsRect rect(aBox->GetRect());
-  nsMargin margin(0,0,0,0);
-  aBox->GetXULMargin(margin);
-  rect.Inflate(margin);
-  aSize.width = rect.width;
-  aSize.height = rect.height;
-  return NS_OK;
-}
-#endif
-
 // If you make changes to this function, check its counterparts
 // in nsTextBoxFrame and nsXULLabelFrame
 void
 nsBoxFrame::RegUnregAccessKey(bool aDoReg)
 {
   MOZ_ASSERT(mContent);
 
   // only support accesskeys for the following elements
--- a/layout/xul/nsBoxFrame.h
+++ b/layout/xul/nsBoxFrame.h
@@ -61,20 +61,16 @@ public:
 
   virtual nsresult XULRelayoutChildAtOrdinal(nsIFrame* aChild) override;
 
   virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
   virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
   virtual nsSize GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState) override;
   virtual nscoord GetXULFlex() override;
   virtual nscoord GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) override;
-#ifdef DEBUG_LAYOUT
-  virtual nsresult SetXULDebug(nsBoxLayoutState& aBoxLayoutState, bool aDebug) override;
-  virtual nsresult GetXULDebug(bool& aDebug) override;
-#endif
   virtual Valignment GetXULVAlign() const override { return mValign; }
   virtual Halignment GetXULHAlign() const override { return mHalign; }
   NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState) override;
 
   virtual bool ComputesOwnOverflowArea() override { return false; }
 
   // ----- child and sibling operations ---
 
@@ -141,22 +137,16 @@ public:
   // virtual so nsStackFrame, nsButtonBoxFrame, nsSliderFrame and nsMenuFrame
   // can override it
   virtual void BuildDisplayListForChildren(nsDisplayListBuilder*   aBuilder,
                                            const nsDisplayListSet& aLists);
 
   virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                 const nsDisplayListSet& aLists) override;
 
-#ifdef DEBUG_LAYOUT
-    virtual void SetDebugOnChildList(nsBoxLayoutState& aState, nsIFrame* aChild, bool aDebug);
-    nsresult DisplayDebugInfoFor(nsIFrame*  aBox,
-                                 nsPoint& aPoint);
-#endif
-
   static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIFrame* aBox, const nsRect& aRect);
 
   /**
    * Utility method to redirect events on descendants to this frame.
    * Supports 'allowevents' attribute on descendant elements to allow those
    * elements and their descendants to receive events.
    */
   void WrapListsInRedirector(nsDisplayListBuilder*   aBuilder,
@@ -177,24 +167,16 @@ public:
 private:
   explicit nsBoxFrame(ComputedStyle* aStyle)
     : nsBoxFrame(aStyle, kClassID, false, nullptr) {}
 protected:
   nsBoxFrame(ComputedStyle* aStyle, ClassID aID, bool aIsRoot = false,
              nsBoxLayout* aLayoutManager = nullptr);
   virtual ~nsBoxFrame();
 
-#ifdef DEBUG_LAYOUT
-    virtual void GetBoxName(nsAutoString& aName) override;
-    void PaintXULDebugBackground(gfxContext& aRenderingContext,
-                                 nsPoint aPt);
-    void PaintXULDebugOverlay(DrawTarget& aRenderingContext,
-                              nsPoint aPt);
-#endif
-
     virtual bool GetInitialEqualSize(bool& aEqualSize);
     virtual void GetInitialOrientation(bool& aIsHorizontal);
     virtual void GetInitialDirection(bool& aIsNormal);
     virtual bool GetInitialHAlignment(Halignment& aHalign);
     virtual bool GetInitialVAlignment(Valignment& aValign);
     virtual bool GetInitialAutoStretch(bool& aStretch);
 
     virtual void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
@@ -217,44 +199,20 @@ protected:
 
 protected:
     void RegUnregAccessKey(bool aDoReg);
 
   void CheckBoxOrder();
 
 private:
 
-#ifdef DEBUG_LAYOUT
-    nsresult SetXULDebug(nsPresContext* aPresContext, bool aDebug);
-    bool GetInitialDebug(bool& aDebug);
-    void GetDebugPref();
-
-    void GetDebugBorder(nsMargin& aInset);
-    void GetDebugPadding(nsMargin& aInset);
-    void GetDebugMargin(nsMargin& aInset);
-
-    nsresult GetFrameSizeWithMargin(nsIFrame* aBox, nsSize& aSize);
-
-    void PixelMarginToTwips(nsMargin& aMarginPixels);
-
-    void GetValue(nsPresContext* aPresContext, const nsSize& a, const nsSize& b, char* value);
-    void GetValue(nsPresContext* aPresContext, int32_t a, int32_t b, char* value);
-    void DrawSpacer(nsPresContext* aPresContext, DrawTarget& aDrawTarget, bool aHorizontal, int32_t flex, nscoord x, nscoord y, nscoord size, nscoord spacerSize);
-    void DrawLine(DrawTarget& aDrawTarget,  bool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2);
-    void FillRect(DrawTarget& aDrawTarget,  bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height);
-#endif
     virtual void UpdateMouseThrough();
 
     void CacheAttributes();
 
     // instance variables.
     Halignment mHalign;
     Valignment mValign;
 
-#ifdef DEBUG_LAYOUT
-    static bool gDebug;
-    static nsIFrame* mDebugChild;
-#endif
-
 }; // class nsBoxFrame
 
 #endif
 
--- a/layout/xul/nsLeafBoxFrame.cpp
+++ b/layout/xul/nsLeafBoxFrame.cpp
@@ -36,25 +36,16 @@ using namespace mozilla;
 nsIFrame*
 NS_NewLeafBoxFrame (nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
   return new (aPresShell) nsLeafBoxFrame(aStyle);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsLeafBoxFrame)
 
-#ifdef DEBUG_LAYOUT
-void
-nsLeafBoxFrame::GetBoxName(nsAutoString& aName)
-{
-   GetFrameName(aName);
-}
-#endif
-
-
 /**
  * Initialize us. This is a good time to get the alignment of the box
  */
 void
 nsLeafBoxFrame::Init(nsIContent*       aContent,
                      nsContainerFrame* aParent,
                      nsIFrame*         aPrevInFlow)
 {
--- a/layout/xul/nsLeafBoxFrame.h
+++ b/layout/xul/nsLeafBoxFrame.h
@@ -71,20 +71,16 @@ public:
                                     int32_t aModType) override;
 
   virtual bool ComputesOwnOverflowArea() override { return false; }
 
 protected:
 
   NS_IMETHOD DoXULLayout(nsBoxLayoutState& aState) override;
 
-#ifdef DEBUG_LAYOUT
-  virtual void GetBoxName(nsAutoString& aName) override;
-#endif
-
   virtual nscoord GetIntrinsicISize() override;
 
   explicit nsLeafBoxFrame(ComputedStyle* aStyle, ClassID aID = kClassID)
     : nsLeafFrame(aStyle, aID)
   {}
 
 private:
 
--- a/layout/xul/nsMenuFrame.cpp
+++ b/layout/xul/nsMenuFrame.cpp
@@ -764,53 +764,16 @@ nsMenuFrame::DoXULLayout(nsBoxLayoutStat
   if (popupFrame) {
     bool sizeToPopup = IsSizedToPopup(mContent, false);
     popupFrame->LayoutPopup(aState, this, GetAnchor()->GetPrimaryFrame(), sizeToPopup);
   }
 
   return rv;
 }
 
-#ifdef DEBUG_LAYOUT
-nsresult
-nsMenuFrame::SetXULDebug(nsBoxLayoutState& aState, bool aDebug)
-{
-  // see if our state matches the given debug state
-  bool debugSet = mState & NS_STATE_CURRENTLY_IN_DEBUG;
-  bool debugChanged = (!aDebug && debugSet) || (aDebug && !debugSet);
-
-  // if it doesn't then tell each child below us the new debug state
-  if (debugChanged)
-  {
-      nsBoxFrame::SetXULDebug(aState, aDebug);
-      nsMenuPopupFrame* popupFrame = GetPopup();
-      if (popupFrame)
-        SetXULDebug(aState, popupFrame, aDebug);
-  }
-
-  return NS_OK;
-}
-
-nsresult
-nsMenuFrame::SetXULDebug(nsBoxLayoutState& aState, nsIFrame* aList, bool aDebug)
-{
-      if (!aList)
-          return NS_OK;
-
-      while (aList) {
-        if (aList->IsXULBoxFrame())
-          aList->SetXULDebug(aState, aDebug);
-
-        aList = aList->GetNextSibling();
-      }
-
-      return NS_OK;
-}
-#endif
-
 //
 // Enter
 //
 // Called when the user hits the <Enter>/<Return> keys or presses the
 // shortcut key. If this is a leaf item, the item's action will be executed.
 // In either case, do nothing if the item is disabled.
 //
 nsMenuFrame*
@@ -1329,21 +1292,16 @@ nsMenuFrame::RemoveFrame(ChildListID    
 void
 nsMenuFrame::InsertFrames(ChildListID     aListID,
                           nsIFrame*       aPrevFrame,
                           nsFrameList&    aFrameList)
 {
   if (!HasPopup() && (aListID == kPrincipalList || aListID == kPopupList)) {
     SetPopupFrame(aFrameList);
     if (HasPopup()) {
-#ifdef DEBUG_LAYOUT
-      nsBoxLayoutState state(PresContext());
-      SetXULDebug(state, aFrameList, mState & NS_STATE_CURRENTLY_IN_DEBUG);
-#endif
-
       PresShell()->
         FrameNeedsReflow(this, nsIPresShell::eTreeChange,
                          NS_FRAME_HAS_DIRTY_CHILDREN);
     }
   }
 
   if (aFrameList.IsEmpty())
     return;
@@ -1357,21 +1315,16 @@ nsMenuFrame::InsertFrames(ChildListID   
 
 void
 nsMenuFrame::AppendFrames(ChildListID     aListID,
                           nsFrameList&    aFrameList)
 {
   if (!HasPopup() && (aListID == kPrincipalList || aListID == kPopupList)) {
     SetPopupFrame(aFrameList);
     if (HasPopup()) {
-
-#ifdef DEBUG_LAYOUT
-      nsBoxLayoutState state(PresContext());
-      SetXULDebug(state, aFrameList, mState & NS_STATE_CURRENTLY_IN_DEBUG);
-#endif
       PresShell()->
         FrameNeedsReflow(this, nsIPresShell::eTreeChange,
                          NS_FRAME_HAS_DIRTY_CHILDREN);
     }
   }
 
   if (aFrameList.IsEmpty())
     return;
--- a/layout/xul/nsMenuFrame.h
+++ b/layout/xul/nsMenuFrame.h
@@ -94,20 +94,16 @@ public:
   NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState) override;
   virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
   virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
 
   virtual void Init(nsIContent*       aContent,
                     nsContainerFrame* aParent,
                     nsIFrame*         aPrevInFlow) override;
 
-#ifdef DEBUG_LAYOUT
-  virtual nsresult SetXULDebug(nsBoxLayoutState& aState, bool aDebug) override;
-#endif
-
   // The following methods are all overridden so that the menupopup
   // can be stored in a separate list, so that it doesn't impact reflow of the
   // actual menu item at all.
   virtual const nsFrameList& GetChildList(ChildListID aList) const override;
   virtual void GetChildLists(nsTArray<ChildList>* aLists) const override;
   virtual void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
 
   // Overridden to prevent events from going to children of the menu.
@@ -269,19 +265,16 @@ protected:
   bool ShouldBlink();
   void StartBlinking(mozilla::WidgetGUIEvent* aEvent, bool aFlipChecked);
   void StopBlinking();
   void CreateMenuCommandEvent(mozilla::WidgetGUIEvent* aEvent,
                               bool aFlipChecked);
   void PassMenuCommandEventToPopupManager();
 
 protected:
-#ifdef DEBUG_LAYOUT
-  nsresult SetXULDebug(nsBoxLayoutState& aState, nsIFrame* aList, bool aDebug);
-#endif
   nsresult Notify(nsITimer* aTimer);
 
   bool mIsMenu; // Whether or not we can even have children or not.
   bool mChecked;              // are we checked?
   bool mIgnoreAccelTextChange; // temporarily set while determining the accelerator key
   bool mReflowCallbackPosted;
   nsMenuType mType;
 
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -485,25 +485,16 @@ nsSliderFrame::DoXULLayout(nsBoxLayoutSt
 
   if (!thumbBox) {
     SyncLayout(aState);
     return NS_OK;
   }
 
   EnsureOrient();
 
-#ifdef DEBUG_LAYOUT
-  if (mState & NS_STATE_DEBUG_WAS_SET) {
-      if (mState & NS_STATE_SET_TO_DEBUG)
-          SetXULDebug(aState, true);
-      else
-          SetXULDebug(aState, false);
-  }
-#endif
-
   // get the content area inside our borders
   nsRect clientRect;
   GetXULClientRect(clientRect);
 
   // get the scrollbar
   nsIFrame* scrollbarBox = GetScrollbar();
   nsCOMPtr<nsIContent> scrollbar = GetContentOfBox(scrollbarBox);
 
--- a/layout/xul/nsSprocketLayout.cpp
+++ b/layout/xul/nsSprocketLayout.cpp
@@ -20,23 +20,16 @@
 #include "nsContainerFrame.h"
 #include "nsBoxFrame.h"
 #include "StackArena.h"
 #include "mozilla/Likely.h"
 #include <algorithm>
 
 nsBoxLayout* nsSprocketLayout::gInstance = nullptr;
 
-//#define DEBUG_GROW
-
-#define DEBUG_SPRING_SIZE 8
-#define DEBUG_BORDER_SIZE 2
-#define COIL_SIZE 8
-
-
 nsresult
 NS_NewSprocketLayout(nsCOMPtr<nsBoxLayout>& aNewLayout)
 {
   if (!nsSprocketLayout::gInstance) {
     nsSprocketLayout::gInstance = new nsSprocketLayout();
     NS_IF_ADDREF(nsSprocketLayout::gInstance);
   }
   // we have not instance variables so just return our static one.
@@ -485,17 +478,16 @@ nsSprocketLayout::XULLayout(nsIFrame* aB
         child->XULLayout(aState);
 
       // If the child was a block or inline (e.g., HTML) it may have changed its rect *during* layout.
       // We have to check for this.
       nsRect newChildRect(child->GetRect());
 
       if (!newChildRect.IsEqualInterior(childRect)) {
 #ifdef DEBUG_GROW
-        child->XULDumpBox(stdout);
         printf(" GREW from (%d,%d) -> (%d,%d)\n", childRect.width, childRect.height, newChildRect.width, newChildRect.height);
 #endif
         newChildRect.Inflate(margin);
         childRect.Inflate(margin);
 
         // The child changed size during layout.  The ChildResized method handles this
         // scenario.
         ChildResized(aBox,
@@ -650,19 +642,16 @@ nsSprocketLayout::PopulateBoxSizes(nsIFr
   // used for the equal size flag
   nscoord biggestPrefWidth = 0;
   nscoord biggestMinWidth = 0;
   nscoord smallestMaxWidth = NS_INTRINSICSIZE;
 
   nsFrameState frameState = nsFrameState(0);
   GetFrameState(aBox, frameState);
 
-  //if (frameState & NS_STATE_CURRENTLY_IN_DEBUG)
-  //   printf("In debug\n");
-
   aMinSize = 0;
   aMaxSize = NS_INTRINSICSIZE;
 
   bool isHorizontal;
 
   if (IsXULHorizontal(aBox))
      isHorizontal = true;
   else