Bug 1353948 - Add SizeOfIncludingThis() methods to ServoStyle{Set,Sheet,SheetInner}. r=heycam.

This fills things in a bit more on the Gecko side.

--HG--
extra : rebase_source : a7cd16969fa0ce06f7d9e39f83d67bf3bd472ea4
This commit is contained in:
Nicholas Nethercote 2017-04-06 12:22:36 +10:00
Родитель 1c44dce8d2
Коммит c54a8b6198
7 изменённых файлов: 67 добавлений и 3 удалений

Просмотреть файл

@ -11002,8 +11002,10 @@ PresShell::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
if (nsStyleSet* styleSet = StyleSet()->GetAsGecko()) {
*aStyleSetsSize += styleSet->SizeOfIncludingThis(aMallocSizeOf);
} else if (ServoStyleSet* styleSet = StyleSet()->GetAsServo()) {
*aStyleSetsSize += styleSet->SizeOfIncludingThis(aMallocSizeOf);
} else {
NS_WARNING("ServoStyleSets do not support memory measurements yet");
MOZ_CRASH();
}
*aTextRunsSize += SizeOfTextRuns(aMallocSizeOf);

Просмотреть файл

@ -192,9 +192,11 @@ CSSStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
// is worthwhile:
// - s->mRuleCollection
// - s->mRuleProcessors
// - s->mStyleSets
//
// The following members are not measured:
// - s->mOwnerRule, because it's non-owning
// - s->mScopeElement, because it's non-owning
s = s->mNext ? s->mNext->AsGecko() : nullptr;
}

Просмотреть файл

@ -169,8 +169,14 @@ ServoStyleRule::Clone() const
size_t
ServoStyleRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
// TODO Implement this!
return aMallocSizeOf(this);
size_t n = aMallocSizeOf(this);
// Measurement of the following members may be added later if DMD finds it is
// worthwhile:
// - mRawRule
// - mDecls
return n;
}
#ifdef DEBUG

Просмотреть файл

@ -99,6 +99,23 @@ ServoStyleSet::Shutdown()
mRawSet = nullptr;
}
size_t
ServoStyleSet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this);
// Measurement of the following members may be added later if DMD finds it is
// worthwhile:
// - mRawSet
// - mSheets
// - mNonInheritingStyleContexts
//
// The following members are not measured:
// - mPresContext, because it a non-owning pointer
return n;
}
bool
ServoStyleSet::GetAuthorStyleDisabled() const
{

Просмотреть файл

@ -92,6 +92,8 @@ public:
void BeginShutdown();
void Shutdown();
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
bool GetAuthorStyleDisabled() const;
nsresult SetAuthorStyleDisabled(bool aStyleDisabled);

Просмотреть файл

@ -30,6 +30,16 @@ ServoStyleSheetInner::ServoStyleSheetInner(CORSMode aCORSMode,
{
}
size_t
ServoStyleSheetInner::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this);
// XXX: need to measure mSheet
return n;
}
ServoStyleSheet::ServoStyleSheet(css::SheetParsingMode aParsingMode,
CORSMode aCORSMode,
net::ReferrerPolicy aReferrerPolicy,
@ -233,4 +243,25 @@ ServoStyleSheet::InsertRuleIntoGroupInternal(const nsAString& aRule,
return rules->InsertRule(aRule, aIndex);
}
size_t
ServoStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = StyleSheet::SizeOfIncludingThis(aMallocSizeOf);
const ServoStyleSheet* s = this;
while (s) {
// See the comment in CSSStyleSheet::SizeOfIncludingThis() for an
// explanation of this.
if (s->Inner()->mSheets.LastElement() == s) {
n += s->Inner()->SizeOfIncludingThis(aMallocSizeOf);
}
// Measurement of the following members may be added later if DMD finds it
// is worthwhile:
// - s->mRuleList
s = s->mNext ? s->mNext->AsServo() : nullptr;
}
return n;
}
} // namespace mozilla

Просмотреть файл

@ -33,6 +33,8 @@ struct ServoStyleSheetInner : public StyleSheetInfo
ReferrerPolicy aReferrerPolicy,
const dom::SRIMetadata& aIntegrity);
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
RefPtr<const RawServoStyleSheet> mSheet;
// XXX StyleSheetInfo already has mSheetURI, mBaseURI, and mPrincipal.
// Can we somehow replace them with URLExtraData directly? The issue
@ -123,6 +125,8 @@ protected:
void EnabledStateChangedInternal() {}
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
private:
ServoStyleSheet(const ServoStyleSheet& aCopy,
ServoStyleSheet* aParentToUse,