Bug 1290335: Improve error message of the anonymous box assertion. draft
authorEmilio Cobos Álvarez <ecoal95@gmail.com>
Wed, 27 Jul 2016 20:03:49 -0700
changeset 396031 64bbcea8a3848f8398fd3269aae79f7ac183f5de
parent 396030 6d7c1a0f064761a8dc1d0c600270bce4eac0f9db
child 396032 acf7c285b201a3e3d3ead2970d459258fcd7fa91
push id24900
push userbmo:ealvarez@mozilla.com
push dateWed, 03 Aug 2016 08:06:14 +0000
bugs1290335
milestone51.0a1
Bug 1290335: Improve error message of the anonymous box assertion. MozReview-Commit-ID: 6cJSBz03Yji
layout/style/ServoStyleSet.cpp
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ServoStyleSet.h"
 
 #include "mozilla/ServoRestyleManager.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsCSSPseudoElements.h"
 #include "nsIDocumentInlines.h"
+#include "nsPrintfCString.h"
 #include "nsStyleContext.h"
 #include "nsStyleSet.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 ServoStyleSet::ServoStyleSet()
   : mPresContext(nullptr)
@@ -185,17 +186,25 @@ ServoStyleSet::ResolveAnonymousBoxStyle(
   bool skipFixup = aFlags & nsStyleSet::eSkipParentDisplayBasedStyleFixup;
 
   ServoComputedValues* parentStyle =
     aParentContext ? aParentContext->StyleSource().AsServoComputedValues()
                    : nullptr;
   RefPtr<ServoComputedValues> computedValues =
     dont_AddRef(Servo_GetComputedValuesForAnonymousBox(parentStyle, aPseudoTag,
                                                        mRawSet.get()));
-  MOZ_ASSERT(computedValues);
+#ifdef DEBUG
+  if (!computedValues) {
+    nsString pseudo;
+    aPseudoTag->ToString(pseudo);
+    NS_ERROR(nsPrintfCString("stylo: could not get anon-box: %s",
+             NS_ConvertUTF16toUTF8(pseudo).get()).get());
+    MOZ_CRASH();
+  }
+#endif
 
   return NS_NewStyleContext(aParentContext, mPresContext, aPseudoTag,
                             CSSPseudoElementType::AnonBox,
                             computedValues.forget(), skipFixup);
 }
 
 // manage the set of style sheets in the style set
 nsresult