mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 751356 - Make presshell arena allocation methods inline and non-virtual. r=bz
This commit is contained in:
parent
02b3f2cc95
commit
eab03f0c33
@ -41,7 +41,6 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsFontMetrics.h"
|
||||
#include "nsRenderingContext.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
|
@ -147,10 +147,10 @@ typedef struct CapturingContentInfo {
|
||||
nsIContent* mContent;
|
||||
} CapturingContentInfo;
|
||||
|
||||
// a0d9bae4-2257-4b0b-b08a-3d95122419e2
|
||||
// d2236911-9b7c-490a-a08b-2580d5f7a6de
|
||||
#define NS_IPRESSHELL_IID \
|
||||
{ 0xa0d9bae4, 0x2257, 0x4b0b, \
|
||||
{ 0xb0, 0x8a, 0x3d, 0x95, 0x12, 0x24, 0x19, 0xe2 } }
|
||||
{ 0xd2236911, 0x9b7c, 0x490a, \
|
||||
{ 0xa0, 0x8b, 0x25, 0x80, 0xd5, 0xf7, 0xa6, 0xde } }
|
||||
|
||||
// debug VerifyReflow flags
|
||||
#define VERIFY_REFLOW_ON 0x01
|
||||
@ -227,8 +227,27 @@ public:
|
||||
* to the same aSize value. AllocateFrame returns zero-filled memory.
|
||||
* AllocateFrame is fallible, it returns nsnull on out-of-memory.
|
||||
*/
|
||||
virtual void* AllocateFrame(nsQueryFrame::FrameIID aID, size_t aSize) = 0;
|
||||
virtual void FreeFrame(nsQueryFrame::FrameIID aID, void* aChunk) = 0;
|
||||
void* AllocateFrame(nsQueryFrame::FrameIID aID, size_t aSize)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mPresArenaAllocCount++;
|
||||
#endif
|
||||
void* result = mFrameArena.AllocateByFrameID(aID, aSize);
|
||||
|
||||
if (result) {
|
||||
memset(result, 0, aSize);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void FreeFrame(nsQueryFrame::FrameIID aID, void* aPtr)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mPresArenaAllocCount--;
|
||||
#endif
|
||||
if (PRESARENA_MUST_FREE_DURING_DESTROY || !mIsDestroying)
|
||||
mFrameArena.FreeByFrameID(aID, aPtr);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is for allocating other types of objects (not frames). Separate free
|
||||
@ -236,8 +255,27 @@ public:
|
||||
* the same aSize value. AllocateByObjectID returns zero-filled memory.
|
||||
* AllocateByObjectID is fallible, it returns nsnull on out-of-memory.
|
||||
*/
|
||||
virtual void* AllocateByObjectID(nsPresArena::ObjectID aID, size_t aSize) = 0;
|
||||
virtual void FreeByObjectID(nsPresArena::ObjectID aID, void* aPtr) = 0;
|
||||
void* AllocateByObjectID(nsPresArena::ObjectID aID, size_t aSize)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mPresArenaAllocCount++;
|
||||
#endif
|
||||
void* result = mFrameArena.AllocateByObjectID(aID, aSize);
|
||||
|
||||
if (result) {
|
||||
memset(result, 0, aSize);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void FreeByObjectID(nsPresArena::ObjectID aID, void* aPtr)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mPresArenaAllocCount--;
|
||||
#endif
|
||||
if (PRESARENA_MUST_FREE_DURING_DESTROY || !mIsDestroying)
|
||||
mFrameArena.FreeByObjectID(aID, aPtr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Other objects closely related to the frame tree that are allocated
|
||||
@ -248,8 +286,22 @@ public:
|
||||
*
|
||||
* @deprecated use AllocateByObjectID/FreeByObjectID instead
|
||||
*/
|
||||
virtual void* AllocateMisc(size_t aSize) = 0;
|
||||
virtual void FreeMisc(size_t aSize, void* aChunk) = 0;
|
||||
void* AllocateMisc(size_t aSize)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mPresArenaAllocCount++;
|
||||
#endif
|
||||
return mFrameArena.AllocateBySize(aSize);
|
||||
}
|
||||
|
||||
void FreeMisc(size_t aSize, void* aPtr)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mPresArenaAllocCount--;
|
||||
#endif
|
||||
if (PRESARENA_MUST_FREE_DURING_DESTROY || !mIsDestroying)
|
||||
mFrameArena.FreeBySize(aSize, aPtr);
|
||||
}
|
||||
|
||||
nsIDocument* GetDocument() const { return mDocument; }
|
||||
|
||||
@ -1288,6 +1340,7 @@ protected:
|
||||
nsStyleSet* mStyleSet; // [OWNS]
|
||||
nsCSSFrameConstructor* mFrameConstructor; // [OWNS]
|
||||
nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to
|
||||
nsPresArena mFrameArena;
|
||||
nsFrameSelection* mSelection;
|
||||
// Pointer into mFrameConstructor - this is purely so that FrameManager() and
|
||||
// GetRootFrame() can be inlined:
|
||||
@ -1296,6 +1349,8 @@ protected:
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
nsIFrame* mDrawEventTargetFrame;
|
||||
// Ensure that every allocation from the PresArena is eventually freed.
|
||||
PRUint32 mPresArenaAllocCount;
|
||||
#endif
|
||||
|
||||
// Count of the number of times this presshell has been painted to
|
||||
|
@ -1070,73 +1070,6 @@ PresShell::Destroy()
|
||||
mHaveShutDown = true;
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::FreeFrame(nsQueryFrame::FrameIID aID, void* aPtr)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mPresArenaAllocCount--;
|
||||
#endif
|
||||
if (PRESARENA_MUST_FREE_DURING_DESTROY || !mIsDestroying)
|
||||
mFrameArena.FreeByFrameID(aID, aPtr);
|
||||
}
|
||||
|
||||
void*
|
||||
PresShell::AllocateFrame(nsQueryFrame::FrameIID aID, size_t aSize)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mPresArenaAllocCount++;
|
||||
#endif
|
||||
void* result = mFrameArena.AllocateByFrameID(aID, aSize);
|
||||
|
||||
if (result) {
|
||||
memset(result, 0, aSize);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void*
|
||||
PresShell::AllocateByObjectID(nsPresArena::ObjectID aID, size_t aSize)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mPresArenaAllocCount++;
|
||||
#endif
|
||||
void* result = mFrameArena.AllocateByObjectID(aID, aSize);
|
||||
|
||||
if (result) {
|
||||
memset(result, 0, aSize);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::FreeByObjectID(nsPresArena::ObjectID aID, void* aPtr)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mPresArenaAllocCount--;
|
||||
#endif
|
||||
if (PRESARENA_MUST_FREE_DURING_DESTROY || !mIsDestroying)
|
||||
mFrameArena.FreeByObjectID(aID, aPtr);
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::FreeMisc(size_t aSize, void* aPtr)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mPresArenaAllocCount--;
|
||||
#endif
|
||||
if (PRESARENA_MUST_FREE_DURING_DESTROY || !mIsDestroying)
|
||||
mFrameArena.FreeBySize(aSize, aPtr);
|
||||
}
|
||||
|
||||
void*
|
||||
PresShell::AllocateMisc(size_t aSize)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mPresArenaAllocCount++;
|
||||
#endif
|
||||
return mFrameArena.AllocateBySize(aSize);
|
||||
}
|
||||
|
||||
void
|
||||
nsIPresShell::SetAuthorStyleDisabled(bool aStyleDisabled)
|
||||
{
|
||||
|
@ -108,19 +108,6 @@ public:
|
||||
nsCompatibility aCompatMode);
|
||||
virtual NS_HIDDEN_(void) Destroy();
|
||||
|
||||
virtual NS_HIDDEN_(void*) AllocateFrame(nsQueryFrame::FrameIID aID,
|
||||
size_t aSize);
|
||||
virtual NS_HIDDEN_(void) FreeFrame(nsQueryFrame::FrameIID aID,
|
||||
void* aChunk);
|
||||
|
||||
virtual NS_HIDDEN_(void*) AllocateByObjectID(nsPresArena::ObjectID aID,
|
||||
size_t aSize);
|
||||
virtual NS_HIDDEN_(void) FreeByObjectID(nsPresArena::ObjectID aID,
|
||||
void* aPtr);
|
||||
|
||||
virtual NS_HIDDEN_(void*) AllocateMisc(size_t aSize);
|
||||
virtual NS_HIDDEN_(void) FreeMisc(size_t aSize, void* aChunk);
|
||||
|
||||
virtual NS_HIDDEN_(nsresult) SetPreferenceStyleRules(bool aForceReflow);
|
||||
|
||||
NS_IMETHOD GetSelection(SelectionType aType, nsISelection** aSelection);
|
||||
@ -570,7 +557,6 @@ protected:
|
||||
nscoord mLastAnchorScrollPositionY;
|
||||
nsRefPtr<nsCaret> mCaret;
|
||||
nsRefPtr<nsCaret> mOriginalCaret;
|
||||
nsPresArena mFrameArena;
|
||||
nsCOMPtr<nsIDragService> mDragService;
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -811,12 +797,6 @@ private:
|
||||
|
||||
PresShell* GetRootPresShell();
|
||||
|
||||
private:
|
||||
#ifdef DEBUG
|
||||
// Ensure that every allocation from the PresArena is eventually freed.
|
||||
PRUint32 mPresArenaAllocCount;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
||||
|
Loading…
Reference in New Issue
Block a user