Bug 668013 - Add nsHTMLStyleSheet::SizeOf(). r=bz

This commit is contained in:
Mounir Lamouri
2011-07-19 09:40:18 -07:00
parent 0eb82dbb5e
commit 4fd1e17d45
5 changed files with 50 additions and 2 deletions

View File

@@ -528,6 +528,43 @@ nsHTMLStyleSheet::List(FILE* out, PRInt32 aIndent) const
}
#endif
static
PLDHashOperator
GetHashEntryAttributesSize(PLDHashTable* aTable, PLDHashEntryHdr* aEntry,
PRUint32 number, void* aArg)
{
NS_PRECONDITION(aEntry, "The entry should not be null!");
NS_PRECONDITION(aArg, "The passed argument should not be null!");
MappedAttrTableEntry* entry = static_cast<MappedAttrTableEntry*>(aEntry);
PRInt64 size = *static_cast<PRInt64*>(aArg);
NS_ASSERTION(entry->mAttributes, "entry->mAttributes should not be null!");
size += sizeof(*entry->mAttributes);
return PL_DHASH_NEXT;
}
PRInt64
nsHTMLStyleSheet::SizeOf() const
{
PRInt64 size = sizeof(*this);
size += mLinkRule ? sizeof(*mLinkRule.get()) : 0;
size += mVisitedRule ? sizeof(*mVisitedRule.get()) : 0;
size += mActiveRule ? sizeof(*mActiveRule.get()) : 0;
size += mTableQuirkColorRule ? sizeof(*mTableQuirkColorRule.get()) : 0;
size += mTableTHRule ? sizeof(*mTableTHRule.get()) : 0;
if (mMappedAttrTable.ops) {
size += PL_DHASH_TABLE_SIZE(&mMappedAttrTable) * sizeof(MappedAttrTableEntry);
PL_DHashTableEnumerate(const_cast<PLDHashTable*>(&mMappedAttrTable),
GetHashEntryAttributesSize, &size);
}
return size;
}
// XXX For convenience and backwards compatibility
nsresult
NS_NewHTMLStyleSheet(nsHTMLStyleSheet** aInstancePtrResult, nsIURI* aURL,
@@ -567,3 +604,4 @@ NS_NewHTMLStyleSheet(nsHTMLStyleSheet** aInstancePtrResult)
*aInstancePtrResult = it; // NS_ADDREF above, or set to null by NS_RELEASE
return rv;
}