Bug 1216362 - Measure nsCSSSelector::mAttrList. r=erahm
authorCameron McCormack <cam@mcc.id.au>
Wed, 21 Oct 2015 16:18:36 +1100
changeset 303889 d11e30970a2d086773b839a5f77e633094c34d30
parent 303888 3f388e64bff834d8911abb899de6ffbc81a434e2
child 303890 00cd6d2a84bb7c9c613e74cb9ab685da6308c383
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1216362
milestone44.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 1216362 - Measure nsCSSSelector::mAttrList. r=erahm
layout/style/StyleRule.cpp
layout/style/StyleRule.h
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -281,16 +281,29 @@ nsAttrSelector::Clone(bool aDeep) const
 
 nsAttrSelector::~nsAttrSelector(void)
 {
   MOZ_COUNT_DTOR(nsAttrSelector);
 
   NS_CSS_DELETE_LIST_MEMBER(nsAttrSelector, this, mNext);
 }
 
+size_t
+nsAttrSelector::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
+{
+  size_t n = 0;
+  const nsAttrSelector* p = this;
+  while (p) {
+    n += aMallocSizeOf(p);
+    n += p->mValue.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
+    p = p->mNext;
+  }
+  return n;
+}
+
 // -- nsCSSSelector -------------------------------
 
 nsCSSSelector::nsCSSSelector(void)
   : mLowercaseTag(nullptr),
     mCasedTag(nullptr),
     mIDList(nullptr),
     mClassList(nullptr),
     mPseudoClassList(nullptr),
@@ -919,21 +932,18 @@ nsCSSSelector::SizeOfIncludingThis(mozil
     n += aMallocSizeOf(s);
 
     #define MEASURE(x)   n += x ? x->SizeOfIncludingThis(aMallocSizeOf) : 0;
 
     MEASURE(s->mIDList);
     MEASURE(s->mClassList);
     MEASURE(s->mPseudoClassList);
     MEASURE(s->mNegations);
+    MEASURE(s->mAttrList);
 
-    // Measurement of the following members may be added later if DMD finds it is
-    // worthwhile:
-    // - s->mAttrList
-    //
     // The following members aren't measured:
     // - s->mLowercaseTag, because it's an atom and therefore shared
     // - s->mCasedTag, because it's an atom and therefore shared
 
     s = s->mNext;
   }
   return n;
 }
--- a/layout/style/StyleRule.h
+++ b/layout/style/StyleRule.h
@@ -101,16 +101,18 @@ public:
   nsAttrSelector(int32_t aNameSpace, nsIAtom* aLowercaseAttr, 
                  nsIAtom* aCasedAttr, uint8_t aFunction, 
                  const nsString& aValue, bool aCaseSensitive);
   ~nsAttrSelector(void);
 
   /** Do a deep clone.  Should be used only on the first in the linked list. */
   nsAttrSelector* Clone() const { return Clone(true); }
 
+  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
+
   nsString        mValue;
   nsAttrSelector* mNext;
   nsCOMPtr<nsIAtom> mLowercaseAttr;
   nsCOMPtr<nsIAtom> mCasedAttr;
   int32_t         mNameSpace;
   uint8_t         mFunction;
   bool            mCaseSensitive; // If we are in an HTML document,
                                   // is the value case sensitive?