diff --git a/layout/style/CSSStyleSheet.cpp b/layout/style/CSSStyleSheet.cpp index dc99e9ec6bfd..92d9d2774ae5 100644 --- a/layout/style/CSSStyleSheet.cpp +++ b/layout/style/CSSStyleSheet.cpp @@ -208,11 +208,9 @@ CSSStyleSheet::RebuildChildList(css::Rule* aRule, void* aBuilder) size_t CSSStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { - size_t n = 0; + size_t n = StyleSheet::SizeOfIncludingThis(aMallocSizeOf); const CSSStyleSheet* s = this; while (s) { - n += aMallocSizeOf(s); - // Each inner can be shared by multiple sheets. So we only count the inner // if this sheet is the last one in the list of those sharing it. As a // result, the last such sheet takes all the blame for the memory @@ -226,8 +224,6 @@ CSSStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const // Measurement of the following members may be added later if DMD finds it // is worthwhile: - // - s->mTitle - // - s->mMedia // - s->mRuleCollection // - s->mRuleProcessors // diff --git a/layout/style/CSSStyleSheet.h b/layout/style/CSSStyleSheet.h index 45440d6d4b0f..76d7031cde33 100644 --- a/layout/style/CSSStyleSheet.h +++ b/layout/style/CSSStyleSheet.h @@ -169,7 +169,7 @@ public: // list after we clone a unique inner for ourselves. static bool RebuildChildList(css::Rule* aRule, void* aBuilder); - size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; + size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override; dom::Element* GetScopeElement() const { return mScopeElement; } void SetScopeElement(dom::Element* aScopeElement) diff --git a/layout/style/ServoStyleSheet.cpp b/layout/style/ServoStyleSheet.cpp index 5c2a62f321a7..8d7e4c4fecb6 100644 --- a/layout/style/ServoStyleSheet.cpp +++ b/layout/style/ServoStyleSheet.cpp @@ -109,12 +109,6 @@ ServoStyleSheet::DropRuleList() } } -size_t -ServoStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const -{ - MOZ_CRASH("stylo: not implemented"); -} - css::Rule* ServoStyleSheet::GetDOMOwnerRule() const { diff --git a/layout/style/ServoStyleSheet.h b/layout/style/ServoStyleSheet.h index f1ec541c712f..fbf56e1005a6 100644 --- a/layout/style/ServoStyleSheet.h +++ b/layout/style/ServoStyleSheet.h @@ -53,8 +53,6 @@ public: */ void LoadFailed(); - size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; - RawServoStyleSheet* RawSheet() const { return mSheet; } void SetSheetForImport(RawServoStyleSheet* aSheet) { MOZ_ASSERT(!mSheet); diff --git a/layout/style/StyleSheet.cpp b/layout/style/StyleSheet.cpp index 382435c65d1d..ec7aeaac8d50 100644 --- a/layout/style/StyleSheet.cpp +++ b/layout/style/StyleSheet.cpp @@ -432,6 +432,24 @@ StyleSheet::AppendStyleSheet(StyleSheet* aSheet) DidDirty(); } +size_t +StyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const +{ + size_t n = 0; + const StyleSheet* s = this; + while (s) { + n += aMallocSizeOf(s); + + // Measurement of the following members may be added later if DMD finds it + // is worthwhile: + // - s->mTitle + // - s->mMedia + + s = s->mNext; + } + return n; +} + #ifdef DEBUG void StyleSheet::List(FILE* out, int32_t aIndent) const diff --git a/layout/style/StyleSheet.h b/layout/style/StyleSheet.h index bfa4eb82999f..dd73ddeaefa6 100644 --- a/layout/style/StyleSheet.h +++ b/layout/style/StyleSheet.h @@ -151,7 +151,7 @@ public: // Get this style sheet's integrity metadata inline void GetIntegrity(dom::SRIMetadata& aResult) const; - inline size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; + virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; #ifdef DEBUG virtual void List(FILE* aOut = stdout, int32_t aIndex = 0) const; #endif diff --git a/layout/style/StyleSheetInlines.h b/layout/style/StyleSheetInlines.h index 3f83798b0f67..c6aa7ad353c8 100644 --- a/layout/style/StyleSheetInlines.h +++ b/layout/style/StyleSheetInlines.h @@ -134,12 +134,6 @@ StyleSheet::GetIntegrity(dom::SRIMetadata& aResult) const aResult = SheetInfo().mIntegrity; } -size_t -StyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const -{ - MOZ_STYLO_FORWARD(SizeOfIncludingThis, (aMallocSizeOf)) -} - void StyleSheet::WillDirty() { MOZ_STYLO_FORWARD(WillDirty, ()) } void StyleSheet::DidDirty() { MOZ_STYLO_FORWARD(DidDirty, ()) }