Bug 1261552 - Reimplement default placement-new for style structs. r=heycam

We require a pointer of the class type, rather than void*, to reduce
the risk of accidentally calling this overload instead of the PresContext
one.
This commit is contained in:
Bobby Holley 2016-03-30 16:15:30 -07:00
parent 0a167079de
commit 9e30bdaebc

View File

@ -180,6 +180,7 @@ struct nsStyleFont
static nscoord UnZoomText(nsPresContext* aPresContext, nscoord aSize);
static already_AddRefed<nsIAtom> GetLanguage(nsPresContext* aPresContext);
void* operator new(size_t sz, nsStyleFont* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleFont, sz);
@ -430,6 +431,7 @@ struct nsStyleColor
return nsChangeHint(0);
}
void* operator new(size_t sz, nsStyleColor* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleColor, sz);
@ -719,6 +721,7 @@ struct nsStyleBackground {
nsStyleBackground(const nsStyleBackground& aOther);
~nsStyleBackground();
void* operator new(size_t sz, nsStyleBackground* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleBackground, sz);
@ -774,6 +777,7 @@ struct nsStyleMargin
MOZ_COUNT_DTOR(nsStyleMargin);
}
void* operator new(size_t sz, nsStyleMargin* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleMargin, sz);
@ -819,6 +823,7 @@ struct nsStylePadding
MOZ_COUNT_DTOR(nsStylePadding);
}
void* operator new(size_t sz, nsStylePadding* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStylePadding, sz);
@ -1019,6 +1024,7 @@ struct nsStyleBorder
nsStyleBorder(const nsStyleBorder& aBorder);
~nsStyleBorder();
void* operator new(size_t sz, nsStyleBorder* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleBorder, sz);
@ -1248,6 +1254,7 @@ struct nsStyleOutline
MOZ_COUNT_DTOR(nsStyleOutline);
}
void* operator new(size_t sz, nsStyleOutline* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleOutline, sz);
@ -1345,6 +1352,7 @@ struct nsStyleList
nsStyleList(const nsStyleList& aStyleList);
~nsStyleList(void);
void* operator new(size_t sz, nsStyleList* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleList, sz);
@ -1552,6 +1560,7 @@ struct nsStylePosition
nsStylePosition(const nsStylePosition& aOther);
~nsStylePosition(void);
void* operator new(size_t sz, nsStylePosition* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStylePosition, sz);
@ -1802,6 +1811,7 @@ struct nsStyleTextReset
nsStyleTextReset(const nsStyleTextReset& aOther);
~nsStyleTextReset(void);
void* operator new(size_t sz, nsStyleTextReset* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleTextReset, sz);
@ -1887,6 +1897,7 @@ struct nsStyleText
nsStyleText(const nsStyleText& aOther);
~nsStyleText(void);
void* operator new(size_t sz, nsStyleText* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleText, sz);
@ -2097,6 +2108,7 @@ struct nsStyleVisibility
MOZ_COUNT_DTOR(nsStyleVisibility);
}
void* operator new(size_t sz, nsStyleVisibility* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleVisibility, sz);
@ -2379,6 +2391,7 @@ struct nsStyleDisplay
MOZ_COUNT_DTOR(nsStyleDisplay);
}
void* operator new(size_t sz, nsStyleDisplay* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleDisplay, sz);
@ -2652,6 +2665,7 @@ struct nsStyleTable
nsStyleTable(const nsStyleTable& aOther);
~nsStyleTable(void);
void* operator new(size_t sz, nsStyleTable* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleTable, sz);
@ -2684,6 +2698,7 @@ struct nsStyleTableBorder
nsStyleTableBorder(const nsStyleTableBorder& aOther);
~nsStyleTableBorder(void);
void* operator new(size_t sz, nsStyleTableBorder* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleTableBorder, sz);
@ -2783,6 +2798,7 @@ struct nsStyleQuotes
nsStyleQuotes(const nsStyleQuotes& aQuotes);
~nsStyleQuotes();
void* operator new(size_t sz, nsStyleQuotes* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleQuotes, sz);
@ -2866,6 +2882,7 @@ struct nsStyleContent
nsStyleContent(const nsStyleContent& aContent);
~nsStyleContent(void);
void* operator new(size_t sz, nsStyleContent* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleContent, sz);
@ -2976,6 +2993,7 @@ struct nsStyleUIReset
nsStyleUIReset(const nsStyleUIReset& aOther);
~nsStyleUIReset(void);
void* operator new(size_t sz, nsStyleUIReset* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleUIReset, sz);
@ -3041,6 +3059,7 @@ struct nsStyleUserInterface
nsStyleUserInterface(const nsStyleUserInterface& aOther);
~nsStyleUserInterface(void);
void* operator new(size_t sz, nsStyleUserInterface* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleUserInterface, sz);
@ -3088,6 +3107,7 @@ struct nsStyleXUL
nsStyleXUL(const nsStyleXUL& aSource);
~nsStyleXUL();
void* operator new(size_t sz, nsStyleXUL* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleXUL, sz);
@ -3125,6 +3145,7 @@ struct nsStyleColumn
nsStyleColumn(const nsStyleColumn& aSource);
~nsStyleColumn();
void* operator new(size_t sz, nsStyleColumn* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleColumn, sz);
@ -3219,6 +3240,7 @@ struct nsStyleSVG
nsStyleSVG(const nsStyleSVG& aSource);
~nsStyleSVG();
void* operator new(size_t sz, nsStyleSVG* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleSVG, sz);
@ -3506,6 +3528,7 @@ struct nsStyleSVGReset
nsStyleSVGReset(const nsStyleSVGReset& aSource);
~nsStyleSVGReset();
void* operator new(size_t sz, nsStyleSVGReset* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleSVGReset, sz);
@ -3561,6 +3584,7 @@ struct nsStyleVariables
nsStyleVariables(const nsStyleVariables& aSource);
~nsStyleVariables();
void* operator new(size_t sz, nsStyleVariables* aSelf) CPP_THROW_NEW { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->PresShell()->
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleVariables, sz);