Bug 1188721 - Part 12: Report style struct refcounts in restyle logs. r?dbaron
MozReview-Commit-ID: 1zeCqWH3rCR
--- 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;
}