Bug 1188721 - Part 12: Report style struct refcounts in restyle logs. r?dbaron draft
authorCameron McCormack <cam@mcc.id.au>
Wed, 23 Mar 2016 17:35:59 +1100
changeset 343762 d07c4a75f2ae39e30b578161c3fdcb1af6be143f
parent 343761 0ca5bf33a58b56537010599a4ed13435c976c7da
child 343763 af51dc1e4396225a81ac8f9696d5538bc80f81af
push id13680
push usercmccormack@mozilla.com
push dateWed, 23 Mar 2016 06:36:18 +0000
reviewersdbaron
bugs1188721
milestone48.0a1
Bug 1188721 - Part 12: Report style struct refcounts in restyle logs. r?dbaron MozReview-Commit-ID: 1zeCqWH3rCR
layout/style/nsStyleContext.cpp
layout/style/nsStyleStruct.h
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -1490,22 +1490,18 @@ nsStyleContext::GetCachedStyleDataAsStri
   for (nsStyleStructID i = nsStyleStructID(0);
        i < nsStyleStructID_Length;
        i = nsStyleStructID(i + 1)) {
     if (aStructs & nsCachedStyleData::GetBitForSID(i)) {
       const nsStyleStruct* data = GetCachedStyleData(i);
       if (!structs.IsEmpty()) {
         structs.Append(' ');
       }
-      structs.AppendPrintf("%s=%p", StructName(i), data);
-      if (HasCachedDependentStyleData(i)) {
-        structs.AppendLiteral("(dependent)");
-      } else {
-        structs.AppendLiteral("(owned)");
-      }
+      structs.AppendPrintf("%s=%p (%d refs)",
+                           StructName(i), data, data->GetRefCnt());
     }
   }
   return structs;
 }
 
 int32_t&
 nsStyleContext::LoggingDepth()
 {
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -127,16 +127,20 @@ public:
     static DestroyFn sDestroyFn[] = {
 #define STYLE_STRUCT(name_, checkdata_cb_) &Destroy##name_,
 #include "nsStyleStructList.h"
 #undef STYLE_STRUCT
     };
     sDestroyFn[aSID](aData, aPresContext);
   }
 
+#ifdef DEBUG
+  MozRefCountType GetRefCnt() const { return mRefCnt; }
+#endif
+
 protected:
   nsStyleStruct() : mRefCnt(0) {}
   nsStyleStruct(const nsStyleStruct& aOther) {}
   nsStyleStruct& operator=(const nsStyleStruct& aOther) {
     // Don't copy mRefCnt.
     return *this;
   }