Bug 1016680, part 5 - Report the memory used by PresShell::mCaret. r=dbaron

This commit is contained in:
Jonathan Watt 2014-06-22 23:02:59 +01:00
parent 96ce538a84
commit 966eacef02
10 changed files with 60 additions and 0 deletions

View File

@ -124,6 +124,7 @@ public:
// nsIWeakReference
NS_DECL_NSIWEAKREFERENCE
virtual size_t SizeOfOnlyThis(mozilla::MallocSizeOf aMallocSizeOf) const;
void NoticeNodeDestruction()
{

View File

@ -500,6 +500,12 @@ nsNodeWeakReference::QueryReferent(const nsIID& aIID, void** aInstancePtr)
NS_ERROR_NULL_POINTER;
}
size_t
nsNodeWeakReference::SizeOfOnlyThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
return aMallocSizeOf(this);
}
NS_IMPL_CYCLE_COLLECTION(nsNodeSupportsWeakRefTearoff, mNode)

View File

@ -853,6 +853,25 @@ nsCaret::CheckCaretDrawingState()
}
}
size_t nsCaret::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
size_t total = aMallocSizeOf(this);
if (mPresShell) {
// We only want the size of the nsWeakReference object, not the PresShell
// (since we don't own the PresShell).
total += mPresShell->SizeOfOnlyThis(aMallocSizeOf);
}
if (mDomSelectionWeak) {
// We only want size of the nsWeakReference object, not the selection
// (again, we don't own the selection).
total += mDomSelectionWeak->SizeOfOnlyThis(aMallocSizeOf);
}
if (mBlinkTimer) {
total += mBlinkTimer->SizeOfIncludingThis(aMallocSizeOf);
}
return total;
}
/*-----------------------------------------------------------------------------
MustDrawCaret

View File

@ -9,6 +9,7 @@
#ifndef nsCaret_h__
#define nsCaret_h__
#include "mozilla/MemoryReporting.h"
#include "nsCoord.h"
#include "nsISelectionListener.h"
#include "nsIWeakReferenceUtils.h"
@ -165,6 +166,8 @@ class nsCaret : public nsISelectionListener
void CheckCaretDrawingState();
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
protected:
void KillTimer();

View File

@ -10494,6 +10494,9 @@ PresShell::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
{
mFrameArena.AddSizeOfExcludingThis(aMallocSizeOf, aArenaObjectsSize);
*aPresShellSize += aMallocSizeOf(this);
if (mCaret) {
*aPresShellSize += mCaret->SizeOfIncludingThis(aMallocSizeOf);
}
*aPresShellSize += mVisibleImages.SizeOfExcludingThis(nullptr,
aMallocSizeOf,
nullptr);

View File

@ -6,6 +6,9 @@
#include "nsISupports.idl"
%{C++
#include "mozilla/MemoryReporting.h"
%}
/**
* An instance of |nsIWeakReference| is a proxy object that cooperates with
@ -31,6 +34,10 @@ interface nsIWeakReference : nsISupports
* that would defeat the purpose of using a non-owning |nsIWeakReference| in the first place.
*/
void QueryReferent( in nsIIDRef uuid, [iid_is(uuid), retval] out nsQIResult result );
%{C++
virtual size_t SizeOfOnlyThis(mozilla::MallocSizeOf aMallocSizeOf) const = 0;
%}
};

View File

@ -19,6 +19,7 @@ class nsWeakReference MOZ_FINAL : public nsIWeakReference
// nsIWeakReference...
NS_DECL_NSIWEAKREFERENCE
virtual size_t SizeOfOnlyThis(mozilla::MallocSizeOf aMallocSizeOf) const;
private:
friend class nsSupportsWeakReference;
@ -118,6 +119,12 @@ nsWeakReference::QueryReferent( const nsIID& aIID, void** aInstancePtr )
return mReferent ? mReferent->QueryInterface(aIID, aInstancePtr) : NS_ERROR_NULL_POINTER;
}
size_t
nsWeakReference::SizeOfOnlyThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
return aMallocSizeOf(this);
}
void
nsSupportsWeakReference::ClearWeakReferences()
{

View File

@ -9,6 +9,8 @@ interface nsIObserver;
interface nsIEventTarget;
%{C++
#include "mozilla/MemoryReporting.h"
/**
* The signature of the timer callback function passed to initWithFuncCallback.
* This is the function that will get called when the timer expires if the
@ -194,6 +196,10 @@ interface nsITimer : nsISupports
* By default the target is the thread that created the timer.
*/
attribute nsIEventTarget target;
%{C++
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const = 0;
%}
};
%{C++

View File

@ -776,6 +776,12 @@ nsTimerImpl::SetDelayInternal(uint32_t aDelay)
#endif
}
size_t
nsTimerImpl::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
return aMallocSizeOf(this);
}
// NOT FOR PUBLIC CONSUMPTION!
nsresult
NS_NewTimer(nsITimer** aResult, nsTimerCallbackFunc aCallback, void* aClosure,

View File

@ -77,6 +77,8 @@ public:
}
#endif
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
private:
~nsTimerImpl();
nsresult InitCommon(uint32_t aType, uint32_t aDelay);