Bug 1288873: stylo: Improve the error message when we don't handle a restyle hint. draft
authorEmilio Cobos Álvarez <ecoal95@gmail.com>
Fri, 22 Jul 2016 15:27:05 -0700
changeset 393051 934bea8d036642e1f124feb33f8147fd31589190
parent 393050 9827d6167d6164dbc6227b598fdf6533c89816ba
child 526478 c1ce12280cde0402ac311b62792352b8fe5c5448
push id24197
push userbmo:ealvarez@mozilla.com
push dateTue, 26 Jul 2016 23:09:19 +0000
bugs1288873
milestone50.0a1
Bug 1288873: stylo: Improve the error message when we don't handle a restyle hint. MozReview-Commit-ID: 3FCCCCF5gQS
layout/base/RestyleManager.cpp
layout/base/RestyleManager.h
layout/base/RestyleManagerBase.cpp
layout/base/RestyleManagerBase.h
layout/base/ServoRestyleManager.cpp
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -3799,17 +3799,17 @@ ElementRestyler::RestyleSelf(nsIFrame* a
   // Getting the hint would be nice too, but that's harder.
 
   // XXXbryner we may be able to avoid some of the refcounting goop here.
   // We do need a reference to oldContext for the lifetime of this function, and it's possible
   // that the frame has the last reference to it, so AddRef it here.
 
   LOG_RESTYLE("RestyleSelf %s, aRestyleHint = %s",
               FrameTagToString(aSelf).get(),
-              RestyleManager::RestyleHintToString(aRestyleHint).get());
+              RestyleManagerBase::RestyleHintToString(aRestyleHint).get());
   LOG_RESTYLE_INDENT();
 
   // Initially assume that it is safe to stop restyling.
   //
   // Throughout most of this function, we update the following two variables
   // independently.  |result| is set to RestyleResult::eContinue when we
   // detect a condition that would not allow us to return RestyleResult::eStop.
   // |canStopWithStyleChange| is set to false when we detect a condition
@@ -5056,50 +5056,16 @@ RestyleManager::StructsToLog()
       }
     }
     initialized = true;
   }
   return structs;
 }
 #endif
 
-/* static */ nsCString
-RestyleManager::RestyleHintToString(nsRestyleHint aHint)
-{
-  nsCString result;
-  bool any = false;
-  const char* names[] = {
-    "Self", "SomeDescendants", "Subtree", "LaterSiblings", "CSSTransitions",
-    "CSSAnimations", "SVGAttrAnimations", "StyleAttribute",
-    "StyleAttribute_Animations", "Force", "ForceDescendants"
-  };
-  uint32_t hint = aHint & ((1 << ArrayLength(names)) - 1);
-  uint32_t rest = aHint & ~((1 << ArrayLength(names)) - 1);
-  for (uint32_t i = 0; i < ArrayLength(names); i++) {
-    if (hint & (1 << i)) {
-      if (any) {
-        result.AppendLiteral(" | ");
-      }
-      result.AppendPrintf("eRestyle_%s", names[i]);
-      any = true;
-    }
-  }
-  if (rest) {
-    if (any) {
-      result.AppendLiteral(" | ");
-    }
-    result.AppendPrintf("0x%0x", rest);
-  } else {
-    if (!any) {
-      result.AppendLiteral("0");
-    }
-  }
-  return result;
-}
-
 #ifdef DEBUG
 /* static */ nsCString
 RestyleManager::ChangeHintToString(nsChangeHint aHint)
 {
   nsCString result;
   bool any = false;
   const char* names[] = {
     "RepaintFrame", "NeedReflow", "ClearAncestorIntrinsics",
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -395,18 +395,16 @@ public:
     PostRestyleEventInternal(true);
   }
 
   void FlushOverflowChangedTracker()
   {
     mOverflowChangedTracker.Flush();
   }
 
-  static nsCString RestyleHintToString(nsRestyleHint aHint);
-
 #ifdef DEBUG
   static nsCString ChangeHintToString(nsChangeHint aHint);
 #endif
 
 private:
   void PostRestyleEventInternal(bool aForLazyConstruction);
 
 public:
--- a/layout/base/RestyleManagerBase.cpp
+++ b/layout/base/RestyleManagerBase.cpp
@@ -95,9 +95,44 @@ RestyleManagerBase::ContentStateChangedI
   if (aStateMask.HasState(NS_EVENT_STATE_VISITED)) {
     // Exposing information to the page about whether the link is
     // visited or not isn't really something we can worry about here.
     // FIXME: We could probably do this a bit better.
     *aOutChangeHint |= nsChangeHint_RepaintFrame;
   }
 }
 
+/* static */ nsCString
+RestyleManagerBase::RestyleHintToString(nsRestyleHint aHint)
+{
+  nsCString result;
+  bool any = false;
+  const char* names[] = {
+    "Self", "SomeDescendants", "Subtree", "LaterSiblings", "CSSTransitions",
+    "CSSAnimations", "SVGAttrAnimations", "StyleAttribute",
+    "StyleAttribute_Animations", "Force", "ForceDescendants"
+  };
+  uint32_t hint = aHint & ((1 << ArrayLength(names)) - 1);
+  uint32_t rest = aHint & ~((1 << ArrayLength(names)) - 1);
+  for (uint32_t i = 0; i < ArrayLength(names); i++) {
+    if (hint & (1 << i)) {
+      if (any) {
+        result.AppendLiteral(" | ");
+      }
+      result.AppendPrintf("eRestyle_%s", names[i]);
+      any = true;
+    }
+  }
+  if (rest) {
+    if (any) {
+      result.AppendLiteral(" | ");
+    }
+    result.AppendPrintf("0x%0x", rest);
+  } else {
+    if (!any) {
+      result.AppendLiteral("0");
+    }
+  }
+  return result;
+}
+
+
 } // namespace mozilla
--- a/layout/base/RestyleManagerBase.h
+++ b/layout/base/RestyleManagerBase.h
@@ -37,16 +37,18 @@ public:
   bool ObservingRefreshDriver() const { return mObservingRefreshDriver; }
 
   void SetObservingRefreshDriver(bool aObserving) {
       mObservingRefreshDriver = aObserving;
   }
 
   void Disconnect() { mPresContext = nullptr; }
 
+  static nsCString RestyleHintToString(nsRestyleHint aHint);
+
 protected:
   void ContentStateChangedInternal(Element* aElement,
                                    EventStates aStateMask,
                                    nsChangeHint* aOutChangeHint,
                                    nsRestyleHint* aOutRestyleHint);
 
   bool IsDisconnected() { return mPresContext == nullptr; }
 
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -161,17 +161,18 @@ ServoRestyleManager::NoteRestyleHint(Ele
       if (cur->IsContent()) {
         cur->SetIsDirtyForServo();
       }
     }
   }
 
   // TODO: Handle all other nsRestyleHint values.
   if (aHint & ~(eRestyle_Self | eRestyle_Subtree | eRestyle_LaterSiblings)) {
-    NS_ERROR("stylo: Unhandled restyle hint");
+    NS_ERROR(nsPrintfCString("stylo: Unhandled restyle hint %s",
+                             RestyleManagerBase::RestyleHintToString(aHint).get()).get());
   }
 }
 
 void
 ServoRestyleManager::ProcessPendingRestyles()
 {
   if (!HasPendingRestyles()) {
     return;