Bug 919865: Replace #ifdef DEBUG with DebugOnly<> in a few spots in layout/generic. r=mats
authorDaniel Holbert <dholbert@cs.stanford.edu>
Tue, 01 Oct 2013 22:02:23 -0700
changeset 163432 d43432aad57decba4930a3a4d4c0142685851940
parent 163431 3384d15466b23889457f02fb785e299dca971d72
child 163433 e19ed60eaffadc441bdba5c32aee14dd74d00e48
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs919865
milestone27.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 919865: Replace #ifdef DEBUG with DebugOnly<> in a few spots in layout/generic. r=mats
layout/generic/nsContainerFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsImageFrame.h
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -1388,20 +1388,17 @@ nsContainerFrame::DeleteNextInFlowChild(
     for (int32_t i = frames.Length() - 1; i >= 0; --i) {
       nsIFrame* delFrame = frames.ElementAt(i);
       static_cast<nsContainerFrame*>(delFrame->GetParent())
         ->DeleteNextInFlowChild(aPresContext, delFrame, aDeletingEmptyFrames);
     }
   }
 
   // Take the next-in-flow out of the parent's child list
-#ifdef DEBUG
-  nsresult rv =
-#endif
-    StealFrame(aPresContext, aNextInFlow);
+  DebugOnly<nsresult> rv = StealFrame(aPresContext, aNextInFlow);
   NS_ASSERTION(NS_SUCCEEDED(rv), "StealFrame failure");
 
 #ifdef DEBUG
   if (aDeletingEmptyFrames) {
     nsLayoutUtils::AssertTreeOnlyEmptyNextInFlows(aNextInFlow);
   }
 #endif
 
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -873,20 +873,17 @@ nsIFrame::GetUsedMargin() const
       IsSVGText())
     return margin;
 
   nsMargin *m = static_cast<nsMargin*>
                            (Properties().Get(UsedMarginProperty()));
   if (m) {
     margin = *m;
   } else {
-#ifdef DEBUG
-    bool hasMargin = 
-#endif
-    StyleMargin()->GetMargin(margin);
+    DebugOnly<bool> hasMargin = StyleMargin()->GetMargin(margin);
     NS_ASSERTION(hasMargin, "We should have a margin here! (out of memory?)");
   }
   return margin;
 }
 
 /* virtual */ nsMargin
 nsIFrame::GetUsedBorder() const
 {
@@ -951,20 +948,17 @@ nsIFrame::GetUsedPadding() const
     }
   }
 
   nsMargin *p = static_cast<nsMargin*>
                            (Properties().Get(UsedPaddingProperty()));
   if (p) {
     padding = *p;
   } else {
-#ifdef DEBUG
-    bool hasPadding = 
-#endif
-    StylePadding()->GetPadding(padding);
+    DebugOnly<bool> hasPadding = StylePadding()->GetPadding(padding);
     NS_ASSERTION(hasPadding, "We should have padding here! (out of memory?)");
   }
   return padding;
 }
 
 void
 nsIFrame::ApplySkipSides(nsMargin& aMargin,
                          const nsHTMLReflowState* aReflowState) const
@@ -5064,20 +5058,17 @@ ComputeOutlineAndEffectsRect(nsIFrame* a
 
   // box-shadow
   r.UnionRect(r, nsLayoutUtils::GetBoxShadowRectForFrame(aFrame, aNewSize));
 
   const nsStyleOutline* outline = aFrame->StyleOutline();
   uint8_t outlineStyle = outline->GetOutlineStyle();
   if (outlineStyle != NS_STYLE_BORDER_STYLE_NONE) {
     nscoord width;
-#ifdef DEBUG
-    bool result = 
-#endif
-      outline->GetOutlineWidth(width);
+    DebugOnly<bool> result = outline->GetOutlineWidth(width);
     NS_ASSERTION(result, "GetOutlineWidth had no cached outline width");
     if (width > 0) {
       if (aStoreRectProperties) {
         aFrame->Properties().
           Set(nsIFrame::OutlineInnerRectProperty(), new nsRect(r));
       }
 
       nscoord offset = outline->mOutlineOffset;
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -3176,31 +3176,25 @@ nsXULScrollFrame::AddVerticalScrollbar(n
 
   return AddRemoveScrollbar(aState, aOnRight, false, true);
 }
 
 void
 nsXULScrollFrame::RemoveHorizontalScrollbar(nsBoxLayoutState& aState, bool aOnBottom)
 {
   // removing a scrollbar should always fit
-#ifdef DEBUG
-  bool result =
-#endif
-  AddRemoveScrollbar(aState, aOnBottom, true, false);
+  DebugOnly<bool> result = AddRemoveScrollbar(aState, aOnBottom, true, false);
   NS_ASSERTION(result, "Removing horizontal scrollbar failed to fit??");
 }
 
 void
 nsXULScrollFrame::RemoveVerticalScrollbar(nsBoxLayoutState& aState, bool aOnRight)
 {
   // removing a scrollbar should always fit
-#ifdef DEBUG
-  bool result =
-#endif
-  AddRemoveScrollbar(aState, aOnRight, false, false);
+  DebugOnly<bool> result = AddRemoveScrollbar(aState, aOnRight, false, false);
   NS_ASSERTION(result, "Removing vertical scrollbar failed to fit??");
 }
 
 bool
 nsXULScrollFrame::AddRemoveScrollbar(nsBoxLayoutState& aState,
                                      bool aOnRightOrBottom, bool aHorizontal, bool aAdd)
 {
   if (aHorizontal) {
--- a/layout/generic/nsImageFrame.h
+++ b/layout/generic/nsImageFrame.h
@@ -12,16 +12,17 @@
 #include "nsIIOService.h"
 #include "nsIObserver.h"
 
 #include "imgINotificationObserver.h"
 
 #include "nsDisplayList.h"
 #include "imgIContainer.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/DebugOnly.h"
 #include "nsIReflowCallback.h"
 
 class nsImageMap;
 class nsIURI;
 class nsILoadGroup;
 struct nsHTMLReflowState;
 struct nsHTMLReflowMetrics;
 class nsDisplayImage;
@@ -322,21 +323,18 @@ private:
 
     void AddIconObserver(nsImageFrame *frame) {
         NS_ABORT_IF_FALSE(!mIconObservers.Contains(frame),
                           "Observer shouldn't aleady be in array");
         mIconObservers.AppendElement(frame);
     }
 
     void RemoveIconObserver(nsImageFrame *frame) {
-#ifdef DEBUG
-        bool rv =
-#endif
-            mIconObservers.RemoveElement(frame);
-        NS_ABORT_IF_FALSE(rv, "Observer not in array");
+      mozilla::DebugOnly<bool> didRemove = mIconObservers.RemoveElement(frame);
+      NS_ABORT_IF_FALSE(didRemove, "Observer not in array");
     }
 
   private:
     void GetPrefs();
     nsTObserverArray<nsImageFrame*> mIconObservers;
 
 
   public: